From 15df7e494247eb887bac1c698e729cd9d66ab53e Mon Sep 17 00:00:00 2001 From: Andriy Knysh Date: Tue, 3 Sep 2024 15:37:07 -0400 Subject: [PATCH] Update to Atmos `1.88.0` (#425) * Update to Atmos 1.88.0 * Update to Atmos 1.88.0 --- .../utils_spacelift_stack_config_test.go | 2 +- go.mod | 57 ++++---- go.sum | 112 +++++++------- .../component/component_processor_test.go | 36 ++--- internal/convert/json_test.go | 10 +- internal/convert/slice_test.go | 8 +- internal/convert/yaml_test.go | 10 +- internal/describe/describe_stacks_test.go | 38 ++--- internal/merge/merge_test.go | 138 ++++++++++++++++-- .../provider/data_source_component_config.go | 2 +- .../provider/data_source_deep_merge_json.go | 8 +- .../provider/data_source_deep_merge_yaml.go | 11 +- .../provider/data_source_describe_stacks.go | 8 +- .../data_source_spacelift_stack_config.go | 10 +- .../provider/data_source_stack_config_yaml.go | 3 +- internal/provider/json_utils.go | 34 +++++ internal/provider/provider_utils.go | 16 ++ internal/provider/yaml_utils.go | 21 +++ .../spacelift_stack_processor_test.go | 20 +-- internal/stack/stack_processor_test.go | 72 +++++---- 20 files changed, 403 insertions(+), 213 deletions(-) create mode 100644 internal/provider/json_utils.go create mode 100644 internal/provider/yaml_utils.go diff --git a/examples/data-sources/utils_spacelift_stack_config/utils_spacelift_stack_config_test.go b/examples/data-sources/utils_spacelift_stack_config/utils_spacelift_stack_config_test.go index 17e5bbe..7ee13d2 100644 --- a/examples/data-sources/utils_spacelift_stack_config/utils_spacelift_stack_config_test.go +++ b/examples/data-sources/utils_spacelift_stack_config/utils_spacelift_stack_config_test.go @@ -5,7 +5,7 @@ import ( "github.com/gruntwork-io/terratest/modules/terraform" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" ) func TestSpaceliftStackProcessorWithTerraform(t *testing.T) { diff --git a/go.mod b/go.mod index cac9ab7..ec7cfa7 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,14 @@ module github.com/cloudposse/terraform-provider-utils go 1.23 require ( - github.com/cloudposse/atmos v1.87.0 - github.com/gruntwork-io/terratest v0.47.0 + github.com/cloudposse/atmos v1.88.0 + github.com/gruntwork-io/terratest v0.47.1 github.com/hashicorp/terraform-plugin-docs v0.19.4 github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 github.com/json-iterator/go v1.1.12 + github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.9.0 - gopkg.in/yaml.v2 v2.4.0 + gopkg.in/yaml.v3 v3.0.1 ) require ( @@ -22,8 +23,8 @@ require ( github.com/BurntSushi/toml v1.3.2 // indirect github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.2.0 // indirect - github.com/Masterminds/sprig/v3 v3.2.3 // indirect + github.com/Masterminds/semver/v3 v3.3.0 // indirect + github.com/Masterminds/sprig/v3 v3.3.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/OneOfOne/xxhash v1.2.8 // indirect github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect @@ -67,15 +68,13 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chainguard-dev/git-urls v1.0.2 // indirect github.com/charmbracelet/bubbles v0.19.0 // indirect - github.com/charmbracelet/bubbletea v0.27.0 // indirect + github.com/charmbracelet/bubbletea v1.1.0 // indirect github.com/charmbracelet/lipgloss v0.13.0 // indirect - github.com/charmbracelet/x/ansi v0.1.4 // indirect - github.com/charmbracelet/x/input v0.1.2 // indirect - github.com/charmbracelet/x/term v0.1.1 // indirect - github.com/charmbracelet/x/windows v0.1.2 // indirect + github.com/charmbracelet/x/ansi v0.2.3 // indirect + github.com/charmbracelet/x/term v0.2.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect - github.com/containerd/containerd v1.7.20 // indirect + github.com/containerd/containerd v1.7.21 // indirect github.com/containerd/errdefs v0.1.0 // indirect github.com/containerd/log v0.1.0 // indirect github.com/containerd/platforms v0.2.1 // indirect @@ -142,7 +141,7 @@ require ( github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/hc-install v0.7.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/hcl/v2 v2.21.0 // indirect + github.com/hashicorp/hcl/v2 v2.22.0 // indirect github.com/hashicorp/logutils v1.0.0 // indirect github.com/hashicorp/serf v0.10.1 // indirect github.com/hashicorp/terraform-config-inspect v0.0.0-20240801114854-6714b46f5fe4 // indirect @@ -155,8 +154,7 @@ require ( github.com/hashicorp/vault/api v1.6.0 // indirect github.com/hashicorp/vault/sdk v0.5.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect - github.com/huandu/xstrings v1.3.3 // indirect - github.com/imdario/mergo v0.3.15 // indirect + github.com/huandu/xstrings v1.5.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect @@ -164,7 +162,7 @@ require ( github.com/joho/godotenv v1.4.0 // indirect github.com/jwalton/go-supportscolor v1.2.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.17.2 // indirect + github.com/klauspost/compress v1.17.9 // indirect github.com/kubescape/go-git-url v0.0.30 // indirect github.com/lrstanley/bubblezone v0.0.0-20240820044643-3964e2111228 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -186,21 +184,21 @@ require ( github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/termenv v0.15.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/oklog/run v1.1.0 // indirect - github.com/open-policy-agent/opa v0.67.1 // indirect + github.com/open-policy-agent/opa v0.68.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/otiai10/copy v1.14.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pierrec/lz4 v2.6.1+incompatible // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/posener/complete v1.2.3 // indirect - github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_golang v1.20.2 // indirect github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.48.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rs/zerolog v1.26.1 // indirect @@ -211,12 +209,12 @@ require ( github.com/samber/lo v1.47.0 // indirect github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect - github.com/shopspring/decimal v1.3.1 // indirect + github.com/shopspring/decimal v1.4.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/skeema/knownhosts v1.2.2 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect - github.com/spf13/cast v1.6.0 // indirect + github.com/spf13/cast v1.7.0 // indirect github.com/spf13/cobra v1.8.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.19.0 // indirect @@ -232,7 +230,6 @@ require ( github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect - github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yashtewari/glob-intersection v0.2.0 // indirect github.com/yuin/goldmark v1.7.1 // indirect github.com/yuin/goldmark-meta v1.1.0 // indirect @@ -252,16 +249,16 @@ require ( go4.org/intern v0.0.0-20230205224052-192e9f60865c // indirect go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect gocloud.dev v0.25.1-0.20220408200107-09b10f7359f7 // indirect - golang.org/x/crypto v0.25.0 // indirect + golang.org/x/crypto v0.26.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/oauth2 v0.20.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.24.0 // indirect golang.org/x/term v0.23.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/time v0.5.0 // indirect + golang.org/x/text v0.17.0 // indirect + golang.org/x/time v0.6.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect google.golang.org/api v0.171.0 // indirect @@ -269,12 +266,12 @@ require ( google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/grpc v1.65.0 // indirect + google.golang.org/grpc v1.66.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a // indirect k8s.io/client-go v0.28.4 // indirect k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect diff --git a/go.sum b/go.sum index 5f7be31..b3ce8f9 100644 --- a/go.sum +++ b/go.sum @@ -247,10 +247,10 @@ github.com/Kunde21/markdownfmt/v3 v3.1.0/go.mod h1:tPXN1RTyOzJwhfHoon9wUr4HGYmWg github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= -github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= -github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= -github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= +github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= +github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= +github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= @@ -397,18 +397,14 @@ github.com/chainguard-dev/git-urls v1.0.2 h1:pSpT7ifrpc5X55n4aTTm7FFUE+ZQHKiqpiw github.com/chainguard-dev/git-urls v1.0.2/go.mod h1:rbGgj10OS7UgZlbzdUQIQpT0k/D4+An04HJY7Ol+Y/o= github.com/charmbracelet/bubbles v0.19.0 h1:gKZkKXPP6GlDk6EcfujDK19PCQqRjaJZQ7QRERx1UF0= github.com/charmbracelet/bubbles v0.19.0/go.mod h1:WILteEqZ+krG5c3ntGEMeG99nCupcuIk7V0/zOP0tOA= -github.com/charmbracelet/bubbletea v0.27.0 h1:Mznj+vvYuYagD9Pn2mY7fuelGvP0HAXtZYGgRBCbHvU= -github.com/charmbracelet/bubbletea v0.27.0/go.mod h1:5MdP9XH6MbQkgGhnlxUqCNmBXf9I74KRQ8HIidRxV1Y= +github.com/charmbracelet/bubbletea v1.1.0 h1:FjAl9eAL3HBCHenhz/ZPjkKdScmaS5SK69JAK2YJK9c= +github.com/charmbracelet/bubbletea v1.1.0/go.mod h1:9Ogk0HrdbHolIKHdjfFpyXJmiCzGwy+FesYkZr7hYU4= github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= -github.com/charmbracelet/x/ansi v0.1.4 h1:IEU3D6+dWwPSgZ6HBH+v6oUuZ/nVawMiWj5831KfiLM= -github.com/charmbracelet/x/ansi v0.1.4/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= -github.com/charmbracelet/x/input v0.1.2 h1:QJAZr33eOhDowkkEQ24rsJy4Llxlm+fRDf/cQrmqJa0= -github.com/charmbracelet/x/input v0.1.2/go.mod h1:LGBim0maUY4Pitjn/4fHnuXb4KirU3DODsyuHuXdOyA= -github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI= -github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw= -github.com/charmbracelet/x/windows v0.1.2 h1:Iumiwq2G+BRmgoayww/qfcvof7W/3uLoelhxojXlRWg= -github.com/charmbracelet/x/windows v0.1.2/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ= +github.com/charmbracelet/x/ansi v0.2.3 h1:VfFN0NUpcjBRd4DnKfRaIRo53KRgey/nhOoEqosGDEY= +github.com/charmbracelet/x/ansi v0.2.3/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= +github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -418,8 +414,8 @@ github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= -github.com/cloudposse/atmos v1.87.0 h1:qfecMIfp+bDcVYCqP/XaI/dwgZF62Fnchk+heaLOqEI= -github.com/cloudposse/atmos v1.87.0/go.mod h1:oqkYy39OeU7xK4G7/v6dFOfYGr3zVSw0KCceguylXzk= +github.com/cloudposse/atmos v1.88.0 h1:NuJnd+fPpxmCUwV0xJisPYByIrCjz4nFI+JUOv5cAS0= +github.com/cloudposse/atmos v1.88.0/go.mod h1:OTdaIp8N+p+AOSHnDTV8gXq5ICfWzFpre0sMOve9Hz0= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -434,8 +430,8 @@ github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= -github.com/containerd/containerd v1.7.20 h1:Sl6jQYk3TRavaU83h66QMbI2Nqg9Jm6qzwX57Vsn1SQ= -github.com/containerd/containerd v1.7.20/go.mod h1:52GsS5CwquuqPuLncsXwG0t2CiUce+KsNHJZQJvAgR0= +github.com/containerd/containerd v1.7.21 h1:USGXRK1eOC/SX0L195YgxTHb0a00anxajOzgfN0qrCA= +github.com/containerd/containerd v1.7.21/go.mod h1:e3Jz1rYRUZ2Lt51YrH9Rz0zPyJBOlSvB3ghr2jbVD8g= github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG023MDM= github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM= @@ -686,7 +682,6 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -724,8 +719,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4 github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= -github.com/gruntwork-io/terratest v0.47.0 h1:xIy1pT7NbGVlMLDZEHl3+3iSnvffh8tN2pL6idn448c= -github.com/gruntwork-io/terratest v0.47.0/go.mod h1:oywHw1cFKXSYvKPm27U7quZVzDUlA22H2xUrKCe26xM= +github.com/gruntwork-io/terratest v0.47.1 h1:qOaxnL7Su5+KpDHYUN/ek1jn8ImvCKtOkaY4OSMS4tI= +github.com/gruntwork-io/terratest v0.47.1/go.mod h1:LnYX8BN5WxUMpDr8rtD39oToSL4CBERWSCusbJ0d/64= github.com/hairyhenderson/go-fsimpl v0.0.0-20220529183339-9deae3e35047 h1:nSSfN9G8O8XXDqB3aDEHJ8K+0llYYToNlTcWOe1Pti8= github.com/hairyhenderson/go-fsimpl v0.0.0-20220529183339-9deae3e35047/go.mod h1:30RY4Ey+bg+BGKBufZE2IEmxk7hok9U9mjdgZYomwN4= github.com/hairyhenderson/gomplate/v3 v3.11.8 h1:T63wLRk+Y9C601ChYa/+FZ30XT/UEWydMDZhOOJM3K0= @@ -816,8 +811,8 @@ github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLY github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl/v2 v2.9.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= -github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= -github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= +github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M= +github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= @@ -850,13 +845,10 @@ github.com/hashicorp/vault/sdk v0.5.0/go.mod h1:UJZHlfwj7qUJG8g22CuxUgkdJouFrBNv github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= -github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= +github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= -github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= @@ -932,8 +924,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= -github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -1027,6 +1019,8 @@ github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= +github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= +github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -1041,14 +1035,16 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= -github.com/open-policy-agent/opa v0.67.1 h1:rzy26J6g1X+CKknAcx0Vfbt41KqjuSzx4E0A8DAZf3E= -github.com/open-policy-agent/opa v0.67.1/go.mod h1:aqKlHc8E2VAAylYE9x09zJYr/fYzGX+JKne89UGqFzk= +github.com/open-policy-agent/opa v0.68.0 h1:Jl3U2vXRjwk7JrHmS19U3HZO5qxQRinQbJ2eCJYSqJQ= +github.com/open-policy-agent/opa v0.68.0/go.mod h1:5E5SvaPwTpwt2WM177I9Z3eT7qUpmOGjk1ZdHs+TZ4w= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= @@ -1081,8 +1077,8 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= +github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -1091,13 +1087,13 @@ github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= -github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -1140,8 +1136,8 @@ github.com/shabbyrobe/gocovmerge v0.0.0-20190829150210-3e036491d500 h1:WnNuhiq+F github.com/shabbyrobe/gocovmerge v0.0.0-20190829150210-3e036491d500/go.mod h1:+njLrG5wSeoG4Ds61rFgEzKvenR2UHbjMoDHsczxly0= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= -github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= +github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -1161,9 +1157,8 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.2.0/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= -github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= +github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -1224,8 +1219,6 @@ github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMc github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= -github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yashtewari/glob-intersection v0.2.0 h1:8iuHdN88yYuCzCdjt0gDe+6bAhUwBeEWqThExu54RFg= github.com/yashtewari/glob-intersection v0.2.0/go.mod h1:LK7pIC3piUjovexikBbJ26Yml7g8xa5bsjfx2v1fwok= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -1332,9 +1325,8 @@ golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1436,9 +1428,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1466,8 +1457,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= -golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1576,7 +1567,6 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= @@ -1585,7 +1575,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1599,16 +1588,16 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= +golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -1909,8 +1898,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c= +google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1951,7 +1940,6 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/component/component_processor_test.go b/internal/component/component_processor_test.go index 4e3b2eb..ba19c24 100644 --- a/internal/component/component_processor_test.go +++ b/internal/component/component_processor_test.go @@ -4,9 +4,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v2" c "github.com/cloudposse/atmos/pkg/component" + u "github.com/cloudposse/atmos/pkg/utils" ) func TestComponentProcessor(t *testing.T) { @@ -14,15 +14,15 @@ func TestComponentProcessor(t *testing.T) { var component string var stack string namespace := "" - var yamlConfig []byte + var yamlConfig string var tenant1Ue2DevTestTestComponent map[string]any component = "test/test-component" stack = "tenant1-ue2-dev" tenant1Ue2DevTestTestComponent, err = c.ProcessComponentInStack(component, stack, "", "") assert.Nil(t, err) - tenant1Ue2DevTestTestComponentBackend := tenant1Ue2DevTestTestComponent["backend"].(map[any]any) - tenant1Ue2DevTestTestComponentRemoteStateBackend := tenant1Ue2DevTestTestComponent["remote_state_backend"].(map[any]any) + tenant1Ue2DevTestTestComponentBackend := tenant1Ue2DevTestTestComponent["backend"].(map[string]any) + tenant1Ue2DevTestTestComponentRemoteStateBackend := tenant1Ue2DevTestTestComponent["remote_state_backend"].(map[string]any) tenant1Ue2DevTestTestComponentBaseComponent := tenant1Ue2DevTestTestComponent["component"] tenant1Ue2DevTestTestComponentTerraformWorkspace := tenant1Ue2DevTestTestComponent["workspace"].(string) tenant1Ue2DevTestTestComponentWorkspace := tenant1Ue2DevTestTestComponent["workspace"].(string) @@ -52,8 +52,8 @@ func TestComponentProcessor(t *testing.T) { stage := "dev" tenant1Ue2DevTestTestComponent2, err = c.ProcessComponentFromContext(component, namespace, tenant, environment, stage, "", "") assert.Nil(t, err) - tenant1Ue2DevTestTestComponentBackend2 := tenant1Ue2DevTestTestComponent2["backend"].(map[any]any) - tenant1Ue2DevTestTestComponentRemoteStateBackend2 := tenant1Ue2DevTestTestComponent2["remote_state_backend"].(map[any]any) + tenant1Ue2DevTestTestComponentBackend2 := tenant1Ue2DevTestTestComponent2["backend"].(map[string]any) + tenant1Ue2DevTestTestComponentRemoteStateBackend2 := tenant1Ue2DevTestTestComponent2["remote_state_backend"].(map[string]any) tenant1Ue2DevTestTestComponentBaseComponent2 := tenant1Ue2DevTestTestComponent2["component"] tenant1Ue2DevTestTestComponentTerraformWorkspace2 := tenant1Ue2DevTestTestComponent2["workspace"].(string) tenant1Ue2DevTestTestComponentWorkspace2 := tenant1Ue2DevTestTestComponent2["workspace"].(string) @@ -76,21 +76,21 @@ func TestComponentProcessor(t *testing.T) { assert.Equal(t, "orgs/cp/tenant1/dev/us-east-2", tenant1Ue2DevTestTestComponentDeps2[8]) assert.Equal(t, "tenant1-ue2-dev", tenant1Ue2DevTestTestComponentTerraformWorkspace2) - yamlConfig, err = yaml.Marshal(tenant1Ue2DevTestTestComponent) + yamlConfig, err = u.ConvertToYAML(tenant1Ue2DevTestTestComponent) assert.Nil(t, err) - t.Log(string(yamlConfig)) + t.Log(yamlConfig) var tenant1Ue2DevTestTestComponentOverrideComponent map[string]any component = "test/test-component-override" stack = "tenant1-ue2-dev" tenant1Ue2DevTestTestComponentOverrideComponent, err = c.ProcessComponentInStack(component, stack, "", "") assert.Nil(t, err) - tenant1Ue2DevTestTestComponentOverrideComponentBackend := tenant1Ue2DevTestTestComponentOverrideComponent["backend"].(map[any]any) + tenant1Ue2DevTestTestComponentOverrideComponentBackend := tenant1Ue2DevTestTestComponentOverrideComponent["backend"].(map[string]any) tenant1Ue2DevTestTestComponentOverrideComponentBaseComponent := tenant1Ue2DevTestTestComponentOverrideComponent["component"].(string) tenant1Ue2DevTestTestComponentOverrideComponentWorkspace := tenant1Ue2DevTestTestComponentOverrideComponent["workspace"].(string) tenant1Ue2DevTestTestComponentOverrideComponentBackendWorkspaceKeyPrefix := tenant1Ue2DevTestTestComponentOverrideComponentBackend["workspace_key_prefix"].(string) tenant1Ue2DevTestTestComponentOverrideComponentDeps := tenant1Ue2DevTestTestComponentOverrideComponent["deps"].([]any) - tenant1Ue2DevTestTestComponentOverrideComponentRemoteStateBackend := tenant1Ue2DevTestTestComponentOverrideComponent["remote_state_backend"].(map[any]any) + tenant1Ue2DevTestTestComponentOverrideComponentRemoteStateBackend := tenant1Ue2DevTestTestComponentOverrideComponent["remote_state_backend"].(map[string]any) tenant1Ue2DevTestTestComponentOverrideComponentRemoteStateBackendVal2 := tenant1Ue2DevTestTestComponentOverrideComponentRemoteStateBackend["val2"].(string) assert.Equal(t, "test-test-component", tenant1Ue2DevTestTestComponentOverrideComponentBackendWorkspaceKeyPrefix) assert.Equal(t, "test/test-component", tenant1Ue2DevTestTestComponentOverrideComponentBaseComponent) @@ -117,15 +117,15 @@ func TestComponentProcessor(t *testing.T) { stage = "dev" tenant1Ue2DevTestTestComponentOverrideComponent2, err = c.ProcessComponentFromContext(component, namespace, tenant, environment, stage, "", "") assert.Nil(t, err) - tenant1Ue2DevTestTestComponentOverrideComponent2Backend := tenant1Ue2DevTestTestComponentOverrideComponent2["backend"].(map[any]any) + tenant1Ue2DevTestTestComponentOverrideComponent2Backend := tenant1Ue2DevTestTestComponentOverrideComponent2["backend"].(map[string]any) tenant1Ue2DevTestTestComponentOverrideComponent2Workspace := tenant1Ue2DevTestTestComponentOverrideComponent2["workspace"].(string) tenant1Ue2DevTestTestComponentOverrideComponent2WorkspaceKeyPrefix := tenant1Ue2DevTestTestComponentOverrideComponent2Backend["workspace_key_prefix"].(string) assert.Equal(t, "tenant1-ue2-dev-test-test-component-override-2", tenant1Ue2DevTestTestComponentOverrideComponent2Workspace) assert.Equal(t, "test-test-component", tenant1Ue2DevTestTestComponentOverrideComponent2WorkspaceKeyPrefix) - yamlConfig, err = yaml.Marshal(tenant1Ue2DevTestTestComponentOverrideComponent2) + yamlConfig, err = u.ConvertToYAML(tenant1Ue2DevTestTestComponentOverrideComponent2) assert.Nil(t, err) - t.Log(string(yamlConfig)) + t.Log(yamlConfig) // Test having a dash `-` in the stage name var tenant1Ue2Test1TestTestComponentOverrideComponent2 map[string]any @@ -135,7 +135,7 @@ func TestComponentProcessor(t *testing.T) { stage = "test-1" tenant1Ue2Test1TestTestComponentOverrideComponent2, err = c.ProcessComponentFromContext(component, namespace, tenant, environment, stage, "", "") assert.Nil(t, err) - tenant1Ue2Test1TestTestComponentOverrideComponent2Backend := tenant1Ue2DevTestTestComponentOverrideComponent2["backend"].(map[any]any) + tenant1Ue2Test1TestTestComponentOverrideComponent2Backend := tenant1Ue2DevTestTestComponentOverrideComponent2["backend"].(map[string]any) tenant1Ue2Test1TestTestComponentOverrideComponent2Workspace := tenant1Ue2Test1TestTestComponentOverrideComponent2["workspace"].(string) tenant1Ue2Test1TestTestComponentOverrideComponent2WorkspaceKeyPrefix := tenant1Ue2Test1TestTestComponentOverrideComponent2Backend["workspace_key_prefix"].(string) assert.Equal(t, "tenant1-ue2-test-1-test-test-component-override-2", tenant1Ue2Test1TestTestComponentOverrideComponent2Workspace) @@ -164,7 +164,7 @@ func TestComponentProcessor(t *testing.T) { } func TestComponentProcessorHierarchicalInheritance(t *testing.T) { - var yamlConfig []byte + var yamlConfig string namespace := "" component := "derived-component-2" tenant := "tenant1" @@ -174,11 +174,11 @@ func TestComponentProcessorHierarchicalInheritance(t *testing.T) { componentMap, err := c.ProcessComponentFromContext(component, namespace, tenant, environment, stage, "", "") assert.Nil(t, err) - componentVars := componentMap["vars"].(map[any]any) + componentVars := componentMap["vars"].(map[string]any) componentHierarchicalInheritanceTestVar := componentVars["hierarchical_inheritance_test"].(string) assert.Equal(t, "base-component-1", componentHierarchicalInheritanceTestVar) - yamlConfig, err = yaml.Marshal(componentMap) + yamlConfig, err = u.ConvertToYAML(componentMap) assert.Nil(t, err) - t.Log(string(yamlConfig)) + t.Log(yamlConfig) } diff --git a/internal/convert/json_test.go b/internal/convert/json_test.go index 129bf60..5d91f76 100644 --- a/internal/convert/json_test.go +++ b/internal/convert/json_test.go @@ -1,20 +1,22 @@ package convert import ( - c "github.com/cloudposse/atmos/pkg/convert" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" + + u "github.com/cloudposse/atmos/pkg/utils" ) func TestJSONToMapOfInterfaces(t *testing.T) { input := "{\"hello\": \"world\"}" - result, err := c.JSONToMapOfInterfaces(input) + result, err := u.JSONToMapOfInterfaces(input) assert.Nil(t, err) assert.Equal(t, result["hello"], "world") } func TestJSONToMapOfInterfacesRedPath(t *testing.T) { input := "Not JSON" - _, err := c.JSONToMapOfInterfaces(input) + _, err := u.JSONToMapOfInterfaces(input) assert.NotNil(t, err) } diff --git a/internal/convert/slice_test.go b/internal/convert/slice_test.go index 8776663..a2388c6 100644 --- a/internal/convert/slice_test.go +++ b/internal/convert/slice_test.go @@ -1,9 +1,11 @@ package convert import ( - c "github.com/cloudposse/atmos/pkg/convert" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" + + u "github.com/cloudposse/atmos/pkg/utils" ) func TestSliceOfInterfacesToSliceOfStrings(t *testing.T) { @@ -12,7 +14,7 @@ func TestSliceOfInterfacesToSliceOfStrings(t *testing.T) { input = append(input, "b") input = append(input, "c") - result, err := c.SliceOfInterfacesToSliceOfStrings(input) + result, err := u.SliceOfInterfacesToSliceOfStrings(input) assert.Nil(t, err) assert.Equal(t, len(input), len(result)) diff --git a/internal/convert/yaml_test.go b/internal/convert/yaml_test.go index 7ca927c..d13face 100644 --- a/internal/convert/yaml_test.go +++ b/internal/convert/yaml_test.go @@ -1,21 +1,23 @@ package convert import ( - c "github.com/cloudposse/atmos/pkg/convert" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" + + u "github.com/cloudposse/atmos/pkg/utils" ) func TestYAMLToMapOfInterfaces(t *testing.T) { input := `--- hello: world` - result, err := c.YAMLToMapOfInterfaces(input) + result, err := u.UnmarshalYAML[map[any]any](input) assert.Nil(t, err) assert.Equal(t, result["hello"], "world") } func TestYAMLToMapOfInterfacesRedPath(t *testing.T) { input := "Not YAML" - _, err := c.YAMLToMapOfInterfaces(input) + _, err := u.UnmarshalYAML[map[any]any](input) assert.NotNil(t, err) } diff --git a/internal/describe/describe_stacks_test.go b/internal/describe/describe_stacks_test.go index cb1ddc0..3bb0df7 100644 --- a/internal/describe/describe_stacks_test.go +++ b/internal/describe/describe_stacks_test.go @@ -4,11 +4,11 @@ import ( "testing" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v2" cfg "github.com/cloudposse/atmos/pkg/config" - "github.com/cloudposse/atmos/pkg/describe" + describe "github.com/cloudposse/atmos/pkg/describe" "github.com/cloudposse/atmos/pkg/schema" + u "github.com/cloudposse/atmos/pkg/utils" ) func TestDescribeStacks(t *testing.T) { @@ -20,9 +20,9 @@ func TestDescribeStacks(t *testing.T) { stacks, err := describe.ExecuteDescribeStacks(cliConfig, "", nil, nil, nil, false) assert.Nil(t, err) - dependentsYaml, err := yaml.Marshal(stacks) + dependentsYaml, err := u.ConvertToYAML(stacks) assert.Nil(t, err) - t.Log(string(dependentsYaml)) + t.Log(dependentsYaml) } func TestDescribeStacksWithFilter1(t *testing.T) { @@ -36,9 +36,9 @@ func TestDescribeStacksWithFilter1(t *testing.T) { stacks, err := describe.ExecuteDescribeStacks(cliConfig, stack, nil, nil, nil, false) assert.Nil(t, err) - dependentsYaml, err := yaml.Marshal(stacks) + dependentsYaml, err := u.ConvertToYAML(stacks) assert.Nil(t, err) - t.Log(string(dependentsYaml)) + t.Log(dependentsYaml) } func TestDescribeStacksWithFilter2(t *testing.T) { @@ -53,9 +53,9 @@ func TestDescribeStacksWithFilter2(t *testing.T) { stacks, err := describe.ExecuteDescribeStacks(cliConfig, stack, components, nil, nil, false) assert.Nil(t, err) - dependentsYaml, err := yaml.Marshal(stacks) + dependentsYaml, err := u.ConvertToYAML(stacks) assert.Nil(t, err) - t.Log(string(dependentsYaml)) + t.Log(dependentsYaml) } func TestDescribeStacksWithFilter3(t *testing.T) { @@ -70,9 +70,9 @@ func TestDescribeStacksWithFilter3(t *testing.T) { stacks, err := describe.ExecuteDescribeStacks(cliConfig, stack, nil, nil, sections, false) assert.Nil(t, err) - dependentsYaml, err := yaml.Marshal(stacks) + dependentsYaml, err := u.ConvertToYAML(stacks) assert.Nil(t, err) - t.Log(string(dependentsYaml)) + t.Log(dependentsYaml) } func TestDescribeStacksWithFilter4(t *testing.T) { @@ -87,9 +87,9 @@ func TestDescribeStacksWithFilter4(t *testing.T) { stacks, err := describe.ExecuteDescribeStacks(cliConfig, "", nil, componentTypes, sections, false) assert.Nil(t, err) - dependentsYaml, err := yaml.Marshal(stacks) + dependentsYaml, err := u.ConvertToYAML(stacks) assert.Nil(t, err) - t.Log(string(dependentsYaml)) + t.Log(dependentsYaml) } func TestDescribeStacksWithFilter5(t *testing.T) { @@ -110,7 +110,7 @@ func TestDescribeStacksWithFilter5(t *testing.T) { tenant1Ue2DevStackComponents := tenant1Ue2DevStack["components"].(map[string]any) tenant1Ue2DevStackComponentsTerraform := tenant1Ue2DevStackComponents["terraform"].(map[string]any) tenant1Ue2DevStackComponentsTerraformComponent := tenant1Ue2DevStackComponentsTerraform["top-level-component1"].(map[string]any) - tenant1Ue2DevStackComponentsTerraformComponentVars := tenant1Ue2DevStackComponentsTerraformComponent["vars"].(map[any]any) + tenant1Ue2DevStackComponentsTerraformComponentVars := tenant1Ue2DevStackComponentsTerraformComponent["vars"].(map[string]any) tenant1Ue2DevStackComponentsTerraformComponentVarsTenant := tenant1Ue2DevStackComponentsTerraformComponentVars["tenant"].(string) tenant1Ue2DevStackComponentsTerraformComponentVarsStage := tenant1Ue2DevStackComponentsTerraformComponentVars["stage"].(string) tenant1Ue2DevStackComponentsTerraformComponentVarsEnvironment := tenant1Ue2DevStackComponentsTerraformComponentVars["environment"].(string) @@ -118,9 +118,9 @@ func TestDescribeStacksWithFilter5(t *testing.T) { assert.Equal(t, "ue2", tenant1Ue2DevStackComponentsTerraformComponentVarsEnvironment) assert.Equal(t, "dev", tenant1Ue2DevStackComponentsTerraformComponentVarsStage) - stacksYaml, err := yaml.Marshal(stacks) + stacksYaml, err := u.ConvertToYAML(stacks) assert.Nil(t, err) - t.Log(string(stacksYaml)) + t.Log(stacksYaml) } func TestDescribeStacksWithFilter6(t *testing.T) { @@ -145,9 +145,9 @@ func TestDescribeStacksWithFilter6(t *testing.T) { tenant1Ue2DevStackComponentsTerraformWorkspace := tenant1Ue2DevStackComponentsTerraformComponent["workspace"].(string) assert.Equal(t, "tenant1-ue2-dev", tenant1Ue2DevStackComponentsTerraformWorkspace) - stacksYaml, err := yaml.Marshal(stacks) + stacksYaml, err := u.ConvertToYAML(stacks) assert.Nil(t, err) - t.Log(string(stacksYaml)) + t.Log(stacksYaml) } func TestDescribeStacksWithFilter7(t *testing.T) { @@ -172,7 +172,7 @@ func TestDescribeStacksWithFilter7(t *testing.T) { tenant1Ue2DevStackComponentsTerraformWorkspace := tenant1Ue2DevStackComponentsTerraformComponent["workspace"].(string) assert.Equal(t, "test-component-override-3-workspace", tenant1Ue2DevStackComponentsTerraformWorkspace) - stacksYaml, err := yaml.Marshal(stacks) + stacksYaml, err := u.ConvertToYAML(stacks) assert.Nil(t, err) - t.Log(string(stacksYaml)) + t.Log(stacksYaml) } diff --git a/internal/merge/merge_test.go b/internal/merge/merge_test.go index 9c7a0d9..85f9a44 100644 --- a/internal/merge/merge_test.go +++ b/internal/merge/merge_test.go @@ -1,34 +1,148 @@ package merge import ( - "github.com/stretchr/testify/assert" "testing" + "github.com/stretchr/testify/assert" + m "github.com/cloudposse/atmos/pkg/merge" "github.com/cloudposse/atmos/pkg/schema" + u "github.com/cloudposse/atmos/pkg/utils" ) func TestMergeBasic(t *testing.T) { - map1 := map[any]any{"foo": "bar"} - map2 := map[any]any{"baz": "bat"} + cliConfig := schema.CliConfiguration{} - inputs := []map[any]any{map1, map2} - expected := map[any]any{"foo": "bar", "baz": "bat"} + map1 := map[string]any{"foo": "bar"} + map2 := map[string]any{"baz": "bat"} - result, err := m.Merge(schema.CliConfiguration{}, inputs) + inputs := []map[string]any{map1, map2} + expected := map[string]any{"foo": "bar", "baz": "bat"} + + result, err := m.Merge(cliConfig, inputs) assert.Nil(t, err) assert.Equal(t, expected, result) } func TestMergeBasicOverride(t *testing.T) { - map1 := map[any]any{"foo": "bar"} - map2 := map[any]any{"baz": "bat"} - map3 := map[any]any{"foo": "ood"} + cliConfig := schema.CliConfiguration{} + + map1 := map[string]any{"foo": "bar"} + map2 := map[string]any{"baz": "bat"} + map3 := map[string]any{"foo": "ood"} + + inputs := []map[string]any{map1, map2, map3} + expected := map[string]any{"foo": "ood", "baz": "bat"} + + result, err := m.Merge(cliConfig, inputs) + assert.Nil(t, err) + assert.Equal(t, expected, result) +} + +func TestMergeListReplace(t *testing.T) { + cliConfig := schema.CliConfiguration{ + Settings: schema.CliSettings{ + ListMergeStrategy: m.ListMergeStrategyReplace, + }, + } + + map1 := map[string]any{ + "list": []string{"1", "2", "3"}, + } + + map2 := map[string]any{ + "list": []string{"4", "5", "6"}, + } + + inputs := []map[string]any{map1, map2} + expected := map[string]any{"list": []any{"4", "5", "6"}} + + result, err := m.Merge(cliConfig, inputs) + assert.Nil(t, err) + assert.Equal(t, expected, result) + + yamlConfig, err := u.ConvertToYAML(result) + assert.Nil(t, err) + t.Log(yamlConfig) +} + +func TestMergeListAppend(t *testing.T) { + cliConfig := schema.CliConfiguration{ + Settings: schema.CliSettings{ + ListMergeStrategy: m.ListMergeStrategyAppend, + }, + } + + map1 := map[string]any{ + "list": []string{"1", "2", "3"}, + } - inputs := []map[any]any{map1, map2, map3} - expected := map[any]any{"foo": "ood", "baz": "bat"} + map2 := map[string]any{ + "list": []string{"4", "5", "6"}, + } - result, err := m.Merge(schema.CliConfiguration{}, inputs) + inputs := []map[string]any{map1, map2} + expected := map[string]any{"list": []any{"1", "2", "3", "4", "5", "6"}} + + result, err := m.Merge(cliConfig, inputs) assert.Nil(t, err) assert.Equal(t, expected, result) + + yamlConfig, err := u.ConvertToYAML(result) + assert.Nil(t, err) + t.Log(yamlConfig) +} + +func TestMergeListMerge(t *testing.T) { + cliConfig := schema.CliConfiguration{ + Settings: schema.CliSettings{ + ListMergeStrategy: m.ListMergeStrategyMerge, + }, + } + + map1 := map[string]any{ + "list": []map[string]string{ + { + "1": "1", + "2": "2", + "3": "3", + "4": "4", + }, + }, + } + + map2 := map[string]any{ + "list": []map[string]string{ + { + "1": "1b", + "2": "2", + "3": "3b", + "5": "5", + }, + }, + } + + inputs := []map[string]any{map1, map2} + + result, err := m.Merge(cliConfig, inputs) + assert.Nil(t, err) + + var mergedList []any + var ok bool + + if mergedList, ok = result["list"].([]any); !ok { + t.Errorf("invalid merge result: %v", result) + } + + merged := mergedList[0].(map[string]any) + + assert.Equal(t, "1b", merged["1"]) + assert.Equal(t, "2", merged["2"]) + assert.Equal(t, "3b", merged["3"]) + assert.Equal(t, "4", merged["4"]) + assert.Equal(t, "5", merged["5"]) + + yamlConfig, err := u.ConvertToYAML(result) + assert.Nil(t, err) + t.Log(yamlConfig) } diff --git a/internal/provider/data_source_component_config.go b/internal/provider/data_source_component_config.go index c6f6d76..71bdfb9 100644 --- a/internal/provider/data_source_component_config.go +++ b/internal/provider/data_source_component_config.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" p "github.com/cloudposse/atmos/pkg/component" c "github.com/cloudposse/atmos/pkg/convert" diff --git a/internal/provider/data_source_deep_merge_json.go b/internal/provider/data_source_deep_merge_json.go index 669b02e..66ea23b 100644 --- a/internal/provider/data_source_deep_merge_json.go +++ b/internal/provider/data_source_deep_merge_json.go @@ -2,11 +2,13 @@ package provider import ( "context" - c "github.com/cloudposse/atmos/pkg/convert" - m "github.com/cloudposse/atmos/pkg/merge" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" jsoniter "github.com/json-iterator/go" + + c "github.com/cloudposse/atmos/pkg/convert" + m "github.com/cloudposse/atmos/pkg/merge" ) func dataSourceDeepMergeJSON() *schema.Resource { @@ -48,7 +50,7 @@ func dataSourceDeepMergeJSONRead(ctx context.Context, d *schema.ResourceData, me appendList := d.Get("append_list").(bool) deepCopyList := d.Get("deep_copy_list").(bool) - data, err := c.JSONSliceOfInterfaceToSliceOfMaps(input.([]any)) + data, err := JSONSliceOfInterfaceToSliceOfMaps(input.([]any)) if err != nil { return diag.FromErr(err) } diff --git a/internal/provider/data_source_deep_merge_yaml.go b/internal/provider/data_source_deep_merge_yaml.go index 6a15d6c..16b45e6 100644 --- a/internal/provider/data_source_deep_merge_yaml.go +++ b/internal/provider/data_source_deep_merge_yaml.go @@ -2,11 +2,13 @@ package provider import ( "context" - c "github.com/cloudposse/atmos/pkg/convert" - m "github.com/cloudposse/atmos/pkg/merge" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" + + c "github.com/cloudposse/atmos/pkg/convert" + m "github.com/cloudposse/atmos/pkg/merge" ) func dataSourceDeepMergeYAML() *schema.Resource { @@ -44,12 +46,11 @@ func dataSourceDeepMergeYAML() *schema.Resource { } func dataSourceDeepMergeYAMLRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { - input := d.Get("input") appendList := d.Get("append_list").(bool) deepCopyList := d.Get("deep_copy_list").(bool) - data, err := c.YAMLSliceOfInterfaceToSliceOfMaps(input.([]any)) + data, err := YAMLSliceOfInterfaceToSliceOfMaps(input.([]any)) if err != nil { return diag.FromErr(err) } diff --git a/internal/provider/data_source_describe_stacks.go b/internal/provider/data_source_describe_stacks.go index 73a0cee..b043f42 100644 --- a/internal/provider/data_source_describe_stacks.go +++ b/internal/provider/data_source_describe_stacks.go @@ -2,10 +2,10 @@ package provider import ( "context" - "gopkg.in/yaml.v2" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "gopkg.in/yaml.v3" cfg "github.com/cloudposse/atmos/pkg/config" c "github.com/cloudposse/atmos/pkg/convert" @@ -126,17 +126,17 @@ func dataSourceDescribeStacksRead(ctx context.Context, d *schema.ResourceData, m var err error var yamlConfig []byte - componentsList, err := c.SliceOfInterfacesToSliceOfStrings(components.([]any)) + componentsList, err := SliceOfInterfacesToSliceOfStrings(components.([]any)) if err != nil { return diag.FromErr(err) } - componentTypesList, err := c.SliceOfInterfacesToSliceOfStrings(componentTypes.([]any)) + componentTypesList, err := SliceOfInterfacesToSliceOfStrings(componentTypes.([]any)) if err != nil { return diag.FromErr(err) } - sectionsList, err := c.SliceOfInterfacesToSliceOfStrings(sections.([]any)) + sectionsList, err := SliceOfInterfacesToSliceOfStrings(sections.([]any)) if err != nil { return diag.FromErr(err) } diff --git a/internal/provider/data_source_spacelift_stack_config.go b/internal/provider/data_source_spacelift_stack_config.go index 36157bd..d62255b 100644 --- a/internal/provider/data_source_spacelift_stack_config.go +++ b/internal/provider/data_source_spacelift_stack_config.go @@ -2,11 +2,13 @@ package provider import ( "context" - c "github.com/cloudposse/atmos/pkg/convert" - s "github.com/cloudposse/atmos/pkg/spacelift" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" + + c "github.com/cloudposse/atmos/pkg/convert" + s "github.com/cloudposse/atmos/pkg/spacelift" ) func dataSourceSpaceliftStackConfig() *schema.Resource { @@ -86,7 +88,7 @@ func dataSourceSpaceliftStackConfigRead(ctx context.Context, d *schema.ResourceD return diag.FromErr(err) } - paths, err := c.SliceOfInterfacesToSliceOfStrings(input.([]any)) + paths, err := SliceOfInterfacesToSliceOfStrings(input.([]any)) if err != nil { return diag.FromErr(err) } diff --git a/internal/provider/data_source_stack_config_yaml.go b/internal/provider/data_source_stack_config_yaml.go index bc3547e..2cdbcf8 100644 --- a/internal/provider/data_source_stack_config_yaml.go +++ b/internal/provider/data_source_stack_config_yaml.go @@ -11,6 +11,7 @@ import ( c "github.com/cloudposse/atmos/pkg/convert" atmosSchema "github.com/cloudposse/atmos/pkg/schema" s "github.com/cloudposse/atmos/pkg/stack" + u "github.com/cloudposse/atmos/pkg/utils" ) func dataSourceStackConfigYAML() *schema.Resource { @@ -82,7 +83,7 @@ func dataSourceStackConfigYAMLRead(ctx context.Context, d *schema.ResourceData, return diag.FromErr(err) } - paths, err := c.SliceOfInterfacesToSliceOfStrings(input.([]any)) + paths, err := u.SliceOfInterfacesToSliceOfStrings(input.([]any)) if err != nil { return diag.FromErr(err) } diff --git a/internal/provider/json_utils.go b/internal/provider/json_utils.go new file mode 100644 index 0000000..e6aadc3 --- /dev/null +++ b/internal/provider/json_utils.go @@ -0,0 +1,34 @@ +package provider + +import "encoding/json" + +// JSONToMapOfInterfaces takes a JSON string as input and returns a map[string]any +func JSONToMapOfInterfaces(input string) (map[string]any, error) { + var data map[string]any + byt := []byte(input) + + if err := json.Unmarshal(byt, &data); err != nil { + return nil, err + } + return data, nil +} + +// JSONSliceOfInterfaceToSliceOfMaps takes a slice of JSON strings as input and returns a slice of map[any]any +func JSONSliceOfInterfaceToSliceOfMaps(input []any) ([]map[string]any, error) { + outputMap := make([]map[string]any, 0) + for _, current := range input { + data, err := JSONToMapOfInterfaces(current.(string)) + if err != nil { + return nil, err + } + + map2 := map[string]any{} + + for k, v := range data { + map2[k] = v + } + + outputMap = append(outputMap, map2) + } + return outputMap, nil +} diff --git a/internal/provider/provider_utils.go b/internal/provider/provider_utils.go index b79392d..b3db1a7 100644 --- a/internal/provider/provider_utils.go +++ b/internal/provider/provider_utils.go @@ -2,6 +2,8 @@ package provider import ( "os" + + "github.com/pkg/errors" ) func setEnv(envMap map[string]any) error { @@ -14,3 +16,17 @@ func setEnv(envMap map[string]any) error { } return nil } + +// SliceOfInterfacesToSliceOfStrings takes a slice of interfaces and converts it to a slice of strings +func SliceOfInterfacesToSliceOfStrings(input []any) ([]string, error) { + if input == nil { + return nil, errors.New("input must not be nil") + } + + output := make([]string, 0) + for _, current := range input { + output = append(output, current.(string)) + } + + return output, nil +} diff --git a/internal/provider/yaml_utils.go b/internal/provider/yaml_utils.go new file mode 100644 index 0000000..3c72552 --- /dev/null +++ b/internal/provider/yaml_utils.go @@ -0,0 +1,21 @@ +package provider + +import ( + u "github.com/cloudposse/atmos/pkg/utils" +) + +// YAMLSliceOfInterfaceToSliceOfMaps takes a slice of interfaces as input and returns a slice of map[any]any +func YAMLSliceOfInterfaceToSliceOfMaps(input []any) ([]map[string]any, error) { + output := make([]map[string]any, 0) + for _, current := range input { + // Apply YAMLToMap only if string is passed + if currentYaml, ok := current.(string); ok { + data, err := u.UnmarshalYAML[map[string]any](currentYaml) + if err != nil { + return nil, err + } + output = append(output, data) + } + } + return output, nil +} diff --git a/internal/spacelift/spacelift_stack_processor_test.go b/internal/spacelift/spacelift_stack_processor_test.go index cb88615..08505ef 100644 --- a/internal/spacelift/spacelift_stack_processor_test.go +++ b/internal/spacelift/spacelift_stack_processor_test.go @@ -4,9 +4,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v2" s "github.com/cloudposse/atmos/pkg/spacelift" + u "github.com/cloudposse/atmos/pkg/utils" ) func TestSpaceliftStackProcessor(t *testing.T) { @@ -31,7 +31,7 @@ func TestSpaceliftStackProcessor(t *testing.T) { tenant1Ue2DevInfraVpcStack := spaceliftStacks["tenant1-ue2-dev-infra-vpc"].(map[string]any) tenant1Ue2DevInfraVpcStackInfrastructureStackName := tenant1Ue2DevInfraVpcStack["stack"].(string) - tenant1Ue2DevInfraVpcStackBackend := tenant1Ue2DevInfraVpcStack["backend"].(map[any]any) + tenant1Ue2DevInfraVpcStackBackend := tenant1Ue2DevInfraVpcStack["backend"].(map[string]any) tenant1Ue2DevInfraVpcStackBackendWorkspaceKeyPrefix := tenant1Ue2DevInfraVpcStackBackend["workspace_key_prefix"].(string) assert.Equal(t, "tenant1-ue2-dev", tenant1Ue2DevInfraVpcStackInfrastructureStackName) assert.Equal(t, "infra-vpc", tenant1Ue2DevInfraVpcStackBackendWorkspaceKeyPrefix) @@ -39,14 +39,14 @@ func TestSpaceliftStackProcessor(t *testing.T) { // Test having a dash `-` in tenant/environment/stage names tenant1Ue2Test1InfraVpcStack := spaceliftStacks["tenant1-ue2-test-1-infra-vpc"].(map[string]any) tenant1Ue2Test1InfraVpcStackInfrastructureStackName := tenant1Ue2Test1InfraVpcStack["stack"].(string) - tenant1Ue2Test1InfraVpcStackBackend := tenant1Ue2Test1InfraVpcStack["backend"].(map[any]any) + tenant1Ue2Test1InfraVpcStackBackend := tenant1Ue2Test1InfraVpcStack["backend"].(map[string]any) tenant1Ue2Test1InfraVpcStackBackendWorkspaceKeyPrefix := tenant1Ue2Test1InfraVpcStackBackend["workspace_key_prefix"].(string) assert.Equal(t, "tenant1-ue2-test-1", tenant1Ue2Test1InfraVpcStackInfrastructureStackName) assert.Equal(t, "infra-vpc", tenant1Ue2Test1InfraVpcStackBackendWorkspaceKeyPrefix) tenant1Ue2DevTestTestComponentOverrideComponent := spaceliftStacks["tenant1-ue2-dev-test-test-component-override"].(map[string]any) tenant1Ue2DevTestTestComponentOverrideComponentInfrastructureStackName := tenant1Ue2DevTestTestComponentOverrideComponent["stack"].(string) - tenant1Ue2DevTestTestComponentOverrideComponentBackend := tenant1Ue2DevTestTestComponentOverrideComponent["backend"].(map[any]any) + tenant1Ue2DevTestTestComponentOverrideComponentBackend := tenant1Ue2DevTestTestComponentOverrideComponent["backend"].(map[string]any) tenant1Ue2DevTestTestComponentOverrideComponentBaseComponent := tenant1Ue2DevTestTestComponentOverrideComponent["base_component"].(string) tenant1Ue2DevTestTestComponentOverrideComponentBackendWorkspaceKeyPrefix := tenant1Ue2DevTestTestComponentOverrideComponentBackend["workspace_key_prefix"].(string) tenant1Ue2DevTestTestComponentOverrideComponentDeps := tenant1Ue2DevTestTestComponentOverrideComponent["deps"].([]string) @@ -99,9 +99,9 @@ func TestSpaceliftStackProcessor(t *testing.T) { assert.Equal(t, "depends-on:tenant1-ue2-dev-test-test-component", tenant1Ue2ProdTopLevelComponent1Labels[35]) assert.Equal(t, "depends-on:tenant1-ue2-prod-test-test-component-override", tenant1Ue2ProdTopLevelComponent1Labels[36]) - yamlSpaceliftStacks, err := yaml.Marshal(spaceliftStacks) + yamlSpaceliftStacks, err := u.ConvertToYAML(spaceliftStacks) assert.Nil(t, err) - t.Log(string(yamlSpaceliftStacks)) + t.Log(yamlSpaceliftStacks) } func TestLegacySpaceliftStackProcessor(t *testing.T) { @@ -139,12 +139,12 @@ func TestLegacySpaceliftStackProcessor(t *testing.T) { assert.Equal(t, 44, len(spaceliftStacks)) tenant1Ue2DevInfraVpcStack := spaceliftStacks["orgs-cp-tenant1-dev-us-east-2-infra-vpc"].(map[string]any) - tenant1Ue2DevInfraVpcStackBackend := tenant1Ue2DevInfraVpcStack["backend"].(map[any]any) + tenant1Ue2DevInfraVpcStackBackend := tenant1Ue2DevInfraVpcStack["backend"].(map[string]any) tenant1Ue2DevInfraVpcStackBackendWorkspaceKeyPrefix := tenant1Ue2DevInfraVpcStackBackend["workspace_key_prefix"].(string) assert.Equal(t, "infra-vpc", tenant1Ue2DevInfraVpcStackBackendWorkspaceKeyPrefix) tenant1Ue2DevTestTestComponentOverrideComponent := spaceliftStacks["orgs-cp-tenant1-dev-us-east-2-test-test-component-override"].(map[string]any) - tenant1Ue2DevTestTestComponentOverrideComponentBackend := tenant1Ue2DevTestTestComponentOverrideComponent["backend"].(map[any]any) + tenant1Ue2DevTestTestComponentOverrideComponentBackend := tenant1Ue2DevTestTestComponentOverrideComponent["backend"].(map[string]any) tenant1Ue2DevTestTestComponentOverrideComponentBaseComponent := tenant1Ue2DevTestTestComponentOverrideComponent["base_component"].(string) tenant1Ue2DevTestTestComponentOverrideComponentBackendWorkspaceKeyPrefix := tenant1Ue2DevTestTestComponentOverrideComponentBackend["workspace_key_prefix"].(string) tenant1Ue2DevTestTestComponentOverrideComponentDeps := tenant1Ue2DevTestTestComponentOverrideComponent["deps"].([]string) @@ -180,7 +180,7 @@ func TestLegacySpaceliftStackProcessor(t *testing.T) { assert.Equal(t, "deps:stacks/orgs/cp/tenant1/dev/us-east-2.yaml", tenant1Ue2DevTestTestComponentOverrideComponentLabels[35]) assert.Equal(t, "folder:component/test/test-component-override", tenant1Ue2DevTestTestComponentOverrideComponentLabels[36]) - yamlSpaceliftStacks, err := yaml.Marshal(spaceliftStacks) + yamlSpaceliftStacks, err := u.ConvertToYAML(spaceliftStacks) assert.Nil(t, err) - t.Log(string(yamlSpaceliftStacks)) + t.Log(yamlSpaceliftStacks) } diff --git a/internal/stack/stack_processor_test.go b/internal/stack/stack_processor_test.go index 688addc..546783d 100644 --- a/internal/stack/stack_processor_test.go +++ b/internal/stack/stack_processor_test.go @@ -4,19 +4,13 @@ import ( "testing" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v2" - cfg "github.com/cloudposse/atmos/pkg/config" - c "github.com/cloudposse/atmos/pkg/convert" - atmosSchema "github.com/cloudposse/atmos/pkg/schema" + "github.com/cloudposse/atmos/pkg/schema" s "github.com/cloudposse/atmos/pkg/stack" u "github.com/cloudposse/atmos/pkg/utils" ) func TestStackProcessor(t *testing.T) { - cliConfig, err := cfg.InitCliConfig(atmosSchema.ConfigAndStacksInfo{}, false) - assert.Nil(t, err) - stacksBasePath := "../../examples/tests/stacks" terraformComponentsBasePath := "../../examples/tests/components/terraform" helmfileComponentsBasePath := "../../examples/tests/components/helmfile" @@ -31,7 +25,21 @@ func TestStackProcessor(t *testing.T) { processStackDeps := true processComponentDeps := true - listResult, mapResult, _, err := s.ProcessYAMLConfigFiles( + cliConfig := schema.CliConfiguration{ + Templates: schema.Templates{ + Settings: schema.TemplatesSettings{ + Enabled: true, + Sprig: schema.TemplatesSettingsSprig{ + Enabled: true, + }, + Gomplate: schema.TemplatesSettingsGomplate{ + Enabled: true, + }, + }, + }, + } + + var listResult, mapResult, _, err = s.ProcessYAMLConfigFiles( cliConfig, stacksBasePath, terraformComponentsBasePath, @@ -52,13 +60,13 @@ func TestStackProcessor(t *testing.T) { assert.Equal(t, "orgs/cp/tenant1/staging/us-east-2", mapResultKeys[2]) assert.Equal(t, "orgs/cp/tenant1/test1/us-east-2", mapResultKeys[3]) - mapConfig1, err := c.YAMLToMapOfInterfaces(listResult[0]) + mapConfig1, err := u.UnmarshalYAML[schema.AtmosSectionMapType](listResult[0]) assert.Nil(t, err) imports := mapConfig1["imports"].([]any) mapConfig2 := mapResult["orgs/cp/tenant1/dev/us-east-2"] - assert.Equal(t, len(imports), len(mapConfig2.(map[any]any)["imports"].([]string))) + assert.Equal(t, len(imports), len(mapConfig2.(map[string]any)["imports"].([]string))) assert.Equal(t, 26, len(imports)) assert.Equal(t, "catalog/helmfile/echo-server", imports[0]) @@ -88,14 +96,14 @@ func TestStackProcessor(t *testing.T) { assert.Equal(t, "orgs/cp/tenant1/_defaults", imports[24]) assert.Equal(t, "orgs/cp/tenant1/dev/_defaults", imports[25]) - components := mapConfig1["components"].(map[any]any) - terraformComponents := components["terraform"].(map[any]any) - helmfileComponents := components["helmfile"].(map[any]any) + components := mapConfig1["components"].(map[string]any) + terraformComponents := components["terraform"].(map[string]any) + helmfileComponents := components["helmfile"].(map[string]any) - infraVpcComponent := terraformComponents["infra/vpc"].(map[any]any) - infraVpcComponentBackend := infraVpcComponent["backend"].(map[any]any) + infraVpcComponent := terraformComponents["infra/vpc"].(map[string]any) + infraVpcComponentBackend := infraVpcComponent["backend"].(map[string]any) infraVpcComponentBackendType := infraVpcComponent["backend_type"] - infraVpcComponentRemoteSateBackend := infraVpcComponent["remote_state_backend"].(map[any]any) + infraVpcComponentRemoteSateBackend := infraVpcComponent["remote_state_backend"].(map[string]any) infraVpcComponentRemoteSateBackendType := infraVpcComponent["remote_state_backend_type"] infraVpcComponentBackendWorkspaceKeyPrefix := infraVpcComponentBackend["workspace_key_prefix"] infraVpcComponentRemoteStateBackendWorkspaceKeyPrefix := infraVpcComponentRemoteSateBackend["workspace_key_prefix"] @@ -104,13 +112,13 @@ func TestStackProcessor(t *testing.T) { assert.Equal(t, "s3", infraVpcComponentBackendType) assert.Equal(t, "s3", infraVpcComponentRemoteSateBackendType) - testTestComponent := terraformComponents["test/test-component"].(map[any]any) - testTestComponentBackend := testTestComponent["backend"].(map[any]any) + testTestComponent := terraformComponents["test/test-component"].(map[string]any) + testTestComponentBackend := testTestComponent["backend"].(map[string]any) testTestComponentBackendType := testTestComponent["backend_type"] testTestComponentBackendBucket := testTestComponentBackend["bucket"] testTestComponentBackendWorkspaceKeyPrefix := testTestComponentBackend["workspace_key_prefix"] testTestComponentBackendRoleArn := testTestComponentBackend["role_arn"] - testTestComponentRemoteStateBackend := testTestComponent["remote_state_backend"].(map[any]any) + testTestComponentRemoteStateBackend := testTestComponent["remote_state_backend"].(map[string]any) testTestComponentRemoteStateBackendType := testTestComponent["remote_state_backend_type"] testTestComponentRemoteStateBackendBucket := testTestComponentRemoteStateBackend["bucket"] testTestComponentRemoteStateBackendWorkspaceKeyPrefix := testTestComponentRemoteStateBackend["workspace_key_prefix"] @@ -124,12 +132,12 @@ func TestStackProcessor(t *testing.T) { assert.Equal(t, nil, testTestComponentBackendRoleArn) assert.Equal(t, "arn:aws:iam::123456789012:role/cp-gbl-root-terraform", testTestComponentRemoteStateBackendRoleArn) - testTestComponentOverrideComponent := terraformComponents["test/test-component-override"].(map[any]any) - testTestComponentOverrideComponentBackend := testTestComponentOverrideComponent["backend"].(map[any]any) + testTestComponentOverrideComponent := terraformComponents["test/test-component-override"].(map[string]any) + testTestComponentOverrideComponentBackend := testTestComponentOverrideComponent["backend"].(map[string]any) testTestComponentOverrideComponentBackendType := testTestComponentOverrideComponent["backend_type"] testTestComponentOverrideComponentBackendWorkspaceKeyPrefix := testTestComponentOverrideComponentBackend["workspace_key_prefix"] testTestComponentOverrideComponentBackendBucket := testTestComponentOverrideComponentBackend["bucket"] - testTestComponentOverrideComponentRemoteStateBackend := testTestComponentOverrideComponent["remote_state_backend"].(map[any]any) + testTestComponentOverrideComponentRemoteStateBackend := testTestComponentOverrideComponent["remote_state_backend"].(map[string]any) testTestComponentOverrideComponentRemoteStateBackendVal1 := testTestComponentOverrideComponentRemoteStateBackend["val1"].(bool) testTestComponentOverrideComponentRemoteStateBackendVal2 := testTestComponentOverrideComponentRemoteStateBackend["val2"] testTestComponentOverrideComponentRemoteStateBackendVal3 := testTestComponentOverrideComponentRemoteStateBackend["val3"].(int) @@ -146,16 +154,16 @@ func TestStackProcessor(t *testing.T) { assert.Equal(t, 3, testTestComponentOverrideComponentRemoteStateBackendVal3) assert.Equal(t, nil, testTestComponentOverrideComponentRemoteStateBackendVal4) - topLevelComponent1 := terraformComponents["top-level-component1"].(map[any]any) - topLevelComponent1Backend := topLevelComponent1["backend"].(map[any]any) - topLevelComponent1RemoteSateBackend := topLevelComponent1["remote_state_backend"].(map[any]any) + topLevelComponent1 := terraformComponents["top-level-component1"].(map[string]any) + topLevelComponent1Backend := topLevelComponent1["backend"].(map[string]any) + topLevelComponent1RemoteSateBackend := topLevelComponent1["remote_state_backend"].(map[string]any) topLevelComponent1BackendWorkspaceKeyPrefix := topLevelComponent1Backend["workspace_key_prefix"] topLevelComponent1RemoteStateBackendWorkspaceKeyPrefix := topLevelComponent1RemoteSateBackend["workspace_key_prefix"] assert.Equal(t, "top-level-component1", topLevelComponent1BackendWorkspaceKeyPrefix) assert.Equal(t, "top-level-component1", topLevelComponent1RemoteStateBackendWorkspaceKeyPrefix) - testTestComponentOverrideComponent2 := terraformComponents["test/test-component-override-2"].(map[any]any) - testTestComponentOverrideComponentBackend2 := testTestComponentOverrideComponent2["backend"].(map[any]any) + testTestComponentOverrideComponent2 := terraformComponents["test/test-component-override-2"].(map[string]any) + testTestComponentOverrideComponentBackend2 := testTestComponentOverrideComponent2["backend"].(map[string]any) testTestComponentOverrideComponentBackendType2 := testTestComponentOverrideComponent2["backend_type"] testTestComponentOverrideComponentBackendWorkspaceKeyPrefix2 := testTestComponentOverrideComponentBackend2["workspace_key_prefix"] testTestComponentOverrideComponentBackendBucket2 := testTestComponentOverrideComponentBackend2["bucket"] @@ -168,21 +176,21 @@ func TestStackProcessor(t *testing.T) { assert.Equal(t, "test/test-component-override", testTestComponentOverrideInheritance2[0]) assert.Equal(t, "test/test-component", testTestComponentOverrideInheritance2[1]) - infraInfraServerOverrideComponent := helmfileComponents["infra/infra-server-override"].(map[any]any) + infraInfraServerOverrideComponent := helmfileComponents["infra/infra-server-override"].(map[string]any) infraInfraServerOverrideComponentCommand := infraInfraServerOverrideComponent["command"] - infraInfraServerOverrideComponentVars := infraInfraServerOverrideComponent["vars"].(map[any]any) + infraInfraServerOverrideComponentVars := infraInfraServerOverrideComponent["vars"].(map[string]any) infraInfraServerOverrideComponentVarsA := infraInfraServerOverrideComponentVars["a"] infraInfraServerOverrideComponentInheritance := infraInfraServerOverrideComponent["inheritance"].([]any) assert.Equal(t, "helmfile", infraInfraServerOverrideComponentCommand) assert.Equal(t, "infra/infra-server", infraInfraServerOverrideComponentInheritance[0]) assert.Equal(t, "1_override", infraInfraServerOverrideComponentVarsA) - testTestComponentOverrideComponent3 := terraformComponents["test/test-component-override-3"].(map[any]any) - testTestComponentOverrideComponent3Metadata := testTestComponentOverrideComponent3["metadata"].(map[any]any) + testTestComponentOverrideComponent3 := terraformComponents["test/test-component-override-3"].(map[string]any) + testTestComponentOverrideComponent3Metadata := testTestComponentOverrideComponent3["metadata"].(map[string]any) testTestComponentOverrideComponent3TerraformWorkspace := testTestComponentOverrideComponent3Metadata["terraform_workspace"] assert.Equal(t, "test-component-override-3-workspace", testTestComponentOverrideComponent3TerraformWorkspace) - yamlConfig, err := yaml.Marshal(mapConfig1) + yamlConfig, err := u.ConvertToYAML(mapConfig1) assert.Nil(t, err) t.Log(string(yamlConfig)) }