Skip to content
Merged
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
8 changes: 1 addition & 7 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ jobs:
- name: Build Static
run: make ociv
- name: upload binary
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ociv
path: ociv
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lint Go Code
run: make lint
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ GOLINTER_VERSION := v1.54.2
GOLINTER := $(TOOLSDIR)/bin/golangci-lint


ociv: *.go lint
ociv: *.go
go env
CGO_ENABLED=0 go build ${LDFLAGS} ${GOTAGS} -o ociv ./...

$(GOLINTER):
Expand Down
28 changes: 19 additions & 9 deletions ociutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,26 @@ func (lr layerRef) summary(filter string) string {
return cachedSummary
}

filterArg := ""
if filter != "" {
filterArg = " | grep " + filter
fileListFilename := fmt.Sprintf("/tmp/%s-filelist", lr.hash)
if _, err := os.Stat(fileListFilename); os.IsNotExist(err) {
cmdstr := "tar tzvf " + lr.blobfilepath
if strings.Contains(lr.mediaType, "squashfs") {
cmdstr = "unsquashfs -llc " + lr.blobfilepath
}
cmd := exec.Command("sh", "-c", cmdstr+" > "+fileListFilename)
err := cmd.Run()
if err != nil {
log.Printf("error: %v", err)
return fmt.Sprintf(" error: %v", err)
}
}

cmdstr := "tar tzvf " + lr.blobfilepath + filterArg
if strings.Contains(lr.mediaType, "squashfs") {
cmdstr = "echo TODO: gunzip -c " + lr.blobfilepath + " |unsquashfs -llc "
//TODO: can't unsquash via pipe, need to gunzip to tempfile and delete
filterArg := "cat "
if filter != "" {
filterArg = " grep " + filter
}
cmd := exec.Command("sh", "-c", cmdstr)
cmd := exec.Command("sh", "-c", filterArg+" "+fileListFilename)

var out strings.Builder
var stderr strings.Builder
cmd.Stdout = &out
Expand All @@ -157,7 +166,8 @@ func (lr layerRef) summary(filter string) string {
if err != nil {
log.Printf("error: %v", err)
}
summaryString := fmt.Sprintf("%q\n%q\n%s\n%s", lr.displayString, cmdstr, out.String(), stderr.String())

summaryString := fmt.Sprintf("file listing of blob %q (%s)\n\n%s\n%s", lr.displayString, lr.mediaType, out.String(), stderr.String())
LayerSummaryCache[layerfilterkey] = summaryString
return summaryString
}
Expand Down