Skip to content

Commit 29d03fe

Browse files
kylos101roboquat
authored andcommitted
[kubecdl] create $HOME/.kube if not exist
1 parent 598b537 commit 29d03fe

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

dev/kubecdl/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package main
77
import (
88
"bytes"
99
"encoding/json"
10+
"errors"
1011
"fmt"
1112
"io/ioutil"
1213
"os"
@@ -50,6 +51,14 @@ func main() {
5051
if err != nil {
5152
logrus.Fatal(err)
5253
}
54+
55+
if _, err := os.Stat(filepath.Join(home, ".kube")); errors.Is(err, os.ErrNotExist) {
56+
err := os.Mkdir(filepath.Join(home, ".kube"), os.ModePerm)
57+
if err != nil {
58+
logrus.Fatal(err)
59+
}
60+
}
61+
5362
kubecfgfn = filepath.Join(home, ".kube", "config")
5463
}
5564

0 commit comments

Comments
 (0)