diff --git a/internal/action/crds.go b/internal/action/crds.go index 883b9ded7..a2dc25825 100644 --- a/internal/action/crds.go +++ b/internal/action/crds.go @@ -24,6 +24,7 @@ import ( helmaction "helm.sh/helm/v3/pkg/action" helmchart "helm.sh/helm/v3/pkg/chart" + helmchartutil "helm.sh/helm/v3/pkg/chartutil" helmkube "helm.sh/helm/v3/pkg/kube" apiextension "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -64,7 +65,9 @@ func (*rootScoped) Name() apimeta.RESTScopeName { return apimeta.RESTScopeNameRoot } -func applyCRDs(cfg *helmaction.Configuration, policy v2.CRDsPolicy, chrt *helmchart.Chart, visitorFunc ...resource.VisitorFunc) error { +func applyCRDs(cfg *helmaction.Configuration, policy v2.CRDsPolicy, chrt *helmchart.Chart, + vals helmchartutil.Values, visitorFunc ...resource.VisitorFunc) error { + if len(chrt.CRDObjects()) == 0 { return nil } @@ -74,6 +77,10 @@ func applyCRDs(cfg *helmaction.Configuration, policy v2.CRDsPolicy, chrt *helmch return nil } + if err := helmchartutil.ProcessDependenciesWithMerge(chrt, vals); err != nil { + return fmt.Errorf("failed to process chart dependencies: %w", err) + } + // Collect all CRDs from all files in `crds` directory. allCRDs := make(helmkube.ResourceList, 0) for _, obj := range chrt.CRDObjects() { diff --git a/internal/action/install.go b/internal/action/install.go index da093c688..842c7ac09 100644 --- a/internal/action/install.go +++ b/internal/action/install.go @@ -55,7 +55,7 @@ func Install(ctx context.Context, config *helmaction.Configuration, obj *v2.Helm if err != nil { return nil, err } - if err := applyCRDs(config, policy, chrt, setOriginVisitor(v2.GroupVersion.Group, obj.Namespace, obj.Name)); err != nil { + if err := applyCRDs(config, policy, chrt, vals, setOriginVisitor(v2.GroupVersion.Group, obj.Namespace, obj.Name)); err != nil { return nil, fmt.Errorf("failed to apply CustomResourceDefinitions: %w", err) } diff --git a/internal/action/upgrade.go b/internal/action/upgrade.go index 079a1336a..db7f792fa 100644 --- a/internal/action/upgrade.go +++ b/internal/action/upgrade.go @@ -55,7 +55,7 @@ func Upgrade(ctx context.Context, config *helmaction.Configuration, obj *v2.Helm if err != nil { return nil, err } - if err := applyCRDs(config, policy, chrt, setOriginVisitor(v2.GroupVersion.Group, obj.Namespace, obj.Name)); err != nil { + if err := applyCRDs(config, policy, chrt, vals, setOriginVisitor(v2.GroupVersion.Group, obj.Namespace, obj.Name)); err != nil { return nil, fmt.Errorf("failed to apply CustomResourceDefinitions: %w", err) }