update observability module

This commit is contained in:
2024-06-02 21:34:03 +03:00
parent 4e302c4e8b
commit 3109816dee
10 changed files with 524 additions and 81 deletions

48
internal/config/helm.go Normal file
View 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
}