Skip to content

Commit

Permalink
fix(chartmuseum) Add CACHE_URL environment variable only if cache sec…
Browse files Browse the repository at this point in the history
…ret is specifed

Signed-off-by: Pierre Péronnet <pierre.peronnet@ovhcloud.com>
  • Loading branch information
holyhope committed Mar 3, 2020
1 parent be30cbd commit ecd3f40
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions controllers/harbor/components/chartmuseum/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (c *ChartMuseum) GetDeployments(ctx context.Context) []*appsv1.Deployment {
Value: "/mnt/chartmuseum",
}}
envFroms := []corev1.EnvFromSource{}
initEnv := []corev1.EnvVar{}

if c.harbor.Spec.Components.ChartMuseum.StorageSecret != "" {
volumes = []corev1.Volume{}
Expand Down Expand Up @@ -86,6 +87,23 @@ func (c *ChartMuseum) GetDeployments(ctx context.Context) []*appsv1.Deployment {
}}
}

if c.harbor.Spec.Components.ChartMuseum.CacheSecret != "" {
initEnv = []corev1.EnvVar{
{
Name: "CACHE_URL",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: c.harbor.Spec.Components.ChartMuseum.CacheSecret,
},
Key: containerregistryv1alpha1.HarborChartMuseumCacheURLKey,
Optional: &varTrue,
},
},
},
}
}

return []*appsv1.Deployment{
{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -158,20 +176,7 @@ func (c *ChartMuseum) GetDeployments(ctx context.Context) []*appsv1.Deployment {
ReadOnly: false,
},
},
Env: []corev1.EnvVar{
{
Name: "CACHE_URL",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: c.harbor.Spec.Components.ChartMuseum.CacheSecret,
},
Key: containerregistryv1alpha1.HarborChartMuseumCacheURLKey,
Optional: &varTrue,
},
},
},
},
Env: initEnv,
},
},
Containers: []corev1.Container{
Expand Down

0 comments on commit ecd3f40

Please sign in to comment.