From 22abebd9cde7a0c46b30010178aa20f0fbcbe3b4 Mon Sep 17 00:00:00 2001 From: winebarrel Date: Sat, 27 May 2023 13:42:37 +0900 Subject: [PATCH] Add DMTS_CLUSTER env --- README.md | 1 + definition/definition.go | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index caf5c29..8665205 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Flags: -c, --container-overrides=STRING JSON/YAML string that overrides ECS container definition. + --cluster=STRING ECS cluster name ($DMTS_CLUSTER). Commands: run --ecspresso-cmd="ecspresso" --conf-dir="~/.demitas" --config="ecspresso.yml" --container-def="ecs-container-def.jsonnet" diff --git a/definition/definition.go b/definition/definition.go index eec0b05..22d6c4d 100644 --- a/definition/definition.go +++ b/definition/definition.go @@ -16,6 +16,7 @@ type DefinitionOpts struct { ServiceOverrides string `short:"s" help:"JSON/YAML string that overrides ECS service definition."` TaskOverrides string `short:"t" help:"JSON/YAML string that overrides ECS task definition."` ContainerOverrides string `short:"c" help:"JSON/YAML string that overrides ECS container definition."` + Cluster string `env:"DMTS_CLUSTER" help:"ECS cluster name."` } type Definition struct { @@ -87,10 +88,16 @@ func (opts *DefinitionOpts) Load(profile string, command string, image string, c return nil, err } - cluster, err := ecspressoConf.get("cluster") + var cluster string - if err != nil { - return nil, err + if opts.Cluster != "" { + cluster = opts.Cluster + } else { + cluster, err = ecspressoConf.get("cluster") + + if err != nil { + return nil, err + } } return &Definition{