Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
927c084f
Commit
927c084f
authored
Feb 09, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(client): add helm user agent
parent
1e741afb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
8 deletions
+23
-8
client.go
dm/client.go
+3
-0
client_test.go
dm/client_test.go
+20
-8
No files found.
dm/client.go
View file @
927c084f
...
@@ -100,6 +100,9 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read
...
@@ -100,6 +100,9 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read
// callHTTP is a low-level primative for executing HTTP operations.
// callHTTP is a low-level primative for executing HTTP operations.
func
(
c
*
Client
)
callHTTP
(
path
,
method
,
action
string
,
reader
io
.
ReadCloser
)
(
string
,
error
)
{
func
(
c
*
Client
)
callHTTP
(
path
,
method
,
action
string
,
reader
io
.
ReadCloser
)
(
string
,
error
)
{
request
,
err
:=
http
.
NewRequest
(
method
,
path
,
reader
)
request
,
err
:=
http
.
NewRequest
(
method
,
path
,
reader
)
// TODO: dynamically set version
request
.
Header
.
Set
(
"User-Agent"
,
"helm/0.0.1"
)
request
.
Header
.
Add
(
"Content-Type"
,
"application/json"
)
request
.
Header
.
Add
(
"Content-Type"
,
"application/json"
)
client
:=
http
.
Client
{
client
:=
http
.
Client
{
...
...
dm/client_test.go
View file @
927c084f
...
@@ -3,6 +3,7 @@ package dm
...
@@ -3,6 +3,7 @@ package dm
import
(
import
(
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
"strings"
"testing"
"testing"
"github.com/kubernetes/deployment-manager/common"
"github.com/kubernetes/deployment-manager/common"
...
@@ -65,15 +66,11 @@ func TestURL(t *testing.T) {
...
@@ -65,15 +66,11 @@ func TestURL(t *testing.T) {
type
fakeClient
struct
{
type
fakeClient
struct
{
*
Client
*
Client
server
*
httptest
.
Server
server
*
httptest
.
Server
handler
http
.
HandlerFunc
handler
http
.
HandlerFunc
response
[]
byte
}
}
func
(
c
*
fakeClient
)
setup
()
*
fakeClient
{
func
(
c
*
fakeClient
)
setup
()
*
fakeClient
{
c
.
handler
=
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Write
(
c
.
response
)
})
c
.
server
=
httptest
.
NewServer
(
c
.
handler
)
c
.
server
=
httptest
.
NewServer
(
c
.
handler
)
c
.
Client
=
NewClient
(
c
.
server
.
URL
)
c
.
Client
=
NewClient
(
c
.
server
.
URL
)
return
c
return
c
...
@@ -83,9 +80,22 @@ func (c *fakeClient) teardown() {
...
@@ -83,9 +80,22 @@ func (c *fakeClient) teardown() {
c
.
server
.
Close
()
c
.
server
.
Close
()
}
}
func
TestUserAgent
(
t
*
testing
.
T
)
{
fc
:=
&
fakeClient
{
handler
:
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
!
strings
.
HasPrefix
(
r
.
UserAgent
(),
"helm"
)
{
t
.
Error
(
"user agent is not set"
)
}
}),
}
fc
.
setup
()
.
ListDeployments
()
}
func
TestListDeployments
(
t
*
testing
.
T
)
{
func
TestListDeployments
(
t
*
testing
.
T
)
{
fc
:=
&
fakeClient
{
fc
:=
&
fakeClient
{
response
:
[]
byte
(
`["guestbook.yaml"]`
),
handler
:
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Write
([]
byte
(
`["guestbook.yaml"]`
))
}),
}
}
defer
fc
.
teardown
()
defer
fc
.
teardown
()
...
@@ -101,7 +111,9 @@ func TestListDeployments(t *testing.T) {
...
@@ -101,7 +111,9 @@ func TestListDeployments(t *testing.T) {
func
TestGetDeployment
(
t
*
testing
.
T
)
{
func
TestGetDeployment
(
t
*
testing
.
T
)
{
fc
:=
&
fakeClient
{
fc
:=
&
fakeClient
{
response
:
[]
byte
(
`{"name":"guestbook.yaml","id":0,"createdAt":"2016-02-08T12:17:49.251658308-08:00","deployedAt":"2016-02-08T12:17:49.251658589-08:00","modifiedAt":"2016-02-08T12:17:51.177518098-08:00","deletedAt":"0001-01-01T00:00:00Z","state":{"status":"Deployed"},"latestManifest":"manifest-1454962670728402229"}`
),
handler
:
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Write
([]
byte
(
`{"name":"guestbook.yaml","id":0,"createdAt":"2016-02-08T12:17:49.251658308-08:00","deployedAt":"2016-02-08T12:17:49.251658589-08:00","modifiedAt":"2016-02-08T12:17:51.177518098-08:00","deletedAt":"0001-01-01T00:00:00Z","state":{"status":"Deployed"},"latestManifest":"manifest-1454962670728402229"}`
))
}),
}
}
defer
fc
.
teardown
()
defer
fc
.
teardown
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment