Skip to content

Conversation

@shrsr
Copy link
Collaborator

@shrsr shrsr commented Nov 27, 2025

No description provided.

@shrsr shrsr self-assigned this Nov 27, 2025
@github-actions github-actions bot changed the title Addition of resource and data source for tenant_policies_igmp_interface_policy Addition of resource and data source for tenant_policies_igmp_interface_policy (DCNE-278) Nov 27, 2025
mso/utils.go Outdated
return nil
}

func removePatchPayloadToContainer(payloadContainer *container.Container, op, path string) error {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator Author

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..

Comment on lines 511 to 524
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
}
}
}
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

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?

Copy link
Collaborator Author

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete log

@shrsr shrsr requested a review from akinross December 3, 2025 17:57
}

resource "mso_tenant_policies_route_map_policy_multicast" "state_limit" {
template_id = mso_template.template_tenant.id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template_id = mso_template.template_tenant.id
template_id = mso_template.tenant_template.id

@shrsr shrsr requested a review from akinross December 4, 2025 16:39
samiib
samiib previously approved these changes Dec 5, 2025
Copy link
Collaborator

@samiib samiib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

akinross
akinross previously approved these changes Dec 10, 2025
Copy link
Collaborator

@akinross akinross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

gmicol
gmicol previously approved these changes Dec 10, 2025
Copy link
Collaborator

@gmicol gmicol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shrsr shrsr requested review from akinross, gmicol and samiib December 16, 2025 03:29
return err
}

d.SetId(fmt.Sprintf("templateId/%s/IGMPInterfacePolicy/%s", templateId, d.Get("name").(string)))
Copy link
Collaborator

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?

Copy link
Collaborator Author

@shrsr shrsr Dec 18, 2025

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()))
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed it here

Comment on lines 179 to 180
enableV3Asm, _ := response.S("enableV3Asm").Data().(bool)
d.Set("version3_asm", enableV3Asm)
Copy link
Collaborator

@akinross akinross Dec 18, 2025

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?

Copy link
Collaborator Author

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
@shrsr shrsr requested a review from akinross December 18, 2025 16:05
Copy link
Collaborator

@akinross akinross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a resource and data source for "IGMP Interface Policy" object under Tenant Policies (DCNE-278)

4 participants