diff options
Diffstat (limited to 'src/k8splugin/internal/utils.go')
-rw-r--r-- | src/k8splugin/internal/utils.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/k8splugin/internal/utils.go b/src/k8splugin/internal/utils.go index 627fb305..47a236c2 100644 --- a/src/k8splugin/internal/utils.go +++ b/src/k8splugin/internal/utils.go @@ -18,6 +18,7 @@ import ( "log" "os" "path/filepath" + "path" "plugin" "strings" @@ -128,3 +129,14 @@ func CheckInitialSettings() error { return nil } + +//EnsureDirectory makes sure that the directories specified in the path exist +//If not, it will create them, if possible. +func EnsureDirectory(f string) error { + base := path.Dir(f) + _, err := os.Stat(base) + if err != nil && !os.IsNotExist(err) { + return err + } + return os.MkdirAll(base, 0755) +} |