Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cli created cluster with wrong sa name #3500

Merged
merged 1 commit into from
May 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions internal/cli/cmd/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,6 @@ func (o *CreateOptions) Validate() error {
return fmt.Errorf("does not support --set and --set-file being specified at the same time")
}

// if name is not specified, generate a random cluster name
if o.Name == "" {
name, err := generateClusterName(o.Dynamic, o.Namespace)
if err != nil {
return err
}
if name == "" {
return fmt.Errorf("failed to generate a random cluster name")
}
o.Name = name
}
if len(o.Name) > 16 {
return fmt.Errorf("cluster name should be less than 16 characters")
}
Expand All @@ -331,6 +320,7 @@ func (o *CreateOptions) Complete() error {
clusterCompSpecs []appsv1alpha1.ClusterComponentSpec
err error
)

if len(o.SetFile) > 0 {
if compByte, err = MultipleSourceComponents(o.SetFile, o.IOStreams.In); err != nil {
return err
Expand All @@ -349,6 +339,18 @@ func (o *CreateOptions) Complete() error {
}
}

// if name is not specified, generate a random cluster name
if o.Name == "" {
name, err := generateClusterName(o.Dynamic, o.Namespace)
if err != nil {
return err
}
if name == "" {
return fmt.Errorf("failed to generate a random cluster name")
}
o.Name = name
}

// build annotation
o.buildAnnotation(cls)

Expand Down