Don't hard code true for auth job
Signed-off-by: Michael Crosby <michael@docker.com> Conflicts: registry/service.gomaster
							parent
							
								
									50e11c9d8e
								
							
						
					
					
						commit
						552c17d618
					
				| 
						 | 
					@ -13,12 +13,15 @@ import (
 | 
				
			||||||
//  'pull': Download images from any registry (TODO)
 | 
					//  'pull': Download images from any registry (TODO)
 | 
				
			||||||
//  'push': Upload images to any registry (TODO)
 | 
					//  'push': Upload images to any registry (TODO)
 | 
				
			||||||
type Service struct {
 | 
					type Service struct {
 | 
				
			||||||
 | 
						insecureRegistries []string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NewService returns a new instance of Service ready to be
 | 
					// NewService returns a new instance of Service ready to be
 | 
				
			||||||
// installed no an engine.
 | 
					// installed no an engine.
 | 
				
			||||||
func NewService() *Service {
 | 
					func NewService(insecureRegistries []string) *Service {
 | 
				
			||||||
	return &Service{}
 | 
						return &Service{
 | 
				
			||||||
 | 
							insecureRegistries: insecureRegistries,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Install installs registry capabilities to eng.
 | 
					// Install installs registry capabilities to eng.
 | 
				
			||||||
| 
						 | 
					@ -32,15 +35,12 @@ func (s *Service) Install(eng *engine.Engine) error {
 | 
				
			||||||
// and returns OK if authentication was sucessful.
 | 
					// and returns OK if authentication was sucessful.
 | 
				
			||||||
// It can be used to verify the validity of a client's credentials.
 | 
					// It can be used to verify the validity of a client's credentials.
 | 
				
			||||||
func (s *Service) Auth(job *engine.Job) engine.Status {
 | 
					func (s *Service) Auth(job *engine.Job) engine.Status {
 | 
				
			||||||
	var (
 | 
						var authConfig = new(AuthConfig)
 | 
				
			||||||
		err        error
 | 
					 | 
				
			||||||
		authConfig = &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 != IndexServerAddress() {
 | 
						if addr := authConfig.ServerAddress; addr != "" && addr != IndexServerAddress() {
 | 
				
			||||||
		endpoint, err := NewEndpoint(addr, true)
 | 
							endpoint, err := NewEndpoint(addr, IsSecure(addr, s.insecureRegistries))
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return job.Error(err)
 | 
								return job.Error(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -49,11 +49,11 @@ func (s *Service) Auth(job *engine.Job) engine.Status {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		authConfig.ServerAddress = endpoint.String()
 | 
							authConfig.ServerAddress = endpoint.String()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	status, err := Login(authConfig, HTTPRequestFactory(nil))
 | 
					
 | 
				
			||||||
	if err != nil {
 | 
						if _, err := Login(authConfig, HTTPRequestFactory(nil)); err != nil {
 | 
				
			||||||
		return job.Error(err)
 | 
							return job.Error(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	job.Printf("%s\n", status)
 | 
					
 | 
				
			||||||
	return engine.StatusOK
 | 
						return engine.StatusOK
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue