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

fix #2835 address comments #3171

Merged
merged 1 commit into from
Apr 8, 2022
Merged

Conversation

johnpoth
Copy link
Member

@johnpoth johnpoth commented Apr 5, 2022

Addresses comments by @astefanutti in #2835

Thanks !

Release Note

NONE

@@ -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 {
Copy link
Member

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.

Copy link
Member Author

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 ?

https://go.dev/tour/moretypes/12#:~:text=The%20zero%20value%20of%20a,and%20has%20no%20underlying%20array.

I just wrote it to be bullet proof but I am happy to remove it if you think it's unnecessary ?

Thanks !

Copy link
Member Author

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!

Copy link
Member Author

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 {
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

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 {
Copy link
Member

Choose a reason for hiding this comment

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

same here

@johnpoth johnpoth merged commit dcd7e34 into apache:main Apr 8, 2022
@johnpoth johnpoth deleted the local-dependencies-2 branch April 8, 2022 11:48
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