Skip to content

Commit

Permalink
Bump atmos to the latest version. Update tests (#202)
Browse files Browse the repository at this point in the history
* Bump `atmos` to the latest version

* Update provider docs
  • Loading branch information
aknysh authored Sep 22, 2022
1 parent bb97844 commit 4afc016
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 13 deletions.
5 changes: 3 additions & 2 deletions docs/data-sources/aws_eks_update_kubeconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "utils_aws_eks_update_kubeconfig Data Source - terraform-provider-utils"
subcategory: ""
description: |-
The 'utilsawseksupdatekubeconfig' data source executes 'aws eks update-kubeconfig' commands
The 'awseksupdate_kubeconfig' data source executes 'aws eks update-kubeconfig' commands
---

# utils_aws_eks_update_kubeconfig (Data Source)

The 'utils_aws_eks_update_kubeconfig' data source executes 'aws eks update-kubeconfig' commands
The 'aws_eks_update_kubeconfig' data source executes 'aws eks update-kubeconfig' commands

## Example Usage

Expand Down Expand Up @@ -113,6 +113,7 @@ data "utils_aws_eks_update_kubeconfig" "example4" {
- `alias` (String) Alias for the cluster context name. Defaults to match cluster ARN.
- `cluster_name` (String) EKS cluster name.
- `component` (String) Component name.
- `env` (Map of String) Map of ENV vars in the format 'key=value'. These ENV vars will be set before executing the data source
- `environment` (String) Environment.
- `kubeconfig` (String) kubeconfig file path to write the kubeconfig to. By default, the configuration is written to the first file path in the KUBECONFIG environment variable (if it is set) or the default kubeconfig path (.kube/config) in your home directory
- `profile` (String) AWS profile to use for cluster authentication.
Expand Down
12 changes: 12 additions & 0 deletions docs/data-sources/component_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ The `component_config` data source accepts a component and a stack name and retu
locals {
component = "test/test-component-override"
stack = "tenant1-ue2-dev"
namespace = ""
tenant = "tenant1"
environment = "ue2"
stage = "dev"
env = {
ENVIRONMENT = local.environment
STAGE = local.stage
ATMOS_CLI_CONFIG_PATH = "."
}
result1 = yamldecode(data.utils_component_config.example1.output)
result2 = yamldecode(data.utils_component_config.example2.output)
}
Expand All @@ -28,14 +35,17 @@ data "utils_component_config" "example1" {
component = local.component
stack = local.stack
ignore_errors = false
env = local.env
}
data "utils_component_config" "example2" {
component = local.component
namespace = local.namespace
tenant = local.tenant
environment = local.environment
stage = local.stage
ignore_errors = false
env = local.env
}
```

Expand All @@ -48,8 +58,10 @@ data "utils_component_config" "example2" {

### Optional

- `env` (Map of String) Map of ENV vars in the format 'key=value'. These ENV vars will be set before executing the data source
- `environment` (String) Environment.
- `ignore_errors` (Boolean) Flag to ignore errors if the component is not found in the stack.
- `namespace` (String) Namespace.
- `stack` (String) Stack name.
- `stage` (String) Stage.
- `tenant` (String) Tenant.
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/spacelift_stack_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ data "utils_spacelift_stack_config" "example" {
### Optional

- `base_path` (String) Stack config base path.
- `env` (Map of String) Map of ENV vars in the format 'key=value'. These ENV vars will be set before executing the data source
- `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.
Expand Down
3 changes: 2 additions & 1 deletion docs/data-sources/stack_config_yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The `stack_config_yaml` data source accepts a list of stack config file names an

```terraform
locals {
base_path = "../../config/stacks"
base_path = "../../complete/stacks"
stack_config_files = [
"${local.base_path}/tenant1/ue2/dev.yaml",
Expand Down Expand Up @@ -46,6 +46,7 @@ data "utils_stack_config_yaml" "example" {
### Optional

- `base_path` (String) Stack config base path.
- `env` (Map of String) Map of ENV vars in the format 'key=value'. These ENV vars will be set before executing the data source
- `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.

Expand Down
2 changes: 2 additions & 0 deletions examples/data-sources/utils_component_config/data-source.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
locals {
component = "test/test-component-override"
stack = "tenant1-ue2-dev"
namespace = ""
tenant = "tenant1"
environment = "ue2"
stage = "dev"
Expand All @@ -24,6 +25,7 @@ data "utils_component_config" "example1" {

data "utils_component_config" "example2" {
component = local.component
namespace = local.namespace
tenant = local.tenant
environment = local.environment
stage = local.stage
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/cloudposse/terraform-provider-utils
go 1.19

require (
github.com/cloudposse/atmos v1.8.0
github.com/cloudposse/atmos v1.8.1
github.com/gruntwork-io/terratest v0.40.22
github.com/hashicorp/terraform-plugin-docs v0.13.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.22.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.23.0
github.com/json-iterator/go v1.1.12
github.com/stretchr/testify v1.8.0
gopkg.in/yaml.v2 v2.4.0
Expand All @@ -33,7 +33,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
Expand Down
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudposse/atmos v1.8.0 h1:9m7t8I2rY2NoIi8Sfr7hJ3DMNxmLv0hSRs/OvczSBAo=
github.com/cloudposse/atmos v1.8.0/go.mod h1:O6uZCWB+tF1kYJTjdE7Db0sAmtSXg/emNahEr6IXxlc=
github.com/cloudposse/atmos v1.8.1 h1:mbMTDZjdKHoserQbNxRyx7VWP7P6W0s2cHp4rrw+5O0=
github.com/cloudposse/atmos v1.8.1/go.mod h1:O6uZCWB+tF1kYJTjdE7Db0sAmtSXg/emNahEr6IXxlc=
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=
Expand Down Expand Up @@ -215,8 +217,9 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
Expand Down Expand Up @@ -312,8 +315,8 @@ github.com/hashicorp/terraform-plugin-go v0.14.0 h1:ttnSlS8bz3ZPYbMb84DpcPhY4F5D
github.com/hashicorp/terraform-plugin-go v0.14.0/go.mod h1:2nNCBeRLaenyQEi78xrGrs9hMbulveqG/zDMQSvVJTE=
github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs=
github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.22.0 h1:MzfNfrheTt24xbEbA4npUSbX3GYu4xjXS7czcpJFyQY=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.22.0/go.mod h1:q1XKSxXg9nDmhV0IvNZNZxe3gcTAHzMqrjs8wX1acng=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.23.0 h1:D4EeQm0piYXIHp6ZH3zjyP2Elq6voC64x3GZptaiefA=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.23.0/go.mod h1:xkJGavPvP9kYS/VbiW8o7JuTNgPwm7Tiw/Ie/b46r4c=
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg=
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
Expand Down
7 changes: 4 additions & 3 deletions internal/component/component_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func TestComponentProcessor(t *testing.T) {
var err error
var component string
var stack string
namespace := ""
var yamlConfig []byte

var tenant1Ue2DevTestTestComponent map[string]any
Expand Down Expand Up @@ -49,7 +50,7 @@ func TestComponentProcessor(t *testing.T) {
tenant := "tenant1"
environment := "ue2"
stage := "dev"
tenant1Ue2DevTestTestComponent2, err = c.ProcessComponentFromContext(component, tenant, environment, stage)
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)
Expand Down Expand Up @@ -119,7 +120,7 @@ func TestComponentProcessor(t *testing.T) {
tenant = "tenant1"
environment = "ue2"
stage = "dev"
tenant1Ue2DevTestTestComponentOverrideComponent2, err = c.ProcessComponentFromContext(component, tenant, environment, stage)
tenant1Ue2DevTestTestComponentOverrideComponent2, err = c.ProcessComponentFromContext(component, namespace, tenant, environment, stage)
assert.Nil(t, err)
tenant1Ue2DevTestTestComponentOverrideComponent2Backend := tenant1Ue2DevTestTestComponentOverrideComponent2["backend"].(map[any]any)
tenant1Ue2DevTestTestComponentOverrideComponent2Workspace := tenant1Ue2DevTestTestComponentOverrideComponent2["workspace"].(string)
Expand All @@ -137,7 +138,7 @@ func TestComponentProcessor(t *testing.T) {
tenant = "tenant1"
environment = "ue2"
stage = "test-1"
tenant1Ue2Test1TestTestComponentOverrideComponent2, err = c.ProcessComponentFromContext(component, tenant, environment, stage)
tenant1Ue2Test1TestTestComponentOverrideComponent2, err = c.ProcessComponentFromContext(component, namespace, tenant, environment, stage)
assert.Nil(t, err)
tenant1Ue2Test1TestTestComponentOverrideComponent2Backend := tenant1Ue2DevTestTestComponentOverrideComponent2["backend"].(map[any]any)
tenant1Ue2Test1TestTestComponentOverrideComponent2Workspace := tenant1Ue2Test1TestTestComponentOverrideComponent2["workspace"].(string)
Expand Down
9 changes: 8 additions & 1 deletion internal/provider/data_source_component_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ func dataSourceComponentConfig() *schema.Resource {
Optional: true,
Default: "",
},
"namespace": {
Description: "Namespace.",
Type: schema.TypeString,
Optional: true,
Default: "",
},
"environment": {
Description: "Environment.",
Type: schema.TypeString,
Expand Down Expand Up @@ -74,6 +80,7 @@ func dataSourceComponentConfig() *schema.Resource {
func dataSourceComponentConfigRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {
component := d.Get("component").(string)
stack := d.Get("stack").(string)
namespace := d.Get("namespace").(string)
tenant := d.Get("tenant").(string)
environment := d.Get("environment").(string)
stage := d.Get("stage").(string)
Expand All @@ -95,7 +102,7 @@ func dataSourceComponentConfigRead(ctx context.Context, d *schema.ResourceData,
return diag.FromErr(err)
}
} else {
result, err = p.ProcessComponentFromContext(component, tenant, environment, stage)
result, err = p.ProcessComponentFromContext(component, namespace, tenant, environment, stage)
if err != nil && !ignoreErrors {
return diag.FromErr(err)
}
Expand Down

0 comments on commit 4afc016

Please sign in to comment.