update observability module
This commit is contained in:
@@ -15,9 +15,10 @@ type Host struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
WorkDir string
|
||||
Verbose bool
|
||||
Credentials struct {
|
||||
WorkDir string
|
||||
KubeconfigFile string `yaml:"kubeconfig_file" env-default:"k8s-admin.conf"`
|
||||
Verbose bool
|
||||
Credentials struct {
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
AskSudoPassword bool `yaml:"ask_sudo_password"`
|
||||
|
||||
48
internal/config/helm.go
Normal file
48
internal/config/helm.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
helm_client "github.com/mittwald/go-helm-client"
|
||||
)
|
||||
|
||||
var client *helm_client.Client
|
||||
|
||||
func CreateHelmClient() helm_client.Client {
|
||||
config := GetConfig()
|
||||
file, err := os.Open(filepath.Join(config.WorkDir, config.KubeconfigFile))
|
||||
if err != nil {
|
||||
log.Fatalf("failed to open file: %s", err)
|
||||
}
|
||||
defer file.Close()
|
||||
kubeconfig, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to read file: %s", err)
|
||||
}
|
||||
opts := &helm_client.KubeConfClientOptions{
|
||||
Options: &helm_client.Options{
|
||||
Namespace: "default", // Change this to the namespace you wish to install the chart in.
|
||||
RepositoryCache: "/tmp/.helmcache",
|
||||
RepositoryConfig: "/tmp/.helmrepo",
|
||||
Debug: true,
|
||||
Linting: true, // Change this to false if you don't want linting.
|
||||
DebugLog: func(format string, v ...interface{}) {
|
||||
// Change this to your own logger. Default is 'log.Printf(format, v...)'.
|
||||
},
|
||||
},
|
||||
KubeContext: "",
|
||||
KubeConfig: kubeconfig,
|
||||
}
|
||||
client, err := helm_client.NewClientFromKubeConf(opts)
|
||||
if err != nil {
|
||||
log.Fatalf("error while creating helm client: %s", err)
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
func GetHelmClient() *helm_client.Client {
|
||||
return client
|
||||
}
|
||||
@@ -11,7 +11,7 @@ var kubernetesConfig *rest.Config
|
||||
|
||||
func GetKubernetesConfig() *rest.Config {
|
||||
appConfig := GetConfig()
|
||||
kubeconfigPath := filepath.Join(appConfig.WorkDir, "k8s-admin.conf")
|
||||
kubeconfigPath := filepath.Join(appConfig.WorkDir, appConfig.KubeconfigFile)
|
||||
|
||||
kubernetesConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user