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
9b494f55
Commit
9b494f55
authored
Feb 05, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(deploy): deploy charts instead of templates
parent
9b9705e7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
21 deletions
+102
-21
deploy.go
cmd/helm/deploy.go
+30
-13
deploy.go
deploy/deploy.go
+25
-8
client.go
dm/client.go
+47
-0
No files found.
cmd/helm/deploy.go
View file @
9b494f55
package
main
import
(
"encoding/json"
"errors"
"os"
"github.com/codegangsta/cli"
dep
"github.com/deis/helm-dm/deploy"
"github.com/deis/helm-dm/format"
"github.com/kubernetes/deployment-manager/chart"
)
func
deploy
(
c
*
cli
.
Context
)
error
{
...
...
@@ -35,7 +35,7 @@ func deploy(c *cli.Context) error {
d
.
Input
=
os
.
Stdin
}
//
return doDeploy(d, c.GlobalString("host"), c.Bool("dry-run"))
return
doDeploy
(
d
,
c
.
GlobalString
(
"host"
),
c
.
Bool
(
"dry-run"
))
return
nil
}
...
...
@@ -44,26 +44,43 @@ func doDeploy(cfg *dep.Deployment, host string, dry bool) error {
return
errors
.
New
(
"A filename must be specified. For a tar archive, this is the name of the root template in the archive."
)
}
if
err
:=
cfg
.
Prepare
();
err
!=
nil
{
format
.
Error
(
"Failed to prepare deployment: %s"
,
err
)
fi
,
err
:=
os
.
Stat
(
cfg
.
Filename
)
if
err
!=
nil
{
return
err
}
// For a dry run, print the template and exit.
if
dry
{
format
.
Info
(
"Template prepared for %s"
,
cfg
.
Template
.
Name
)
data
,
err
:=
json
.
MarshalIndent
(
cfg
.
Template
,
""
,
"
\t
"
)
if
fi
.
IsDir
()
{
format
.
Info
(
"Chart is directory"
)
c
,
err
:=
chart
.
LoadDir
(
cfg
.
Filename
)
if
err
!=
nil
{
return
err
}
//tdir, err := ioutil.TempDir("", "helm-")
//if err != nil {
//format.Warn("Could not create temporary directory. Using .")
//tdir = "."
//} else {
//defer os.RemoveAll(tdir)
//}
tdir
:=
"."
tfile
,
err
:=
chart
.
Save
(
c
,
tdir
)
if
err
!=
nil
{
return
err
}
format
.
Msg
(
string
(
data
))
return
nil
cfg
.
Filename
=
tfile
}
if
err
:=
cfg
.
Commit
(
host
);
err
!=
nil
{
format
.
Error
(
"Failed to commit deployment: %s"
,
err
)
return
err
if
!
dry
{
if
err
:=
uploadTar
(
cfg
.
Filename
);
err
!=
nil
{
return
err
}
}
return
nil
}
func
uploadTar
(
filename
string
)
error
{
return
nil
}
deploy/deploy.go
View file @
9b494f55
...
...
@@ -8,6 +8,7 @@ import (
//"strings"
//"github.com/ghodss/yaml"
"github.com/kubernetes/deployment-manager/chart"
"github.com/kubernetes/deployment-manager/common"
//"github.com/kubernetes/deployment-manager/expandybird/expander"
//"github.com/kubernetes/deployment-manager/registry"
...
...
@@ -41,6 +42,8 @@ type Deployment struct {
// The template, typically generated by the Deployment.
Template
*
common
.
Template
lchart
*
chart
.
Chart
}
// Prepare loads templates and checks for client-side errors.
...
...
@@ -48,23 +51,37 @@ type Deployment struct {
// This will generate the Template based on other information.
func
(
d
*
Deployment
)
Prepare
()
error
{
/*
tpl, err := d.resolveTemplate()
// Is Filename a local dir, a local file, or a remote URL?
fi
,
err
:=
os
.
Stat
(
d
.
Filename
)
if
err
!=
nil
{
return
err
}
var
c
*
chart
.
Chart
if
fi
.
IsDir
()
{
c
,
err
=
chart
.
LoadDir
(
d
.
Filename
)
if
err
!=
nil
{
return
err
}
// If a deployment Name is specified, set that explicitly.
if
d.Name != ""
{
tpl.Name = d.Name
}
else
{
c
,
err
=
chart
.
Load
(
d
.
Filename
)
if
err
!=
nil
{
return
err
}
}
d.Template = tpl
*/
// Override name if we need to
// Properties
d
.
lchart
=
c
return
nil
}
func
(
d
*
Deployment
)
Chart
()
*
chart
.
Chart
{
return
d
.
lchart
}
// Commit prepares the Deployment and then commits it to the remote processor.
func
(
d
*
Deployment
)
Commit
(
host
string
)
error
{
return
nil
...
...
dm/client.go
View file @
9b494f55
...
...
@@ -6,6 +6,8 @@ import (
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
"time"
"github.com/ghodss/yaml"
...
...
@@ -106,3 +108,48 @@ func (c *Client) ListDeployments() error {
fmt
.
Printf
(
"%#v
\n
"
,
d
)
return
nil
}
func
(
c
*
Client
)
DeployChart
(
filename
,
deployname
string
)
error
{
f
,
err
:=
os
.
Open
(
filename
)
if
err
!=
nil
{
return
err
}
defer
f
.
Close
()
request
,
err
:=
http
.
NewRequest
(
"POST"
,
"/v2/deployments/"
,
f
)
// There is an argument to be made for using the legacy x-octet-stream for
// this. But since we control both sides, we should use the standard one.
// Also, gzip (x-compress) is usually treated as a content encoding. In this
// case it probably is not, but it makes more sense to follow the standard,
// even though we don't assume the remote server will strip it off.
request
.
Header
.
Add
(
"Content-Type"
,
"application/x-tar"
)
request
.
Header
.
Add
(
"Content-Encoding"
,
"gzip"
)
request
.
Header
.
Add
(
"X-Deployment-Name"
,
deployname
)
request
.
Header
.
Add
(
"X-Chart-Name"
,
filepath
.
Base
(
filename
))
client
:=
http
.
Client
{
Timeout
:
time
.
Duration
(
time
.
Duration
(
DefaultHTTPTimeout
)
*
time
.
Second
),
Transport
:
c
.
Transport
,
}
response
,
err
:=
client
.
Do
(
request
)
if
err
!=
nil
{
return
err
}
body
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
response
.
Body
.
Close
()
if
err
!=
nil
{
return
err
}
// FIXME: We only want 200 OK or 204(?) CREATED
if
response
.
StatusCode
<
http
.
StatusOK
||
response
.
StatusCode
>=
http
.
StatusMultipleChoices
{
message
:=
fmt
.
Sprintf
(
"status code: %d status: %s : %s"
,
response
.
StatusCode
,
response
.
Status
,
body
)
return
fmt
.
Errorf
(
"Failed to post: %s"
,
message
)
}
return
nil
}
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