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

add --ca-data flag to vcluster platform add cluster command to allow … #2153

Merged
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
27 changes: 14 additions & 13 deletions cmd/vclusterctl/cmd/platform/add/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ import (
type ClusterCmd struct {
Log log.Logger
*flags.GlobalFlags
Namespace string
ServiceAccount string
DisplayName string
Context string
Insecure bool
Wait bool
HelmChartPath string
HelmChartVersion string
HelmSet []string
HelmValues []string
Namespace string
ServiceAccount string
DisplayName string
Context string
Insecure bool
Wait bool
HelmChartPath string
HelmChartVersion string
HelmSet []string
HelmValues []string
CertificateAuthorityData []byte
}

// NewClusterCmd creates a new command
Expand Down Expand Up @@ -80,14 +81,14 @@ vcluster platform add cluster my-cluster
c.Flags().StringArrayVar(&cmd.HelmSet, "helm-set", []string{}, "Extra helm values for the agent chart")
c.Flags().StringArrayVar(&cmd.HelmValues, "helm-values", []string{}, "Extra helm values for the agent chart")
c.Flags().StringVar(&cmd.Context, "context", "", "The kube context to use for installation")
c.Flags().BytesBase64Var(&cmd.CertificateAuthorityData, "ca-data", []byte{}, "additional, base64 encoded certificate authority data that will be passed to the platform secret")

return c
}

func (cmd *ClusterCmd) Run(ctx context.Context, args []string) error {
// Get clusterName from command argument
clusterName := args[0]

platformClient, err := platform.InitClientFromConfig(ctx, cmd.LoadedConfig(cmd.Log))
if err != nil {
return fmt.Errorf("new client from path: %w", err)
Expand Down Expand Up @@ -187,8 +188,8 @@ func (cmd *ClusterCmd) Run(ctx context.Context, args []string) error {
helmArgs = append(helmArgs, "--set", "insecureSkipVerify=true")
}

if accessKey.CaCert != "" {
helmArgs = append(helmArgs, "--set", "additionalCA="+accessKey.CaCert)
if len(cmd.CertificateAuthorityData) > 0 {
helmArgs = append(helmArgs, "--set", "additionalCA="+string(cmd.CertificateAuthorityData))
}

if cmd.Wait {
Expand Down
2 changes: 0 additions & 2 deletions cmd/vclusterctl/cmd/platform/add/vcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ vcluster platform add vcluster --project my-project --all
addCmd.Flags().StringVar(&cmd.Host, "host", "", "The host where to reach the platform")
addCmd.Flags().BoolVar(&cmd.Insecure, "insecure", false, "If the platform host is insecure")
addCmd.Flags().BytesBase64Var(&cmd.CertificateAuthorityData, "ca-data", []byte{}, "additional, base64 encoded certificate authority data that will be passed to the platform secret")
// This is hidden until the platform side will be ready to use it
_ = addCmd.Flags().MarkHidden("ca-data")
addCmd.Flags().BoolVar(&cmd.All, "all", false, "all will try to add Virtual Cluster found in all namespaces in the host cluster. If this flag is set, any provided vCluster name argument is ignored")

return addCmd
Expand Down
Loading