зеркало из https://github.com/microsoft/docker.git
Insert version checkers when call NewRegistry()
This commit is contained in:
Родитель
65185a565b
Коммит
5705a49308
|
@ -66,18 +66,6 @@ type APIVersion struct {
|
|||
GoVersion string `json:",omitempty"`
|
||||
}
|
||||
|
||||
func (v *APIVersion) Name() string {
|
||||
return "docker"
|
||||
}
|
||||
|
||||
func (v *APIVersion) Version() string {
|
||||
r, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return r.Version
|
||||
}
|
||||
return string(r)
|
||||
}
|
||||
|
||||
type APIWait struct {
|
||||
StatusCode int
|
||||
}
|
||||
|
|
33
server.go
33
server.go
|
@ -26,6 +26,33 @@ func (srv *Server) DockerVersion() APIVersion {
|
|||
}
|
||||
}
|
||||
|
||||
type plainVersionChecker struct {
|
||||
name string
|
||||
version string
|
||||
}
|
||||
|
||||
func (v *plainVersionChecker) Name() string {
|
||||
return v.name
|
||||
}
|
||||
|
||||
func (v *plainVersionChecker) Version() string {
|
||||
return v.version
|
||||
}
|
||||
|
||||
func (srv *Server) versionCheckers() []registry.VersionChecker {
|
||||
v := srv.DockerVersion()
|
||||
ret := make([]registry.VersionChecker, 0, 3)
|
||||
ret = append(ret, &plainVersionChecker{"docker", v.Version})
|
||||
|
||||
if len(v.GoVersion) > 0 {
|
||||
ret = append(ret, &plainVersionChecker{"go", v.GoVersion})
|
||||
}
|
||||
if len(v.GitCommit) > 0 {
|
||||
ret = append(ret, &plainVersionChecker{"git-commit", v.GitCommit})
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (srv *Server) ContainerKill(name string) error {
|
||||
if container := srv.runtime.Get(name); container != nil {
|
||||
if err := container.Kill(); err != nil {
|
||||
|
@ -55,7 +82,7 @@ func (srv *Server) ContainerExport(name string, out io.Writer) error {
|
|||
}
|
||||
|
||||
func (srv *Server) ImagesSearch(term string) ([]APISearch, error) {
|
||||
r, err := registry.NewRegistry(srv.runtime.root, nil, srv.DockerVersion())
|
||||
r, err := registry.NewRegistry(srv.runtime.root, nil, srv.versionCheckers()...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -470,7 +497,7 @@ func (srv *Server) poolRemove(kind, key string) error {
|
|||
}
|
||||
|
||||
func (srv *Server) ImagePull(localName string, tag string, out io.Writer, sf *utils.StreamFormatter, authConfig *auth.AuthConfig) error {
|
||||
r, err := registry.NewRegistry(srv.runtime.root, authConfig, srv.DockerVersion())
|
||||
r, err := registry.NewRegistry(srv.runtime.root, authConfig, srv.versionCheckers()...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -687,7 +714,7 @@ func (srv *Server) ImagePush(localName string, out io.Writer, sf *utils.StreamFo
|
|||
|
||||
out = utils.NewWriteFlusher(out)
|
||||
img, err := srv.runtime.graph.Get(localName)
|
||||
r, err2 := registry.NewRegistry(srv.runtime.root, authConfig, srv.DockerVersion())
|
||||
r, err2 := registry.NewRegistry(srv.runtime.root, authConfig, srv.versionCheckers()...)
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче