Skip to content

Commit

Permalink
Merge pull request #255 from thaJeztah/fix_lint
Browse files Browse the repository at this point in the history
Makefile: make "lint" target also lint cmd/continuity module and fix linting issues
  • Loading branch information
AkihiroSuda authored Oct 30, 2024
2 parents 0e83ada + 4c00ab7 commit 163414b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ generate:
lint:
@echo "+ $@"
@golangci-lint run
@(cd cmd/continuity && golangci-lint --config=../../.golangci.yml run)

build:
@echo "+ $@"
Expand Down
23 changes: 18 additions & 5 deletions cmd/continuity/commands/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import (
"fmt"
"log"
"os"
"strconv"
"text/tabwriter"

"github.com/containerd/continuity/proto"
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"
)
Expand All @@ -42,17 +44,28 @@ var LSCmd = &cobra.Command{
w := tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0)

for _, entry := range bm.Resource {
user, group := getUserGroup(entry)
for _, path := range entry.Path {
if os.FileMode(entry.Mode)&os.ModeSymlink != 0 {
//nolint:unconvert
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v -> %v\n", os.FileMode(entry.Mode), entry.User, entry.Group, humanize.Bytes(uint64(entry.Size)), path, entry.Target)
_, _ = fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v -> %v\n", os.FileMode(entry.Mode), user, group, humanize.Bytes(uint64(entry.Size)), path, entry.Target) //nolint:unconvert
} else {
//nolint:unconvert
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n", os.FileMode(entry.Mode), entry.User, entry.Group, humanize.Bytes(uint64(entry.Size)), path)
_, _ = fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n", os.FileMode(entry.Mode), user, group, humanize.Bytes(uint64(entry.Size)), path) //nolint:unconvert
}
}
}

w.Flush()
_ = w.Flush()
},
}

func getUserGroup(entry *proto.Resource) (user, group string) {
user = entry.User //nolint:staticcheck // ignore SA1019: entry.User is deprecated.
if user == "" {
user = strconv.FormatInt(entry.Uid, 10)
}
group = entry.Group //nolint:staticcheck // ignore SA1019: entry.Group is deprecated.
if group == "" {
group = strconv.FormatInt(entry.Gid, 10)
}
return user, group
}
2 changes: 1 addition & 1 deletion cmd/continuity/continuityfs/fuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ type direnter interface {
func (d *Dir) Lookup(ctx context.Context, name string) (fs.Node, error) {
node, ok := d.nodes[name]
if !ok {
return nil, fuse.ENOENT
return nil, syscall.ENOENT
}
return node, nil
}
Expand Down

0 comments on commit 163414b

Please sign in to comment.