Skip to content

Commit

Permalink
Use Bifrost API URL in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
thokra-nav committed Nov 26, 2024
1 parent e408c04 commit a8efbe1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions internal/cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func run(ctx context.Context, cfg *Config, log logrus.FieldLogger) error {
promReg,
vulnClient,
hookdClient,
cfg.Unleash.BifrostApiUrl,
log,
)
})
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ type unleashConfig struct {
Namespace string `env:"UNLEASH_NAMESPACE,default=bifrost-unleash"`

// BifrostApiEndpoint is the endpoint for the Bifrost API
BifrostApiUrl string `env:"UNLEASH_BIFROST_API_URL,default=http://bifrost-backend"`
BifrostApiUrl string `env:"UNLEASH_BIFROST_API_URL,default=*fake*"`
}

type Config struct {
Expand Down
6 changes: 4 additions & 2 deletions internal/cmd/api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func runHttpServer(
reg prometheus.Gatherer,
vClient vulnerability.Client,
hookdClient hookd.Client,
bifrostAPIURL string,
log logrus.FieldLogger,
) error {
router := chi.NewRouter()
Expand All @@ -92,7 +93,7 @@ func runHttpServer(
otelhttp.WithRouteTag("playground", otelhttp.NewHandler(playground.Handler("GraphQL playground", "/graphql"), "playground")),
)

contextDependencies, err := ConfigureGraph(ctx, insecureAuthAndFakes, watcherMgr, mgmtWatcherMgr, pool, k8sClients, vClient, tenantName, clusters, hookdClient, log)
contextDependencies, err := ConfigureGraph(ctx, insecureAuthAndFakes, watcherMgr, mgmtWatcherMgr, pool, k8sClients, vClient, tenantName, clusters, hookdClient, bifrostAPIURL, log)
if err != nil {
return err
}
Expand Down Expand Up @@ -177,6 +178,7 @@ func ConfigureGraph(
tenantName string,
clusters []string,
hookdClient hookd.Client,
bifrostAPIURL string,
log logrus.FieldLogger,
) (func(http.Handler) http.Handler, error) {
appWatcher := application.NewWatcher(ctx, watcherMgr)
Expand Down Expand Up @@ -254,7 +256,7 @@ func ConfigureGraph(
ctx = deployment.NewLoaderContext(ctx, hookdClient)
ctx = serviceaccount.NewLoaderContext(ctx, pool)
ctx = session.NewLoaderContext(ctx, pool)
ctx = unleash.NewLoaderContext(ctx, tenantName, unleashWatcher, "*fake*", log)
ctx = unleash.NewLoaderContext(ctx, tenantName, unleashWatcher, bifrostAPIURL, log)
return ctx
}), nil
}
3 changes: 2 additions & 1 deletion internal/integration/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/nais/api/internal/role"
"github.com/nais/api/internal/role/rolesql"
fakeHookd "github.com/nais/api/internal/thirdparty/hookd/fake"
"github.com/nais/api/internal/unleash"
"github.com/nais/api/internal/user"
"github.com/nais/api/internal/usersync"
"github.com/nais/api/internal/vulnerability"
Expand Down Expand Up @@ -147,7 +148,7 @@ func newGQLRunner(ctx context.Context, config *Config, pool *pgxpool.Pool, topic

vulnerabilityClient := vulnerability.NewDependencyTrackClient(vulnerability.DependencyTrackConfig{EnableFakes: true}, log)

graphMiddleware, err := api.ConfigureGraph(ctx, true, watcherMgr, managementWatcherMgr, pool, clusterConfig, vulnerabilityClient, config.TenantName, clusters(), fakeHookd.New(), log)
graphMiddleware, err := api.ConfigureGraph(ctx, true, watcherMgr, managementWatcherMgr, pool, clusterConfig, vulnerabilityClient, config.TenantName, clusters(), fakeHookd.New(), unleash.FakeBifrostURL, log)
if err != nil {
return nil, fmt.Errorf("failed to configure graph: %w", err)
}
Expand Down
4 changes: 3 additions & 1 deletion internal/unleash/dataloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type ctxKey int
const (
prometheusURL = "https://nais-prometheus.%s.cloud.nais.io"
loadersKey ctxKey = iota

FakeBifrostURL = "*fake*"
)

// NewLoaderContext creates a new context with a loaders value.
Expand Down Expand Up @@ -47,7 +49,7 @@ type loaders struct {
func newLoaders(tenantName string, appWatcher *watcher.Watcher[*UnleashInstance], bifrostAPIURL string, log logrus.FieldLogger) *loaders {
var client BifrostClient
var prometheus Prometheus
if bifrostAPIURL == "*fake*" {
if bifrostAPIURL == FakeBifrostURL {
client = NewFakeBifrostClient(appWatcher)
prometheus = NewFakePrometheusClient()
} else {
Expand Down

0 comments on commit a8efbe1

Please sign in to comment.