-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix generation of kustomization.yaml for macOS if absent
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
- Loading branch information
Sanskar Jaiswal
committed
Apr 21, 2022
1 parent
65d0fe9
commit b13ff9f
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package controllers | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
// CreateAbsTempDir creates a tmp dir and returns the absolute path to the dir. | ||
// This is required since macOS creates temporary files in | ||
// `/private/var` to which `/var` is a symlink to. | ||
func CreateAbsTempDir() (string, error) { | ||
// create tmp dir | ||
tmpDir, err := os.MkdirTemp("", "kustomization-") | ||
defer os.RemoveAll(tmpDir) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
tmpDir, err = filepath.EvalSymlinks(tmpDir) | ||
if err != nil { | ||
return "", fmt.Errorf("error evaluating symlink: %w", err) | ||
} | ||
return tmpDir, nil | ||
} |