diff --git a/go/src/bashbrew/cmd-push.go b/go/src/bashbrew/cmd-push.go index 87948bf..d6f7c64 100644 --- a/go/src/bashbrew/cmd-push.go +++ b/go/src/bashbrew/cmd-push.go @@ -16,11 +16,15 @@ func cmdPush(c *cli.Context) error { } uniq := c.Bool("uniq") + targetNamespace := c.String("target-namespace") dryRun := c.Bool("dry-run") force := c.Bool("force") - if namespace == "" { - return fmt.Errorf(`"--namespace" is a required flag for "push"`) + if targetNamespace == "" { + targetNamespace = namespace + } + if targetNamespace == "" { + return fmt.Errorf(`either "--target-namespace" or "--namespace" is a required flag for "push"`) } for _, repo := range repos { @@ -29,7 +33,7 @@ func cmdPush(c *cli.Context) error { return cli.NewMultiError(fmt.Errorf(`failed fetching repo %q`, repo), err) } - tagRepo := path.Join(namespace, r.RepoName) + tagRepo := path.Join(targetNamespace, r.RepoName) for _, entry := range r.Entries() { if r.SkipConstraints(entry) { continue diff --git a/go/src/bashbrew/cmd-put-shared.go b/go/src/bashbrew/cmd-put-shared.go index 51b2631..edb3a65 100644 --- a/go/src/bashbrew/cmd-put-shared.go +++ b/go/src/bashbrew/cmd-put-shared.go @@ -84,11 +84,15 @@ func cmdPutShared(c *cli.Context) error { } dryRun := c.Bool("dry-run") + targetNamespace := c.String("target-namespace") force := c.Bool("force") singleArch := c.Bool("single-arch") - if namespace == "" { - return fmt.Errorf(`"--namespace" is a required flag for "put-shared"`) + if targetNamespace == "" { + targetNamespace = namespace + } + if targetNamespace == "" { + return fmt.Errorf(`either "--target-namespace" or "--namespace" is a required flag for "put-shared"`) } for _, repo := range repos { @@ -97,7 +101,7 @@ func cmdPutShared(c *cli.Context) error { return cli.NewMultiError(fmt.Errorf(`failed fetching repo %q`, repo), err) } - targetRepo := path.Join(namespace, r.RepoName) + targetRepo := path.Join(targetNamespace, r.RepoName) sharedTagGroups := []manifest.SharedTagGroup{} diff --git a/go/src/bashbrew/cmd-tag.go b/go/src/bashbrew/cmd-tag.go index 05f16a7..87d408b 100644 --- a/go/src/bashbrew/cmd-tag.go +++ b/go/src/bashbrew/cmd-tag.go @@ -17,9 +17,6 @@ func cmdTag(c *cli.Context) error { targetNamespace := c.String("target-namespace") dryRun := c.Bool("dry-run") - if namespace == "" { - return fmt.Errorf(`"--namespace" is a required flag for "tag"`) - } if targetNamespace == "" { return fmt.Errorf(`"--target-namespace" is a required flag for "tag"`) } diff --git a/go/src/bashbrew/main.go b/go/src/bashbrew/main.go index 86cf181..27c65a1 100644 --- a/go/src/bashbrew/main.go +++ b/go/src/bashbrew/main.go @@ -214,6 +214,10 @@ func main() { Name: "force", Usage: "always push (skip the clever Hub API lookups that no-op things sooner if a push doesn't seem necessary)", }, + "target-namespace": cli.StringFlag{ + Name: "target-namespace", + Usage: `target namespace to act into ("docker tag namespace/repo:tag target-namespace/repo:tag", "docker push target-namespace/repo:tag")`, + }, } app.Commands = []cli.Command{ @@ -261,10 +265,7 @@ func main() { commonFlags["all"], commonFlags["uniq"], commonFlags["dry-run"], - cli.StringFlag{ - Name: "target-namespace", - Usage: `target namespace to tag into ("docker tag namespace/repo:tag target-namespace/repo:tag")`, - }, + commonFlags["target-namespace"], }, Before: subcommandBeforeFactory("tag"), Action: cmdTag, @@ -277,6 +278,7 @@ func main() { commonFlags["uniq"], commonFlags["dry-run"], commonFlags["force"], + commonFlags["target-namespace"], }, Before: subcommandBeforeFactory("push"), Action: cmdPush, @@ -288,6 +290,7 @@ func main() { commonFlags["all"], commonFlags["dry-run"], commonFlags["force"], + commonFlags["target-namespace"], cli.BoolFlag{ Name: "single-arch", Usage: `only act on the current architecture (for pushing "amd64/hello-world:latest", for example)`,