Skip to content

Commit 886633b

Browse files
fix(deis): rename DeisVersion to ControllerVersion and set it in all requests (#93)
1 parent 6f9ec57 commit 886633b

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

deis.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ type Client struct {
7777
// API Version used by the controller, set after a http request.
7878
ControllerAPIVersion string
7979

80-
// Version of the deis platform in use, set after a http request.
81-
DeisVersion string
80+
// Version of the deis controller in use, set after a http request.
81+
ControllerVersion string
8282

8383
// Token is used to authenticate the request against the API.
8484
Token string

http.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (c *Client) Request(method string, path string, body []byte) (*http.Respons
6767

6868
// Update controller api and platform version
6969
c.ControllerAPIVersion = apiVersion
70-
c.DeisVersion = res.Header.Get("DEIS_PLATFORM_VERSION")
70+
setControllerVersion(c, res.Header)
7171

7272
// Return results along with api compatibility error
7373
return res, checkAPICompatibility(apiVersion, APIVersion)
@@ -131,6 +131,7 @@ your deis version is correct.`
131131
// Update controller api version
132132
apiVersion := res.Header.Get("DEIS_API_VERSION")
133133
c.ControllerAPIVersion = apiVersion
134+
setControllerVersion(c, res.Header)
134135

135136
return checkAPICompatibility(apiVersion, APIVersion)
136137
}
@@ -159,10 +160,15 @@ func (c *Client) Healthcheck() error {
159160
// Update controller api version
160161
apiVersion := res.Header.Get("DEIS_API_VERSION")
161162
c.ControllerAPIVersion = apiVersion
163+
setControllerVersion(c, res.Header)
162164

163165
return checkAPICompatibility(apiVersion, APIVersion)
164166
}
165167

166168
func addUserAgent(headers *http.Header, userAgent string) {
167169
headers.Add("User-Agent", userAgent)
168170
}
171+
172+
func setControllerVersion(c *Client, headers http.Header) {
173+
c.ControllerVersion = headers.Get("DEIS_PLATFORM_VERSION")
174+
}

http_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ func TestBasicRequest(t *testing.T) {
179179
t.Errorf("Expected %s, Got %s", handler.Version, deis.ControllerAPIVersion)
180180
}
181181

182-
if deis.DeisVersion != handler.PlatformVersion {
183-
t.Errorf("Expected %s, Got %s", handler.PlatformVersion, deis.DeisVersion)
182+
if deis.ControllerVersion != handler.PlatformVersion {
183+
t.Errorf("Expected %s, Got %s", handler.PlatformVersion, deis.ControllerVersion)
184184
}
185185

186186
// Make sure the request doesn't modify the URL

0 commit comments

Comments
 (0)