Skip to content

Commit

Permalink
Fix the index of boundary error for metadata field (#10417)
Browse files Browse the repository at this point in the history
  • Loading branch information
zli82016 authored Apr 11, 2024
1 parent ffaae41 commit 5e2e040
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion mmv1/third_party/terraform/tpgresource/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func SetMetadataAnnotationsDiff(_ context.Context, d *schema.ResourceDiff, meta
// "effective_annotations" cannot be set directly due to a bug that SetNew doesn't work on nested fields
// in terraform sdk.
// https://github.com/hashicorp/terraform-plugin-sdk/issues/459
if !d.GetRawPlan().GetAttr("metadata").AsValueSlice()[0].GetAttr("annotations").IsWhollyKnown() {
values := d.GetRawPlan().GetAttr("metadata").AsValueSlice()
if len(values) > 0 && !values[0].GetAttr("annotations").IsWhollyKnown() {
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion mmv1/third_party/terraform/tpgresource/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ func SetMetadataLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta inter
// "terraform_labels" and "effective_labels" cannot be set directly due to a bug that SetNew doesn't work on nested fields
// in terraform sdk.
// https://github.com/hashicorp/terraform-plugin-sdk/issues/459
if !d.GetRawPlan().GetAttr("metadata").AsValueSlice()[0].GetAttr("labels").IsWhollyKnown() {
values := d.GetRawPlan().GetAttr("metadata").AsValueSlice()
if len(values) > 0 && !values[0].GetAttr("labels").IsWhollyKnown() {
return nil
}

Expand Down

0 comments on commit 5e2e040

Please sign in to comment.