From 164bc4b99652b0b1c2d88d4b86d5dd5ac650684d Mon Sep 17 00:00:00 2001 From: Jonathan Chappelow Date: Tue, 7 Nov 2023 13:29:27 -0600 Subject: [PATCH] kwil-admin: make parent .kwil-admin director if needed --- cmd/kwil-admin/node.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/kwil-admin/node.go b/cmd/kwil-admin/node.go index fc1ce0e71..79f9c57ce 100644 --- a/cmd/kwil-admin/node.go +++ b/cmd/kwil-admin/node.go @@ -51,6 +51,9 @@ func (ngkc *NodeGenAuthKeyCmd) run(ctx context.Context, a *args) error { if fileExists(clientKeyFile) { return fmt.Errorf("key file exists: %v", clientKeyFile) } + if err := os.MkdirAll(filepath.Dir(clientKeyFile), 0755); err != nil { + return fmt.Errorf("failed to create key file dir: %v", err) + } clientCertFile := a.Node.ClientTLSCertFile if !filepath.IsAbs(clientCertFile) { @@ -59,6 +62,9 @@ func (ngkc *NodeGenAuthKeyCmd) run(ctx context.Context, a *args) error { if fileExists(clientCertFile) { return fmt.Errorf("cert file exists: %v", clientCertFile) } + if err := os.MkdirAll(filepath.Dir(clientCertFile), 0755); err != nil { + return fmt.Errorf("failed to create key file dir: %v", err) + } return transport.GenTLSKeyPair(clientCertFile, clientKeyFile, "kwild CA", nil) }