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
84146a29
Commit
84146a29
authored
Feb 25, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(deploy): upload chart if its local
parent
b4c31808
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
9 deletions
+30
-9
deploy.go
cmd/helm/deploy.go
+18
-1
client.go
dm/client.go
+12
-8
No files found.
cmd/helm/deploy.go
View file @
84146a29
...
...
@@ -2,6 +2,7 @@ package main
import
(
"io/ioutil"
"os"
"github.com/codegangsta/cli"
"github.com/kubernetes/deployment-manager/common"
...
...
@@ -60,7 +61,17 @@ func deploy(c *cli.Context) error {
// file with it.
args
:=
c
.
Args
()
if
len
(
args
)
>
0
{
cfg
.
Resources
[
0
]
.
Type
=
args
[
0
]
cname
:=
args
[
0
]
if
isLocalChart
(
cname
)
{
// If we get here, we need to first package then upload the chart.
loc
,
err
:=
doUpload
(
cname
,
""
,
c
)
if
err
!=
nil
{
return
err
}
cfg
.
Resources
[
0
]
.
Name
=
loc
}
else
{
cfg
.
Resources
[
0
]
.
Type
=
cname
}
}
// Override the name if one is passed in.
...
...
@@ -82,6 +93,12 @@ func deploy(c *cli.Context) error {
return
client
(
c
)
.
PostDeployment
(
cfg
)
}
// isLocalChart returns true if the given path can be statted.
func
isLocalChart
(
path
string
)
bool
{
_
,
err
:=
os
.
Stat
(
path
)
return
err
==
nil
}
// loadConfig loads a file into a common.Configuration.
func
loadConfig
(
c
*
common
.
Configuration
,
filename
string
)
error
{
data
,
err
:=
ioutil
.
ReadFile
(
filename
)
...
...
dm/client.go
View file @
84146a29
...
...
@@ -174,18 +174,21 @@ func (c *Client) ListDeployments() ([]string, error) {
return
l
,
nil
}
// UploadChart sends a chart to DM for deploying.
func
(
c
*
Client
)
PostChart
(
filename
,
deployname
string
)
error
{
// PostChart sends a chart to DM for deploying.
//
// This returns the location for the new chart, typically of the form
// `helm:repo/bucket/name-version.tgz`.
func
(
c
*
Client
)
PostChart
(
filename
,
deployname
string
)
(
string
,
error
)
{
f
,
err
:=
os
.
Open
(
filename
)
if
err
!=
nil
{
return
err
return
""
,
err
}
u
,
err
:=
c
.
url
(
"/v2/charts"
)
request
,
err
:=
http
.
NewRequest
(
"POST"
,
u
,
f
)
if
err
!=
nil
{
f
.
Close
()
return
err
return
""
,
err
}
// There is an argument to be made for using the legacy x-octet-stream for
...
...
@@ -206,7 +209,7 @@ func (c *Client) PostChart(filename, deployname string) error {
response
,
err
:=
client
.
Do
(
request
)
if
err
!=
nil
{
return
err
return
""
,
err
}
// We only want 201 CREATED. Admittedly, we could accept 200 and 202.
...
...
@@ -214,12 +217,13 @@ func (c *Client) PostChart(filename, deployname string) error {
body
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
response
.
Body
.
Close
()
if
err
!=
nil
{
return
err
return
""
,
err
}
return
&
HTTPError
{
StatusCode
:
response
.
StatusCode
,
Message
:
string
(
body
),
URL
:
request
.
URL
}
return
""
,
&
HTTPError
{
StatusCode
:
response
.
StatusCode
,
Message
:
string
(
body
),
URL
:
request
.
URL
}
}
return
nil
loc
:=
response
.
Header
.
Get
(
"Location"
)
return
loc
,
nil
}
// HTTPError is an error caused by an unexpected HTTP status code.
...
...
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