fix: clean template destination path for pull (#12559)

This commit is contained in:
Danny Kopping
2024-03-14 14:41:23 +02:00
committed by GitHub
parent 395bf54f4f
commit 14130deb07
2 changed files with 98 additions and 92 deletions

View File

@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"os"
"path/filepath"
"sort"
"github.com/codeclysm/extract/v3"
@ -130,6 +131,13 @@ func (r *RootCmd) templatePull() *clibase.Cmd {
dest = templateName
}
clean, err := filepath.Abs(filepath.Clean(dest))
if err != nil {
return xerrors.Errorf("cleaning destination path %s failed: %w", dest, err)
}
dest = clean
err = os.MkdirAll(dest, 0o750)
if err != nil {
return xerrors.Errorf("mkdirall %q: %w", dest, err)