Do not ping registry from the cli
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
7fb8738839
commit
e2eace9715
13
auth/auth.go
13
auth/auth.go
|
@ -151,12 +151,15 @@ func SaveConfig(configFile *ConfigFile) error {
|
||||||
|
|
||||||
// try to register/login to the registry server
|
// try to register/login to the registry server
|
||||||
func Login(authConfig *AuthConfig, factory *utils.HTTPRequestFactory) (string, error) {
|
func Login(authConfig *AuthConfig, factory *utils.HTTPRequestFactory) (string, error) {
|
||||||
client := &http.Client{}
|
var (
|
||||||
reqStatusCode := 0
|
status string
|
||||||
var status string
|
reqBody []byte
|
||||||
var reqBody []byte
|
err error
|
||||||
|
client = &http.Client{}
|
||||||
|
reqStatusCode = 0
|
||||||
|
serverAddress = authConfig.ServerAddress
|
||||||
|
)
|
||||||
|
|
||||||
serverAddress := authConfig.ServerAddress
|
|
||||||
if serverAddress == "" {
|
if serverAddress == "" {
|
||||||
serverAddress = IndexServerAddress()
|
serverAddress = IndexServerAddress()
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,11 +266,7 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
|
||||||
}
|
}
|
||||||
serverAddress := auth.IndexServerAddress()
|
serverAddress := auth.IndexServerAddress()
|
||||||
if len(cmd.Args()) > 0 {
|
if len(cmd.Args()) > 0 {
|
||||||
serverAddress, err = registry.ExpandAndVerifyRegistryUrl(cmd.Arg(0))
|
serverAddress = cmd.Arg(0)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
fmt.Fprintf(cli.out, "Login against server at %s\n", serverAddress)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
promptDefault := func(prompt string, configDefault string) {
|
promptDefault := func(prompt string, configDefault string) {
|
||||||
|
|
14
server.go
14
server.go
|
@ -200,8 +200,20 @@ func (srv *Server) ContainerKill(job *engine.Job) engine.Status {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (srv *Server) Auth(job *engine.Job) engine.Status {
|
func (srv *Server) Auth(job *engine.Job) engine.Status {
|
||||||
authConfig := &auth.AuthConfig{}
|
var (
|
||||||
|
err error
|
||||||
|
authConfig = &auth.AuthConfig{}
|
||||||
|
)
|
||||||
|
|
||||||
job.GetenvJson("authConfig", authConfig)
|
job.GetenvJson("authConfig", authConfig)
|
||||||
|
// TODO: this is only done here because auth and registry need to be merged into one pkg
|
||||||
|
if addr := authConfig.ServerAddress; addr != "" && addr != auth.IndexServerAddress() {
|
||||||
|
addr, err = registry.ExpandAndVerifyRegistryUrl(addr)
|
||||||
|
if err != nil {
|
||||||
|
return job.Error(err)
|
||||||
|
}
|
||||||
|
authConfig.ServerAddress = addr
|
||||||
|
}
|
||||||
status, err := auth.Login(authConfig, srv.HTTPRequestFactory(nil))
|
status, err := auth.Login(authConfig, srv.HTTPRequestFactory(nil))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return job.Error(err)
|
return job.Error(err)
|
||||||
|
|
Loading…
Reference in New Issue