diff --git a/Makefile b/Makefile index 2a3cbd6..8823b90 100644 --- a/Makefile +++ b/Makefile @@ -37,3 +37,7 @@ lint: # Run acceptance tests testacc: install TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 3m + +tfplugindocs: + go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs + tfplugindocs generate diff --git a/docs/data-sources/component_config.md b/docs/data-sources/component_config.md new file mode 100644 index 0000000..4c49cd3 --- /dev/null +++ b/docs/data-sources/component_config.md @@ -0,0 +1,59 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "utils_component_config Data Source - terraform-provider-utils" +subcategory: "" +description: |- + The component_config data source accepts a component and a stack name and returns the component configuration in the stack +--- + +# utils_component_config (Data Source) + +The `component_config` data source accepts a component and a stack name and returns the component configuration in the stack + +## Example Usage + +```terraform +locals { + component = "test/test-component-override" + stack = "tenant1-ue2-dev" + tenant = "tenant1" + environment = "ue2" + stage = "dev" + + result1 = yamldecode(data.utils_component_config.example1.output) + result2 = yamldecode(data.utils_component_config.example2.output) +} + +data "utils_component_config" "example1" { + component = local.component + stack = local.stack +} + +data "utils_component_config" "example2" { + component = local.component + tenant = local.tenant + environment = local.environment + stage = local.stage +} +``` + + +## Schema + +### Required + +- **component** (String) Component name. + +### Optional + +- **environment** (String) Environment. +- **id** (String) The ID of this resource. +- **stack** (String) Stack name. +- **stage** (String) Stage. +- **tenant** (String) Tenant. + +### Read-Only + +- **output** (String) Component configuration. + + diff --git a/docs/data-sources/deep_merge_json.md b/docs/data-sources/deep_merge_json.md index cdf06ab..013b44f 100644 --- a/docs/data-sources/deep_merge_json.md +++ b/docs/data-sources/deep_merge_json.md @@ -6,21 +6,13 @@ description: |- The deep_merge_json data source accepts a list of JSON strings as input and deep merges into a single JSON string as output. --- -# Data Source `utils_deep_merge_json` +# utils_deep_merge_json (Data Source) The `deep_merge_json` data source accepts a list of JSON strings as input and deep merges into a single JSON string as output. ## Example Usage ```terraform -terraform { - required_providers { - utils = { - source = "cloudposse/utils" - } - } -} - locals { json_data_1 = file("${path.module}/json1.json") json_data_2 = file("${path.module}/json2.json") @@ -32,10 +24,6 @@ data "utils_deep_merge_json" "example" { local.json_data_2 ] } - -output "deep_merge_output" { - value = data.utils_deep_merge_json.example.output -} ``` @@ -43,13 +31,15 @@ output "deep_merge_output" { ### Required -- **inputs** (List of String) A list JSON strings that is deep merged into the `output` attribute. +- **input** (List of String) A list of JSON strings that is deep merged into the `output` attribute. ### Optional +- **append_list** (Boolean) A boolean flag to enable/disable appending lists instead of overwriting them. +- **deep_copy_list** (Boolean) A boolean flag to enable/disable merging of list elements one by one. - **id** (String) The ID of this resource. -### Read-only +### Read-Only - **output** (String) The deep-merged output. diff --git a/docs/data-sources/deep_merge_yaml.md b/docs/data-sources/deep_merge_yaml.md index 3b81105..7ee10b8 100644 --- a/docs/data-sources/deep_merge_yaml.md +++ b/docs/data-sources/deep_merge_yaml.md @@ -6,21 +6,13 @@ description: |- The deep_merge_yaml data source accepts a list of YAML strings as input and deep merges into a single YAML string as output. --- -# Data Source `utils_deep_merge_yaml` +# utils_deep_merge_yaml (Data Source) The `deep_merge_yaml` data source accepts a list of YAML strings as input and deep merges into a single YAML string as output. ## Example Usage ```terraform -terraform { - required_providers { - utils = { - source = "cloudposse/utils" - } - } -} - locals { yaml_data_1 = file("${path.module}/data1.yaml") yaml_data_2 = file("${path.module}/data2.yaml") @@ -32,10 +24,6 @@ data "utils_deep_merge_yaml" "example" { local.yaml_data_2 ] } - -output "deep_merge_output" { - value = data.utils_deep_merge_yaml.example.output -} ``` @@ -43,13 +31,15 @@ output "deep_merge_output" { ### Required -- **inputs** (List of String) A list YAML strings that is deep merged into the `output` attribute. +- **input** (List of String) A list of YAML strings that is deep merged into the `output` attribute. ### Optional +- **append_list** (Boolean) A boolean flag to enable/disable appending lists instead of overwriting them. +- **deep_copy_list** (Boolean) A boolean flag to enable/disable merging of list elements one by one. - **id** (String) The ID of this resource. -### Read-only +### Read-Only - **output** (String) The deep-merged output. diff --git a/docs/data-sources/spacelift_stack_config.md b/docs/data-sources/spacelift_stack_config.md new file mode 100644 index 0000000..0f25a18 --- /dev/null +++ b/docs/data-sources/spacelift_stack_config.md @@ -0,0 +1,48 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "utils_spacelift_stack_config Data Source - terraform-provider-utils" +subcategory: "" +description: |- + The spacelift_stack_config data source accepts a list of stack config file names and returns a map of Spacelift stack configurations. +--- + +# utils_spacelift_stack_config (Data Source) + +The `spacelift_stack_config` data source accepts a list of stack config file names and returns a map of Spacelift stack configurations. + +## Example Usage + +```terraform +locals { + result = yamldecode(data.utils_spacelift_stack_config.example.output) +} + +data "utils_spacelift_stack_config" "example" { + process_component_deps = true + process_stack_deps = true + process_imports = true + stack_config_path_template = "stacks/%s.yaml" +} +``` + + +## Schema + +### Required + +- **stack_config_path_template** (String) Stack config path template. + +### Optional + +- **base_path** (String) Stack config base path. +- **id** (String) The ID of this resource. +- **input** (List of String) A list of stack config file names. +- **process_component_deps** (Boolean) A boolean flag to enable/disable processing config dependencies for the components. +- **process_imports** (Boolean) A boolean flag to enable/disable processing stack imports. +- **process_stack_deps** (Boolean) A boolean flag to enable/disable processing all stack dependencies for the components. + +### Read-Only + +- **output** (String) A map of Spacelift stack configurations. + + diff --git a/docs/data-sources/stack_config_yaml.md b/docs/data-sources/stack_config_yaml.md new file mode 100644 index 0000000..83c66b4 --- /dev/null +++ b/docs/data-sources/stack_config_yaml.md @@ -0,0 +1,57 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "utils_stack_config_yaml Data Source - terraform-provider-utils" +subcategory: "" +description: |- + The stack_config_yaml data source accepts a list of stack config file names and returns a list of stack configurations. +--- + +# utils_stack_config_yaml (Data Source) + +The `stack_config_yaml` data source accepts a list of stack config file names and returns a list of stack configurations. + +## Example Usage + +```terraform +locals { + base_path = "../../config/stacks" + + stack_config_files = [ + "${local.base_path}/tenant1/ue2/dev.yaml", + "${local.base_path}/tenant1/ue2/prod.yaml", + "${local.base_path}/tenant1/ue2/staging.yaml", + "${local.base_path}/tenant2/ue2/dev.yaml", + "${local.base_path}/tenant2/ue2/prod.yaml", + "${local.base_path}/tenant2/ue2/staging.yaml", + ] + + result = [for i in data.utils_stack_config_yaml.example.output : yamldecode(i)] +} + +data "utils_stack_config_yaml" "example" { + base_path = local.base_path + input = local.stack_config_files + process_component_deps = true + process_stack_deps = false +} +``` + + +## Schema + +### Required + +- **input** (List of String) A list of stack config file names. + +### Optional + +- **base_path** (String) Stack config base path. +- **id** (String) The ID of this resource. +- **process_component_deps** (Boolean) A boolean flag to enable/disable processing config dependencies for the components. +- **process_stack_deps** (Boolean) A boolean flag to enable/disable processing all stack dependencies for the components. + +### Read-Only + +- **output** (List of String) A list of stack configurations. + + diff --git a/docs/index.md b/docs/index.md index e212a0b..c699dee 100644 --- a/docs/index.md +++ b/docs/index.md @@ -18,4 +18,4 @@ provider "utils" { ``` -## Schema +## Schema \ No newline at end of file diff --git a/go.mod b/go.mod index 837b465..7308e12 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/cloudposse/terraform-provider-utils go 1.16 require ( - github.com/cloudposse/atmos v1.3.25 - github.com/gruntwork-io/terratest v0.38.9 + github.com/cloudposse/atmos v1.3.26 + github.com/gruntwork-io/terratest v0.39.0 github.com/hashicorp/terraform-plugin-docs v0.5.1 github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1 github.com/json-iterator/go v1.1.12 diff --git a/go.sum b/go.sum index f180b21..c9f3bbd 100644 --- a/go.sum +++ b/go.sum @@ -184,8 +184,8 @@ github.com/cilium/ebpf v0.4.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudposse/atmos v1.3.25 h1:+zPEJtFXVVgVmmRhhIjWnBOZPUigzRhN5SvHVTgzwgU= -github.com/cloudposse/atmos v1.3.25/go.mod h1:QzJQBrCTMKjpqXPzm3qsXh4czWOsUj5Cy7uotYmC8+0= +github.com/cloudposse/atmos v1.3.26 h1:MsuL/ld1yJX+dprBzztyHq0MYm4xQ6C5S3BZy4Sd4/s= +github.com/cloudposse/atmos v1.3.26/go.mod h1:QzJQBrCTMKjpqXPzm3qsXh4czWOsUj5Cy7uotYmC8+0= 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= @@ -515,8 +515,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gruntwork-io/go-commons v0.8.0/go.mod h1:gtp0yTtIBExIZp7vyIV9I0XQkVwiQZze678hvDXof78= -github.com/gruntwork-io/terratest v0.38.9 h1:OYEwDZnaqi8cS0ZyPd6MyxGxFlC/MsSguCjWgB1jirg= -github.com/gruntwork-io/terratest v0.38.9/go.mod h1:F4r5ay5mcPtmjFUmnAIvNQZ617/Co+lneTOfJKumPmE= +github.com/gruntwork-io/terratest v0.39.0 h1:Lq7aNCoFxhhmdQIyuBFBf8N87aCnypmNBFYgvsdIfCQ= +github.com/gruntwork-io/terratest v0.39.0/go.mod h1:CjHsEgP1Pe987X5N8K5qEqCuLtu1bqERGIAF8bTj1s0= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0=