-
Notifications
You must be signed in to change notification settings - Fork 180
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
chore: Implements tags
and labels
as MapAttribute in advanced_cluster
schema v2
#2996
Conversation
tags
and labels
as MapAttribute in advanced_cluster
schema v2
value := block["value"] | ||
checks = append(checks, | ||
acc.TestCheckResourceAttrSchemaV2(isAcc, resourceName, key, value), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @EspenAlbert for the tips for checking maps
elms := make(map[string]string) | ||
if input != nil { | ||
for _, item := range *input { | ||
key := conversion.SafeValue(item.Key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we are not using item.GetKey()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks changed here: f24f8dc
Value: types.StringValue(item.Value), | ||
func NewTagsObjType(ctx context.Context, diags *diag.Diagnostics, input *[]admin.ResourceTag) types.Map { | ||
elms := make(map[string]string) | ||
if input != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice refactor!
@@ -113,25 +115,26 @@ func resolveZoneNameOrUseDefault(item *TFReplicationSpecsModel) string { | |||
return *zoneName | |||
} | |||
|
|||
func newResourceTag(ctx context.Context, input types.Set, diags *diag.Diagnostics) *[]admin.ResourceTag { | |||
func newResourceTag(ctx context.Context, diags *diag.Diagnostics, input types.Map) *[]admin.ResourceTag { | |||
if input.IsUnknown() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input.IsUnknown()
can be removed now that it is optional
only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks changed here: f24f8dc
@@ -94,6 +94,11 @@ func setStateResponse(ctx context.Context, diags *diag.Diagnostics, stateIn *tfp | |||
return | |||
} | |||
setOptionalModelAttrs(ctx, stateObj, model) | |||
|
|||
// Set tags and labels to null instead of empty so there is no plan change if there are no tags or labels when Read is called. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you had to learn this the hard way? If you do nothing they are set to empty map? {}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha ha, exactly
if mapIn.IsNull() { | ||
*mapOut = types.MapNull(types.StringType) | ||
} else { | ||
*mapOut = types.MapValueMust(types.StringType, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice usage of Must
tags = { | ||
"Key Tag 1" = "Value Tag 1" | ||
"Key Tag 2" = "Value Tag 2" | ||
tag = "tagvalue" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool how it only uses "
when necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, i love it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor comments. But looks good!
* master: chore: Adds cipher config & default_max_time_ms to advanced_cluster_tpf (#2972)
overrideMapStringWithPrevStateValue(&modelIn.Labels, &modelOut.Labels) | ||
overrideMapStringWithPrevStateValue(&modelIn.Tags, &modelOut.Tags) | ||
} | ||
func overrideMapStringWithPrevStateValue(mapIn, mapOut *types.Map) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see for cases of the empty lists/map we sometimes go for setting nil directly (example) or in cases like this one support defining the empty map in the config. I would assess what is the drawback UX wise if we dont have this logic to avoid relying on previous state is not ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed offline
…uster` schema v2 (#2996) * schema change * model change * create TF models * create Admin models * labels & tags conversion * TEMPORARY skip mocked tests * handle null vs [] * Revert "TEMPORARY skip mocked tests" This reverts commit 3653edc. * temporary don't test check label and tags * improve update and override * fix plan changes in state upgrade * test checks for labels and tags * apply feedback
* master: chore: Adds nil check before retrieving httpResponse data from API calls (#3015) chore: Run advanced_cluster_tpf tests group only on workflow dispatch (#3016) test: Adds a case for finding `DISK_SIZE_GB_INCONSISTENT` error from API and update TPF implementation in advanced_cluster (#3014) chore: Bump github.com/hashicorp/terraform-exec from 0.21.0 to 0.22.0 (#3007) chore: Bump github.com/hashicorp/terraform-plugin-framework-timeouts (#3009) chore: Bump github.com/evanphx/json-patch/v5 from 5.9.0 to 5.9.11 (#3010) chore: Bump github.com/zclconf/go-cty from 1.16.1 to 1.16.2 (#3011) chore: Uses always new schema when moving from cluster (#3004) chore: Implements `tags` and `labels` as MapAttribute in `advanced_cluster` schema v2 (#2996)
Description
Implements
tags
andlabels
as MapAttribute inadvanced_cluster
schema v2.Link to any related issue(s): CLOUDP-295198
Type of change:
Required Checklist:
Further comments