Skip to content

Commit

Permalink
ui: Ensure value is always passed to CONSUL_SSO_ENABLED (#7913)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
johncowen authored and hashicorp-ci committed May 18, 2020
1 parent 6969d08 commit c96b31e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ui-v2/config/environment.js
Expand Up @@ -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 }}',
});
Expand Down
4 changes: 2 additions & 2 deletions ui-v2/node-tests/config/environment.js
Expand Up @@ -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 }}',
},
{
Expand Down

0 comments on commit c96b31e

Please sign in to comment.