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

Not public (will remove this line once cl chain is submitted) #439

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,18 @@ type FakeChainLayer struct {
}

// New creates a new FakeChainLayer.
func New(testDir string, index int, diffID digest.Digest, command string, layer image.Layer, files map[string]string) (*FakeChainLayer, error) {
for name, contents := range files {
filename := filepath.Join(testDir, name)
file, err := os.Create(filename)
if err != nil {
return nil, err
func New(testDir string, index int, diffID digest.Digest, command string, layer image.Layer, files map[string]string, filesAlreadyExist bool) (*FakeChainLayer, error) {
if !filesAlreadyExist {
for name, contents := range files {
filename := filepath.Join(testDir, name)
if err := os.MkdirAll(filepath.Dir(filename), 0700); err != nil {
return nil, err
}

if err := os.WriteFile(filename, []byte(contents), 0600); err != nil {
return nil, err
}
}
file.WriteString(contents)
file.Close()
}
return &FakeChainLayer{
index: index,
Expand Down
2 changes: 1 addition & 1 deletion artifact/image/layerscanning/trace/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func setupFakeChainLayer(t *testing.T, testDir string, index int, diffID digest.
t.Helper()

layer := fakelayer.New(diffID, command)
chainLayer, err := fakechainlayer.New(testDir, index, diffID, command, layer, fileContents)
chainLayer, err := fakechainlayer.New(testDir, index, diffID, command, layer, fileContents, false)
if err != nil {
t.Fatalf("fakechainlayer.New(%d, %q, %q, %v, %v) failed: %v", index, diffID, command, layer, fileContents, err)
}
Expand Down