Skip to content

Commit

Permalink
chore: remove the cv check
Browse files Browse the repository at this point in the history
  • Loading branch information
ldming committed Jul 11, 2024
1 parent 00cad75 commit bc6522f
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions pkg/cmd/cluster/create_subcmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,10 @@ func (o *CreateSubCmdsOptions) complete(cmd *cobra.Command) error {
}

func (o *CreateSubCmdsOptions) validate() error {
if err := o.validateVersion(); err != nil {
return err
}
return cluster.ValidateValues(o.ChartInfo, o.Values)
}

func (o *CreateSubCmdsOptions) Run() error {

objs, err := o.getObjectsInfo()
if err != nil {
return err
Expand Down Expand Up @@ -240,44 +236,6 @@ func (o *CreateSubCmdsOptions) Run() error {
return nil
}

func (o *CreateSubCmdsOptions) validateVersion() error {
var err error
cv, ok := o.Values[cluster.VersionSchemaProp.String()].(string)
if ok && cv != "" {
if err = cluster.ValidateClusterVersion(o.Dynamic, o.ChartInfo.ClusterDef, cv); err == nil {
return nil
}
if err = cluster.ValidateClusterVersionByComponentDef(o.Dynamic, o.ChartInfo.ComponentDef, cv); err == nil {
return nil
}
return fmt.Errorf("cluster version \"%s\" does not exist", cv)
}
if o.ChartInfo.ClusterDef != "" {
cv, _ = cluster.GetDefaultVersion(o.Dynamic, o.ChartInfo.ClusterDef)
}
if len(o.ChartInfo.ComponentDef) != 0 {
cv, _ = cluster.GetDefaultVersionByCompDefs(o.Dynamic, o.ChartInfo.ComponentDef)
}
if cv == "" {
return fmt.Errorf(": failed to find default cluster version referencing cluster definition or component definition")
}

// set cluster version
o.Values[cluster.VersionSchemaProp.String()] = cv

dryRun, err := o.GetDryRunStrategy()
if err != nil {
return err
}
// if dryRun is set, run in quiet mode, avoid to output yaml file with the info
if dryRun != action.DryRunNone {
return nil
}

fmt.Fprintf(o.Out, "Info: --version is not specified, %s is applied by default.\n", cv)
return nil
}

// getObjectsInfo returns all objects in helm charts along with their GVK information.
func (o *CreateSubCmdsOptions) getObjectsInfo() ([]*objectInfo, error) {
// move values that belong to sub chart to sub map
Expand Down

0 comments on commit bc6522f

Please sign in to comment.