diff --git a/plural/helm/console/Chart.yaml b/plural/helm/console/Chart.yaml index 11ea2e669f..26b64842de 100644 --- a/plural/helm/console/Chart.yaml +++ b/plural/helm/console/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 appVersion: 0.3.16 description: A chart for plural console name: console -version: 0.7.36 +version: 0.7.37 dependencies: - name: test-base repository: https://pluralsh.github.io/module-library diff --git a/plural/helm/console/values.yaml.lua b/plural/helm/console/values.yaml.lua new file mode 100755 index 0000000000..a176e7c874 --- /dev/null +++ b/plural/helm/console/values.yaml.lua @@ -0,0 +1,122 @@ +output = { + global={ + application={ + links={ + { description= "console web ui", + url=Var.Values.console_dns + } + } + } + }, + enabled=true, + provider=Var.Provider, + license=Var.License, + ingress={ + console_dns=Var.Values.console_dns, + }, + serviceAccount= { + create=true, + annotations={ + ['eks.amazonaws.com/role-arn']="arn:aws:iam::" .. Var.Project .. ":role/" ..Var.Cluster .. "-console" + }, + }, + secrets={ + jwt=dedupe(Var, "console.secrets.jwt", randAlphaNum(20)), + admin_name=default("someone", Var.Values.admin_name), + admin_email=dedupe(Var, "console.secrets.admin_email", default("someone@example.com", Var.Config.Email)), + admin_password=dedupe(Var, "console.secrets.admin_password", randAlphaNum(20)), + cluster_name=Var.Cluster, + erlang=dedupe(Var, "console.secrets.erlang", randAlphaNum(14)), + id_rsa=ternary(Var.Values.private_key, dedupe(Var, "console.secrets.id_rsa", ""), hasKey (Var.Values, "private_key")), + id_rsa_pub=ternary(Var.Values.public_key, dedupe(Var, "console.secrets.id_rsa_pub", ""), hasKey(Var.Values, "public_key")), + ssh_passphrase=ternary(Var.Values.passphrase, dedupe(Var, "console.secrets.ssh_passphrase", ""), hasKey(Var.Values, "passphrase")), + git_access_token=ternary(Var.Values.access_token, dedupe(Var, "console.secrets.git_access_token", ""), hasKey(Var.Values, "access_token")), + git_user=default("console", Var.Values.git_user), + git_email=default("console@plural.sh", Var.Values.git_email), + git_url="", + repo_root="", + branch_name="", + config="", + key="", + }, + extraEnv={} +} + +if Var.Provider == "kind" then + output.ingress.annotations = { + ['external-dns.alpha.kubernetes.io/target']='127.0.0.1' + } + output.replicaCount=1 +end + +if Var.Provider == "google" then + output.serviceAccount.create = false +end + +if Var.Configuration then + if Var.Configuration.loki then + output.extraEnv={ + { + name= "LOKI_HOST", + value= 'http://loki-loki-distributed-gateway.loki' + } + } + end +end + +if Var.Provider == "azure" then + output.podLabels={ + ["aadpodidbinding"]="console" + } + output.consoleIdentityId=importValue("Terraform", "console_msi_id") + output.consoleIdentityClientId=importValue("Terraform", "console_msi_client_id") + table.insert(output.extraEnv, + { + name="ARM_USE_MSI", + value = 'true' + + } + ) + table.insert(output.extraEnv, + { + name="ARM_SUBSCRIPTION_ID", + value=Var.Context.SubscriptionId + } + ) + table.insert(output.extraEnv, + { + name="ARM_TENANT_ID", + value= Var.Context.TenantId + } + ) +end + +if Var.OIDC ~= nil then + output.secrets.plural_client_id=Var.OIDC.ClientId + output.secrets.plural_client_secret=Var.OIDC.ClientSecret +end + +if Var.Values.is_demo then + output.secrets.is_demo=Var.Values.is_demo +end + +if Var.Values.console_dns then + local gitUrl=dig("console", "secrets", "git_url", "default", Var) + local identity=pathJoin(repoRoot(), ".plural-crypt", "identity") + if gitUrl == "default" or gitUrl == "" then + output.secrets.git_url=repoUrl() + else + output.secrets.git_url=gitUrl + end + + output.secrets.repo_root=repoName() + output.secrets.branch_name=branchName() + output.secrets.config=readFile(pathJoin(homeDir(),".plural","config.yml")) + + if fileExists(identity) then + output.secrets.identity=readFile(identity) + elseif dig("console", "secrets", "identity", "default", Var) ~= "default" then + output.secrets.identity= Var.console.secrets.identity + end + output.secrets.key=dedupe(Var, "console.secrets.key", readFile(pathJoin(homeDir(), ".plural", "key"))) +end diff --git a/plural/helm/console/values.yaml.tpl b/plural/helm/console/values.yaml.tpl deleted file mode 100644 index 3cb01a4692..0000000000 --- a/plural/helm/console/values.yaml.tpl +++ /dev/null @@ -1,105 +0,0 @@ -global: - application: - links: - - description: console web ui - url: {{ .Values.console_dns }} - -{{- if eq .Provider "kind" }} -replicaCount: 1 -{{- end }} - -ingress: - console_dns: {{ .Values.console_dns }} - {{- if eq .Provider "kind" }} - annotations: - external-dns.alpha.kubernetes.io/target: "127.0.0.1" - {{- end }} - -provider: {{ .Provider }} - -{{ if eq .Provider "azure" }} -podLabels: - aadpodidbinding: console - -consoleIdentityId: {{ importValue "Terraform" "console_msi_id" }} -consoleIdentityClientId: {{ importValue "Terraform" "console_msi_client_id" }} -{{ end }} - -{{- if or (eq .Provider "azure") .Configuration.loki }} -extraEnv: -{{- if .Configuration.loki }} -- name: LOKI_HOST - value: http://loki-loki-distributed-gateway.loki -{{- end }} -{{ if eq .Provider "azure" }} -- name: ARM_USE_MSI - value: 'true' -- name: ARM_SUBSCRIPTION_ID - value: {{ .Context.SubscriptionId }} -- name: ARM_TENANT_ID - value: {{ .Context.TenantId }} -{{- end }} -{{- end }} - -serviceAccount: -{{ if eq .Provider "google" }} - create: false -{{ end }} - annotations: - eks.amazonaws.com/role-arn: arn:aws:iam::{{ .Project }}:role/{{ .Cluster }}-console - -secrets: - jwt: {{ dedupe . "console.secrets.jwt" (randAlphaNum 20) }} - admin_name: {{ .Values.admin_name }} - admin_email: {{ dedupe . "console.secrets.admin_email" (default "someone@example.com" .Config.Email) }} - admin_password: {{ dedupe . "console.secrets.admin_password" (randAlphaNum 20) }} -{{ if .Values.console_dns }} -{{ $gitUrl := dig "console" "secrets" "git_url" "default" .}} -{{ if or (eq $gitUrl "default") (not $gitUrl) }} - git_url: {{ repoUrl }} -{{ else }} - git_url: {{ $gitUrl }} -{{ end }} - repo_root: {{ repoName }} - branch_name: {{ branchName }} - config: {{ readFile (homeDir ".plural" "config.yml") | quote }} -{{ $identity := pathJoin repoRoot ".plural-crypt" "identity" }} -{{ if fileExists $identity }} - identity: {{ readFile $identity | quote }} -{{ else if ne (dig "console" "secrets" "identity" "default" .) "default" }} - identity: {{ .console.secrets.identity | quote }} -{{ end }} - key: {{ dedupe . "console.secrets.key" (readFile (homeDir ".plural" "key")) | quote }} -{{ else }} - git_url: '' - repo_root: '' - branch_name: '' - config: '' - key: '' -{{ end }} - cluster_name: {{ .Cluster }} - erlang: {{ dedupe . "console.secrets.erlang" (randAlphaNum 14) }} - id_rsa: {{ ternary .Values.private_key (dedupe . "console.secrets.id_rsa" "") (hasKey .Values "private_key") | quote }} - id_rsa_pub: {{ ternary .Values.public_key (dedupe . "console.secrets.id_rsa_pub" "") (hasKey .Values "public_key") | quote }} - ssh_passphrase: {{ ternary .Values.passphrase (dedupe . "console.secrets.ssh_passphrase" "") (hasKey .Values "passphrase") | quote }} - git_access_token: {{ ternary .Values.access_token (dedupe . "console.secrets.git_access_token" "") (hasKey .Values "access_token") | quote }} - git_user: {{ default "console" .Values.git_user }} - git_email: {{ default "console@plural.sh" .Values.git_email }} -{{ if .OIDC }} - plural_client_id: {{ .OIDC.ClientId }} - plural_client_secret: {{ .OIDC.ClientSecret }} -{{ end }} -{{ if .Values.is_demo }} - is_demo: {{ .Values.is_demo }} -{{ end }} - -license: {{ .License | quote }} - -{{- if .Values.testBase.enabled }} -test-base: - enabled: true - secret: - CYPRESS_EMAIL: {{ .Values.testBase.cypressEmail }} - CYPRESS_PASSWORD: {{ .Values.testBase.cypressPassword }} - CYPRESS_BASE_URL: https://{{ .Values.console_dns }}/ -{{- end }}