Skip to content

Commit

Permalink
feat(env-type): update description of env-type using tf
Browse files Browse the repository at this point in the history
  • Loading branch information
dharsanb authored Apr 11, 2024
1 parent 2649f11 commit 6fb3bf7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/hashicorp/terraform-plugin-go v0.21.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.32.0
github.com/humanitec/humanitec-go-autogen v0.0.0-20240313140210-52935f0baed6
github.com/humanitec/humanitec-go-autogen v0.0.0-20240409130502-cfb171fe9dc4
github.com/stretchr/testify v1.9.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbg
github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/humanitec/humanitec-go-autogen v0.0.0-20240313140210-52935f0baed6 h1:vvzktUEv99nnWHzzqb6moBiNJaC9I61CUf44l9AofwQ=
github.com/humanitec/humanitec-go-autogen v0.0.0-20240313140210-52935f0baed6/go.mod h1:WqItJ/MhAHcjP7LIhIt2/NrgXeXRbLuxvXlin7qY0j4=
github.com/humanitec/humanitec-go-autogen v0.0.0-20240409130502-cfb171fe9dc4 h1:5Axj0K5JH9YGaKohz8GqL+BcLLBwV5nn16l42p8PnMM=
github.com/humanitec/humanitec-go-autogen v0.0.0-20240409130502-cfb171fe9dc4/go.mod h1:WqItJ/MhAHcjP7LIhIt2/NrgXeXRbLuxvXlin7qY0j4=
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=
Expand Down
29 changes: 28 additions & 1 deletion internal/provider/resource_environment_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,34 @@ func (r *ResourceEnvironmentType) Read(ctx context.Context, req resource.ReadReq
}

func (r *ResourceEnvironmentType) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
resp.Diagnostics.AddError("UNSUPPORTED_OPERATION", "Updating an environment type is currently not supported")
var data *EnvironmentTypeModel

// Read Terraform plan data into the model
resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...)

if resp.Diagnostics.HasError() {
return
}

id := data.ID.ValueString()

httpResp, err := r.client.UpdateEnvironmentTypeWithResponse(ctx, r.orgId, id, client.UpdateEnvironmentTypeJSONRequestBody{
Description: data.Description.ValueStringPointer(),
})
if err != nil {
resp.Diagnostics.AddError(HUM_CLIENT_ERR, fmt.Sprintf("Unable to update environment type, got error: %s", err))
return
}

if httpResp.StatusCode() != 200 {
resp.Diagnostics.AddError(HUM_API_ERR, fmt.Sprintf("Unable to update environment type, unexpected status code: %d, body: %s", httpResp.StatusCode(), httpResp.Body))
return
}

parseEnvironmentTypeResponse(httpResp.JSON200, data)

// Save data into Terraform state
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}

func (r *ResourceEnvironmentType) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
Expand Down

0 comments on commit 6fb3bf7

Please sign in to comment.