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 15, 2024
1 parent d304f7d commit 033a400
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ func initConfig() {
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(caCert)
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{RootCAs: caCertPool}
} else {
configFilePath := utils.GetLitmusConfigPath(rootCmd)
obj, err := config2.YamltoObject(configFilePath)
cobra.CheckErr(err)
// Check if CACert file string is present in the config file
if obj.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 033a400

Please sign in to comment.