mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-13 05:40:42 +00:00
feat: switch config file to XDG conform location
The config file is now located in an folder according to the XDG specification (`XDG_CONFIG_HOME`). Migration is performed automatically. This fixes #235. Signed-off-by: Patrick Pichler <git@patrickpichler.dev>
This commit is contained in:
committed by
Patrick Pichler
parent
51b1b352ac
commit
dee435514d
@@ -3,8 +3,10 @@ package util
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"regexp"
|
||||
|
||||
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
|
||||
@@ -150,3 +152,23 @@ func GetPodListByLabels(client k.Interface,
|
||||
|
||||
return pods, nil
|
||||
}
|
||||
|
||||
func FileExists(path string) (bool, error) {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return true, nil
|
||||
} else if errors.Is(err, os.ErrNotExist) {
|
||||
return false, nil
|
||||
} else {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
|
||||
func EnsureDirExists(dir string) error {
|
||||
err := os.Mkdir(dir, 0755)
|
||||
|
||||
if errors.Is(err, os.ErrExist) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user