mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Rename: VersionChecker->VersionInfo.
This commit is contained in:
parent
cd209f406e
commit
ede1e6d475
3 changed files with 25 additions and 25 deletions
|
@ -98,9 +98,9 @@ func ResolveRepositoryName(reposName string) (string, string, error) {
|
|||
return endpoint, reposName, err
|
||||
}
|
||||
|
||||
// VersionChecker is used to model entities which has a version.
|
||||
// VersionInfo is used to model entities which has a version.
|
||||
// It is basically a tupple with name and version.
|
||||
type VersionChecker interface {
|
||||
type VersionInfo interface {
|
||||
Name() string
|
||||
Version() string
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ func doWithCookies(c *http.Client, req *http.Request) (*http.Response, error) {
|
|||
|
||||
// Set the user agent field in the header based on the versions provided
|
||||
// in NewRegistry() and extra.
|
||||
func (r *Registry) setUserAgent(req *http.Request, extra ...VersionChecker) {
|
||||
func (r *Registry) setUserAgent(req *http.Request, extra ...VersionInfo) {
|
||||
if len(r.baseVersions)+len(extra) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -569,11 +569,11 @@ type ImgData struct {
|
|||
type Registry struct {
|
||||
client *http.Client
|
||||
authConfig *auth.AuthConfig
|
||||
baseVersions []VersionChecker
|
||||
baseVersions []VersionInfo
|
||||
baseVersionsStr string
|
||||
}
|
||||
|
||||
func validVersion(version VersionChecker) bool {
|
||||
func validVersion(version VersionInfo) bool {
|
||||
stopChars := " \t\r\n/"
|
||||
if strings.ContainsAny(version.Name(), stopChars) {
|
||||
return false
|
||||
|
@ -586,11 +586,11 @@ func validVersion(version VersionChecker) bool {
|
|||
|
||||
// Convert versions to a string and append the string to the string base.
|
||||
//
|
||||
// Each VersionChecker will be converted to a string in the format of
|
||||
// Each VersionInfo will be converted to a string in the format of
|
||||
// "product/version", where the "product" is get from the Name() method, while
|
||||
// version is get from the Version() method. Several pieces of verson information
|
||||
// will be concatinated and separated by space.
|
||||
func appendVersions(base string, versions ...VersionChecker) string {
|
||||
func appendVersions(base string, versions ...VersionInfo) string {
|
||||
if len(versions) == 0 {
|
||||
return base
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ func appendVersions(base string, versions ...VersionChecker) string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
func NewRegistry(root string, authConfig *auth.AuthConfig, baseVersions ...VersionChecker) (r *Registry, err error) {
|
||||
func NewRegistry(root string, authConfig *auth.AuthConfig, baseVersions ...VersionInfo) (r *Registry, err error) {
|
||||
httpTransport := &http.Transport{
|
||||
DisableKeepAlives: true,
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
|
|
22
server.go
22
server.go
|
@ -26,21 +26,21 @@ func (srv *Server) DockerVersion() APIVersion {
|
|||
}
|
||||
}
|
||||
|
||||
// plainVersionChecker is a simple implementation of
|
||||
// the interface VersionChecker, which is used
|
||||
// simpleVersionInfo is a simple implementation of
|
||||
// the interface VersionInfo, which is used
|
||||
// to provide version information for some product,
|
||||
// component, etc. It stores the product name and the version
|
||||
// in string and returns them on calls to Name() and Version().
|
||||
type plainVersionChecker struct {
|
||||
type simpleVersionInfo struct {
|
||||
name string
|
||||
version string
|
||||
}
|
||||
|
||||
func (v *plainVersionChecker) Name() string {
|
||||
func (v *simpleVersionInfo) Name() string {
|
||||
return v.name
|
||||
}
|
||||
|
||||
func (v *plainVersionChecker) Version() string {
|
||||
func (v *simpleVersionInfo) Version() string {
|
||||
return v.version
|
||||
}
|
||||
|
||||
|
@ -48,20 +48,20 @@ func (v *plainVersionChecker) Version() string {
|
|||
// docker, go, git-commit (of the docker) and the host's kernel.
|
||||
//
|
||||
// Such information will be used on call to NewRegistry().
|
||||
func (srv *Server) versionCheckers() []registry.VersionChecker {
|
||||
func (srv *Server) versionCheckers() []registry.VersionInfo {
|
||||
v := srv.DockerVersion()
|
||||
ret := make([]registry.VersionChecker, 0, 4)
|
||||
ret = append(ret, &plainVersionChecker{"docker", v.Version})
|
||||
ret := make([]registry.VersionInfo, 0, 4)
|
||||
ret = append(ret, &simpleVersionInfo{"docker", v.Version})
|
||||
|
||||
if len(v.GoVersion) > 0 {
|
||||
ret = append(ret, &plainVersionChecker{"go", v.GoVersion})
|
||||
ret = append(ret, &simpleVersionInfo{"go", v.GoVersion})
|
||||
}
|
||||
if len(v.GitCommit) > 0 {
|
||||
ret = append(ret, &plainVersionChecker{"git-commit", v.GitCommit})
|
||||
ret = append(ret, &simpleVersionInfo{"git-commit", v.GitCommit})
|
||||
}
|
||||
kernelVersion, err := utils.GetKernelVersion()
|
||||
if err == nil {
|
||||
ret = append(ret, &plainVersionChecker{"kernel", kernelVersion.String()})
|
||||
ret = append(ret, &simpleVersionInfo{"kernel", kernelVersion.String()})
|
||||
}
|
||||
|
||||
return ret
|
||||
|
|
Loading…
Add table
Reference in a new issue