-
Notifications
You must be signed in to change notification settings - Fork 32
Addition of resource and data source for tenant_policies_igmp_interface_policy (DCNE-278) #403
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
base: master
Are you sure you want to change the base?
Conversation
mso/utils.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func removePatchPayloadToContainer(payloadContainer *container.Container, op, path string) error { |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
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.
delete log
| } | ||
|
|
||
| resource "mso_tenant_policies_route_map_policy_multicast" "state_limit" { | ||
| template_id = mso_template.template_tenant.id |
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.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| template_id = mso_template.template_tenant.id | |
| template_id = mso_template.tenant_template.id |
samiib
left a comment
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.
LGTM
akinross
left a comment
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.
LGTM
gmicol
left a comment
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.
LGTM
…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
| return err | ||
| } | ||
|
|
||
| d.SetId(fmt.Sprintf("templateId/%s/IGMPInterfacePolicy/%s", templateId, d.Get("name").(string))) |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is there no response.Exists() for all of the attributes to be set? is this because some would always exist?
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 missed it here
| enableV3Asm, _ := response.S("enableV3Asm").Data().(bool) | ||
| d.Set("version3_asm", enableV3Asm) |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
…nterface_policy to make type assertion checks
akinross
left a comment
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.
LGTM
No description provided.