Skip to content
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

New Resource: azurerm_extended_location_custom_location #24267

Merged
merged 35 commits into from
Aug 13, 2024

Conversation

jiaweitao001
Copy link
Contributor

  • All related tests passed.

},

"authentication": {
Type: pluginsdk.TypeList,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we improve the validation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Will contact service team's POC for requirements of this authentication.

Copy link
Member

Choose a reason for hiding this comment

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

Similarly here, do we have validation information / acceptable values for the docs from the Service Team?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

value now has a validation func, service team did not provide any info about type.

cluster_extension_ids = [
"${azurerm_arc_kubernetes_cluster_extension.test.id}"
]
display_name = "customlocation%[2]d"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need to specify display_name in the basic config, because it's optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove.

),
},
data.ImportStep(),
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add one more step to test whether the resource could be able to update to the basic config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

Copy link
Member

Choose a reason for hiding this comment

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

This looks to have been missed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not possible to update to basic from update in this case, because once display_name is set here, it cannot be removed.

data.ImportStep(),
})
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add one more testcase to test whether we could deploy the complete config directly instead of updating it from the basic config? And consider updating the config name from "update" to "complete"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix.

resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
cluster_extension_ids = [
"${azurerm_arc_kubernetes_cluster_extension.test.id}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we remove the "${}", please also update other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

resource_group_name = azurerm_resource_group.example.name
location = "West Europe"
cluster_extension_ids = [
"${azurerm_arc_kubernetes_cluster_extension.test.id}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be "azurerm_arc_kubernetes_cluster_extension.example.id"?

Copy link
Contributor

@ms-henglu ms-henglu left a comment

Choose a reason for hiding this comment

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

Thanks for this PR!
I have left some additional mostly minor comments but overall LGTM!

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Thanks @jiaweitao001 - Just a couple more items (I think some code went missing in the rebase?) and I think this is good to go. Testing is looking good at this stage, so if you can check the comments I think we can get this merged.

state.Namespace = pointer.From(props.Namespace)
}

if props.Authentication != nil && props.Authentication.Type != nil && props.Authentication.Value != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This feels like a bug, if the property is optional in the spec and all of it's properties are null, this should be null too? Can you open an issue on the spec to track and add a comment here?

d := metadata.ResourceData

if d.HasChanges("authentication") {
if len(state.Authentication) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

We seem to have lost this change to remove the auth when empty as part of the rebase?

Properties: pointer.To(customLocationProps),
}

if _, err := client.Update(ctx, *id, props); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

The number of properties doesn't really matter, it's the behaviour of the API and compatibility with Terraform's expectations. So, if we have one or more properties that are allowed to be removed entirely, such as authentication, we need to know how to unset those. If sending a nil for a value doesn't remove/unset it (as per the HTTP spec, this should be a no-op) we need to send the appropriate value to remove it.

To the point of Update vs CreateOrUpdate, the "location is required" error will not happen if we use a Get to retrieve the existing data, then simply update that with any user changes before sending it back, rather than using the Patch only method?

Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Thanks @jiaweitao001 - I think this looks good to go now, thanks for the changes and the persistence 👍

@jackofallops
Copy link
Member

Tests passing:

image

@jackofallops jackofallops merged commit 19ad4f1 into hashicorp:main Aug 13, 2024
37 checks passed
@github-actions github-actions bot added this to the v3.116.0 milestone Aug 13, 2024
jackofallops added a commit that referenced this pull request Aug 13, 2024
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants