Skip to content

Commit

Permalink
chore: temporary dirs are created under PWD
Browse files Browse the repository at this point in the history
Git can be configured per directory using the includeIf statement in ~/.gitconfig.
This allows per-customer (if you have many clients for whom you work) ssh key.

Up to now, kustomize builds its yaml in /tmp/kustomize- prefixed directory.
Per say, no .gitconfig on that directory.

This patch instructs kustomize to use $PWD/kustomize- prefixed directory.
  • Loading branch information
david-barbion committed Dec 12, 2024
1 parent a8c5b10 commit a83988e
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions kyaml/filesys/confirmeddir.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type ConfirmedDir string
// The directory is cleaned, no symlinks, etc. so it's
// returned as a ConfirmedDir.
func NewTmpConfirmedDir() (ConfirmedDir, error) {
n, err := os.MkdirTemp("", "kustomize-")
currentDir, err := os.Getwd()
n, err := os.MkdirTemp(currentDir, ".kustomize-")
if err != nil {
return "", err
}
Expand All @@ -41,14 +42,14 @@ func NewTmpConfirmedDir() (ConfirmedDir, error) {
// HasPrefix emulates the semantics of strings.HasPrefix
// such that the following are true:
//
// strings.HasPrefix("foobar", "foobar")
// strings.HasPrefix("foobar", "foo")
// strings.HasPrefix("foobar", "")
// strings.HasPrefix("foobar", "foobar")
// strings.HasPrefix("foobar", "foo")
// strings.HasPrefix("foobar", "")
//
// d := fSys.ConfirmDir("/foo/bar")
// d.HasPrefix("/foo/bar")
// d.HasPrefix("/foo")
// d.HasPrefix("/")
// d := fSys.ConfirmDir("/foo/bar")
// d.HasPrefix("/foo/bar")
// d.HasPrefix("/foo")
// d.HasPrefix("/")
//
// Not contacting a file system here to check for
// actual path existence.
Expand All @@ -57,10 +58,11 @@ func NewTmpConfirmedDir() (ConfirmedDir, error) {
// on other operating systems.
// TODO(monopole) Refactor when #golang/go/18358 closes.
// See also:
// https://github.com/golang/go/issues/18358
// https://github.com/golang/dep/issues/296
// https://github.com/golang/dep/blob/master/internal/fs/fs.go#L33
// https://codereview.appspot.com/5712045
//
// https://github.com/golang/go/issues/18358
// https://github.com/golang/dep/issues/296
// https://github.com/golang/dep/blob/master/internal/fs/fs.go#L33
// https://codereview.appspot.com/5712045
func (d ConfirmedDir) HasPrefix(path ConfirmedDir) bool {
if path.String() == string(filepath.Separator) || path == d {
return true
Expand Down

0 comments on commit a83988e

Please sign in to comment.