Skip to content

Commit

Permalink
fix: Normalize file paths for images that contains a '/'
Browse files Browse the repository at this point in the history
  • Loading branch information
julienvey committed Mar 7, 2022
1 parent c508856 commit 294f5ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dib/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -140,7 +141,7 @@ func doRebuild(img *dag.Image, builder types.ImageBuilder, rateLimiter ratelimit
if err := os.MkdirAll("dist/logs", 0o755); err != nil {
return fmt.Errorf("could not create directory %s: %w", "dist/logs", err)
}
filePath := path.Join("dist/logs", fmt.Sprintf("%s.txt", img.ShortName))
filePath := path.Join("dist/logs", fmt.Sprintf("%s.txt", strings.ReplaceAll(img.ShortName, "/", "_")))
fileOutput, err := os.Create(filePath)
if err != nil {
return fmt.Errorf("failed to create file %s: %w", filePath, err)
Expand Down
3 changes: 2 additions & 1 deletion goss/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ func (b TestRunner) exportJunitReport(opts types.RunTestOptions, stdout string,
return fmt.Errorf("could not create directory %s: %w", testRunner.ReportsDirectory, err)
}

junitFilename := path.Join(testRunner.ReportsDirectory, fmt.Sprintf("junit-%s.xml", opts.ImageName))
junitFilename := path.Join(testRunner.ReportsDirectory,
fmt.Sprintf("junit-%s.xml", strings.ReplaceAll(opts.ImageName, "/", "_")))
if err := ioutil.WriteFile(junitFilename, []byte(stdout), 0o644); err != nil { // nolint: gosec
return fmt.Errorf("could not write junit report to file %s: %w", junitFilename, err)
}
Expand Down

0 comments on commit 294f5ef

Please sign in to comment.