From 0b9359b7fee4af97e3847640a4aa131e02e0ad44 Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Thu, 29 Aug 2019 15:37:11 -0700 Subject: [PATCH] Create directory for config file. Signed-off-by: Lantao Liu --- cmd/crictl/config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/crictl/config.go b/cmd/crictl/config.go index c91bc755d9..6fb45b9ed0 100644 --- a/cmd/crictl/config.go +++ b/cmd/crictl/config.go @@ -20,6 +20,7 @@ import ( "fmt" "io/ioutil" "os" + gofilepath "path/filepath" "strconv" "github.com/sirupsen/logrus" @@ -56,6 +57,9 @@ func writeConfig(c *Config, filepath string) error { if err != nil { return err } + if err := os.MkdirAll(gofilepath.Dir(filepath), 0755); err != nil { + return err + } return ioutil.WriteFile(filepath, data, 0644) }