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
0cdd0771
Commit
0cdd0771
authored
Feb 10, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(*): minor codebase cleanups
Cleaned up some of the code we inherited from DM.
parent
1058fb9c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
helm.go
cmd/helm/helm.go
+1
-1
client.go
dm/client.go
+15
-11
No files found.
cmd/helm/helm.go
View file @
0cdd0771
...
@@ -29,7 +29,7 @@ func main() {
...
@@ -29,7 +29,7 @@ func main() {
Name
:
"host,u"
,
Name
:
"host,u"
,
Usage
:
"The URL of the DM server."
,
Usage
:
"The URL of the DM server."
,
EnvVar
:
"HELM_HOST"
,
EnvVar
:
"HELM_HOST"
,
Value
:
"https://localhost:8
181/FIXME_NOT_RIGHT
"
,
Value
:
"https://localhost:8
000/
"
,
},
},
cli
.
IntFlag
{
cli
.
IntFlag
{
Name
:
"timeout"
,
Name
:
"timeout"
,
...
...
dm/client.go
View file @
0cdd0771
...
@@ -85,6 +85,10 @@ func (c *Client) url(rawurl string) (string, error) {
...
@@ -85,6 +85,10 @@ func (c *Client) url(rawurl string) (string, error) {
return
c
.
baseURL
.
ResolveReference
(
u
)
.
String
(),
nil
return
c
.
baseURL
.
ResolveReference
(
u
)
.
String
(),
nil
}
}
func
(
c
*
Client
)
agent
()
string
{
return
fmt
.
Sprintf
(
"helm/%s"
,
"0.0.1"
)
}
// CallService is a low-level function for making an API call.
// CallService is a low-level function for making an API call.
//
//
// This calls the service and then unmarshals the returned data into dest.
// This calls the service and then unmarshals the returned data into dest.
...
@@ -109,29 +113,28 @@ func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (st
...
@@ -109,29 +113,28 @@ func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (st
request
,
err
:=
http
.
NewRequest
(
method
,
path
,
reader
)
request
,
err
:=
http
.
NewRequest
(
method
,
path
,
reader
)
// TODO: dynamically set version
// TODO: dynamically set version
request
.
Header
.
Set
(
"User-Agent"
,
"helm/0.0.1"
)
request
.
Header
.
Set
(
"User-Agent"
,
c
.
agent
()
)
request
.
Header
.
Add
(
"Content-Type"
,
"application/json"
)
request
.
Header
.
Add
(
"Content-Type"
,
"application/json"
)
client
:=
http
.
Client
{
client
:=
&
http
.
Client
{
Timeout
:
time
.
Duration
(
time
.
Duration
(
DefaultHTTPTimeout
)
*
time
.
Second
)
,
Timeout
:
c
.
HTTPTimeout
,
Transport
:
c
.
transport
(),
Transport
:
c
.
transport
(),
}
}
response
,
err
:=
client
.
Do
(
request
)
response
,
err
:=
client
.
Do
(
request
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"cannot %s: %s
\n
"
,
action
,
err
)
return
""
,
err
}
}
defer
response
.
Body
.
Close
()
defer
response
.
Body
.
Close
()
body
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
body
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"cannot %s: %s
\n
"
,
action
,
err
)
return
""
,
err
}
}
if
response
.
StatusCode
<
http
.
StatusOK
||
s
:=
response
.
StatusCode
response
.
StatusCode
>=
http
.
StatusMultipleChoices
{
if
s
<
http
.
StatusOK
||
s
>=
http
.
StatusMultipleChoices
{
message
:=
fmt
.
Sprintf
(
"status code: %d status: %s : %s"
,
response
.
StatusCode
,
response
.
Status
,
body
)
return
""
,
fmt
.
Errorf
(
"request '%s %s' failed with %d: %s
\n
"
,
action
,
path
,
s
,
body
)
return
""
,
fmt
.
Errorf
(
"cannot %s: %s
\n
"
,
action
,
message
)
}
}
return
string
(
body
),
nil
return
string
(
body
),
nil
...
@@ -194,9 +197,10 @@ func (c *Client) DeployChart(filename, deployname string) error {
...
@@ -194,9 +197,10 @@ func (c *Client) DeployChart(filename, deployname string) error {
request
.
Header
.
Add
(
"Content-Encoding"
,
"gzip"
)
request
.
Header
.
Add
(
"Content-Encoding"
,
"gzip"
)
request
.
Header
.
Add
(
"X-Deployment-Name"
,
deployname
)
request
.
Header
.
Add
(
"X-Deployment-Name"
,
deployname
)
request
.
Header
.
Add
(
"X-Chart-Name"
,
filepath
.
Base
(
filename
))
request
.
Header
.
Add
(
"X-Chart-Name"
,
filepath
.
Base
(
filename
))
request
.
Header
.
Set
(
"User-Agent"
,
c
.
agent
())
client
:=
http
.
Client
{
client
:=
&
http
.
Client
{
Timeout
:
time
.
Duration
(
time
.
Duration
(
DefaultHTTPTimeout
)
*
time
.
Second
)
,
Timeout
:
c
.
HTTPTimeout
,
Transport
:
c
.
transport
(),
Transport
:
c
.
transport
(),
}
}
...
...
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