Skip to content

Commit

Permalink
Fix helmfile CLI (#8)
Browse files Browse the repository at this point in the history
* Add `region` to `helm` and `helmfile` CLI

* Add `job "helmfile-command"`

* Add `job "helmfile-command"`
  • Loading branch information
aknysh authored Nov 29, 2020
1 parent de31b28 commit 28edfa2
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG VERSION=0.139.0
ARG VERSION=0.139.1
ARG OS=alpine
ARG CLI_NAME=atmos

Expand Down
2 changes: 2 additions & 0 deletions example/stacks/globals.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
namespace: eg

kubeconfig_profile_environment: gbl
15 changes: 14 additions & 1 deletion modules/helm/helm-core.variant
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ job "helm subcommand" {
type = string
}

config "stack-config" {
source job {
name = "helmfile config"
args = {
component = param.component
stack = opt.stack
format = "json"
merge = true
}
}
}

variable "kube-namespace-arg" {
type = list(string)
value = opt.kube-namespace != "" ? ["--namespace", opt.kube-namespace] : []
Expand All @@ -61,7 +73,8 @@ job "helm subcommand" {

step "helm kubeconfig" {
run "aws eks kubeconfig" {
stack = opt.stack
stack = opt.stack
region = conf.stack-config.region
}
}

Expand Down
51 changes: 50 additions & 1 deletion modules/helmfile/helmfile-core.variant
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ job "helmfile subcommand" {

step "helmfile kubeconfig" {
run "aws eks kubeconfig" {
stack = opt.stack
stack = opt.stack
region = conf.stack-config.region
}
}

Expand All @@ -123,6 +124,7 @@ job "helmfile subcommand" {
{
KUBECONFIG = "${opt.kubeconfig-path}/${opt.stack}-kubecfg",
STACK = opt.stack
NAMESPACE = conf.stack-config.namespace,
ENVIRONMENT = conf.stack-config.environment,
REGION = conf.stack-config.region,
STAGE = conf.stack-config.stage
Expand Down Expand Up @@ -184,3 +186,50 @@ job "helmfile write varfile" {
file = "${opt.helmfile-dir}/${param.component}/${opt.stack}.helmfile.vars.yaml"
}
}

# Find 'helmfile' binary to execute.
# It could come from the config file 'command' attribute, or from the '--command=' command line argument.
# Otherwise, the default 'helmfile' binary will be used (from the PATH)
job "helmfile-command" {
concurrency = 1
description = "Find 'helmfile' binary to execute"
private = true

parameter "component" {
type = string
description = "Component"
}

option "stack" {
type = string
description = "Stack"
short = "s"
}

option "command" {
default = "helmfile"
type = string
description = "Command to execute, e.g. 'helmfile', or path to the command, e.g. '/usr/local/bin/helmfile'"
}

config "stack-config" {
source job {
name = "helmfile config"
args = {
component = param.component
stack = opt.stack
format = "json"
merge = false
}
}
}

variable "command" {
value = coalesce(lookup(conf.stack-config, "command", null), opt.command)
}

exec {
command = "echo"
args = list("command: ${var.command}")
}
}
15 changes: 14 additions & 1 deletion modules/istio/istioctl-core.variant
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,22 @@ job "istioctl subcommand" {
)
}

config "stack-config" {
source job {
name = "helmfile config"
args = {
component = param.component
stack = opt.stack
format = "json"
merge = true
}
}
}

step "istioctl kubeconfig" {
run "aws eks kubeconfig" {
stack = opt.stack
stack = opt.stack
region = conf.stack-config.region
}
}

Expand Down
5 changes: 5 additions & 0 deletions modules/kubeconfig/kubeconfig.variant
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ job "aws eks kubeconfig" {
short = "s"
}

option "region" {
type = string
description = "Region"
}

variable "cmd-name" {
value = "aws"
type = string
Expand Down

0 comments on commit 28edfa2

Please sign in to comment.