ui: Ensure value is always passed to CONSUL_SSO_ENABLED (#7913)

ACLsEnabled is always set to either true or false. .SSOEnabled is only set if you are running enterprise (the same as .NamespacesEnabled). Therefore .SSOEnabled and .NamespacesEnabled require conditionals to check their existence.

In order to avoid future confusion we moved all go-template variables to use the conditional form, and added a comment to that effect.

Tests have been added to reflect this, but they only test that the template outputs what we expect, true e2e testing here would be advantageous.
This commit is contained in:
John Cowen 2020-05-18 20:22:37 +01:00 committed by GitHub
parent 228284758b
commit 5d5bb6cca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -127,9 +127,11 @@ module.exports = function(environment, $ = process.env) {
});
break;
case environment === 'production':
// Make sure all templated variables check for existence first
// before outputting them, this means they all should be conditionals
ENV = Object.assign({}, ENV, {
CONSUL_ACLS_ENABLED: '{{.ACLsEnabled}}',
CONSUL_SSO_ENABLED: '{{.SSOEnabled}}',
CONSUL_ACLS_ENABLED: '{{ if .ACLsEnabled }}{{.ACLsEnabled}}{{ else }}false{{ end }}',
CONSUL_SSO_ENABLED: '{{ if .SSOEnabled }}{{.SSOEnabled}}{{ else }}false{{ end }}',
CONSUL_NSPACES_ENABLED:
'{{ if .NamespacesEnabled }}{{.NamespacesEnabled}}{{ else }}false{{ end }}',
});

View File

@ -9,8 +9,8 @@ test(
{
environment: 'production',
CONSUL_BINARY_TYPE: 'oss',
CONSUL_ACLS_ENABLED: '{{.ACLsEnabled}}',
CONSUL_SSO_ENABLED: '{{.SSOEnabled}}',
CONSUL_ACLS_ENABLED: '{{ if .ACLsEnabled }}{{.ACLsEnabled}}{{ else }}false{{ end }}',
CONSUL_SSO_ENABLED: '{{ if .SSOEnabled }}{{.SSOEnabled}}{{ else }}false{{ end }}',
CONSUL_NSPACES_ENABLED: '{{ if .NamespacesEnabled }}{{.NamespacesEnabled}}{{ else }}false{{ end }}',
},
{