Browse code

Add arch/os info to user agent (Registry)

Guillaume J. Charmes authored on 2013/12/21 01:11:35
Showing 3 changed files
... ...
@@ -2018,6 +2018,8 @@ func (srv *Server) HTTPRequestFactory(metaHeaders map[string][]string) *utils.HT
2018 2018
 	httpVersion = append(httpVersion, &simpleVersionInfo{"go", v.Get("GoVersion")})
2019 2019
 	httpVersion = append(httpVersion, &simpleVersionInfo{"git-commit", v.Get("GitCommit")})
2020 2020
 	httpVersion = append(httpVersion, &simpleVersionInfo{"kernel", v.Get("KernelVersion")})
2021
+	httpVersion = append(httpVersion, &simpleVersionInfo{"os", v.Get("Os")})
2022
+	httpVersion = append(httpVersion, &simpleVersionInfo{"arch", v.Get("Arch")})
2021 2023
 	ud := utils.NewHTTPUserAgentDecorator(httpVersion...)
2022 2024
 	md := &utils.HTTPMetaHeadersDecorator{
2023 2025
 		Headers: metaHeaders,
... ...
@@ -76,9 +76,9 @@ type HTTPUserAgentDecorator struct {
76 76
 }
77 77
 
78 78
 func NewHTTPUserAgentDecorator(versions ...VersionInfo) HTTPRequestDecorator {
79
-	ret := new(HTTPUserAgentDecorator)
80
-	ret.versions = versions
81
-	return ret
79
+	return &HTTPUserAgentDecorator{
80
+		versions: versions,
81
+	}
82 82
 }
83 83
 
84 84
 func (h *HTTPUserAgentDecorator) ChangeRequest(req *http.Request) (newReq *http.Request, err error) {
... ...
@@ -108,15 +108,15 @@ func (h *HTTPMetaHeadersDecorator) ChangeRequest(req *http.Request) (newReq *htt
108 108
 }
109 109
 
110 110
 type HTTPAuthDecorator struct {
111
-	login string
111
+	login    string
112 112
 	password string
113 113
 }
114 114
 
115 115
 func NewHTTPAuthDecorator(login, password string) HTTPRequestDecorator {
116
-	ret := new(HTTPAuthDecorator)
117
-	ret.login = login
118
-	ret.password = password
119
-	return ret
116
+	return &HTTPAuthDecorator{
117
+		login:    login,
118
+		password: password,
119
+	}
120 120
 }
121 121
 
122 122
 func (self *HTTPAuthDecorator) ChangeRequest(req *http.Request) (*http.Request, error) {
... ...
@@ -136,7 +136,7 @@ func NewHTTPRequestFactory(d ...HTTPRequestDecorator) *HTTPRequestFactory {
136 136
 	}
137 137
 }
138 138
 
139
-func (self *HTTPRequestFactory) AddDecorator(d... HTTPRequestDecorator) {
139
+func (self *HTTPRequestFactory) AddDecorator(d ...HTTPRequestDecorator) {
140 140
 	self.decorators = append(self.decorators, d...)
141 141
 }
142 142
 
... ...
@@ -25,6 +25,8 @@ func dockerVersion() *engine.Env {
25 25
 	v.Set("Version", VERSION)
26 26
 	v.Set("GitCommit", GITCOMMIT)
27 27
 	v.Set("GoVersion", runtime.Version())
28
+	v.Set("Os", runtime.GOOS)
29
+	v.Set("Arch", runtime.GOARCH)
28 30
 	// FIXME:utils.GetKernelVersion should only be needed here
29 31
 	if kernelVersion, err := utils.GetKernelVersion(); err == nil {
30 32
 		v.Set("KernelVersion", kernelVersion.String())