Skip to content

Commit

Permalink
fix: Allow for empty S3 SecretKeyRef
Browse files Browse the repository at this point in the history
Signed-off-by: David Griffiths <dave.griffiths@sainsburys.co.uk>
  • Loading branch information
davidg-sainsbury authored and bitsf committed Mar 6, 2022
1 parent dfe1852 commit 325e405
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions controllers/goharbor/registry/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,19 @@ func (r *Reconciler) ApplyFilesystemStorageEnvs(ctx context.Context, registry *g
func (r *Reconciler) ApplyS3StorageEnvs(ctx context.Context, registry *goharborv1.Registry, deploy *appsv1.Deployment) error {
regContainer := &deploy.Spec.Template.Spec.Containers[registryContainerIndex]

regContainer.Env = append(regContainer.Env, corev1.EnvVar{
Name: "REGISTRY_STORAGE_S3_SECRETKEY",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
Key: harbormetav1.SharedSecretKey,
LocalObjectReference: corev1.LocalObjectReference{
Name: registry.Spec.Storage.Driver.S3.SecretKeyRef,
if registry.Spec.Storage.Driver.S3.SecretKeyRef != "" {
regContainer.Env = append(regContainer.Env, corev1.EnvVar{
Name: "REGISTRY_STORAGE_S3_SECRETKEY",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
Key: harbormetav1.SharedSecretKey,
LocalObjectReference: corev1.LocalObjectReference{
Name: registry.Spec.Storage.Driver.S3.SecretKeyRef,
},
},
},
},
})
})
}

return nil
}
Expand Down

0 comments on commit 325e405

Please sign in to comment.