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
6058cad0
Commit
6058cad0
authored
Feb 09, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(client): add timeout cli option
parent
8cf1f350
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
9 deletions
+21
-9
get.go
cmd/helm/get.go
+1
-5
helm.go
cmd/helm/helm.go
+13
-0
list.go
cmd/helm/list.go
+1
-4
client.go
dm/client.go
+6
-0
No files found.
cmd/helm/get.go
View file @
6058cad0
...
...
@@ -4,7 +4,6 @@ import (
"errors"
"github.com/codegangsta/cli"
"github.com/deis/helm-dm/dm"
"github.com/deis/helm-dm/format"
)
...
...
@@ -22,10 +21,7 @@ func get(c *cli.Context) error {
return
errors
.
New
(
"First argument, deployment name, is required. Try 'helm get --help'"
)
}
name
:=
args
[
0
]
host
:=
c
.
GlobalString
(
"host"
)
client
:=
dm
.
NewClient
(
host
)
.
SetDebug
(
c
.
GlobalBool
(
"debug"
))
deployment
,
err
:=
client
.
GetDeployment
(
name
)
deployment
,
err
:=
client
(
c
)
.
GetDeployment
(
name
)
if
err
!=
nil
{
return
err
}
...
...
cmd/helm/helm.go
View file @
6058cad0
...
...
@@ -4,6 +4,7 @@ import (
"os"
"github.com/codegangsta/cli"
"github.com/deis/helm-dm/dm"
"github.com/deis/helm-dm/format"
)
...
...
@@ -24,6 +25,11 @@ func main() {
EnvVar
:
"HELM_HOST"
,
Value
:
"https://localhost:8181/FIXME_NOT_RIGHT"
,
},
cli
.
IntFlag
{
Name
:
"timeout"
,
Usage
:
"Time in seconds to wait for response"
,
Value
:
10
,
},
cli
.
BoolFlag
{
Name
:
"debug"
,
Usage
:
"Enable verbose debugging output"
,
...
...
@@ -184,3 +190,10 @@ func run(c *cli.Context, f func(c *cli.Context) error) {
os
.
Exit
(
1
)
}
}
func
client
(
c
*
cli
.
Context
)
*
dm
.
Client
{
host
:=
c
.
GlobalString
(
"host"
)
debug
:=
c
.
GlobalBool
(
"debug"
)
timeout
:=
c
.
GlobalInt
(
"timeout"
)
return
dm
.
NewClient
(
host
)
.
SetDebug
(
debug
)
.
SetTimeout
(
timeout
)
}
cmd/helm/list.go
View file @
6058cad0
...
...
@@ -2,7 +2,6 @@ package main
import
(
"github.com/codegangsta/cli"
"github.com/deis/helm-dm/dm"
"github.com/deis/helm-dm/format"
)
...
...
@@ -15,9 +14,7 @@ func listCmd() cli.Command {
}
func
list
(
c
*
cli
.
Context
)
error
{
host
:=
c
.
GlobalString
(
"host"
)
client
:=
dm
.
NewClient
(
host
)
.
SetDebug
(
c
.
GlobalBool
(
"debug"
))
list
,
err
:=
client
.
ListDeployments
()
list
,
err
:=
client
(
c
)
.
ListDeployments
()
if
err
!=
nil
{
return
err
}
...
...
dm/client.go
View file @
6058cad0
...
...
@@ -69,6 +69,12 @@ func (c *Client) SetTransport(tr http.RoundTripper) *Client {
return
c
}
// SetTimeout sets a timeout for http connections
func
(
c
*
Client
)
SetTimeout
(
seconds
int
)
*
Client
{
c
.
HTTPTimeout
=
time
.
Duration
(
time
.
Duration
(
seconds
)
*
time
.
Second
)
return
c
}
// url constructs the URL.
func
(
c
*
Client
)
url
(
rawurl
string
)
(
string
,
error
)
{
u
,
err
:=
url
.
Parse
(
rawurl
)
...
...
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