From ede1e6d4754f3cffeac72f5d760fe4d87c5ae570 Mon Sep 17 00:00:00 2001 From: Nan Monnand Deng Date: Tue, 23 Jul 2013 17:05:13 -0400 Subject: [PATCH] Rename: VersionChecker->VersionInfo. --- registry/registry.go | 16 ++++++++-------- runtime_test.go | 12 ++++++------ server.go | 22 +++++++++++----------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/registry/registry.go b/registry/registry.go index 6ba80cbea5..e6f4f592e2 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -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, diff --git a/runtime_test.go b/runtime_test.go index 6b94e5ce2c..74ca09cc8d 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -18,12 +18,12 @@ import ( ) const ( - unitTestImageName = "docker-test-image" - unitTestImageID = "83599e29c455eb719f77d799bc7c51521b9551972f5a850d7ad265bc1b5292f6" // 1.0 - unitTestNetworkBridge = "testdockbr0" - unitTestStoreBase = "/var/lib/docker/unit-tests" - testDaemonAddr = "127.0.0.1:4270" - testDaemonProto = "tcp" + unitTestImageName = "docker-test-image" + unitTestImageID = "83599e29c455eb719f77d799bc7c51521b9551972f5a850d7ad265bc1b5292f6" // 1.0 + unitTestNetworkBridge = "testdockbr0" + unitTestStoreBase = "/var/lib/docker/unit-tests" + testDaemonAddr = "127.0.0.1:4270" + testDaemonProto = "tcp" ) var globalRuntime *Runtime diff --git a/server.go b/server.go index 925e4e3386..62c0243820 100644 --- a/server.go +++ b/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