-
Notifications
You must be signed in to change notification settings - Fork 347
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
fix #2835 address comments #3171
Conversation
6111511
to
36ec1d0
Compare
@@ -91,6 +94,16 @@ func generateJavaKeystore(ctx *builderContext) error { | |||
return jvm.GenerateKeystore(ctx.C, ctx.Path, ctx.Maven.TrustStoreName, ctx.Maven.TrustStorePass, certsData) | |||
} | |||
|
|||
func mergeSecrets(secrets []corev1.SecretKeySelector, secret *corev1.SecretKeySelector) []corev1.SecretKeySelector { | |||
if secrets == nil && secret == nil { |
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.
Is this check necessary? secrets == nil
I think it's always safe to assume a slice is not nil in Go.
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.
Hi @tadayosi ! Thanks for reviewing!
I didn't know a slice cannot be nil in Go ?
I just wrote it to be bullet proof but I am happy to remove it if you think it's unnecessary ?
Thanks !
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.
After running it debug mode it seems that ctx.Build.Maven.CASecrets
does get set to nil so the check is necessary ? Thanks!
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.
Let me merge this for now and we can reiterate later
|
||
if e.Platform.Status.Build.Maven.CASecret != nil { | ||
certsData, err := kubernetes.GetSecretsRefData(e.Ctx, e.Client, e.Platform.Namespace, e.Platform.Status.Build.Maven.CASecret) | ||
if secrets != nil { |
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.
same here
@@ -348,6 +350,16 @@ func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.Dat | |||
return nil | |||
} | |||
|
|||
func mergeSecrets(secrets []corev1.SecretKeySelector, secret *corev1.SecretKeySelector) []corev1.SecretKeySelector { | |||
if secrets == nil && secret == nil { |
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.
same here
caCerts, err = kubernetes.GetSecretsRefData(ctx, client, namespace, mvn.CASecret) | ||
// nolint: staticcheck | ||
secrets := mergeSecrets(mvn.CASecrets, mvn.CASecret) | ||
if secrets != nil { |
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.
same here
@@ -104,6 +107,16 @@ func GenerateCatalog( | |||
return GenerateCatalogCommon(ctx, globalSettings, []byte(userSettings), caCerts, mvn, runtime, providerDependencies) | |||
} | |||
|
|||
func mergeSecrets(secrets []corev1.SecretKeySelector, secret *corev1.SecretKeySelector) []corev1.SecretKeySelector { | |||
if secrets == nil && secret == nil { |
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.
same here
36ec1d0
to
08ed9ed
Compare
08ed9ed
to
eed9837
Compare
Addresses comments by @astefanutti in #2835
Thanks !
Release Note