From f157f169c41ed92a2eba45f18053888a24428464 Mon Sep 17 00:00:00 2001 From: Dongming Date: Fri, 1 Nov 2024 15:44:27 +0800 Subject: [PATCH] chore: support to skip helm schema validattion (#481) (cherry picked from commit 2e2279f837e1f492940636ac05e180ad4ef712e0) --- pkg/cluster/cluster_chart.go | 3 +++ pkg/cmd/cluster/create_subcmds.go | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/cluster/cluster_chart.go b/pkg/cluster/cluster_chart.go index a0e73edf9..5e399f90f 100644 --- a/pkg/cluster/cluster_chart.go +++ b/pkg/cluster/cluster_chart.go @@ -130,6 +130,9 @@ func (c *ChartInfo) BuildClusterSchema() error { var err error cht := c.Chart buildSchema := func(bs []byte) (*spec.Schema, error) { + if len(bs) == 0 { + return nil, nil + } schema := &spec.Schema{} if err = json.Unmarshal(bs, schema); err != nil { return nil, errors.Wrapf(err, "failed to build schema for engine %s", cht.Name()) diff --git a/pkg/cmd/cluster/create_subcmds.go b/pkg/cmd/cluster/create_subcmds.go index 3fa49998e..c580248cb 100644 --- a/pkg/cmd/cluster/create_subcmds.go +++ b/pkg/cmd/cluster/create_subcmds.go @@ -53,14 +53,18 @@ type CreateSubCmdsOptions struct { // and validate the values. ChartInfo *cluster.ChartInfo + // SkipSchemaValidation is used to skip the schema validation of the helm chart. + SkipSchemaValidation bool `json:"-"` + *action.CreateOptions } func NewSubCmdsOptions(createOptions *action.CreateOptions, t cluster.ClusterType) (*CreateSubCmdsOptions, error) { var err error o := &CreateSubCmdsOptions{ - CreateOptions: createOptions, - ClusterType: t, + CreateOptions: createOptions, + ClusterType: t, + SkipSchemaValidation: false, } if o.ChartInfo, err = cluster.BuildChartInfo(t); err != nil { @@ -303,7 +307,7 @@ func (o *CreateSubCmdsOptions) getObjectsInfo() ([]*objectInfo, error) { } // get cluster manifests - manifests, err := cluster.GetManifests(o.ChartInfo.Chart, false, o.Namespace, o.Name, kubeVersion, values) + manifests, err := cluster.GetManifests(o.ChartInfo.Chart, o.SkipSchemaValidation, o.Namespace, o.Name, kubeVersion, values) if err != nil { return nil, err }