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

chore: rename activate flag to add and move to helm flags #1881

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pkg/cli/add_vcluster_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ func AddVClusterHelm(
}
}

log.Donef("Successfully activated vCluster %s/%s", vCluster.Namespace, vCluster.Name)
log.Donef("Successfully added vCluster %s/%s", vCluster.Namespace, vCluster.Name)
return nil
}
10 changes: 5 additions & 5 deletions pkg/cli/create_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type CreateOptions struct {
CreateNamespace bool
UpdateCurrent bool
BackgroundProxy bool
Add bool
CreateContext bool
SwitchContext bool
Expose bool
Expand All @@ -68,7 +69,6 @@ type CreateOptions struct {
Upgrade bool

// Platform
Activate bool
Project string
Cluster string
Template string
Expand Down Expand Up @@ -276,8 +276,8 @@ func CreateHelm(ctx context.Context, options *CreateOptions, globalFlags *flags.
}

// create platform secret
if cmd.Activate {
err = cmd.activateVCluster(ctx, vClusterConfig)
if cmd.Add {
err = cmd.addVCluster(ctx, vClusterConfig)
if err != nil {
return err
}
Expand Down Expand Up @@ -339,15 +339,15 @@ func (cmd *createHelm) parseVClusterYAML(chartValues string) (*config.Config, er
return vClusterConfig, nil
}

func (cmd *createHelm) activateVCluster(ctx context.Context, vClusterConfig *config.Config) error {
func (cmd *createHelm) addVCluster(ctx context.Context, vClusterConfig *config.Config) error {
if vClusterConfig.Platform.API.AccessKey != "" || vClusterConfig.Platform.API.SecretRef.Name != "" {
return nil
}

_, err := platform.InitClientFromConfig(ctx, cmd.LoadedConfig(cmd.log))
if err != nil {
if vClusterConfig.IsProFeatureEnabled() {
return fmt.Errorf("you have vCluster pro features activated, but seems like you are not logged in (%w). Please make sure to log into vCluster Platform to use vCluster pro features or run this command with --activate=false", err)
return fmt.Errorf("you have vCluster pro features enabled, but seems like you are not logged in (%w). Please make sure to log into vCluster Platform to use vCluster pro features or run this command with --add=false", err)
}

cmd.log.Debugf("create platform client: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/flags/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func AddHelmFlags(cmd *cobra.Command, options *cli.CreateOptions) {
cmd.Flags().StringVar(&options.LocalChartDir, "local-chart-dir", "", "The virtual cluster local chart dir to use")
cmd.Flags().BoolVar(&options.ExposeLocal, "expose-local", true, "If true and a local Kubernetes distro is detected, will deploy vcluster with a NodePort service. Will be set to false and the passed value will be ignored if --expose is set to true.")
cmd.Flags().BoolVar(&options.BackgroundProxy, "background-proxy", true, "Try to use a background-proxy to access the vCluster. Only works if docker is installed and reachable")
cmd.Flags().BoolVar(&options.Add, "add", true, "Adds the virtual cluster automatically to the current vCluster platform when using helm driver")

_ = cmd.Flags().MarkHidden("local-chart-dir")
_ = cmd.Flags().MarkHidden("expose-local")
Expand All @@ -44,7 +45,6 @@ func AddHelmFlags(cmd *cobra.Command, options *cli.CreateOptions) {
func AddPlatformFlags(cmd *cobra.Command, options *cli.CreateOptions, prefixes ...string) {
prefix := strings.Join(prefixes, "")

cmd.Flags().BoolVar(&options.Activate, "activate", true, fmt.Sprintf("%sActivate the vCluster automatically when using helm driver", prefix))
cmd.Flags().StringVar(&options.Project, "project", "", fmt.Sprintf("%sThe vCluster platform project to use", prefix))
cmd.Flags().StringSliceVarP(&options.Labels, "labels", "l", []string{}, fmt.Sprintf("%sComma separated labels to apply to the virtualclusterinstance", prefix))
cmd.Flags().StringSliceVar(&options.Annotations, "annotations", []string{}, fmt.Sprintf("%sComma separated annotations to apply to the virtualclusterinstance", prefix))
Expand Down
Loading