Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Commit

Permalink
Strip trailing slashes when squashing images
Browse files Browse the repository at this point in the history
  • Loading branch information
iaguis committed Jan 28, 2015
1 parent a26d17d commit a379e3b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/docker2aci.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,10 @@ func reduceACIs(squashAcc *SquashAcc, currentPath string) (*SquashAcc, error) {
continue
}

if !in(squashAcc.Filelist, hdr.Name) {
squashAcc.Filelist = append(squashAcc.Filelist, hdr.Name)
sanitizedName := stripTrailingSlashes(hdr.Name)

if !in(squashAcc.Filelist, sanitizedName) {
squashAcc.Filelist = append(squashAcc.Filelist, sanitizedName)

if err := squashAcc.OutWriter.WriteHeader(hdr); err != nil {
return nil, fmt.Errorf("Error writing header: %v", err)
Expand All @@ -682,6 +684,14 @@ func reduceACIs(squashAcc *SquashAcc, currentPath string) (*SquashAcc, error) {
return squashAcc, nil
}

func stripTrailingSlashes(str string) string {
for len(str) > 0 && str[len(str)-1] == '/' {
str = str[0 : len(str)-1]
}

return str
}

func getFileInTar(fileName string, tarFile *os.File) (*tar.Header, *bytes.Buffer, error) {
defer func() {
tarFile.Seek(0, 0)
Expand Down

0 comments on commit a379e3b

Please sign in to comment.