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

feature/compartment #413

Merged
merged 3 commits into from
Feb 20, 2024
Merged

feature/compartment #413

merged 3 commits into from
Feb 20, 2024

Conversation

sbhagate-infoblox
Copy link
Contributor

No description provided.

Copy link
Contributor

@drewwells drewwells left a comment

Choose a reason for hiding this comment

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

I like that the key is a string. Consumers can write their own getters. Let's get rid of the multivarient thing that account_id uses. The context key is var string = "compartment_id" no reason to support any other key.

auth/jwt.go Outdated
Comment on lines 40 to 43
multiCompartmentVariants = []string{
MultiCompartmentField,
"CompartmentID",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
multiCompartmentVariants = []string{
MultiCompartmentField,
"CompartmentID",
}

Let's not do this. You have defined the field name as compartment_id, there's no reason for it to then attempt to read CompartmentID. I have no idea why AccountID supports two variations, probably backwards compatibility to dead code

auth/jwt.go Outdated
Comment on lines 90 to 99
for _, compartmentField := range multiCompartmentVariants {
val, err = GetJWTField(ctx, compartmentField, keyfunc)
if err == nil {
return val, nil
}
}
if err == errMissingField {
return val, nil
}
return val, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for _, compartmentField := range multiCompartmentVariants {
val, err = GetJWTField(ctx, compartmentField, keyfunc)
if err == nil {
return val, nil
}
}
if err == errMissingField {
return val, nil
}
return val, err
return GetJWTField(ctx, compartmentField, keyfunc)

auth/jwt.go Outdated
Comment on lines 82 to 89
var val string
var err error
val, err = GetJWTField(ctx, MultiCompartmentField, keyfunc)
if err == nil || err == errMissingField {
return val, nil
} else {
return val, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This does the same thing. Guess I'm fine with ignoring missing compartment errors.

Suggested change
var val string
var err error
val, err = GetJWTField(ctx, MultiCompartmentField, keyfunc)
if err == nil || err == errMissingField {
return val, nil
} else {
return val, err
}
val, err := GetJWTField(ctx, MultiCompartmentField, keyfunc)
if err == errMissingField {
return "", nil
}
return val, err

@drewwells drewwells self-requested a review February 19, 2024 17:29
@kumaya kumaya enabled auto-merge (squash) February 20, 2024 10:36
@kumaya kumaya merged commit ad96515 into infobloxopen:master Feb 20, 2024
2 checks passed
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.

3 participants