Skip to content

Commit

Permalink
Merge pull request #138 from netboxlabs/develop
Browse files Browse the repository at this point in the history
🚚 release
  • Loading branch information
mfiedorowicz authored Jul 23, 2024
2 parents d055018 + 7cf65dd commit 6502587
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion diode-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ curl -o .env https://raw.githubusercontent.com/netboxlabs/diode/develop/diode-se
Edit the `.env` to match your environment:
* `NETBOX_DIODE_PLUGIN_API_BASE_URL`: URL for the Diode NetBox plugin API
* `DIODE_TO_NETBOX_API_KEY`: API key generated with the Diode NetBox plugin installation
* `INGESTION_API_KEY`: API key generated with the Diode NetBox plugin installation
* `DIODE_API_KEY`: API key generated with the Diode NetBox plugin installation
* `NETBOX_TO_DIODE_API_KEY`: API key generated with the Diode NetBox plugin installation

### Running the Diode server
Expand Down
2 changes: 1 addition & 1 deletion diode-server/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ services:
- NETBOX_DIODE_PLUGIN_API_BASE_URL=${NETBOX_DIODE_PLUGIN_API_BASE_URL}
- DIODE_TO_NETBOX_API_KEY=${DIODE_TO_NETBOX_API_KEY}
- NETBOX_TO_DIODE_API_KEY=${NETBOX_TO_DIODE_API_KEY}
- INGESTION_API_KEY=${INGESTION_API_KEY}
- DIODE_API_KEY=${DIODE_API_KEY}
- LOGGING_LEVEL=${LOGGING_LEVEL}
- SENTRY_DSN=${SENTRY_DSN}
restart: always
Expand Down
2 changes: 1 addition & 1 deletion diode-server/docker/netbox/env/netbox.env
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ SUPERUSER_PASSWORD=admin
WEBHOOKS_ENABLED=true
DIODE_TO_NETBOX_API_KEY=1368dbad13e418d5a443d93cf255edde03a2a754
NETBOX_TO_DIODE_API_KEY=1e99338b8cab5fc637bc55f390bda1446f619c42
INGESTION_API_KEY=5a52c45ee8231156cb620d193b0291912dd15433
DIODE_API_KEY=5a52c45ee8231156cb620d193b0291912dd15433
BASE_PATH=netbox/
2 changes: 1 addition & 1 deletion diode-server/docker/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ RECONCILER_GRPC_PORT=8081
NETBOX_DIODE_PLUGIN_API_BASE_URL=http://NETBOX_HOST/api/plugins/diode
DIODE_TO_NETBOX_API_KEY=1368dbad13e418d5a443d93cf255edde03a2a754
NETBOX_TO_DIODE_API_KEY=1e99338b8cab5fc637bc55f390bda1446f619c42
INGESTION_API_KEY=5a52c45ee8231156cb620d193b0291912dd15433
DIODE_API_KEY=5a52c45ee8231156cb620d193b0291912dd15433
LOGGING_LEVEL=DEBUG
SENTRY_DSN=
3 changes: 2 additions & 1 deletion diode-server/reconciler/api_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package reconciler
import (
"context"
"encoding/json"

"github.com/redis/go-redis/v9"
)

Expand All @@ -18,7 +19,7 @@ func loadAPIKeys(ctx context.Context, cfg Config, rc *redis.Client) (APIKeys, er
apiKeys := map[string]string{
"DIODE_TO_NETBOX": cfg.DiodeToNetBoxAPIKey,
"NETBOX_TO_DIODE": cfg.NetBoxToDiodeAPIKey,
"INGESTION": cfg.IngestionAPIKey,
"DIODE": cfg.DiodeAPIKey,
}

if err := rc.HSet(ctx, "diode.api_keys", apiKeys).Err(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion diode-server/reconciler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ type Config struct {
// API keys
DiodeToNetBoxAPIKey string `envconfig:"DIODE_TO_NETBOX_API_KEY" required:"true"`
NetBoxToDiodeAPIKey string `envconfig:"NETBOX_TO_DIODE_API_KEY" required:"true"`
IngestionAPIKey string `envconfig:"INGESTION_API_KEY" required:"true"`
DiodeAPIKey string `envconfig:"DIODE_API_KEY" required:"true"`
}
5 changes: 2 additions & 3 deletions diode-server/reconciler/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"log/slog"
"net"
"strings"

"github.com/kelseyhightower/envconfig"
"github.com/redis/go-redis/v9"
Expand Down Expand Up @@ -95,15 +94,15 @@ func (s *Server) RetrieveIngestionDataSources(_ context.Context, in *reconcilerp
filterByName := in.Name != ""

if filterByName {
if _, ok := s.apiKeys[in.Name]; !ok || !strings.HasPrefix(in.Name, "INGESTION") {
if _, ok := s.apiKeys[in.Name]; !ok || in.Name != "DIODE" {
return nil, fmt.Errorf("data source %s not found", in.Name)
}
dataSources = append(dataSources, &reconcilerpb.IngestionDataSource{Name: in.Name, ApiKey: s.apiKeys[in.Name]})
return &reconcilerpb.RetrieveIngestionDataSourcesResponse{IngestionDataSources: dataSources}, nil
}

for name, key := range s.apiKeys {
if strings.HasPrefix(name, "INGESTION") {
if name == "DIODE" {
dataSources = append(dataSources, &reconcilerpb.IngestionDataSource{Name: name, ApiKey: key})
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/features/configs.ini.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[tests_config]
user_token = USER_TOKEN_CREATED_ON_NETBOX
api_root_path = NETBOX API URL (e.g. http://localhost/netbox/api)
api_key = INGESTION_API_KEY
api_key = DIODE_API_KEY

0 comments on commit 6502587

Please sign in to comment.