diff --git a/api/cmd/serve.go b/api/cmd/serve.go index ebb2a580..9d5eaf65 100644 --- a/api/cmd/serve.go +++ b/api/cmd/serve.go @@ -75,13 +75,12 @@ func startServer(cfg *config.Config) { mount(router, "/v2", api.NewRouter(appCtx, v2Controllers)) uiEnv := uiEnvHandler{ - APIURL: cfg.APIHost, - OauthClientID: cfg.OauthClientID, - Environment: cfg.Environment, - SentryDSN: cfg.SentryDSN, - Streams: cfg.Streams, - Docs: cfg.Docs, - MetadataUpdateEnabled: cfg.MetadataUpdateEnabled, + APIURL: cfg.APIHost, + OauthClientID: cfg.OauthClientID, + Environment: cfg.Environment, + SentryDSN: cfg.SentryDSN, + Streams: cfg.Streams, + Docs: cfg.Docs, MaxAuthzCacheExpiryMinutes: fmt.Sprintf("%.0f", math.Ceil((time.Duration(enforcer.MaxKeyExpirySeconds) * time.Second).Minutes())), UIConfig: cfg.UI, @@ -115,7 +114,6 @@ type uiEnvHandler struct { Streams config.Streams `json:"REACT_APP_STREAMS"` Docs config.Documentations `json:"REACT_APP_DOC_LINKS"` MaxAuthzCacheExpiryMinutes string `json:"REACT_APP_MAX_AUTHZ_CACHE_EXPIRY_MINUTES"` - MetadataUpdateEnabled bool `json:"REACT_APP_METADATA_UPDATE_ENABLED"` } func (h uiEnvHandler) handler(w http.ResponseWriter, r *http.Request) { diff --git a/api/config/config.go b/api/config/config.go index 6b6b7e20..fc36682f 100644 --- a/api/config/config.go +++ b/api/config/config.go @@ -18,12 +18,11 @@ import ( ) type Config struct { - APIHost string `validate:"required"` - Environment string `validate:"required"` - Port int `validate:"required"` - SentryDSN string - OauthClientID string - MetadataUpdateEnabled bool + APIHost string `validate:"required"` + Environment string `validate:"required"` + Port int `validate:"required"` + SentryDSN string + OauthClientID string Streams Streams `validate:"dive,required"` Docs Documentations @@ -117,8 +116,9 @@ type UIConfig struct { StaticPath string `validated:"required"` IndexPath string `validated:"required"` - ClockworkUIHomepage string `json:"REACT_APP_CLOCKWORK_UI_HOMEPAGE"` - KubeflowUIHomepage string `json:"REACT_APP_KUBEFLOW_UI_HOMEPAGE"` + ClockworkUIHomepage string `json:"REACT_APP_CLOCKWORK_UI_HOMEPAGE"` + KubeflowUIHomepage string `json:"REACT_APP_KUBEFLOW_UI_HOMEPAGE"` + MetadataUpdateEnabled bool `json:"REACT_APP_METADATA_UPDATE_ENABLED"` } // Transform env variables to the format consumed by koanf. diff --git a/api/config/config_test.go b/api/config/config_test.go index 21c72c48..18d8a01a 100644 --- a/api/config/config_test.go +++ b/api/config/config_test.go @@ -65,7 +65,6 @@ func TestLoad(t *testing.T) { CacheCleanUpIntervalSeconds: 900, }, }, - MetadataUpdateEnabled: false, Database: &config.DatabaseConfig{ Host: "localhost", Port: 5432, @@ -86,8 +85,9 @@ func TestLoad(t *testing.T) { "EmptyStream": {}, }, UI: &config.UIConfig{ - StaticPath: "ui/build", - IndexPath: "index.html", + StaticPath: "ui/build", + IndexPath: "index.html", + MetadataUpdateEnabled: false, }, DefaultSecretStorage: &config.SecretStorage{ Name: "default-secret-storage", @@ -122,7 +122,6 @@ func TestLoad(t *testing.T) { CacheCleanUpIntervalSeconds: 900, }, }, - MetadataUpdateEnabled: false, Database: &config.DatabaseConfig{ Host: "localhost", Port: 5432, @@ -144,8 +143,9 @@ func TestLoad(t *testing.T) { "EmptyStream": {}, }, UI: &config.UIConfig{ - StaticPath: "ui/build", - IndexPath: "index.html", + StaticPath: "ui/build", + IndexPath: "index.html", + MetadataUpdateEnabled: false, }, DefaultSecretStorage: &config.SecretStorage{ Name: "default-secret-storage", @@ -199,7 +199,6 @@ func TestLoad(t *testing.T) { }, }, }, - MetadataUpdateEnabled: false, Authorization: &config.AuthorizationConfig{ Enabled: true, KetoRemoteRead: "http://localhost:4466", @@ -241,8 +240,9 @@ func TestLoad(t *testing.T) { StaticPath: "ui/build", IndexPath: "index.html", - ClockworkUIHomepage: "http://clockwork.dev", - KubeflowUIHomepage: "http://kubeflow.org", + ClockworkUIHomepage: "http://clockwork.dev", + KubeflowUIHomepage: "http://kubeflow.org", + MetadataUpdateEnabled: false, }, DefaultSecretStorage: &config.SecretStorage{ Name: "default-secret-storage", @@ -300,7 +300,6 @@ func TestValidate(t *testing.T) { CacheCleanUpIntervalSeconds: 900, }, }, - MetadataUpdateEnabled: false, Database: &config.DatabaseConfig{ Host: "localhost", Port: 5432, @@ -326,6 +325,9 @@ func TestValidate(t *testing.T) { }, }, }, + UI: &config.UIConfig{ + MetadataUpdateEnabled: false, + }, }, }, "extended | success": { @@ -342,7 +344,6 @@ func TestValidate(t *testing.T) { CacheCleanUpIntervalSeconds: 900, }, }, - MetadataUpdateEnabled: false, Database: &config.DatabaseConfig{ Host: "localhost", Port: 5432, @@ -371,6 +372,9 @@ func TestValidate(t *testing.T) { }, }, }, + UI: &config.UIConfig{ + MetadataUpdateEnabled: false, + }, }, }, "default config | failure": { @@ -394,7 +398,6 @@ func TestValidate(t *testing.T) { CacheCleanUpIntervalSeconds: 900, }, }, - MetadataUpdateEnabled: false, Database: &config.DatabaseConfig{ Host: "localhost", Port: 5432, @@ -420,6 +423,9 @@ func TestValidate(t *testing.T) { }, }, }, + UI: &config.UIConfig{ + MetadataUpdateEnabled: false, + }, }, error: errors.New( "failed to validate configuration: " + @@ -440,7 +446,6 @@ func TestValidate(t *testing.T) { Enabled: true, }, }, - MetadataUpdateEnabled: false, Database: &config.DatabaseConfig{ Host: "localhost", Port: 5432, @@ -466,6 +471,9 @@ func TestValidate(t *testing.T) { }, }, }, + UI: &config.UIConfig{ + MetadataUpdateEnabled: false, + }, }, error: errors.New( "failed to validate configuration: " + diff --git a/api/config/testdata/config-1.yaml b/api/config/testdata/config-1.yaml index 8d7ee707..91b6501e 100644 --- a/api/config/testdata/config-1.yaml +++ b/api/config/testdata/config-1.yaml @@ -23,4 +23,7 @@ defaultSecretStorage: mountPath: secret pathPrefix: caraml-secret/{{ .project }}/ authMethod: gcp - gcpAuthType: gce \ No newline at end of file + gcpAuthType: gce + +ui: + metadataUpdateEnabled: false \ No newline at end of file diff --git a/api/config/testdata/config-2.yaml b/api/config/testdata/config-2.yaml index 635b6f02..cdb1647b 100644 --- a/api/config/testdata/config-2.yaml +++ b/api/config/testdata/config-2.yaml @@ -28,6 +28,7 @@ authorization: ui: clockworkUIHomepage: http://clockwork.dev kubeflowUIHomepage: http://kubeflow.org + metadataUpdateEnabled: false defaultSecretStorage: name: default-secret-storage