diff --git a/agent/config/builder.go b/agent/config/builder.go index 695b021cda..c2a8dd8780 100644 --- a/agent/config/builder.go +++ b/agent/config/builder.go @@ -1827,6 +1827,7 @@ func (b *builder) uiConfigVal(v RawUIConfig) UIConfig { MetricsProviderOptionsJSON: stringVal(v.MetricsProviderOptionsJSON), MetricsProxy: b.uiMetricsProxyVal(v.MetricsProxy), DashboardURLTemplates: v.DashboardURLTemplates, + HCPEnabled: os.Getenv("CONSUL_HCP_ENABLED") == "true", } } diff --git a/agent/config/runtime.go b/agent/config/runtime.go index a71dbc387f..de5004e1a5 100644 --- a/agent/config/runtime.go +++ b/agent/config/runtime.go @@ -1433,6 +1433,7 @@ type UIConfig struct { MetricsProviderOptionsJSON string MetricsProxy UIMetricsProxy DashboardURLTemplates map[string]string + HCPEnabled bool } type UIMetricsProxy struct { diff --git a/agent/config/testdata/TestRuntimeConfig_Sanitize.golden b/agent/config/testdata/TestRuntimeConfig_Sanitize.golden index a166dd5174..9f4a6a1962 100644 --- a/agent/config/testdata/TestRuntimeConfig_Sanitize.golden +++ b/agent/config/testdata/TestRuntimeConfig_Sanitize.golden @@ -438,6 +438,7 @@ "DashboardURLTemplates": {}, "Dir": "", "Enabled": false, + "HCPEnabled": false, "MetricsProvider": "", "MetricsProviderFiles": [], "MetricsProviderOptionsJSON": "", diff --git a/agent/uiserver/ui_template_data.go b/agent/uiserver/ui_template_data.go index bb722f798d..bb262861a4 100644 --- a/agent/uiserver/ui_template_data.go +++ b/agent/uiserver/ui_template_data.go @@ -19,6 +19,7 @@ func uiTemplateDataFromConfig(cfg *config.RuntimeConfig) (map[string]interface{} // browser. "metrics_proxy_enabled": cfg.UIConfig.MetricsProxy.BaseURL != "", "dashboard_url_templates": cfg.UIConfig.DashboardURLTemplates, + "hcp_enabled": cfg.UIConfig.HCPEnabled, } // Only set this if there is some actual JSON or we'll cause a JSON diff --git a/agent/uiserver/uiserver_test.go b/agent/uiserver/uiserver_test.go index f72514bac2..73d38df7ce 100644 --- a/agent/uiserver/uiserver_test.go +++ b/agent/uiserver/uiserver_test.go @@ -43,6 +43,7 @@ func TestUIServerIndex(t *testing.T) { "PrimaryDatacenter": "dc1", "ContentPath": "/ui/", "UIConfig": { + "hcp_enabled": false, "metrics_provider": "", "metrics_proxy_enabled": false, "dashboard_url_templates": null @@ -76,6 +77,7 @@ func TestUIServerIndex(t *testing.T) { "PrimaryDatacenter": "dc1", "ContentPath": "/ui/", "UIConfig": { + "hcp_enabled": false, "metrics_provider": "foo", "metrics_provider_options": { "a-very-unlikely-string":1 @@ -97,6 +99,26 @@ func TestUIServerIndex(t *testing.T) { "PrimaryDatacenter": "dc1", "ContentPath": "/ui/", "UIConfig": { + "hcp_enabled": false, + "metrics_provider": "", + "metrics_proxy_enabled": false, + "dashboard_url_templates": null + } + }`, + }, + { + name: "hcp enabled", + cfg: basicUIEnabledConfig(withHCPEnabled()), + path: "/", + wantStatus: http.StatusOK, + wantContains: []string{"