Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pull/246'
Browse files Browse the repository at this point in the history
* origin/pull/246:
  fix: Create dest directory when importing keys
  • Loading branch information
Foxboron committed Sep 26, 2023
2 parents 4d40e79 + 4883d37 commit 6cc8bd1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/sbctl/import-keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ var (

func Import(src, dst string) error {
logging.Print("Importing %s...", src)
if err := os.MkdirAll(filepath.Dir(dst), 0777); err != nil {
logging.NotOk("")
return fmt.Errorf("could not create directory for %q: %w", dst, err)
}
if err := sbctl.CopyFile(src, dst); err != nil {
logging.NotOk("")
return fmt.Errorf("could not move %s: %w", src, err)
Expand Down Expand Up @@ -117,7 +121,7 @@ func RunImportKeys(cmd *cobra.Command, args []string) error {
return fmt.Errorf("invalid private key file")
}
}

for src, dst := range map[string]string{
key.Cert: path.Join(sbctl.KeysPath, key.Type, key.Type+".pem"),
key.Key: path.Join(sbctl.KeysPath, key.Type, key.Type+".key"),
Expand Down

0 comments on commit 6cc8bd1

Please sign in to comment.