Skip to content

Commit

Permalink
Merge pull request #2159 from hidalgopl/backport-set-additional-ca-in…
Browse files Browse the repository at this point in the history
…-platform-add-cluster

[Backport-to-v0.20 set additional ca in platform add cluster
  • Loading branch information
FabianKramm authored Sep 19, 2024
2 parents e23e0b9 + e837a08 commit 2e1dff9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 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 @@ -203,8 +204,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
3 changes: 0 additions & 3 deletions cmd/vclusterctl/cmd/platform/add/vcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ vcluster platform add vcluster my-vcluster --namespace vcluster-my-vcluster --pr
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")

return addCmd
}

Expand Down

0 comments on commit 2e1dff9

Please sign in to comment.