Skip to content

Commit

Permalink
Merge pull request #241 from depot/push-multiple-tags
Browse files Browse the repository at this point in the history
Support pushing multiple tags with `depot push`
  • Loading branch information
jacobwgillespie authored Jan 16, 2024
2 parents 9c61445 + 3dbce89 commit 6bd3f2c
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions pkg/cmd/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewCmdPush(dockerCli command.Cli) *cobra.Command {
projectID string
buildID string
progressFmt string
tag string
tags []string
)

cmd := &cobra.Command{
Expand Down Expand Up @@ -66,19 +66,30 @@ func NewCmdPush(dockerCli command.Cli) *cobra.Command {
}
}

finishPush, err := StartPush(ctx, buildID, tag, token)
if err != nil {
return err
if len(tags) == 0 {
return fmt.Errorf("missing tag, please specify a tag with --tag")
}
err = Push(ctx, progressFmt, buildID, tag, token, dockerCli)
return finishPush(err)

for _, tag := range tags {
finishPush, err := StartPush(ctx, buildID, tag, token)
if err != nil {
return err
}
err = Push(ctx, progressFmt, buildID, tag, token, dockerCli)
err = finishPush(err)
if err != nil {
return err
}
}

return nil
},
}

cmd.Flags().StringVar(&projectID, "project", "", "Depot project ID")
cmd.Flags().StringVar(&token, "token", "", "Depot token")
cmd.Flags().StringVar(&progressFmt, "progress", "auto", `Set type of progress output ("auto", "plain", "tty", "quiet")`)
cmd.Flags().StringVarP(&tag, "tag", "t", "", "Tag for the pushed image")
cmd.Flags().StringArrayVarP(&tags, "tag", "t", []string{}, `Name and tag for the pushed image (format: "name:tag")`)

return cmd
}
Expand Down

0 comments on commit 6bd3f2c

Please sign in to comment.