Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat]: [CDS-69600]: Fix yaml null issue for environment data source Api #610

Merged
merged 8 commits into from
Jul 7, 2023
3 changes: 3 additions & 0 deletions .changelog/610.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
Fix for supporting yaml for environment and environment group data source
```
2 changes: 1 addition & 1 deletion docs/data-sources/platform_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ data "harness_platform_environment" "example" {
- `id` (String) The ID of this resource.
- `tags` (Set of String) Tags to associate with the resource.
- `type` (String) The type of environment.
- `yaml` (String) Input Set YAML
- `yaml` (String) Environment YAML. In YAML, to reference an entity at the organization scope, prefix 'org' to the expression: org.{identifier}. To reference an entity at the account scope, prefix 'account` to the expression: account.{identifier}. For eg, to reference a connector with identifier 'connectorId' at the organization scope in a stage mention it as connectorRef: org.connectorId.


2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/antihax/optional v1.0.0
github.com/docker/docker v20.10.22+incompatible
github.com/harness/harness-go-sdk v0.3.34
github.com/harness/harness-go-sdk v0.3.35
github.com/harness/harness-openapi-go-client v0.0.17
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
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/harness/harness-go-sdk v0.3.34 h1:82yX3CIcGnZEbWuo7PaCp1ksFSm+nuUV4Q1a+08OGtc=
github.com/harness/harness-go-sdk v0.3.34/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-go-sdk v0.3.35 h1:jgQ9VJyswqm9HOCsR7pExOssA8/koknwrlbwheWbiJw=
github.com/harness/harness-go-sdk v0.3.35/go.mod h1:CPXydorp4zd5Dz2u2FXiHyWL4yd5PQafOMN69cgPSvk=
github.com/harness/harness-openapi-go-client v0.0.17 h1:EZneIyi6sV+dlTgXbawxdVD0OoDmG3mnGHEJbwslRzc=
github.com/harness/harness-openapi-go-client v0.0.17/go.mod h1:u0vqYb994BJGotmEwJevF4L3BNAdU9i8ui2d22gmLPA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down
17 changes: 15 additions & 2 deletions internal/service/platform/environment/data_source_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func DataSourceEnvironment() *schema.Resource {
Computed: true,
},
"yaml": {
Description: "Input Set YAML",
Description: "Environment YAML." + helpers.Descriptions.YamlText.String(),
lovish1999 marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeString,
Computed: true,
},
Expand Down Expand Up @@ -78,7 +78,20 @@ func dataSourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta
return nil
}

readEnvironment(d, env)
readDataSourceEnvironment(d, env)

return nil
}

func readDataSourceEnvironment(d *schema.ResourceData, env *nextgen.EnvironmentResponseDetails) {
d.SetId(env.Identifier)
d.Set("identifier", env.Identifier)
d.Set("org_id", env.OrgIdentifier)
d.Set("project_id", env.ProjectIdentifier)
d.Set("name", env.Name)
d.Set("color", env.Color)
d.Set("description", env.Description)
d.Set("tags", helpers.FlattenTags(env.Tags))
d.Set("type", env.Type_.String())
d.Set("yaml", env.Yaml)
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func readEnvironment(d *schema.ResourceData, env *nextgen.EnvironmentResponseDet
d.SetId(env.Identifier)
d.Set("identifier", env.Identifier)
d.Set("org_id", env.OrgIdentifier)
d.Set("project_id", env.ProjectIdentifier)
d.Set("name", env.Name)
d.Set("color", env.Color)
d.Set("description", env.Description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,8 @@ func readEnvironmentGroup(d *schema.ResourceData, env *nextgen.EnvironmentGroupR
d.Set("project_id", env.ProjectIdentifier)
d.Set("identifier", env.Identifier)
d.Set("color", env.Color)
yaml := env.Yaml
if yaml != "" {
d.Set("yaml", yaml)
}
}