Rename: VersionChecker->VersionInfo.

This commit is contained in:
Nan Monnand Deng 2013-07-23 17:05:13 -04:00
parent cd209f406e
commit ede1e6d475
3 changed files with 25 additions and 25 deletions

View File

@ -98,9 +98,9 @@ func ResolveRepositoryName(reposName string) (string, string, error) {
return endpoint, reposName, err 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. // It is basically a tupple with name and version.
type VersionChecker interface { type VersionInfo interface {
Name() string Name() string
Version() 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 // Set the user agent field in the header based on the versions provided
// in NewRegistry() and extra. // 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 { if len(r.baseVersions)+len(extra) == 0 {
return return
} }
@ -569,11 +569,11 @@ type ImgData struct {
type Registry struct { type Registry struct {
client *http.Client client *http.Client
authConfig *auth.AuthConfig authConfig *auth.AuthConfig
baseVersions []VersionChecker baseVersions []VersionInfo
baseVersionsStr string baseVersionsStr string
} }
func validVersion(version VersionChecker) bool { func validVersion(version VersionInfo) bool {
stopChars := " \t\r\n/" stopChars := " \t\r\n/"
if strings.ContainsAny(version.Name(), stopChars) { if strings.ContainsAny(version.Name(), stopChars) {
return false return false
@ -586,11 +586,11 @@ func validVersion(version VersionChecker) bool {
// Convert versions to a string and append the string to the string base. // 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 // "product/version", where the "product" is get from the Name() method, while
// version is get from the Version() method. Several pieces of verson information // version is get from the Version() method. Several pieces of verson information
// will be concatinated and separated by space. // 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 { if len(versions) == 0 {
return base return base
} }
@ -612,7 +612,7 @@ func appendVersions(base string, versions ...VersionChecker) string {
return buf.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{ httpTransport := &http.Transport{
DisableKeepAlives: true, DisableKeepAlives: true,
Proxy: http.ProxyFromEnvironment, Proxy: http.ProxyFromEnvironment,

View File

@ -18,12 +18,12 @@ import (
) )
const ( const (
unitTestImageName = "docker-test-image" unitTestImageName = "docker-test-image"
unitTestImageID = "83599e29c455eb719f77d799bc7c51521b9551972f5a850d7ad265bc1b5292f6" // 1.0 unitTestImageID = "83599e29c455eb719f77d799bc7c51521b9551972f5a850d7ad265bc1b5292f6" // 1.0
unitTestNetworkBridge = "testdockbr0" unitTestNetworkBridge = "testdockbr0"
unitTestStoreBase = "/var/lib/docker/unit-tests" unitTestStoreBase = "/var/lib/docker/unit-tests"
testDaemonAddr = "127.0.0.1:4270" testDaemonAddr = "127.0.0.1:4270"
testDaemonProto = "tcp" testDaemonProto = "tcp"
) )
var globalRuntime *Runtime var globalRuntime *Runtime

View File

@ -26,21 +26,21 @@ func (srv *Server) DockerVersion() APIVersion {
} }
} }
// plainVersionChecker is a simple implementation of // simpleVersionInfo is a simple implementation of
// the interface VersionChecker, which is used // the interface VersionInfo, which is used
// to provide version information for some product, // to provide version information for some product,
// component, etc. It stores the product name and the version // component, etc. It stores the product name and the version
// in string and returns them on calls to Name() and Version(). // in string and returns them on calls to Name() and Version().
type plainVersionChecker struct { type simpleVersionInfo struct {
name string name string
version string version string
} }
func (v *plainVersionChecker) Name() string { func (v *simpleVersionInfo) Name() string {
return v.name return v.name
} }
func (v *plainVersionChecker) Version() string { func (v *simpleVersionInfo) Version() string {
return v.version return v.version
} }
@ -48,20 +48,20 @@ func (v *plainVersionChecker) Version() string {
// docker, go, git-commit (of the docker) and the host's kernel. // docker, go, git-commit (of the docker) and the host's kernel.
// //
// Such information will be used on call to NewRegistry(). // Such information will be used on call to NewRegistry().
func (srv *Server) versionCheckers() []registry.VersionChecker { func (srv *Server) versionCheckers() []registry.VersionInfo {
v := srv.DockerVersion() v := srv.DockerVersion()
ret := make([]registry.VersionChecker, 0, 4) ret := make([]registry.VersionInfo, 0, 4)
ret = append(ret, &plainVersionChecker{"docker", v.Version}) ret = append(ret, &simpleVersionInfo{"docker", v.Version})
if len(v.GoVersion) > 0 { if len(v.GoVersion) > 0 {
ret = append(ret, &plainVersionChecker{"go", v.GoVersion}) ret = append(ret, &simpleVersionInfo{"go", v.GoVersion})
} }
if len(v.GitCommit) > 0 { 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() kernelVersion, err := utils.GetKernelVersion()
if err == nil { if err == nil {
ret = append(ret, &plainVersionChecker{"kernel", kernelVersion.String()}) ret = append(ret, &simpleVersionInfo{"kernel", kernelVersion.String()})
} }
return ret return ret