diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 319ca64..b3c19a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,8 +2,6 @@ name: goreleaser on: push: - branches: - - "!*" tags: - "v*" diff --git a/examples/advanced/dynamic-config-inheritance/config/globals.yaml b/examples/advanced/dynamic-config-inheritance/config/globals.yaml new file mode 100644 index 0000000..1c75a1f --- /dev/null +++ b/examples/advanced/dynamic-config-inheritance/config/globals.yaml @@ -0,0 +1,5 @@ +vars: + namespace: eg + +override_with_empty: [1] +override_with_ints: [1] diff --git a/examples/advanced/dynamic-config-inheritance/config/ue2-globals.yaml b/examples/advanced/dynamic-config-inheritance/config/ue2-globals.yaml new file mode 100644 index 0000000..09c73af --- /dev/null +++ b/examples/advanced/dynamic-config-inheritance/config/ue2-globals.yaml @@ -0,0 +1,9 @@ +import: +- globals + +vars: + region: us-east-2 + environment: ue2 + +override_with_empty: [] +override_with_ints: [2] diff --git a/examples/advanced/dynamic-config-inheritance/config/ue2-prod.yaml b/examples/advanced/dynamic-config-inheritance/config/ue2-prod.yaml new file mode 100644 index 0000000..96ad5d9 --- /dev/null +++ b/examples/advanced/dynamic-config-inheritance/config/ue2-prod.yaml @@ -0,0 +1,5 @@ +import: +- ue2-globals + +vars: + stage: prod diff --git a/examples/advanced/dynamic-config-inheritance/config/ue3-prod.yaml b/examples/advanced/dynamic-config-inheritance/config/ue3-prod.yaml new file mode 100644 index 0000000..aed48ac --- /dev/null +++ b/examples/advanced/dynamic-config-inheritance/config/ue3-prod.yaml @@ -0,0 +1,5 @@ +import: +- ue3-globals + +vars: + stage: prod diff --git a/examples/advanced/dynamic-config-inheritance/main.variant b/examples/advanced/dynamic-config-inheritance/main.variant new file mode 100644 index 0000000..ca58ec7 --- /dev/null +++ b/examples/advanced/dynamic-config-inheritance/main.variant @@ -0,0 +1,48 @@ +option "config-dir" { + type = string +} + +job "stack config" { + concurrency = 1 + description = "Generate stack config in YAML format" + + option "stack" { + type = string + description = "Stack" + short = "s" + } + + variable "configs" { + value = flatten(concat([ + # 1st level of imports + for k1, imports1 in yamldecode(file(format("%s/%s.yaml", opt.config-dir, opt.stack))): [ + for import1 in imports1: concat([ + # 1st level import's imports = 2nd level of imports + for k2, imports2 in yamldecode(file(format("%s/%s.yaml", opt.config-dir, import1))): [ + for import2 in imports2: [ + # 2nd level import's imports = 3rd level of imports + format("%s/%s.yaml", opt.config-dir, import2) + ] + ] if k2 == "import" + ], [ + format("%s/%s.yaml", opt.config-dir, import1) + ]) + ] if k1 == "import" + ], [ + format("%s/%s.yaml", opt.config-dir, opt.stack) + ])) + } + + config "all" { + source file { + paths = var.configs + } + } + + exec { + command = "echo" + args = [ + jsonencode(conf.all) + ] + } +} diff --git a/examples/advanced/dynamic-config-inheritance/main_test.variant b/examples/advanced/dynamic-config-inheritance/main_test.variant new file mode 100644 index 0000000..77caba8 --- /dev/null +++ b/examples/advanced/dynamic-config-inheritance/main_test.variant @@ -0,0 +1,165 @@ +test "stack config" { + case "ue2-prod" { + stack = "ue2-prod" + exitstatus = 0 + err = "" + namespace = "eg" + region = "us-east-2" + environment = "ue2" + stage = "prod" + override_with_empty = [] + override_with_ints = [2] + } + + // missing stack config + case "ue1-prod" { + stack = "ue1-prod" + exitstatus = 1 + err = trimspace(<