Skip to content

Commit

Permalink
Merge pull request #4 from po3rin/contain_fileop_case
Browse files Browse the repository at this point in the history
add fileOp case
  • Loading branch information
po3rin authored Jun 17, 2019
2 parents ab7e5e9 + 623cf8e commit 9112b21
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docker2dot/docker2dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,35 @@ func attr(dgst digest.Digest, op pb.Op) (string, string) {
return strings.Join(op.Exec.Meta.Args, " "), "box"
case *pb.Op_Build:
return "build", "box3d"
case *pb.Op_File:
txt := getCustomString(op.File.Actions)
if txt == "" {
// if no op.File.Actions, return CompactTextString as message.
return op.File.String(), "box"
}
return txt, "box"

default:
return dgst.String(), "plaintext"
}
}

func getCustomString(actions []*pb.FileAction) string {
// set custom messages from fileOp actions
// https://github.com/po3rin/dockerdot/issues/3
for _, v := range actions {
switch action := v.Action.(type) {
case *pb.FileAction_Copy:
return fmt.Sprintf("copy src='%v' dest='%v'", action.Copy.Src, action.Copy.Dest)
case *pb.FileAction_Mkfile:
return fmt.Sprintf("mkfile %+v", action.Mkfile.Path)
case *pb.FileAction_Mkdir:
return fmt.Sprintf("mkdir: %+v\n", action.Mkdir.Path)
case *pb.FileAction_Rm:
return fmt.Sprintf("rm: %+v\n", action.Rm.Path)
default:
return ""
}
}
return ""
}
Binary file modified main.wasm
Binary file not shown.

0 comments on commit 9112b21

Please sign in to comment.