refactor away direct references to daemon member

- add daemon methods Authenticate & SearchRegistryForImages
 - use new methods instead of directly accessing RegistryService

Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
This commit is contained in:
Morgan Bauer 2015-10-08 16:16:36 -07:00
parent 7787d6dc28
commit 215bfc73d2
No known key found for this signature in database
GPG key ID: 23F15C502128F348
3 changed files with 18 additions and 5 deletions

View file

@ -17,7 +17,7 @@ func (s *router) postAuth(ctx context.Context, w http.ResponseWriter, r *http.Re
if err != nil {
return err
}
status, err := s.daemon.RegistryService.Auth(config)
status, err := s.daemon.AuthenticateToRegistry(config)
if err != nil {
return err
}

View file

@ -504,7 +504,7 @@ func (s *router) getImagesSearch(ctx context.Context, w http.ResponseWriter, r *
headers[k] = v
}
}
query, err := s.daemon.RegistryService.Search(r.Form.Get("term"), config, headers)
query, err := s.daemon.SearchRegistryForImages(r.Form.Get("term"), config, headers)
if err != nil {
return err
}

View file

@ -21,15 +21,15 @@ import (
"github.com/Sirupsen/logrus"
"github.com/docker/docker/api"
"github.com/docker/docker/api/types"
"github.com/docker/docker/cliconfig"
"github.com/docker/docker/daemon/events"
"github.com/docker/docker/daemon/execdriver"
"github.com/docker/docker/daemon/execdriver/execdrivers"
"github.com/docker/docker/daemon/graphdriver"
derr "github.com/docker/docker/errors"
// register vfs
_ "github.com/docker/docker/daemon/graphdriver/vfs"
_ "github.com/docker/docker/daemon/graphdriver/vfs" // register vfs
"github.com/docker/docker/daemon/logger"
"github.com/docker/docker/daemon/network"
derr "github.com/docker/docker/errors"
"github.com/docker/docker/graph"
"github.com/docker/docker/image"
"github.com/docker/docker/pkg/archive"
@ -1240,3 +1240,16 @@ func configureVolumes(config *Config) (*store.VolumeStore, error) {
return s, nil
}
// AuthenticateToRegistry checks the validity of credentials in authConfig
func (daemon *Daemon) AuthenticateToRegistry(authConfig *cliconfig.AuthConfig) (string, error) {
return daemon.RegistryService.Auth(authConfig)
}
// SearchRegistryForImages queries the registry for images matching
// term. authConfig is used to login.
func (daemon *Daemon) SearchRegistryForImages(term string,
authConfig *cliconfig.AuthConfig,
headers map[string][]string) (*registry.SearchResults, error) {
return daemon.RegistryService.Search(term, authConfig, headers)
}