From a11b0b5f4f4f91964a54555441e46c6d3608d63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bojanowski?= Date: Wed, 18 Sep 2024 17:20:32 +0200 Subject: [PATCH] add --ca-data flag to vcluster platform add cluster command to allow installing loft agent with additionalCA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Bojanowski --- cmd/vclusterctl/cmd/platform/add/cluster.go | 27 ++++++++++---------- cmd/vclusterctl/cmd/platform/add/vcluster.go | 2 -- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/cmd/vclusterctl/cmd/platform/add/cluster.go b/cmd/vclusterctl/cmd/platform/add/cluster.go index 0542e115c7..98788c424d 100644 --- a/cmd/vclusterctl/cmd/platform/add/cluster.go +++ b/cmd/vclusterctl/cmd/platform/add/cluster.go @@ -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 @@ -80,6 +81,7 @@ 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 } @@ -87,7 +89,6 @@ vcluster platform add cluster my-cluster 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) @@ -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 { diff --git a/cmd/vclusterctl/cmd/platform/add/vcluster.go b/cmd/vclusterctl/cmd/platform/add/vcluster.go index 7b11e348c5..d584ccb068 100644 --- a/cmd/vclusterctl/cmd/platform/add/vcluster.go +++ b/cmd/vclusterctl/cmd/platform/add/vcluster.go @@ -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