Addition of resource and data source for tenant_policies_igmp_interface_policy (DCNE-278)#403
Addition of resource and data source for tenant_policies_igmp_interface_policy (DCNE-278)#403shrsr wants to merge 8 commits intoCiscoDevNet:masterfrom
Conversation
mso/utils.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func removePatchPayloadToContainer(payloadContainer *container.Container, op, path string) error { |
There was a problem hiding this comment.
why do you need a new function for this? cant you pass in nil to value in the addPatchPayloadToContainer function and check if value nil then change the payload to not include value?
There was a problem hiding this comment.
I actually think it's better to have a dedicated function for remove. If we want to have both add and remove functionality in the same function it would be best to update the name of addPatchPayloadToContainer to updatePatchPayloadToContainer or similar.
There was a problem hiding this comment.
I think the naming of add is not linked to the patch operation but the adding of a PATCH payload to the container. So whatever operation add/replace/remove the PATCH payload has could be handled by same function. If you think it is clearer this way should we then also add separate function for replace?
There was a problem hiding this comment.
True. It's not operation related..
| if d.HasChange("state_limit_route_map_uuid") { | ||
| uuid := d.Get("state_limit_route_map_uuid").(string) | ||
| if uuid != "" { | ||
| err := addPatchPayloadToContainer(payloadCont, "replace", fmt.Sprintf("%s/stateLimitRouteMapRef", updatePath), uuid) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| } else { | ||
| err := removePatchPayloadToContainer(payloadCont, "remove", fmt.Sprintf("%s/stateLimitRouteMapRef", updatePath)) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
does this work properly in older sdk version? i thought there was not a clear way to distinguish between not provided and empty string?
There was a problem hiding this comment.
Yes, it works well.
If not provided the ok in ok, val:=d.GetOk("some_string") won't have true and d.HasChange("some_string") won't be true either.
There was a problem hiding this comment.
Well it works that a change is detected on "" or commented out. However both delete the configuration, because we cannot differentiate between empty string or not provided configuration. So let me rephrase my question is it the intend that commenting out the config or providing null explicitly also leads to destroy operation to be invoked?
There was a problem hiding this comment.
yes, both removing/commenting the attribute and its value or providing "" will invoke the remove operation. I actually removed the redundant code in the latest change.
| } | ||
| } | ||
| } | ||
| log.Printf("HERE %v", payloadCont) |
| } | ||
|
|
||
| resource "mso_tenant_policies_route_map_policy_multicast" "state_limit" { | ||
| template_id = mso_template.template_tenant.id |
There was a problem hiding this comment.
| template_id = mso_template.template_tenant.id | |
| template_id = mso_template.tenant_template.id |
| # tenant policies igmp interface policy example | ||
|
|
||
| resource "mso_tenant_policies_igmp_interface_policy" "igmp_policy" { | ||
| template_id = mso_template.template_tenant.id |
There was a problem hiding this comment.
| template_id = mso_template.template_tenant.id | |
| template_id = mso_template.tenant_template.id |
| return err | ||
| } | ||
|
|
||
| d.SetId(fmt.Sprintf("templateId/%s/IGMPInterfacePolicy/%s", templateId, d.Get("name").(string))) |
There was a problem hiding this comment.
Is there a reason to capitalise IGMP on the setID when the list equivalent is igmpInterfacePolicies? What is the rule we follow for setting this?
There was a problem hiding this comment.
I don't remember why I went with capitalizing for the first resource (IPSLA) I created but this is the rule we've been following for all the the NDO TF Ids
| d.Set("report_link_local_groups", reportLinkLocal) | ||
| } | ||
|
|
||
| d.Set("igmp_version", models.StripQuotes(response.S("igmpQuerierVersion").String())) |
There was a problem hiding this comment.
why is there no response.Exists() for all of the attributes to be set? is this because some would always exist?
| enableV3Asm, _ := response.S("enableV3Asm").Data().(bool) | ||
| d.Set("version3_asm", enableV3Asm) |
There was a problem hiding this comment.
is bool casting not working directly?, what is the _ for, an error? Is there a case it can error?
There was a problem hiding this comment.
the _ should actually be 'ok' indicating whether the type assertion succeeded. However, we're using response.Exists() so it should be fine leaving it blank. I don't think we need it the assertion check because API always returns the same type unless they were to change true to enable at some point. I modified to include ok here.
lhercot
left a comment
There was a problem hiding this comment.
See issue in Go Release check: https://github.com/CiscoDevNet/terraform-provider-mso/actions/runs/20343107477/job/60651101226
Seems we need to reduce the test value to be under a int32
|
The build likely failed because Go Releaser was compiling for 32-bit systems (target=freebsd_386_sse2) where the maximum integer value is way less than what's specified in the upper limit (ValidateFunc: validation.IntBetween(1, 4294967295)) which is too large for this system to handle. |
…es_igmp_interface_policy
…s_igmp_interface_policy
…ons used in resource_mso_tenant_policies_igmp_interface_policy
…ies_igmp_interface_policy
…enant_policies_igmp_interface_policy
…_interface_policy
…nterface_policy to make type assertion checks
…se validateUint32Range()
No description provided.