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

Idiomatic resource naming for asoctl #4487

Merged
merged 11 commits into from
Dec 11, 2024

Conversation

theunrepentantgeek
Copy link
Member

What this PR does

Within a Kubernetes Cluster, resources need to have unique names only within resources of that type - the GroupKind of the resource is part of the uniqueness key.

This allows us to change asoctl to simply reuse the last part of the ARM ID for each resource as the name in most cases.

To disambiguate when multiple resources have the same "name" and collide, we add a unique random suffix as required. In testing, this happened rarely.

Closes #4349

How does this PR make you feel?

gif

Checklist

  • this PR contains tests

@theunrepentantgeek theunrepentantgeek force-pushed the feature/idiomatic-asoctl-naming branch from b289c8e to 5dc5f4e Compare December 10, 2024 21:20
Copy link
Collaborator

@super-harsh super-harsh left a comment

Choose a reason for hiding this comment

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

LGTM! Just left a few minor comments.

@@ -442,9 +445,10 @@ func (i *importableARMResource) getStatus(
ctx context.Context,
armID string,
importable genruntime.ImportableARMResource,
factory *importFactory,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can pass just the scheme here rather than the whole struct?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have plans to tidy this further in the future, adding new methods to the factory that simplify this code further.

)

// importFactory is a helper struct that's used to create things.
type importFactory struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ImportHelper sounds like a better name to me

Copy link
Member Author

Choose a reason for hiding this comment

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

I try to avoid names like Helper and Manager as they become dumping grounds for too much.

I used factory as it's used for making things, but I'm open to a better suggestion.

@theunrepentantgeek theunrepentantgeek added this pull request to the merge queue Dec 11, 2024
Merged via the queue into main with commit 9fa97ef Dec 11, 2024
7 checks passed
@theunrepentantgeek theunrepentantgeek deleted the feature/idiomatic-asoctl-naming branch December 11, 2024 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Recently Completed
Development

Successfully merging this pull request may close these issues.

Improve naming generated by asoctl
2 participants