Skip to content

Commit

Permalink
Migrate server.enterpriseLicense to global.enterpriseLicense
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisnotashwin committed Nov 10, 2021
1 parent 4afb418 commit 30d44f5
Show file tree
Hide file tree
Showing 21 changed files with 217 additions and 204 deletions.
4 changes: 2 additions & 2 deletions acceptance/framework/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func (t *TestConfig) HelmValuesFromConfig() (map[string]string, error) {
}

if t.EnterpriseLicense != "" {
setIfNotEmpty(helmValues, "server.enterpriseLicense.secretName", LicenseSecretName)
setIfNotEmpty(helmValues, "server.enterpriseLicense.secretKey", LicenseSecretKey)
setIfNotEmpty(helmValues, "global.enterpriseLicense.secretName", LicenseSecretName)
setIfNotEmpty(helmValues, "global.enterpriseLicense.secretKey", LicenseSecretKey)
}

if t.EnableOpenshift {
Expand Down
4 changes: 2 additions & 2 deletions acceptance/framework/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func TestConfig_HelmValuesFromConfig(t *testing.T) {
EnterpriseLicense: "ent-license",
},
map[string]string{
"server.enterpriseLicense.secretName": "license",
"server.enterpriseLicense.secretKey": "key",
"global.enterpriseLicense.secretName": "license",
"global.enterpriseLicense.secretKey": "key",
"connectInject.transparentProxy.defaultEnabled": "false",
},
},
Expand Down
10 changes: 5 additions & 5 deletions charts/consul/templates/client-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ spec:
- name: aclconfig
emptyDir: {}
{{- else }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload) }}
- name: consul-license
secret:
secretName: {{ .Values.server.enterpriseLicense.secretName }}
secretName: {{ .Values.global.enterpriseLicense.secretName }}
{{- end }}
{{- end }}
containers:
Expand Down Expand Up @@ -181,9 +181,9 @@ spec:
key: {{ .Values.global.gossipEncryption.secretKey }}
{{- end }}
{{- end }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload (not .Values.global.acls.manageSystemACLs)) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload (not .Values.global.acls.manageSystemACLs)) }}
- name: CONSUL_LICENSE_PATH
value: /consul/license/{{ .Values.server.enterpriseLicense.secretKey }}
value: /consul/license/{{ .Values.global.enterpriseLicense.secretKey }}
{{- end }}
{{- if .Values.global.tls.enabled }}
- name: CONSUL_HTTP_ADDR
Expand Down Expand Up @@ -302,7 +302,7 @@ spec:
- name: aclconfig
mountPath: /consul/aclconfig
{{- else }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload) }}
- name: consul-license
mountPath: /consul/license
readOnly: true
Expand Down
14 changes: 7 additions & 7 deletions charts/consul/templates/client-snapshot-agent-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ spec:
{{- if .Values.client.priorityClassName }}
priorityClassName: {{ .Values.client.priorityClassName | quote }}
{{- end }}
{{- if (or .Values.global.acls.manageSystemACLs .Values.global.tls.enabled (and .Values.client.snapshotAgent.configSecret.secretName .Values.client.snapshotAgent.configSecret.secretKey) (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload)) }}
{{- if (or .Values.global.acls.manageSystemACLs .Values.global.tls.enabled (and .Values.client.snapshotAgent.configSecret.secretName .Values.client.snapshotAgent.configSecret.secretKey) (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload)) }}
volumes:
{{- if (and .Values.client.snapshotAgent.configSecret.secretName .Values.client.snapshotAgent.configSecret.secretKey) }}
- name: snapshot-config
Expand All @@ -52,10 +52,10 @@ spec:
- name: aclconfig
emptyDir: {}
{{- else }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload) }}
- name: consul-license
secret:
secretName: {{ .Values.server.enterpriseLicense.secretName }}
secretName: {{ .Values.global.enterpriseLicense.secretName }}
{{- end }}
{{- end }}
{{- if .Values.global.tls.enabled }}
Expand Down Expand Up @@ -102,9 +102,9 @@ spec:
name: "{{ template "consul.fullname" . }}-client-snapshot-agent-acl-token"
key: "token"
{{- else }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload) }}
- name: CONSUL_LICENSE_PATH
value: /consul/license/{{ .Values.server.enterpriseLicense.secretKey }}
value: /consul/license/{{ .Values.global.enterpriseLicense.secretKey }}
{{- end }}
{{- end}}
command:
Expand All @@ -123,7 +123,7 @@ spec:
{{- if .Values.global.acls.manageSystemACLs }}
-config-dir=/consul/aclconfig \
{{- end }}
{{- if (or .Values.global.acls.manageSystemACLs .Values.global.tls.enabled (and .Values.client.snapshotAgent.configSecret.secretName .Values.client.snapshotAgent.configSecret.secretKey) (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload)) }}
{{- if (or .Values.global.acls.manageSystemACLs .Values.global.tls.enabled (and .Values.client.snapshotAgent.configSecret.secretName .Values.client.snapshotAgent.configSecret.secretKey) (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload)) }}
volumeMounts:
{{- if (and .Values.client.snapshotAgent.configSecret.secretName .Values.client.snapshotAgent.configSecret.secretKey) }}
- name: snapshot-config
Expand All @@ -134,7 +134,7 @@ spec:
- name: aclconfig
mountPath: /consul/aclconfig
{{- else }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload) }}
- name: consul-license
mountPath: /consul/license
readOnly: true
Expand Down
7 changes: 4 additions & 3 deletions charts/consul/templates/enterprise-license-job.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{- if .Values.server.enterpriseLicense }}{{ fail "server.enterpriseLicense has been moved to global.enterpriseLicense" }}{{ end -}}
{{- if (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled)) }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey (not .Values.server.enterpriseLicense.enableLicenseAutoload)) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey (not .Values.global.enterpriseLicense.enableLicenseAutoload)) }}
apiVersion: batch/v1
kind: Job
metadata:
Expand Down Expand Up @@ -55,8 +56,8 @@ spec:
- name: ENTERPRISE_LICENSE
valueFrom:
secretKeyRef:
name: {{ .Values.server.enterpriseLicense.secretName }}
key: {{ .Values.server.enterpriseLicense.secretKey }}
name: {{ .Values.global.enterpriseLicense.secretName }}
key: {{ .Values.global.enterpriseLicense.secretKey }}
- name: CONSUL_HTTP_ADDR
{{- if .Values.global.tls.enabled }}
value: https://{{ template "consul.fullname" . }}-server:8501
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled)) }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey (not .Values.server.enterpriseLicense.enableLicenseAutoload)) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey (not .Values.global.enterpriseLicense.enableLicenseAutoload)) }}
{{- if .Values.global.enablePodSecurityPolicies }}
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/enterprise-license-role.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled)) }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey (not .Values.server.enterpriseLicense.enableLicenseAutoload)) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey (not .Values.global.enterpriseLicense.enableLicenseAutoload)) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled)) }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey (not .Values.server.enterpriseLicense.enableLicenseAutoload)) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey (not .Values.global.enterpriseLicense.enableLicenseAutoload)) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled)) }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey (not .Values.server.enterpriseLicense.enableLicenseAutoload)) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey (not .Values.global.enterpriseLicense.enableLicenseAutoload)) }}
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/server-acl-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ spec:
-acl-binding-rule-selector={{ .Values.connectInject.aclBindingRuleSelector }} \
{{- end }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey) }}
-create-enterprise-license-token=true \
{{- end }}
Expand Down
10 changes: 5 additions & 5 deletions charts/consul/templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ spec:
secretName: {{ template "consul.fullname" . }}-server-cert
{{- end }}
{{- end }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload) }}
- name: consul-license
secret:
secretName: {{ .Values.server.enterpriseLicense.secretName }}
secretName: {{ .Values.global.enterpriseLicense.secretName }}
{{- end }}
{{- range .Values.server.extraVolumes }}
- name: userconfig-{{ .name }}
Expand Down Expand Up @@ -174,9 +174,9 @@ spec:
- name: CONSUL_CACERT
value: /consul/tls/ca/tls.crt
{{- end }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload) }}
- name: CONSUL_LICENSE_PATH
value: /consul/license/{{ .Values.server.enterpriseLicense.secretKey }}
value: /consul/license/{{ .Values.global.enterpriseLicense.secretKey }}
{{- end }}
{{- if (and .Values.global.acls.replicationToken.secretName .Values.global.acls.replicationToken.secretKey) }}
- name: ACL_REPLICATION_TOKEN
Expand Down Expand Up @@ -269,7 +269,7 @@ spec:
mountPath: /consul/tls/server
readOnly: true
{{- end }}
{{- if (and .Values.server.enterpriseLicense.secretName .Values.server.enterpriseLicense.secretKey .Values.server.enterpriseLicense.enableLicenseAutoload) }}
{{- if (and .Values.global.enterpriseLicense.secretName .Values.global.enterpriseLicense.secretKey .Values.global.enterpriseLicense.enableLicenseAutoload) }}
- name: consul-license
mountPath: /consul/license
readOnly: true
Expand Down
24 changes: 12 additions & 12 deletions charts/consul/test/unit/client-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1327,8 +1327,8 @@ rollingUpdate:
cd `chart_dir`
local actual=$(helm template \
-s templates/client-daemonset.yaml \
--set 'server.enterpriseLicense.secretName=foo' \
--set 'server.enterpriseLicense.secretKey=bar' \
--set 'global.enterpriseLicense.secretName=foo' \
--set 'global.enterpriseLicense.secretKey=bar' \
. | tee /dev/stderr |
yq -r -c '.spec.template.spec.volumes[] | select(.name == "consul-license")' | tee /dev/stderr)
[ "${actual}" = '{"name":"consul-license","secret":{"secretName":"foo"}}' ]
Expand All @@ -1338,8 +1338,8 @@ rollingUpdate:
cd `chart_dir`
local actual=$(helm template \
-s templates/client-daemonset.yaml \
--set 'server.enterpriseLicense.secretName=foo' \
--set 'server.enterpriseLicense.secretKey=bar' \
--set 'global.enterpriseLicense.secretName=foo' \
--set 'global.enterpriseLicense.secretKey=bar' \
. | tee /dev/stderr |
yq -r -c '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "consul-license")' | tee /dev/stderr)
[ "${actual}" = '{"name":"consul-license","mountPath":"/consul/license","readOnly":true}' ]
Expand All @@ -1349,8 +1349,8 @@ rollingUpdate:
cd `chart_dir`
local actual=$(helm template \
-s templates/client-daemonset.yaml \
--set 'server.enterpriseLicense.secretName=foo' \
--set 'server.enterpriseLicense.secretKey=bar' \
--set 'global.enterpriseLicense.secretName=foo' \
--set 'global.enterpriseLicense.secretKey=bar' \
. | tee /dev/stderr |
yq -r -c '.spec.template.spec.containers[0].env[] | select(.name == "CONSUL_LICENSE_PATH")' | tee /dev/stderr)
[ "${actual}" = '{"name":"CONSUL_LICENSE_PATH","value":"/consul/license/bar"}' ]
Expand All @@ -1360,8 +1360,8 @@ rollingUpdate:
cd `chart_dir`
local actual=$(helm template \
-s templates/client-daemonset.yaml \
--set 'server.enterpriseLicense.secretName=foo' \
--set 'server.enterpriseLicense.secretKey=bar' \
--set 'global.enterpriseLicense.secretName=foo' \
--set 'global.enterpriseLicense.secretKey=bar' \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq -r -c '.spec.template.spec.volumes[] | select(.name == "consul-license")' | tee /dev/stderr)
Expand All @@ -1372,8 +1372,8 @@ rollingUpdate:
cd `chart_dir`
local actual=$(helm template \
-s templates/client-daemonset.yaml \
--set 'server.enterpriseLicense.secretName=foo' \
--set 'server.enterpriseLicense.secretKey=bar' \
--set 'global.enterpriseLicense.secretName=foo' \
--set 'global.enterpriseLicense.secretKey=bar' \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq -r -c '.spec.template.spec.containers[0].volumeMounts[] | select(.name == "consul-license")' | tee /dev/stderr)
Expand All @@ -1384,8 +1384,8 @@ rollingUpdate:
cd `chart_dir`
local actual=$(helm template \
-s templates/client-daemonset.yaml \
--set 'server.enterpriseLicense.secretName=foo' \
--set 'server.enterpriseLicense.secretKey=bar' \
--set 'global.enterpriseLicense.secretName=foo' \
--set 'global.enterpriseLicense.secretKey=bar' \
--set 'global.acls.manageSystemACLs=true' \
. | tee /dev/stderr |
yq -r -c '.spec.template.spec.containers[0].env[] | select(.name == "CONSUL_LICENSE_PATH")' | tee /dev/stderr)
Expand Down
Loading

0 comments on commit 30d44f5

Please sign in to comment.