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,
|
||||
"LocalDatacenter": cfg.Datacenter,
|
||||
"PrimaryDatacenter": cfg.PrimaryDatacenter,
|
||||
"PeeringEnabled": cfg.PeeringEnabled,
|
||||
}
|
||||
|
||||
// Also inject additional provider scripts if needed, otherwise strip the
|
||||
|
|
|
@ -43,6 +43,7 @@ func TestUIServerIndex(t *testing.T) {
|
|||
"LocalDatacenter": "dc1",
|
||||
"PrimaryDatacenter": "dc1",
|
||||
"ContentPath": "/ui/",
|
||||
"PeeringEnabled": true,
|
||||
"UIConfig": {
|
||||
"hcp_enabled": false,
|
||||
"metrics_provider": "",
|
||||
|
@ -78,6 +79,7 @@ func TestUIServerIndex(t *testing.T) {
|
|||
"LocalDatacenter": "dc1",
|
||||
"PrimaryDatacenter": "dc1",
|
||||
"ContentPath": "/ui/",
|
||||
"PeeringEnabled": true,
|
||||
"UIConfig": {
|
||||
"hcp_enabled": false,
|
||||
"metrics_provider": "foo",
|
||||
|
@ -101,6 +103,7 @@ func TestUIServerIndex(t *testing.T) {
|
|||
"LocalDatacenter": "dc1",
|
||||
"PrimaryDatacenter": "dc1",
|
||||
"ContentPath": "/ui/",
|
||||
"PeeringEnabled": true,
|
||||
"UIConfig": {
|
||||
"hcp_enabled": false,
|
||||
"metrics_provider": "",
|
||||
|
@ -121,6 +124,7 @@ func TestUIServerIndex(t *testing.T) {
|
|||
"LocalDatacenter": "dc1",
|
||||
"PrimaryDatacenter": "dc1",
|
||||
"ContentPath": "/ui/",
|
||||
"PeeringEnabled": true,
|
||||
"UIConfig": {
|
||||
"hcp_enabled": true,
|
||||
"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",
|
||||
cfg: basicUIEnabledConfig(
|
||||
|
@ -152,6 +179,7 @@ func TestUIServerIndex(t *testing.T) {
|
|||
"LocalDatacenter": "dc1",
|
||||
"PrimaryDatacenter": "dc1",
|
||||
"ContentPath": "/ui/",
|
||||
"PeeringEnabled": true,
|
||||
"UIConfig": {
|
||||
"hcp_enabled": false,
|
||||
"metrics_provider": "bar",
|
||||
|
@ -250,6 +278,7 @@ func basicUIEnabledConfig(opts ...cfgFunc) *config.RuntimeConfig {
|
|||
},
|
||||
Datacenter: "dc1",
|
||||
PrimaryDatacenter: "dc1",
|
||||
PeeringEnabled: true,
|
||||
}
|
||||
for _, f := range opts {
|
||||
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
|
||||
// beyond the first request. The initial implementation did not as it shared an
|
||||
// bytes.Reader between callers.
|
||||
|
@ -422,6 +457,7 @@ func TestHandler_ServeHTTP_TransformIsEvaluatedOnEachRequest(t *testing.T) {
|
|||
"LocalDatacenter": "dc1",
|
||||
"PrimaryDatacenter": "dc1",
|
||||
"ContentPath": "/ui/",
|
||||
"PeeringEnabled": true,
|
||||
"UIConfig": {
|
||||
"hcp_enabled": false,
|
||||
"metrics_provider": "",
|
||||
|
@ -447,6 +483,7 @@ func TestHandler_ServeHTTP_TransformIsEvaluatedOnEachRequest(t *testing.T) {
|
|||
"LocalDatacenter": "dc1",
|
||||
"PrimaryDatacenter": "dc1",
|
||||
"ContentPath": "/ui/",
|
||||
"PeeringEnabled": true,
|
||||
"UIConfig": {
|
||||
"hcp_enabled": false,
|
||||
"metrics_provider": "",
|
||||
|
|
Loading…
Reference in a new issue