Skip to content

Commit

Permalink
introduce lua script
Browse files Browse the repository at this point in the history
  • Loading branch information
zreigz committed Jan 9, 2023
1 parent 1aff045 commit 2b15703
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 105 deletions.
135 changes: 135 additions & 0 deletions plural/helm/console/values.yaml.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
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("[email protected]", 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("[email protected]", 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

if Var.Values.testBase then
if Var.Values.testBase.enabled then
output["test-base"]={
enabled=true,
secret={
CYPRESS_EMAIL=Var.Values.testBase.cypressEmail,
CYPRESS_PASSWORD=Var.Values.testBase.cypressPassword,
CYPRESS_BASE_URL= "https://" .. Var.Values.console_dns .. "/",
}
}
end
end
105 changes: 0 additions & 105 deletions plural/helm/console/values.yaml.tpl

This file was deleted.

0 comments on commit 2b15703

Please sign in to comment.