Skip to content

Commit

Permalink
Fix generation of kustomization.yaml for macOS if absent
Browse files Browse the repository at this point in the history
Signed-off-by: Sanskar Jaiswal <[email protected]>
  • Loading branch information
Sanskar Jaiswal committed Apr 21, 2022
1 parent 65d0fe9 commit 7524f2d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -301,6 +302,7 @@ func (r *KustomizationReconciler) reconcile(

// create tmp dir
tmpDir, err := os.MkdirTemp("", "kustomization-")
defer os.RemoveAll(tmpDir)
if err != nil {
err = fmt.Errorf("tmp dir error: %w", err)
return kustomizev1.KustomizationNotReady(
Expand All @@ -310,7 +312,19 @@ func (r *KustomizationReconciler) reconcile(
err.Error(),
), err
}
defer os.RemoveAll(tmpDir)

// resolve the absolute path, since macOS creates temporary files in
// `/private/var` to which `/var` is a symlink to.
tmpDir, err = filepath.EvalSymlinks(tmpDir)
if err != nil {
err = fmt.Errorf("error evaluating symlink: %w", err)
return kustomizev1.KustomizationNotReady(
kustomization,
revision,
sourcev1.DirCreationFailedReason,
err.Error(),
), err
}

// download artifact and extract files
err = r.download(source.GetArtifact(), tmpDir)
Expand Down

0 comments on commit 7524f2d

Please sign in to comment.