Add "--target-namespace" to both "push" and "put-shared" and make "tag" more intuitive
This commit is contained in:
parent
4029557244
commit
c922da004c
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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{}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue