Skip to content

Commit

Permalink
fix operator deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Alero Awani <aleroawani18@gmail.com>
  • Loading branch information
Alero-Awani committed Dec 12, 2024
1 parent 023b146 commit 12f4b50
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion utils/kubernetes/apply-helm-chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,42 @@ func createHelmActionConfig(c *Client, cfg ApplyHelmChartConfig) (*action.Config
}
cafilename := cafile.Name()

// Create temp files for client cert and key if they exist
var certfile, keyfile *os.File
var certfilename, keyfilename string

if len(c.RestConfig.TLSClientConfig.CertData) > 0 {
certfile, err = setDataAndReturnFileHandler(c.RestConfig.TLSClientConfig.CertData)
if err != nil {
return nil, err
}
certfilename = certfile.Name()
}

if len(c.RestConfig.TLSClientConfig.KeyData) > 0 {
keyfile, err = setDataAndReturnFileHandler(c.RestConfig.TLSClientConfig.KeyData)
if err != nil {
return nil, err
}
keyfilename = keyfile.Name()
}

kubeConfig := genericclioptions.NewConfigFlags(false)
kubeConfig.APIServer = &c.RestConfig.Host
kubeConfig.CAFile = &cafilename
kubeConfig.BearerToken = &c.RestConfig.BearerToken

// Set client cert and key if they exist
if certfilename != "" {
kubeConfig.CertFile = &certfilename
}
if keyfilename != "" {
kubeConfig.KeyFile = &keyfilename
}

// Only set bearer token if client certs aren't being used
if certfilename == "" && len(c.RestConfig.BearerToken) > 0 {
kubeConfig.BearerToken = &c.RestConfig.BearerToken
}

actionConfig := new(action.Configuration)
if err := actionConfig.Init(kubeConfig, cfg.Namespace, string(cfg.HelmDriver), cfg.Logger); err != nil {
Expand Down

0 comments on commit 12f4b50

Please sign in to comment.