@@ -23,6 +23,7 @@ import (
2323 "strings"
2424 "time"
2525
26+ "github.com/go-logr/logr"
2627 "github.com/hashicorp/go-retryablehttp"
2728 "helm.sh/helm/v3/pkg/chart"
2829 "helm.sh/helm/v3/pkg/chartutil"
@@ -542,6 +543,10 @@ func (r *HelmReleaseReconciler) composeValues(ctx context.Context, hr v2.HelmRel
542543 return nil , fmt .Errorf ("could not find %s '%s'" , v .Kind , namespacedName )
543544 }
544545 if data , ok := resource .Data [v .GetValuesKey ()]; ! ok {
546+ if v .Optional {
547+ (logr .FromContext (ctx )).Info (fmt .Sprintf ("could not find optional key %s in %s '%s'" , v .GetValuesKey (), v .Kind , namespacedName ))
548+ continue
549+ }
545550 return nil , fmt .Errorf ("missing key '%s' in %s '%s'" , v .GetValuesKey (), v .Kind , namespacedName )
546551 } else {
547552 valuesData = []byte (data )
@@ -575,6 +580,10 @@ func (r *HelmReleaseReconciler) composeValues(ctx context.Context, hr v2.HelmRel
575580 return nil , fmt .Errorf ("could not find %s '%s'" , v .Kind , namespacedName )
576581 }
577582 if data , ok := resource .Data [v .GetValuesKey ()]; ! ok {
583+ if v .Optional {
584+ (logr .FromContext (ctx )).Info (fmt .Sprintf ("could not find optional key %s in %s '%s'" , v .GetValuesKey (), v .Kind , namespacedName ))
585+ continue
586+ }
578587 return nil , fmt .Errorf ("missing key '%s' in %s '%s'" , v .GetValuesKey (), v .Kind , namespacedName )
579588 } else {
580589 valuesData = data
0 commit comments