mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
@@ -26,7 +26,7 @@ import (
|
|||||||
// that was confirmed to point to an existing directory.
|
// that was confirmed to point to an existing directory.
|
||||||
type ConfirmedDir string
|
type ConfirmedDir string
|
||||||
|
|
||||||
// Return a temporary dir, else error.
|
// NewTmpConfirmedDir returns a temporary dir, else error.
|
||||||
// The directory is cleaned, no symlinks, etc. so its
|
// The directory is cleaned, no symlinks, etc. so its
|
||||||
// returned as a ConfirmedDir.
|
// returned as a ConfirmedDir.
|
||||||
func NewTmpConfirmedDir() (ConfirmedDir, error) {
|
func NewTmpConfirmedDir() (ConfirmedDir, error) {
|
||||||
@@ -34,7 +34,15 @@ func NewTmpConfirmedDir() (ConfirmedDir, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
return ConfirmedDir(n), nil
|
|
||||||
|
// In MacOs `ioutil.TempDir` creates a directory
|
||||||
|
// with root in the `/var` folder, which is in turn a symlinked path
|
||||||
|
// to `/private/var`.
|
||||||
|
// Function `filepath.EvalSymlinks`is used to
|
||||||
|
// resolve the real absolute path.
|
||||||
|
deLinked, err := filepath.EvalSymlinks(n)
|
||||||
|
return ConfirmedDir(deLinked), err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasPrefix returns true if the directory argument
|
// HasPrefix returns true if the directory argument
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package fs
|
package fs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -101,3 +102,18 @@ func TestHasPrefix_SlashFooBar(t *testing.T) {
|
|||||||
t.Fatalf("/foo/bar should have prefix /")
|
t.Fatalf("/foo/bar should have prefix /")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewTempConfirmDir(t *testing.T) {
|
||||||
|
tmp, err := NewTmpConfirmedDir()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
delinked, err := filepath.EvalSymlinks(string(tmp))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
if string(tmp) != delinked {
|
||||||
|
t.Fatalf("unexpected path containing symlinks")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,7 +27,11 @@ import (
|
|||||||
|
|
||||||
func makeTestDir(t *testing.T) (FileSystem, string) {
|
func makeTestDir(t *testing.T) (FileSystem, string) {
|
||||||
x := MakeRealFS()
|
x := MakeRealFS()
|
||||||
testDir, err := ioutil.TempDir("", "kustomize_testing_dir")
|
td, err := ioutil.TempDir("", "kustomize_testing_dir")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("unexpected error %s", err)
|
||||||
|
}
|
||||||
|
testDir, err := filepath.EvalSymlinks(td)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error %s", err)
|
t.Fatalf("unexpected error %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user