Skip to content

Commit

Permalink
Update crane append to accept flags, not args (google#203)
Browse files Browse the repository at this point in the history
- mark required flags in append and rebase
- regenerate docs without "Auto generated" section
  • Loading branch information
imjasonh authored Jun 5, 2018
1 parent ecb2d03 commit ef804b1
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ script:
- go build -a -v -race ./...

# Verify that generated crane docs are up-to-date.
- mkdir -p /tmp/gendoc && go run cmd/crane/help/main.go --dir /tmp/gendoc && diff -I "###### Auto generated" -Naur /tmp/gendoc/ cmd/crane/doc/
- mkdir -p /tmp/gendoc && go run cmd/crane/help/main.go --dir /tmp/gendoc && diff -Naur /tmp/gendoc/ cmd/crane/doc/
1 change: 0 additions & 1 deletion cmd/crane/doc/crane.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions cmd/crane/doc/crane_append.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cmd/crane/doc/crane_config.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cmd/crane/doc/crane_copy.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cmd/crane/doc/crane_delete.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cmd/crane/doc/crane_digest.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cmd/crane/doc/crane_ls.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cmd/crane/doc/crane_manifest.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cmd/crane/doc/crane_pull.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cmd/crane/doc/crane_push.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion cmd/crane/doc/crane_rebase.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions pkg/crane/append.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,23 @@ import (
func init() { Root.AddCommand(NewCmdAppend()) }

func NewCmdAppend() *cobra.Command {
var output string
var baseRef, newTag, newLayer, outFile string
appendCmd := &cobra.Command{
Use: "append",
Short: "Append contents of a tarball to a remote image",
Args: cobra.ExactArgs(3),
Args: cobra.NoArgs,
Run: func(_ *cobra.Command, args []string) {
src, dst, tar := args[0], args[1], args[2]
doAppend(src, dst, tar, output)
doAppend(baseRef, newTag, newLayer, outFile)
},
}
appendCmd.Flags().StringVarP(&output, "output", "o", "", "Path to new tarball of resulting image")
appendCmd.Flags().StringVarP(&baseRef, "base", "b", "", "Name of base image to append to")
appendCmd.Flags().StringVarP(&newTag, "new_tag", "t", "", "Tag to apply to resulting image")
appendCmd.Flags().StringVarP(&newLayer, "new_layer", "f", "", "Path to tarball to append to image")
appendCmd.Flags().StringVarP(&outFile, "output", "o", "", "Path to new tarball of resulting image")

appendCmd.MarkFlagRequired("base")
appendCmd.MarkFlagRequired("new_tag")
appendCmd.MarkFlagRequired("new_layer")
return appendCmd
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/crane/rebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func NewCmdRebase() *cobra.Command {
rebaseCmd.Flags().StringVarP(&oldBase, "old_base", "", "", "Old base image to remove")
rebaseCmd.Flags().StringVarP(&newBase, "new_base", "", "", "New base image to insert")
rebaseCmd.Flags().StringVarP(&rebased, "rebased", "", "", "Tag to apply to rebased image")

rebaseCmd.MarkFlagRequired("original")
rebaseCmd.MarkFlagRequired("old_base")
rebaseCmd.MarkFlagRequired("new_base")
rebaseCmd.MarkFlagRequired("rebased")
return rebaseCmd
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/crane/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ package crane
import "github.com/spf13/cobra"

var Root = &cobra.Command{
Use: "crane",
Short: "Crane is a tool for managing container images",
Run: func(cmd *cobra.Command, _ []string) { cmd.Usage() },
Use: "crane",
Short: "Crane is a tool for managing container images",
Run: func(cmd *cobra.Command, _ []string) { cmd.Usage() },
DisableAutoGenTag: true,
}

0 comments on commit ef804b1

Please sign in to comment.