-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
TriggerAuth-podIdentity.identityId - validation removed (operator) #5142
Changes from all commits
8091a30
4befa5f
357fd70
ecbd6a7
d7b49c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,15 +107,24 @@ func isTriggerAuthenticationRemovingFinalizer(om metav1.ObjectMeta, oldOm metav1 | |
} | ||
|
||
func validateSpec(spec *TriggerAuthenticationSpec) (admission.Warnings, error) { | ||
if spec.PodIdentity != nil { | ||
switch spec.PodIdentity.Provider { | ||
err := validatePodIdentityID(spec.PodIdentity) | ||
return nil, err | ||
} | ||
|
||
func validatePodIdentityID(podIdentity *AuthPodIdentity) error { | ||
if podIdentity != nil { | ||
switch podIdentity.Provider { | ||
case PodIdentityProviderAzure, PodIdentityProviderAzureWorkload: | ||
if spec.PodIdentity.IdentityID != nil && *spec.PodIdentity.IdentityID == "" { | ||
return nil, fmt.Errorf("identityid of PodIdentity should not be empty. If it's set, identityId has to be different than \"\"") | ||
if isEmptyString(podIdentity.IdentityID) { | ||
return fmt.Errorf("identityid of PodIdentity should not be empty. If it's set, identityId has to be different than \"\"") | ||
} | ||
default: | ||
return nil, nil | ||
return nil | ||
} | ||
} | ||
return nil, nil | ||
return nil | ||
} | ||
|
||
func isEmptyString(str *string) bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Util functions like this one have a high potential for code duplicity. Can you add a new file to func IsDefaultValue[T comparable](value *T) bool {
var def T
return value != nil && *value == def
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that this is a good feedback ❤️ |
||
return str != nil && *str == "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.