Skip to content

Commit

Permalink
added cacert to .litmusconfig
Browse files Browse the repository at this point in the history
Signed-off-by: Kartikay <[email protected]>
  • Loading branch information
kartikaysaxena committed May 10, 2024
1 parent d304f7d commit 090ce6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ func initConfig() {
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{RootCAs: caCertPool}
} else if config2.CACert == "" {
configFilePath := utils.GetLitmusConfigPath(rootCmd)
obj, err := config2.YamltoObject(configFilePath)
cobra.CheckErr(err)
caCertFile, err := os.ReadFile(obj.CACert)
cobra.CheckErr(err)
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCertFile)
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{RootCAs: caCertPool}
}

// If a config file is found, read it in.
Expand Down
1 change: 1 addition & 0 deletions pkg/types/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type LitmuCtlConfig struct {
CurrentAccount string `yaml:"current-account" json:"current-account"`
CurrentUser string `yaml:"current-user" json:"current-user"`
Kind string `yaml:"kind" json:"kind"`
CACert string `yaml:"cacert" json:"cacert"`
}

type Current struct {
Expand Down

0 comments on commit 090ce6b

Please sign in to comment.