Skip to content

Commit 090ce6b

Browse files
added cacert to .litmusconfig
Signed-off-by: Kartikay <[email protected]>
1 parent d304f7d commit 090ce6b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/cmd/root/root.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ func initConfig() {
110110
caCertPool := x509.NewCertPool()
111111
caCertPool.AppendCertsFromPEM(caCert)
112112
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{RootCAs: caCertPool}
113+
} else if config2.CACert == "" {
114+
configFilePath := utils.GetLitmusConfigPath(rootCmd)
115+
obj, err := config2.YamltoObject(configFilePath)
116+
cobra.CheckErr(err)
117+
caCertFile, err := os.ReadFile(obj.CACert)
118+
cobra.CheckErr(err)
119+
caCertPool := x509.NewCertPool()
120+
caCertPool.AppendCertsFromPEM(caCertFile)
121+
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{RootCAs: caCertPool}
113122
}
114123

115124
// If a config file is found, read it in.

pkg/types/config_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type LitmuCtlConfig struct {
3333
CurrentAccount string `yaml:"current-account" json:"current-account"`
3434
CurrentUser string `yaml:"current-user" json:"current-user"`
3535
Kind string `yaml:"kind" json:"kind"`
36+
CACert string `yaml:"cacert" json:"cacert"`
3637
}
3738

3839
type Current struct {

0 commit comments

Comments
 (0)