Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for manifest with symlink #2256

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/pkg/utils/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ func CreatePathAndCopy(source string, destination string) error {
}

// Copy all the source data into the destination location
if err := copy.Copy(source, destination); err != nil {
if err := copy.Copy(source, destination, copy.Options{
OnSymlink: func(_ string) copy.SymlinkAction {
return copy.Deep
},
}); err != nil {
Racer159 marked this conversation as resolved.
Show resolved Hide resolved
return err
}

Expand Down Expand Up @@ -470,7 +474,7 @@ func CreateReproducibleTarballFromDir(dirPath, dirPrefix, tarballPath string) er
}

// If it's a file, write its content
if !info.IsDir() {
if info.Mode().IsRegular() {
file, err := os.Open(filePath)
if err != nil {
return fmt.Errorf("error opening file: %w", err)
Expand Down
28 changes: 28 additions & 0 deletions src/test/e2e/34_manifest_with_symlink_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2021-Present The Zarf Authors

// Package test provides e2e tests for Zarf.
package test

import (
"fmt"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
)

func TestManifestWithSymlink(t *testing.T) {
t.Log("E2E: Manifest With Symlink")
tmpdir := t.TempDir()
cachePath := filepath.Join(tmpdir, ".cache-location")

// Build the package, should succeed, even though there is a symlink in the package.
buildPath := filepath.Join("src", "test", "packages", "34-manifest-with-symlink")
stdOut, stdErr, err := e2e.Zarf("package", "create", buildPath, "--zarf-cache", cachePath, "-o=build", "--confirm")
require.NoError(t, err, stdOut, stdErr)

path := fmt.Sprintf("build/zarf-package-manifest-with-symlink-%s-0.0.1.tar.zst", e2e.Arch)
require.FileExists(t, path)
defer e2e.CleanFiles(path)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
14 changes: 14 additions & 0 deletions src/test/packages/34-manifest-with-symlink/zarf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: ZarfPackageConfig
metadata:
name: manifest-with-symlink
description: Example with a symbolic link embedded in it
version: 0.0.1

components:
- name: manifest-with-symlink
required: true
manifests:
- name: manifest-with-symlink
namespace: manifest-symlink
files:
- manifests
Loading