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

refactor: simplify GetSubnet function #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dkoshkin
Copy link
Contributor

@dkoshkin dkoshkin commented Dec 5, 2024

What problem does this PR solve?:
LMK if I'm missing something but I didn't see why this function couldn't resemble

func (n *clusterClient) GetCluster(cluster string) (*Cluster, error) {
clusterUUID, err := uuid.Parse(cluster)
if err == nil {
return n.getClusterByExtID(clusterUUID)
}
return n.getClusterByName(cluster)
}

Which issue(s) this PR fixes:
Fixes #

How Has This Been Tested?:

Special notes for your reviewer:

@dkoshkin dkoshkin requested a review from jimmidyson December 5, 2024 23:14
@dkoshkin dkoshkin force-pushed the dkoshkin/refactor-GetSubnet branch from ce1cc7f to 0989cd0 Compare December 5, 2024 23:14
@jimmidyson
Copy link
Member

The logic here is due to the fact that a subnet name itself could actually be a uuid so we need to check first if it's the extID and then if no match there then check if there is one with that name.

We should actually update the get cluster logic to match this existing get subnet logic rather than the other way around.

@dkoshkin
Copy link
Contributor Author

dkoshkin commented Dec 10, 2024

The logic here is due to the fact that a subnet name itself could actually be a uuid so we need to check first if it's the extID and then if no match there then check if there is one with that name.

IIUC you're saying thats this is handling the case where the user given name of the Subnet is a UUID but that name doesn't match the UUID of the external ID? Then it falls back to to finding the Subnet by name, a UUID in this case.

@jimmidyson
Copy link
Member

@dkoshkin

IIUC you're saying thats this is handling the case where the user given name of the Subnet is a UUID but that name doesn't match the UUID of the external ID? Then it falls back to to finding the Subnet by name, a UUID in this case.

Correct - although this may sound odd, @thunderboltsid convinced me to support this in previous discussions.

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.

2 participants