Enable/Disable Peering Support in the UI (#13816)
We enabled/disable based on the config flag.
This commit is contained in:
parent
b60ebc022e
commit
6a47c44755
|
@ -35,6 +35,7 @@ func uiTemplateDataFromConfig(cfg *config.RuntimeConfig) (map[string]interface{}
|
||||||
"UIConfig": uiCfg,
|
"UIConfig": uiCfg,
|
||||||
"LocalDatacenter": cfg.Datacenter,
|
"LocalDatacenter": cfg.Datacenter,
|
||||||
"PrimaryDatacenter": cfg.PrimaryDatacenter,
|
"PrimaryDatacenter": cfg.PrimaryDatacenter,
|
||||||
|
"PeeringEnabled": cfg.PeeringEnabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also inject additional provider scripts if needed, otherwise strip the
|
// Also inject additional provider scripts if needed, otherwise strip the
|
||||||
|
|
|
@ -43,6 +43,7 @@ func TestUIServerIndex(t *testing.T) {
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
"PrimaryDatacenter": "dc1",
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
|
"PeeringEnabled": true,
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"hcp_enabled": false,
|
"hcp_enabled": false,
|
||||||
"metrics_provider": "",
|
"metrics_provider": "",
|
||||||
|
@ -78,6 +79,7 @@ func TestUIServerIndex(t *testing.T) {
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
"PrimaryDatacenter": "dc1",
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
|
"PeeringEnabled": true,
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"hcp_enabled": false,
|
"hcp_enabled": false,
|
||||||
"metrics_provider": "foo",
|
"metrics_provider": "foo",
|
||||||
|
@ -101,6 +103,7 @@ func TestUIServerIndex(t *testing.T) {
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
"PrimaryDatacenter": "dc1",
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
|
"PeeringEnabled": true,
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"hcp_enabled": false,
|
"hcp_enabled": false,
|
||||||
"metrics_provider": "",
|
"metrics_provider": "",
|
||||||
|
@ -121,6 +124,7 @@ func TestUIServerIndex(t *testing.T) {
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
"PrimaryDatacenter": "dc1",
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
|
"PeeringEnabled": true,
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"hcp_enabled": true,
|
"hcp_enabled": true,
|
||||||
"metrics_provider": "",
|
"metrics_provider": "",
|
||||||
|
@ -129,6 +133,29 @@ func TestUIServerIndex(t *testing.T) {
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "peering disabled",
|
||||||
|
cfg: basicUIEnabledConfig(
|
||||||
|
withPeeringDisabled(),
|
||||||
|
),
|
||||||
|
path: "/",
|
||||||
|
wantStatus: http.StatusOK,
|
||||||
|
wantContains: []string{"<!-- CONSUL_VERSION:"},
|
||||||
|
wantUICfgJSON: `{
|
||||||
|
"ACLsEnabled": false,
|
||||||
|
"HCPEnabled": false,
|
||||||
|
"LocalDatacenter": "dc1",
|
||||||
|
"PrimaryDatacenter": "dc1",
|
||||||
|
"ContentPath": "/ui/",
|
||||||
|
"PeeringEnabled": false,
|
||||||
|
"UIConfig": {
|
||||||
|
"hcp_enabled": false,
|
||||||
|
"metrics_provider": "",
|
||||||
|
"metrics_proxy_enabled": false,
|
||||||
|
"dashboard_url_templates": null
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "external transformation",
|
name: "external transformation",
|
||||||
cfg: basicUIEnabledConfig(
|
cfg: basicUIEnabledConfig(
|
||||||
|
@ -152,6 +179,7 @@ func TestUIServerIndex(t *testing.T) {
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
"PrimaryDatacenter": "dc1",
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
|
"PeeringEnabled": true,
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"hcp_enabled": false,
|
"hcp_enabled": false,
|
||||||
"metrics_provider": "bar",
|
"metrics_provider": "bar",
|
||||||
|
@ -250,6 +278,7 @@ func basicUIEnabledConfig(opts ...cfgFunc) *config.RuntimeConfig {
|
||||||
},
|
},
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
PrimaryDatacenter: "dc1",
|
PrimaryDatacenter: "dc1",
|
||||||
|
PeeringEnabled: true,
|
||||||
}
|
}
|
||||||
for _, f := range opts {
|
for _, f := range opts {
|
||||||
f(cfg)
|
f(cfg)
|
||||||
|
@ -289,6 +318,12 @@ func withHCPEnabled() cfgFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func withPeeringDisabled() cfgFunc {
|
||||||
|
return func(cfg *config.RuntimeConfig) {
|
||||||
|
cfg.PeeringEnabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TestMultipleIndexRequests validates that the buffered file mechanism works
|
// TestMultipleIndexRequests validates that the buffered file mechanism works
|
||||||
// beyond the first request. The initial implementation did not as it shared an
|
// beyond the first request. The initial implementation did not as it shared an
|
||||||
// bytes.Reader between callers.
|
// bytes.Reader between callers.
|
||||||
|
@ -422,6 +457,7 @@ func TestHandler_ServeHTTP_TransformIsEvaluatedOnEachRequest(t *testing.T) {
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
"PrimaryDatacenter": "dc1",
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
|
"PeeringEnabled": true,
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"hcp_enabled": false,
|
"hcp_enabled": false,
|
||||||
"metrics_provider": "",
|
"metrics_provider": "",
|
||||||
|
@ -447,6 +483,7 @@ func TestHandler_ServeHTTP_TransformIsEvaluatedOnEachRequest(t *testing.T) {
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
"PrimaryDatacenter": "dc1",
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
|
"PeeringEnabled": true,
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"hcp_enabled": false,
|
"hcp_enabled": false,
|
||||||
"metrics_provider": "",
|
"metrics_provider": "",
|
||||||
|
|
Loading…
Reference in New Issue