Skip to content

Commit

Permalink
Update tests and confirm what filepath.Join does for us
Browse files Browse the repository at this point in the history
  • Loading branch information
Racer159 committed Nov 4, 2023
1 parent 9426b94 commit 814043e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/pkg/oci/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ var (

// FileDescriptorExists returns true if the given file exists in the given directory with the expected SHA.
func (o *OrasRemote) FileDescriptorExists(desc ocispec.Descriptor, destinationDir string) bool {
// Convert from the standard '/' to the OS path separator for Windows support
rel := desc.Annotations[ocispec.AnnotationTitle] // filepath.FromSlash(desc.Annotations[ocispec.AnnotationTitle])
rel := desc.Annotations[ocispec.AnnotationTitle]
destinationPath := filepath.Join(destinationDir, rel)

info, err := os.Stat(destinationPath)
Expand Down Expand Up @@ -256,8 +255,7 @@ func (o *OrasRemote) PullLayer(desc ocispec.Descriptor, destinationDir string) e
return err
}

// Convert from the standard '/' to the OS path separator for Windows support
rel := desc.Annotations[ocispec.AnnotationTitle] // filepath.FromSlash(desc.Annotations[ocispec.AnnotationTitle])
rel := desc.Annotations[ocispec.AnnotationTitle]

return utils.WriteFile(filepath.Join(destinationDir, rel), b)
}
Expand Down
4 changes: 1 addition & 3 deletions src/pkg/packager/sources/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ func ValidatePackageIntegrity(loaded *layout.PackagePaths, aggregateChecksum str
err = lineByLine(checksumPath, func(line string) error {
split := strings.Split(line, " ")
sha := split[0]

// Convert from the standard '/' to the OS path separator for Windows support
rel := split[1] // filepath.FromSlash(split[1])
rel := split[1]

if sha == "" || rel == "" {
return fmt.Errorf("invalid checksum line: %s", line)
Expand Down
2 changes: 2 additions & 0 deletions src/test/e2e/11_oci_pull_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func (suite *PullInspectTestSuite) Test_0_Pull() {
stdOut, stdErr, err := e2e.Zarf("package", "pull", ref)
suite.NoError(err, stdOut, stdErr)
suite.Contains(stdErr, fmt.Sprintf("Pulling %q", ref))
suite.Contains(stdErr, "Validating pulled layer checksums")
suite.NotContains(stdErr, "Package signature validated!")

sbomTmp := suite.T().TempDir()

Expand Down

0 comments on commit 814043e

Please sign in to comment.