Skip to content

Commit

Permalink
Fix file permission issue while doing untar of cache archive.
Browse files Browse the repository at this point in the history
Remove Entry Point as it is not required.

Fix Unit Test so it runs on machines where /root directory is not present.

update audience in GCS WIF Pipelinerun
  • Loading branch information
pramodbindal committed Oct 16, 2024
1 parent ff4d602 commit 86fb45f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dev/pr/gcs-wif-pipelinerun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
projected:
sources:
- serviceAccountToken:
audience: https://iam.googleapis.com/projects/272779626560/locations/global/workloadIdentityPools/openshift-pool/providers/opeshift-wif
audience: openshift
expirationSeconds: 3600
path: token

5 changes: 3 additions & 2 deletions internal/provider/oci/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ func TestFetchInvalidFolder(t *testing.T) {
err = crane.Push(img, fmt.Sprintf("%s/test/crane:%s", u.Host, hash))
assert.NoError(t, err, "Failed to push image to registry")

folder := "/root"
folder := "/tmp/readonly-dir-for-unit-testing"
_ = os.MkdirAll(folder, 0o555)
defer os.RemoveAll(folder)
insecure := false

err = Fetch(context.Background(), hash, target, folder, insecure)

assert.Error(t, err, "Fetch should return an error when folder is not writable")
assert.Contains(t, err.Error(), "permission denied", "Error should indicate permission issues for the folder")
}
Expand Down
4 changes: 4 additions & 0 deletions internal/tar/file-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func Tarit(source, target string) error {
return err
}

if info.IsDir() {
header.Mode = 0o755 // create directories with same permissions.
}
header.Name = strings.TrimPrefix(path, source)

if err := tarball.WriteHeader(header); err != nil {
Expand Down Expand Up @@ -70,6 +73,7 @@ func Tarit(source, target string) error {
}

func Untar(ctx context.Context, file *os.File, target string) error {
log.Printf("Untaring file %s to %s", file.Name(), target)
f, err := os.Open(file.Name())
if err != nil {
return err
Expand Down

0 comments on commit 86fb45f

Please sign in to comment.