1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Allow push by ID when using a custom registry

This commit is contained in:
shin- 2013-06-27 19:17:20 +02:00
parent c3dd6e1926
commit e095a1572f

View file

@ -736,14 +736,15 @@ func (cli *DockerCli) CmdPush(args ...string) error {
return err return err
} }
if *registry == "" {
// If we're not using a custom registry, we know the restrictions
// applied to repository names and can warn the user in advance.
// Custom repositories can have different rules, and we must also
// allow pushing by image ID.
if len(strings.SplitN(name, "/", 2)) == 1 { if len(strings.SplitN(name, "/", 2)) == 1 {
return fmt.Errorf("Impossible to push a \"root\" repository. Please rename your repository in <user>/<repo> (ex: %s/%s)", cli.authConfig.Username, name) return fmt.Errorf("Impossible to push a \"root\" repository. Please rename your repository in <user>/<repo> (ex: %s/%s)", cli.authConfig.Username, name)
} }
buf, err := json.Marshal(cli.authConfig)
if err != nil {
return err
}
nameParts := strings.SplitN(name, "/", 2) nameParts := strings.SplitN(name, "/", 2)
validNamespace := regexp.MustCompile(`^([a-z0-9_]{4,30})$`) validNamespace := regexp.MustCompile(`^([a-z0-9_]{4,30})$`)
if !validNamespace.MatchString(nameParts[0]) { if !validNamespace.MatchString(nameParts[0]) {
@ -753,6 +754,12 @@ func (cli *DockerCli) CmdPush(args ...string) error {
if !validRepo.MatchString(nameParts[1]) { if !validRepo.MatchString(nameParts[1]) {
return fmt.Errorf("Invalid repository name (%s), only [a-zA-Z0-9-_.] are allowed", nameParts[1]) return fmt.Errorf("Invalid repository name (%s), only [a-zA-Z0-9-_.] are allowed", nameParts[1])
} }
}
buf, err := json.Marshal(cli.authConfig)
if err != nil {
return err
}
v := url.Values{} v := url.Values{}
v.Set("registry", *registry) v.Set("registry", *registry)