Skip to content

Commit

Permalink
add --ca-data flag to vcluster platform add cluster command to allow …
Browse files Browse the repository at this point in the history
…installing loft agent with additionalCA

Signed-off-by: Paweł Bojanowski <pawelbojanowski@protonmail.com>
  • Loading branch information
hidalgopl committed Sep 18, 2024
1 parent 6143e22 commit a11b0b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
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

0 comments on commit a11b0b5

Please sign in to comment.