ui: Pass primary dc through to uiserver (#11317)
Co-authored-by: John Cowen <johncowen@users.noreply.github.com>
This commit is contained in:
parent
f24bad2a52
commit
3f736467e6
|
@ -28,10 +28,11 @@ func uiTemplateDataFromConfig(cfg *config.RuntimeConfig) (map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
d := map[string]interface{}{
|
d := map[string]interface{}{
|
||||||
"ContentPath": cfg.UIConfig.ContentPath,
|
"ContentPath": cfg.UIConfig.ContentPath,
|
||||||
"ACLsEnabled": cfg.ACLsEnabled,
|
"ACLsEnabled": cfg.ACLsEnabled,
|
||||||
"UIConfig": uiCfg,
|
"UIConfig": uiCfg,
|
||||||
"LocalDatacenter": cfg.Datacenter,
|
"LocalDatacenter": cfg.Datacenter,
|
||||||
|
"PrimaryDatacenter": cfg.PrimaryDatacenter,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also inject additional provider scripts if needed, otherwise strip the
|
// Also inject additional provider scripts if needed, otherwise strip the
|
||||||
|
|
|
@ -40,6 +40,7 @@ func TestUIServerIndex(t *testing.T) {
|
||||||
wantUICfgJSON: `{
|
wantUICfgJSON: `{
|
||||||
"ACLsEnabled": false,
|
"ACLsEnabled": false,
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"metrics_provider": "",
|
"metrics_provider": "",
|
||||||
|
@ -72,6 +73,7 @@ func TestUIServerIndex(t *testing.T) {
|
||||||
wantUICfgJSON: `{
|
wantUICfgJSON: `{
|
||||||
"ACLsEnabled": false,
|
"ACLsEnabled": false,
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"metrics_provider": "foo",
|
"metrics_provider": "foo",
|
||||||
|
@ -92,6 +94,7 @@ func TestUIServerIndex(t *testing.T) {
|
||||||
wantUICfgJSON: `{
|
wantUICfgJSON: `{
|
||||||
"ACLsEnabled": true,
|
"ACLsEnabled": true,
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"metrics_provider": "",
|
"metrics_provider": "",
|
||||||
|
@ -120,6 +123,7 @@ func TestUIServerIndex(t *testing.T) {
|
||||||
"ACLsEnabled": false,
|
"ACLsEnabled": false,
|
||||||
"SSOEnabled": true,
|
"SSOEnabled": true,
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"metrics_provider": "bar",
|
"metrics_provider": "bar",
|
||||||
|
@ -216,7 +220,8 @@ func basicUIEnabledConfig(opts ...cfgFunc) *config.RuntimeConfig {
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
ContentPath: "/ui/",
|
ContentPath: "/ui/",
|
||||||
},
|
},
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
|
PrimaryDatacenter: "dc1",
|
||||||
}
|
}
|
||||||
for _, f := range opts {
|
for _, f := range opts {
|
||||||
f(cfg)
|
f(cfg)
|
||||||
|
@ -380,6 +385,7 @@ func TestHandler_ServeHTTP_TransformIsEvaluatedOnEachRequest(t *testing.T) {
|
||||||
expected := `{
|
expected := `{
|
||||||
"ACLsEnabled": false,
|
"ACLsEnabled": false,
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"metrics_provider": "",
|
"metrics_provider": "",
|
||||||
|
@ -402,6 +408,7 @@ func TestHandler_ServeHTTP_TransformIsEvaluatedOnEachRequest(t *testing.T) {
|
||||||
expected := `{
|
expected := `{
|
||||||
"ACLsEnabled": false,
|
"ACLsEnabled": false,
|
||||||
"LocalDatacenter": "dc1",
|
"LocalDatacenter": "dc1",
|
||||||
|
"PrimaryDatacenter": "dc1",
|
||||||
"ContentPath": "/ui/",
|
"ContentPath": "/ui/",
|
||||||
"UIConfig": {
|
"UIConfig": {
|
||||||
"metrics_provider": "",
|
"metrics_provider": "",
|
||||||
|
|
|
@ -68,9 +68,12 @@ export default function(config = {}, win = window, doc = document) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const operatorConfig = JSON.parse(
|
const operatorConfig = {
|
||||||
doc.querySelector(`[data-${config.modulePrefix}-config]`).textContent
|
...config.operatorConfig,
|
||||||
);
|
...JSON.parse(
|
||||||
|
doc.querySelector(`[data-${config.modulePrefix}-config]`).textContent
|
||||||
|
)
|
||||||
|
};
|
||||||
const ui_config = operatorConfig.UIConfig || {};
|
const ui_config = operatorConfig.UIConfig || {};
|
||||||
const scripts = doc.getElementsByTagName('script');
|
const scripts = doc.getElementsByTagName('script');
|
||||||
// we use the currently executing script as a reference
|
// we use the currently executing script as a reference
|
||||||
|
@ -101,6 +104,8 @@ export default function(config = {}, win = window, doc = document) {
|
||||||
: operatorConfig.PartitionsEnabled;
|
: operatorConfig.PartitionsEnabled;
|
||||||
case 'CONSUL_DATACENTER_LOCAL':
|
case 'CONSUL_DATACENTER_LOCAL':
|
||||||
return operatorConfig.LocalDatacenter;
|
return operatorConfig.LocalDatacenter;
|
||||||
|
case 'CONSUL_DATACENTER_PRIMARY':
|
||||||
|
return operatorConfig.PrimaryDatacenter;
|
||||||
case 'CONSUL_UI_CONFIG':
|
case 'CONSUL_UI_CONFIG':
|
||||||
dashboards = {};
|
dashboards = {};
|
||||||
provider = env('CONSUL_METRICS_PROVIDER');
|
provider = env('CONSUL_METRICS_PROVIDER');
|
||||||
|
@ -209,6 +214,7 @@ export default function(config = {}, win = window, doc = document) {
|
||||||
return user(str) || ui(str);
|
return user(str) || ui(str);
|
||||||
case 'CONSUL_UI_CONFIG':
|
case 'CONSUL_UI_CONFIG':
|
||||||
case 'CONSUL_DATACENTER_LOCAL':
|
case 'CONSUL_DATACENTER_LOCAL':
|
||||||
|
case 'CONSUL_DATACENTER_PRIMARY':
|
||||||
case 'CONSUL_ACLS_ENABLED':
|
case 'CONSUL_ACLS_ENABLED':
|
||||||
case 'CONSUL_NSPACES_ENABLED':
|
case 'CONSUL_NSPACES_ENABLED':
|
||||||
case 'CONSUL_SSO_ENABLED':
|
case 'CONSUL_SSO_ENABLED':
|
||||||
|
|
|
@ -84,6 +84,7 @@ module.exports = function(environment, $ = process.env) {
|
||||||
SSOEnabled: false,
|
SSOEnabled: false,
|
||||||
PartitionsEnabled: false,
|
PartitionsEnabled: false,
|
||||||
LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'),
|
LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'),
|
||||||
|
PrimaryDatacenter: env('CONSUL_DATACENTER_PRIMARY', 'dc1'),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Static variables used in multiple places throughout the UI
|
// Static variables used in multiple places throughout the UI
|
||||||
|
@ -106,6 +107,7 @@ module.exports = function(environment, $ = process.env) {
|
||||||
SSOEnabled: env('CONSUL_SSO_ENABLED', false),
|
SSOEnabled: env('CONSUL_SSO_ENABLED', false),
|
||||||
PartitionsEnabled: env('CONSUL_PARTITIONS_ENABLED', false),
|
PartitionsEnabled: env('CONSUL_PARTITIONS_ENABLED', false),
|
||||||
LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'),
|
LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'),
|
||||||
|
PrimaryDatacenter: env('CONSUL_DATACENTER_PRIMARY', 'dc1'),
|
||||||
},
|
},
|
||||||
|
|
||||||
'@hashicorp/ember-cli-api-double': {
|
'@hashicorp/ember-cli-api-double': {
|
||||||
|
@ -154,6 +156,7 @@ module.exports = function(environment, $ = process.env) {
|
||||||
SSOEnabled: env('CONSUL_SSO_ENABLED', true),
|
SSOEnabled: env('CONSUL_SSO_ENABLED', true),
|
||||||
PartitionsEnabled: env('CONSUL_PARTITIONS_ENABLED', true),
|
PartitionsEnabled: env('CONSUL_PARTITIONS_ENABLED', true),
|
||||||
LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'),
|
LocalDatacenter: env('CONSUL_DATACENTER_LOCAL', 'dc1'),
|
||||||
|
PrimaryDatacenter: env('CONSUL_DATACENTER_PRIMARY', 'dc1'),
|
||||||
},
|
},
|
||||||
|
|
||||||
'@hashicorp/ember-cli-api-double': {
|
'@hashicorp/ember-cli-api-double': {
|
||||||
|
|
|
@ -22,6 +22,7 @@ test(
|
||||||
SSOEnabled: false,
|
SSOEnabled: false,
|
||||||
PartitionsEnabled: false,
|
PartitionsEnabled: false,
|
||||||
LocalDatacenter: 'dc1',
|
LocalDatacenter: 'dc1',
|
||||||
|
PrimaryDatacenter: 'dc1',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -36,6 +37,7 @@ test(
|
||||||
SSOEnabled: false,
|
SSOEnabled: false,
|
||||||
PartitionsEnabled: false,
|
PartitionsEnabled: false,
|
||||||
LocalDatacenter: 'dc1',
|
LocalDatacenter: 'dc1',
|
||||||
|
PrimaryDatacenter: 'dc1',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -50,6 +52,7 @@ test(
|
||||||
SSOEnabled: true,
|
SSOEnabled: true,
|
||||||
PartitionsEnabled: false,
|
PartitionsEnabled: false,
|
||||||
LocalDatacenter: 'dc1',
|
LocalDatacenter: 'dc1',
|
||||||
|
PrimaryDatacenter: 'dc1',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -61,6 +64,7 @@ test(
|
||||||
SSOEnabled: true,
|
SSOEnabled: true,
|
||||||
PartitionsEnabled: true,
|
PartitionsEnabled: true,
|
||||||
LocalDatacenter: 'dc1',
|
LocalDatacenter: 'dc1',
|
||||||
|
PrimaryDatacenter: 'dc1',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
].forEach(
|
].forEach(
|
||||||
|
|
Loading…
Reference in New Issue