Skip to content

Commit

Permalink
feat: fix names
Browse files Browse the repository at this point in the history
  • Loading branch information
leoparente committed Jul 22, 2024
1 parent 787ee1f commit 5714485
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
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:"DIODE_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_API_KEY" {
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_API_KEY" {
dataSources = append(dataSources, &reconcilerpb.IngestionDataSource{Name: name, ApiKey: key})
}
}
Expand Down

0 comments on commit 5714485

Please sign in to comment.