Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor discern enhancements #319

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Changes from 1 commit
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
22 changes: 20 additions & 2 deletions discern/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
After cli.Action `short:"a" long:"after" required:"true" description:"'After' action hash"`
} `command:"diff" description:"Show differences between two actions"`
Show struct {
NoInputs bool `long:"no_inputs" description:"Don't list input files"`
Args struct {

Check failure on line 39 in discern/main.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofmt`-ed with `-s` (gofmt)
Actions []cli.Action `positional-arg-name:"action" required:"true" description:"Hashes of actions to display"`
} `positional-args:"true"`
} `command:"show" description:"Show detail about an action or series of them"`
Expand Down Expand Up @@ -212,8 +213,10 @@
command := &pb.Command{}
mustGetProto(client, a.ToProto(), action)
mustGetProto(client, action.CommandDigest, command)
log.Notice("Inputs:")
showDir(client, action.InputRootDigest, "")
if !opts.Show.NoInputs {
log.Notice("Inputs:")
showDir(client, action.InputRootDigest, "")
}
if ar, err := client.CheckActionCache(context.Background(), &pb.Digest{Hash: a.Hash, SizeBytes: int64(a.Size)}); err != nil {
log.Error("Error retrieving action result: %s", err)
} else if ar == nil {
Expand All @@ -222,6 +225,8 @@
log.Notice("Outputs:")
log.Notice("[%s/%08d] Action result", a.Hash, a.Size)
showActionResult(client, ar)
showOutput(client, ar, ar.StdoutDigest, "Standard output")
showOutput(client, ar, ar.StdoutDigest, "Standard error")
}
}
}
Expand Down Expand Up @@ -296,6 +301,19 @@
}
}

func showOutput(client *client.Client, ar *pb.ActionResult, dg *pb.Digest, name string) {
if dg == nil {
return
}
log.Notice("%s [%s/%08d]:", name, dg.Hash, dg.SizeBytes)
b, _, err := client.ReadBlob(context.Background(), digest.NewFromProtoUnvalidated(dg))
if err != nil {
log.Errorf("Failed to fetch blob: %s", err)
return
}
fmt.Println(string(b))
}

func topn() error {
actions, err := gc.Sizes(opts.Storage.Storage, opts.Storage.InstanceName, "", opts.Storage.TLS, opts.TopN.N)
if err != nil {
Expand Down
Loading