Skip to content

Commit

Permalink
push: Add insecure-registry flag (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermebr authored and jessfraz committed May 24, 2018
1 parent 0ff39c9 commit d8faa09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions client/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// Push sends an image to a remote registry.
func (c *Client) Push(ctx context.Context, image string) error {
func (c *Client) Push(ctx context.Context, image string, insecure bool) error {
// Parse the image name and tag.
named, err := reference.ParseNormalizedNamed(image)
if err != nil {
Expand All @@ -30,5 +30,5 @@ func (c *Client) Push(ctx context.Context, image string) error {
return fmt.Errorf("getting image %q failed: %v", image, err)
}

return push.Push(ctx, opt.SessionManager, opt.ContentStore, imgObj.Target.Digest, image, false)
return push.Push(ctx, opt.SessionManager, opt.ContentStore, imgObj.Target.Digest, image, insecure)
}
9 changes: 6 additions & 3 deletions push.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ func (cmd *pushCommand) ShortHelp() string { return pushHelp }
func (cmd *pushCommand) LongHelp() string { return pushHelp }
func (cmd *pushCommand) Hidden() bool { return false }

func (cmd *pushCommand) Register(fs *flag.FlagSet) {}
func (cmd *pushCommand) Register(fs *flag.FlagSet) {
fs.BoolVar(&cmd.insecure, "insecure-registry", false, "Push to insecure registry")
}

type pushCommand struct {
image string
image string
insecure bool
}

func (cmd *pushCommand) Run(args []string) (err error) {
Expand Down Expand Up @@ -57,7 +60,7 @@ func (cmd *pushCommand) Run(args []string) (err error) {
})
eg.Go(func() error {
defer sess.Close()
return c.Push(ctx, cmd.image)
return c.Push(ctx, cmd.image, cmd.insecure)
})
if err := eg.Wait(); err != nil {
return err
Expand Down

0 comments on commit d8faa09

Please sign in to comment.