From a7401137d068d56570e84661366a9ee4a8e5dd56 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 6 Jan 2016 13:46:03 -0800 Subject: [PATCH 01/73] Initial commit. --- .gitignore | 1 + Makefile | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 11 ++++++++ glide.lock | 4 +++ glide.yaml | 2 ++ 5 files changed, 101 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 glide.lock create mode 100644 glide.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..48b8bf907 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor/ diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..ab20e9dd3 --- /dev/null +++ b/Makefile @@ -0,0 +1,83 @@ +ifndef GOPATH +$(error No GOPATH set) +endif + +BIN_DIR := bin +DIST_DIR := _dist +GO_PACKAGES := action chart config dependency log manifest release plugins/sec plugins/example codec +MAIN_GO := helm.go +HELM_BIN := $(BIN_DIR)/helm +PATH_WITH_HELM = PATH="$(shell pwd)/$(BIN_DIR):$(PATH)" + +VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null)+$(shell git rev-parse --short HEAD) + +export GO15VENDOREXPERIMENT=1 + +ifndef VERSION + VERSION := git-$(shell git rev-parse --short HEAD) +endif + +build: $(MAIN_GO) + go build -o $(HELM_BIN) -ldflags "-X github.com/helm/helm/cli.version=${VERSION}" $< + +bootstrap: + go get -u github.com/golang/lint/golint github.com/mitchellh/gox + glide install + +build-all: + gox -verbose \ + -ldflags "-X main.version=${VERSION}" \ + -os="linux darwin " \ + -arch="amd64 386" \ + -output="$(DIST_DIR)/{{.OS}}-{{.Arch}}/{{.Dir}}" . + +clean: + rm -rf $(DIST_DIR) $(BIN_DIR) + +dist: build-all + @cd $(DIST_DIR) && \ + find * -type d -exec zip -jr helm-$(VERSION)-{}.zip {} \; && \ + cd - + +install: build + install -d ${DESTDIR}/usr/local/bin/ + install -m 755 $(HELM_BIN) ${DESTDIR}/usr/local/bin/helm + +prep-bintray-json: +# TRAVIS_TAG is set to the tag name if the build is a tag +ifdef TRAVIS_TAG + @jq '.version.name |= "$(VERSION)"' _scripts/ci/bintray-template.json | \ + jq '.package.repo |= "helm"' > _scripts/ci/bintray-ci.json +else + @jq '.version.name |= "$(VERSION)"' _scripts/ci/bintray-template.json \ + > _scripts/ci/bintray-ci.json +endif + +quicktest: + $(PATH_WITH_HELM) go test -short ./ $(addprefix ./,$(GO_PACKAGES)) + +test: test-style + $(PATH_WITH_HELM) go test -v ./ $(addprefix ./,$(GO_PACKAGES)) + +test-style: + @if [ $(shell gofmt -e -l -s *.go $(GO_PACKAGES)) ]; then \ + echo "gofmt check failed:"; gofmt -e -l -s *.go $(GO_PACKAGES); exit 1; \ + fi + @for i in . $(GO_PACKAGES); do \ + golint $$i; \ + done + @for i in . $(GO_PACKAGES); do \ + go vet github.com/helm/helm/$$i; \ + done + +.PHONY: bootstrap \ + build \ + build-all \ + clean \ + dist \ + install \ + prep-bintray-json \ + quicktest \ + test \ + test-charts \ + test-style diff --git a/README.md b/README.md new file mode 100644 index 000000000..83afcc1bc --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Helm + +Experimental Helm fork. + +## To Build + +Go 1.5, Glide >0.8, Make + +``` +$ make build +``` diff --git a/glide.lock b/glide.lock new file mode 100644 index 000000000..485affe99 --- /dev/null +++ b/glide.lock @@ -0,0 +1,4 @@ +hash: 9ec7498a0fe304c2d06e42e1d233ee43cfc090abdd0523c102136831263233b6 +updated: 2016-01-06T13:45:44.400476304-08:00 +imports: [] +devImports: [] diff --git a/glide.yaml b/glide.yaml new file mode 100644 index 000000000..84ff11017 --- /dev/null +++ b/glide.yaml @@ -0,0 +1,2 @@ +package: github.com/engineyard/helm-dm +import: [] From 546ee53ac070039845f33ace396ad26b02a8ea49 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 6 Jan 2016 13:46:23 -0800 Subject: [PATCH 02/73] Add license. --- LICENSE | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..a117663a2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright 2015 Engine Yard, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. From 69e6256885a237c2e6c7d9dce6d4a79203c60539 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 6 Jan 2016 13:57:49 -0800 Subject: [PATCH 03/73] feat(*): add scaffolded cli app. --- cmd/helm.go | 39 +++++++++++++++++++++++++++++++++++++++ glide.lock | 8 +++++--- glide.yaml | 3 ++- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 cmd/helm.go diff --git a/cmd/helm.go b/cmd/helm.go new file mode 100644 index 000000000..6e79f2b18 --- /dev/null +++ b/cmd/helm.go @@ -0,0 +1,39 @@ +package main + +import ( + "os" + + "github.com/codegangsta/cli" +) + +var version = "0.0.1" + +func main() { + app := cli.NewApp() + app.Name = "helm" + app.Version = version + app.Usage = `Deploy and manage packages.` + app.Commands = commands() + + app.Run(os.Args) +} + +func commands() []cli.Command { + return []cli.Command{ + { + Name: "install", + }, + { + Name: "target", + }, + { + Name: "doctor", + }, + { + Name: "deploy", + }, + { + Name: "search", + }, + } +} diff --git a/glide.lock b/glide.lock index 485affe99..b4845d369 100644 --- a/glide.lock +++ b/glide.lock @@ -1,4 +1,6 @@ -hash: 9ec7498a0fe304c2d06e42e1d233ee43cfc090abdd0523c102136831263233b6 -updated: 2016-01-06T13:45:44.400476304-08:00 -imports: [] +hash: 2f47b12bf634894e182800b5565efd124c6defff6291b60408cbba6a038778ae +updated: 2016-01-06T13:51:49.954407735-08:00 +imports: +- name: github.com/codegangsta/cli + version: c31a7975863e7810c92e2e288a9ab074f9a88f29 devImports: [] diff --git a/glide.yaml b/glide.yaml index 84ff11017..a9d697098 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,2 +1,3 @@ package: github.com/engineyard/helm-dm -import: [] +import: +- package: github.com/codegangsta/cli From 9cc3688e4ce61a72b794c0b98613b20ca6f49926 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 6 Jan 2016 14:34:41 -0800 Subject: [PATCH 04/73] feat(*): add DM client, fix makefile --- .gitignore | 1 + Makefile | 8 ++--- dm/client.go | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ glide.lock | 51 ++++++++++++++++++++++++++++++-- glide.yaml | 4 +++ 5 files changed, 140 insertions(+), 6 deletions(-) create mode 100644 dm/client.go diff --git a/.gitignore b/.gitignore index 48b8bf907..0f34b7d2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ vendor/ +bin/helm diff --git a/Makefile b/Makefile index ab20e9dd3..974e04d5e 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,8 @@ endif BIN_DIR := bin DIST_DIR := _dist -GO_PACKAGES := action chart config dependency log manifest release plugins/sec plugins/example codec -MAIN_GO := helm.go +GO_PACKAGES := cmd dm +MAIN_GO := cmd/helm.go HELM_BIN := $(BIN_DIR)/helm PATH_WITH_HELM = PATH="$(shell pwd)/$(BIN_DIR):$(PATH)" @@ -18,7 +18,7 @@ ifndef VERSION endif build: $(MAIN_GO) - go build -o $(HELM_BIN) -ldflags "-X github.com/helm/helm/cli.version=${VERSION}" $< + go build -o $(HELM_BIN) -ldflags "-X github.com/helm/helm/cmd.version=${VERSION}" $< bootstrap: go get -u github.com/golang/lint/golint github.com/mitchellh/gox @@ -54,7 +54,7 @@ else endif quicktest: - $(PATH_WITH_HELM) go test -short ./ $(addprefix ./,$(GO_PACKAGES)) + $(PATH_WITH_HELM) go test -short $(addprefix ./,$(GO_PACKAGES)) test: test-style $(PATH_WITH_HELM) go test -v ./ $(addprefix ./,$(GO_PACKAGES)) diff --git a/dm/client.go b/dm/client.go new file mode 100644 index 000000000..b05ca62ee --- /dev/null +++ b/dm/client.go @@ -0,0 +1,82 @@ +package dm + +import ( + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "time" + + "github.com/ghodss/yaml" +) + +var DefaultHTTPTimeout time.Duration + +type Client struct { + // Timeout on HTTP connections. + HTTPTimeout time.Duration + // The remote host + Host string + // The protocol. Currently only http and https are supported. + Protocol string +} + +func NewClient(host string) *Client { + return &Client{ + HTTPTimeout: DefaultHTTPTimeout, + Protocol: "https", + Host: host, + } +} + +func (c *Client) url(path string) string { + // TODO: Switch to net.URL + return c.Protocol + "://" + c.Host + "/" + path +} + +// CallService is a low-level function for making an API call. +func (c *Client) CallService(path, method, action string, reader io.ReadCloser) { + u := c.url(path) + + resp := c.callHttp(u, method, action, reader) + var j interface{} + if err := json.Unmarshal([]byte(resp), &j); err != nil { + panic(fmt.Errorf("Failed to parse JSON response from service: %s", resp)) + } + + y, err := yaml.Marshal(j) + if err != nil { + panic(fmt.Errorf("Failed to serialize JSON response from service: %s", resp)) + } + + fmt.Println(string(y)) +} + +func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) string { + request, err := http.NewRequest(method, path, reader) + request.Header.Add("Content-Type", "application/json") + + client := http.Client{ + Timeout: time.Duration(time.Duration(DefaultHTTPTimeout) * time.Second), + } + + response, err := client.Do(request) + if err != nil { + panic(fmt.Errorf("cannot %s: %s\n", action, err)) + } + + defer response.Body.Close() + body, err := ioutil.ReadAll(response.Body) + if err != nil { + panic(fmt.Errorf("cannot %s: %s\n", action, err)) + } + + if response.StatusCode < http.StatusOK || + response.StatusCode >= http.StatusMultipleChoices { + message := fmt.Sprintf("status code: %d status: %s : %s", response.StatusCode, response.Status, body) + panic(fmt.Errorf("cannot %s: %s\n", action, message)) + } + + return string(body) +} diff --git a/glide.lock b/glide.lock index b4845d369..ddd774cc4 100644 --- a/glide.lock +++ b/glide.lock @@ -1,6 +1,53 @@ -hash: 2f47b12bf634894e182800b5565efd124c6defff6291b60408cbba6a038778ae -updated: 2016-01-06T13:51:49.954407735-08:00 +hash: 4cc1aba06a344d43c0c1005d71dc0659ada5d90f0b2235b1d8e8c7352d1251a7 +updated: 2016-01-06T14:30:55.041267875-08:00 imports: - name: github.com/codegangsta/cli version: c31a7975863e7810c92e2e288a9ab074f9a88f29 +- name: github.com/emicklei/go-restful + version: ce94a9f819d7dd2b5599ff0c017b1124595a64fb +- name: github.com/ghodss/yaml + version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee +- name: github.com/golang/glog + version: fca8c8854093a154ff1eb580aae10276ad6b1b5f +- name: github.com/golang/protobuf + version: 2402d76f3d41f928c7902a765dfc872356dd3aad +- name: github.com/google/go-github + version: 63fbbb283ce4913a5ac1b6de7abae50dbf594a04 +- name: github.com/google/go-querystring + version: 2a60fc2ba6c19de80291203597d752e9ba58e4c0 +- name: github.com/gorilla/context + version: 1c83b3eabd45b6d76072b66b746c20815fb2872d +- name: github.com/gorilla/handlers + version: 1af6d56d7cd39d982856bc0cee11142baf392c52 +- name: github.com/gorilla/mux + version: 26a6070f849969ba72b72256e9f14cf519751690 +- name: github.com/gorilla/schema + version: 14c555599c2a4f493c1e13fd1ea6fdf721739028 +- name: github.com/kubernetes/deployment-manager + version: 62f19486073edd020a11922304130f0c5c1dff20 + subpackages: + - /common +- name: github.com/mjibson/appstats + version: 0542d5f0e87ea3a8fa4174322b9532f5d04f9fa8 +- name: golang.org/x/crypto + version: 552e9d568fde9701ea1944fb01c8aadaceaa7353 +- name: golang.org/x/net + version: 1ade16a5450925b7496e1031938175d1f5d30d31 +- name: golang.org/x/oauth2 + version: 2baa8a1b9338cf13d9eeb27696d761155fa480be +- name: golang.org/x/text + version: cf4986612c83df6c55578ba198316d1684a9a287 +- name: google.golang.com/appengine + version: "" + repo: https://google.golang.com/appengine +- name: google.golang.org/api + version: f5b7ec483f357a211c03c6722a840444c2d395dc +- name: google.golang.org/appengine + version: 54bf9150c922186bfc45a00bf9dfcb91a5063275 +- name: google.golang.org/cloud + version: 1bff51b8fae8d33cb3dab8f7858c266ce001ee3e +- name: google.golang.org/grpc + version: 78905999da08d7f87d5dd11608fa79ff8700daa8 +- name: gopkg.in/yaml.v2 + version: f7716cbe52baa25d2e9b0d0da546fcf909fc16b4 devImports: [] diff --git a/glide.yaml b/glide.yaml index a9d697098..bd597f0ec 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,3 +1,7 @@ package: github.com/engineyard/helm-dm import: - package: github.com/codegangsta/cli +- package: github.com/kubernetes/deployment-manager + subpackages: + - /common +- package: github.com/ghodss/yaml From d3dfdc29c53925992c84d385bdbbcf752d7cfdda Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 6 Jan 2016 14:45:26 -0800 Subject: [PATCH 05/73] fix(*): remove panics from dm.Client --- dm/client.go | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/dm/client.go b/dm/client.go index b05ca62ee..b32bb828e 100644 --- a/dm/client.go +++ b/dm/client.go @@ -11,8 +11,10 @@ import ( "github.com/ghodss/yaml" ) -var DefaultHTTPTimeout time.Duration +// The default HTTP timeout +var DefaultHTTPTimeout time.Duration = time.Second * 10 +// Client is a DM client. type Client struct { // Timeout on HTTP connections. HTTPTimeout time.Duration @@ -22,6 +24,7 @@ type Client struct { Protocol string } +// NewClient creates a new DM client. Host name is required. func NewClient(host string) *Client { return &Client{ HTTPTimeout: DefaultHTTPTimeout, @@ -30,30 +33,39 @@ func NewClient(host string) *Client { } } +// url constructs the URL. func (c *Client) url(path string) string { // TODO: Switch to net.URL return c.Protocol + "://" + c.Host + "/" + path } // CallService is a low-level function for making an API call. -func (c *Client) CallService(path, method, action string, reader io.ReadCloser) { +// +// This calls the service and then unmarshals the returned data into dest. +func (c *Client) CallService(path, method, action string, dest interface{}, reader io.ReadCloser) error { u := c.url(path) - resp := c.callHttp(u, method, action, reader) - var j interface{} - if err := json.Unmarshal([]byte(resp), &j); err != nil { - panic(fmt.Errorf("Failed to parse JSON response from service: %s", resp)) + resp, err := c.callHttp(u, method, action, reader) + if err != nil { + return err + } + if err := json.Unmarshal([]byte(resp), dest); err != nil { + return fmt.Errorf("Failed to parse JSON response from service: %s", resp) } - y, err := yaml.Marshal(j) + // From here down is just printing the data. + + y, err := yaml.Marshal(dest) if err != nil { - panic(fmt.Errorf("Failed to serialize JSON response from service: %s", resp)) + return fmt.Errorf("Failed to serialize JSON response from service: %s", resp) } fmt.Println(string(y)) + return nil } -func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) string { +// callHttp is a low-level primative for executing HTTP operations. +func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (string, error) { request, err := http.NewRequest(method, path, reader) request.Header.Add("Content-Type", "application/json") @@ -63,20 +75,20 @@ func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) str response, err := client.Do(request) if err != nil { - panic(fmt.Errorf("cannot %s: %s\n", action, err)) + return "", fmt.Errorf("cannot %s: %s\n", action, err) } defer response.Body.Close() body, err := ioutil.ReadAll(response.Body) if err != nil { - panic(fmt.Errorf("cannot %s: %s\n", action, err)) + return "", fmt.Errorf("cannot %s: %s\n", action, err) } if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices { message := fmt.Sprintf("status code: %d status: %s : %s", response.StatusCode, response.Status, body) - panic(fmt.Errorf("cannot %s: %s\n", action, message)) + return "", fmt.Errorf("cannot %s: %s\n", action, message) } - return string(body) + return string(body), nil } From 9e1dbeaa483b6887e81e3194dd3ed477bf6ad64b Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 6 Jan 2016 15:19:45 -0800 Subject: [PATCH 06/73] feat(*): stub out install --- cmd/helm.go | 5 +- cmd/install.go | 17 ++++ dm/install.go | 171 ++++++++++++++++++++++++++++++++++++++++ format/messages.go | 22 ++++++ glide.yaml | 2 +- kubectl/cluster_info.go | 12 +++ kubectl/command.go | 32 ++++++++ kubectl/create.go | 29 +++++++ kubectl/create_test.go | 22 ++++++ kubectl/delete.go | 25 ++++++ kubectl/get.go | 27 +++++++ kubectl/get_test.go | 17 ++++ kubectl/kubectl.go | 25 ++++++ kubectl/kubectl_test.go | 12 +++ 14 files changed, 416 insertions(+), 2 deletions(-) create mode 100644 cmd/install.go create mode 100644 dm/install.go create mode 100644 format/messages.go create mode 100644 kubectl/cluster_info.go create mode 100644 kubectl/command.go create mode 100644 kubectl/create.go create mode 100644 kubectl/create_test.go create mode 100644 kubectl/delete.go create mode 100644 kubectl/get.go create mode 100644 kubectl/get_test.go create mode 100644 kubectl/kubectl.go create mode 100644 kubectl/kubectl_test.go diff --git a/cmd/helm.go b/cmd/helm.go index 6e79f2b18..36d08d642 100644 --- a/cmd/helm.go +++ b/cmd/helm.go @@ -21,7 +21,10 @@ func main() { func commands() []cli.Command { return []cli.Command{ { - Name: "install", + Name: "install", + Usage: "Initialize the client and install DM on Kubernetes.", + Description: ``, + Action: func(c *cli.Context) { install() }, }, { Name: "target", diff --git a/cmd/install.go b/cmd/install.go new file mode 100644 index 000000000..5abd44b2a --- /dev/null +++ b/cmd/install.go @@ -0,0 +1,17 @@ +package main + +import ( + "github.com/deis/helm-dm/dm" + "github.com/deis/helm-dm/format" + "github.com/deis/helm-dm/kubectl" +) + +func install() error { + runner := &kubectl.PrintRunner{} + out, err := dm.Install(runner) + if err != nil { + format.Error("Error installing: %s %s", out, err) + } + format.Msg(out) + return nil +} diff --git a/dm/install.go b/dm/install.go new file mode 100644 index 000000000..65899bb61 --- /dev/null +++ b/dm/install.go @@ -0,0 +1,171 @@ +package dm + +import ( + "github.com/deis/helm-dm/kubectl" +) + +// Install uses kubectl to install the base DM. +// +// Returns the string output received from the operation, and an error if the +// command failed. +func Install(runner kubectl.Runner) (string, error) { + o, err := runner.Create([]byte(InstallYAML), "dm") + return string(o), err +} + +// InstallYAML is the installation YAML for DM. +const InstallYAML = ` +###################################################################### +# Copyright 2015 The Kubernetes Authors All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.apache.org/licenses/LICENSE-2.0 +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +###################################################################### + +--- +apiVersion: v1 +kind: Namespace +metadata: + labels: + app: dm + name: dm-namespace + name: dm +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: dm + name: expandybird-service + name: expandybird-service + namespace: dm +spec: + ports: + - name: expandybird + port: 8081 + targetPort: 8080 + selector: + app: dm + name: expandybird +--- +apiVersion: v1 +kind: ReplicationController +metadata: + labels: + app: dm + name: expandybird-rc + name: expandybird-rc + namespace: dm +spec: + replicas: 2 + selector: + app: dm + name: expandybird + template: + metadata: + labels: + app: dm + name: expandybird + spec: + containers: + - env: [] + image: gcr.io/dm-k8s-testing/expandybird:latest + name: expandybird + ports: + - containerPort: 8080 + name: expandybird +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: dm + name: resourcifier-service + name: resourcifier-service + namespace: dm +spec: + ports: + - name: resourcifier + port: 8082 + targetPort: 8080 + selector: + app: dm + name: resourcifier +--- +apiVersion: v1 +kind: ReplicationController +metadata: + labels: + app: dm + name: resourcifier-rc + name: resourcifier-rc + namespace: dm +spec: + replicas: 2 + selector: + app: dm + name: resourcifier + template: + metadata: + labels: + app: dm + name: resourcifier + spec: + containers: + - env: [] + image: gcr.io/dm-k8s-testing/resourcifier:latest + name: resourcifier + ports: + - containerPort: 8080 + name: resourcifier +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: dm + name: manager-service + name: manager-service + namespace: dm +spec: + ports: + - name: manager + port: 8080 + targetPort: 8080 + selector: + app: dm + name: manager +--- +apiVersion: v1 +kind: ReplicationController +metadata: + labels: + app: dm + name: manager-rc + name: manager-rc + namespace: dm +spec: + replicas: 1 + selector: + app: dm + name: manager + template: + metadata: + labels: + app: dm + name: manager + spec: + containers: + - env: [] + image: gcr.io/dm-k8s-testing/manager:latest + name: manager + ports: + - containerPort: 8080 + name: manager +` diff --git a/format/messages.go b/format/messages.go new file mode 100644 index 000000000..0eec683e1 --- /dev/null +++ b/format/messages.go @@ -0,0 +1,22 @@ +package format + +import ( + "fmt" + "os" +) + +// This is all just placeholder. + +func Error(msg string, v ...interface{}) { + msg = "[ERROR]" + msg + "\n" + fmt.Fprintf(os.Stderr, msg, v...) +} + +func Info(msg string, v ...interface{}) { + msg = "[INFO]" + msg + "\n" + fmt.Fprintf(os.Stdout, msg, v...) +} + +func Msg(msg string, v ...interface{}) { + fmt.Fprintf(os.Stdout, msg, v...) +} diff --git a/glide.yaml b/glide.yaml index bd597f0ec..35922b0fc 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,4 +1,4 @@ -package: github.com/engineyard/helm-dm +package: github.com/deis/helm-dm import: - package: github.com/codegangsta/cli - package: github.com/kubernetes/deployment-manager diff --git a/kubectl/cluster_info.go b/kubectl/cluster_info.go new file mode 100644 index 000000000..9449319c0 --- /dev/null +++ b/kubectl/cluster_info.go @@ -0,0 +1,12 @@ +package kubectl + +// ClusterInfo returns Kubernetes cluster info +func (r RealRunner) ClusterInfo() ([]byte, error) { + return command("cluster-info").CombinedOutput() +} + +// ClusterInfo returns the commands to kubectl +func (r PrintRunner) ClusterInfo() ([]byte, error) { + cmd := command("cluster-info") + return []byte(cmd.String()), nil +} diff --git a/kubectl/command.go b/kubectl/command.go new file mode 100644 index 000000000..b36e0ad33 --- /dev/null +++ b/kubectl/command.go @@ -0,0 +1,32 @@ +package kubectl + +import ( + "bytes" + "fmt" + "io/ioutil" + "os/exec" + "strings" +) + +type cmd struct { + *exec.Cmd +} + +func command(args ...string) *cmd { + return &cmd{exec.Command(Path, args...)} +} + +func assignStdin(cmd *cmd, in []byte) { + cmd.Stdin = bytes.NewBuffer(in) +} + +func (c *cmd) String() string { + var stdin string + + if c.Stdin != nil { + b, _ := ioutil.ReadAll(c.Stdin) + stdin = fmt.Sprintf("< %s", string(b)) + } + + return fmt.Sprintf("[CMD] %s %s", strings.Join(c.Args, " "), stdin) +} diff --git a/kubectl/create.go b/kubectl/create.go new file mode 100644 index 000000000..bd903b740 --- /dev/null +++ b/kubectl/create.go @@ -0,0 +1,29 @@ +package kubectl + +// Create uploads a chart to Kubernetes +func (r RealRunner) Create(stdin []byte, ns string) ([]byte, error) { + args := []string{"create", "-f", "-"} + + if ns != "" { + args = append([]string{"--namespace=" + ns}, args...) + } + + cmd := command(args...) + assignStdin(cmd, stdin) + + return cmd.CombinedOutput() +} + +// Create returns the commands to kubectl +func (r PrintRunner) Create(stdin []byte, ns string) ([]byte, error) { + args := []string{"create", "-f", "-"} + + if ns != "" { + args = append([]string{"--namespace=" + ns}, args...) + } + + cmd := command(args...) + assignStdin(cmd, stdin) + + return []byte(cmd.String()), nil +} diff --git a/kubectl/create_test.go b/kubectl/create_test.go new file mode 100644 index 000000000..0623769d7 --- /dev/null +++ b/kubectl/create_test.go @@ -0,0 +1,22 @@ +package kubectl + +import ( + "testing" +) + +func TestPrintCreate(t *testing.T) { + var client Runner = PrintRunner{} + + expected := `[CMD] kubectl --namespace=default-namespace create -f - < some stdin data` + + out, err := client.Create([]byte("some stdin data"), "default-namespace") + if err != nil { + t.Error(err) + } + + actual := string(out) + + if expected != actual { + t.Fatalf("actual %s != expected %s", actual, expected) + } +} diff --git a/kubectl/delete.go b/kubectl/delete.go new file mode 100644 index 000000000..903442585 --- /dev/null +++ b/kubectl/delete.go @@ -0,0 +1,25 @@ +package kubectl + +// Delete removes a chart from Kubernetes. +func (r RealRunner) Delete(name, ktype, ns string) ([]byte, error) { + + args := []string{"delete", ktype, name} + + if ns != "" { + args = append([]string{"--namespace=" + ns}, args...) + } + return command(args...).CombinedOutput() +} + +// Delete returns the commands to kubectl +func (r PrintRunner) Delete(name, ktype, ns string) ([]byte, error) { + + args := []string{"delete", ktype, name} + + if ns != "" { + args = append([]string{"--namespace=" + ns}, args...) + } + + cmd := command(args...) + return []byte(cmd.String()), nil +} diff --git a/kubectl/get.go b/kubectl/get.go new file mode 100644 index 000000000..bacef13d5 --- /dev/null +++ b/kubectl/get.go @@ -0,0 +1,27 @@ +package kubectl + +// Get returns Kubernetes resources +func (r RealRunner) Get(stdin []byte, ns string) ([]byte, error) { + args := []string{"get", "-f", "-"} + + if ns != "" { + args = append([]string{"--namespace=" + ns}, args...) + } + cmd := command(args...) + assignStdin(cmd, stdin) + + return cmd.CombinedOutput() +} + +// Get returns the commands to kubectl +func (r PrintRunner) Get(stdin []byte, ns string) ([]byte, error) { + args := []string{"get", "-f", "-"} + + if ns != "" { + args = append([]string{"--namespace=" + ns}, args...) + } + cmd := command(args...) + assignStdin(cmd, stdin) + + return []byte(cmd.String()), nil +} diff --git a/kubectl/get_test.go b/kubectl/get_test.go new file mode 100644 index 000000000..532724a20 --- /dev/null +++ b/kubectl/get_test.go @@ -0,0 +1,17 @@ +package kubectl + +import ( + "testing" +) + +func TestGet(t *testing.T) { + Client = TestRunner{ + out: []byte("running the get command"), + } + + expects := "running the get command" + out, _ := Client.Get([]byte{}, "") + if string(out) != expects { + t.Errorf("%s != %s", string(out), expects) + } +} diff --git a/kubectl/kubectl.go b/kubectl/kubectl.go new file mode 100644 index 000000000..466944398 --- /dev/null +++ b/kubectl/kubectl.go @@ -0,0 +1,25 @@ +package kubectl + +// Path is the path of the kubectl binary +var Path = "kubectl" + +// Runner is an interface to wrap kubectl convenience methods +type Runner interface { + // ClusterInfo returns Kubernetes cluster info + ClusterInfo() ([]byte, error) + // Create uploads a chart to Kubernetes + Create([]byte, string) ([]byte, error) + // Delete removes a chart from Kubernetes. + Delete(string, string, string) ([]byte, error) + // Get returns Kubernetes resources + Get([]byte, string) ([]byte, error) +} + +// RealRunner implements Runner to execute kubectl commands +type RealRunner struct{} + +// PrintRunner implements Runner to return a []byte of the command to be executed +type PrintRunner struct{} + +// Client stores the instance of Runner +var Client Runner = RealRunner{} diff --git a/kubectl/kubectl_test.go b/kubectl/kubectl_test.go new file mode 100644 index 000000000..453667330 --- /dev/null +++ b/kubectl/kubectl_test.go @@ -0,0 +1,12 @@ +package kubectl + +type TestRunner struct { + Runner + + out []byte + err error +} + +func (r TestRunner) Get(stdin []byte, ns string) ([]byte, error) { + return r.out, r.err +} From 8d6007a7d11462d8d312b137bec18fca4f22f7a0 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 6 Jan 2016 17:05:18 -0800 Subject: [PATCH 07/73] feat(*): install DM --- cmd/helm.go | 14 +++++++++++++- cmd/install.go | 16 ++++++++++++++-- dm/install.go | 13 +++++++++++++ format/messages.go | 4 ++-- kubectl/get.go | 21 +++++++++++++++++++++ kubectl/kubectl.go | 7 +++++++ 6 files changed, 70 insertions(+), 5 deletions(-) diff --git a/cmd/helm.go b/cmd/helm.go index 36d08d642..8821160bf 100644 --- a/cmd/helm.go +++ b/cmd/helm.go @@ -4,6 +4,7 @@ import ( "os" "github.com/codegangsta/cli" + "github.com/deis/helm-dm/format" ) var version = "0.0.1" @@ -24,7 +25,18 @@ func commands() []cli.Command { Name: "install", Usage: "Initialize the client and install DM on Kubernetes.", Description: ``, - Action: func(c *cli.Context) { install() }, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Show what would be installed, but don't install anything.", + }, + }, + Action: func(c *cli.Context) { + if err := install(c.Bool("dry-run")); err != nil { + format.Error(err.Error()) + os.Exit(1) + } + }, }, { Name: "target", diff --git a/cmd/install.go b/cmd/install.go index 5abd44b2a..1d44be082 100644 --- a/cmd/install.go +++ b/cmd/install.go @@ -1,13 +1,25 @@ package main import ( + "errors" + "github.com/deis/helm-dm/dm" "github.com/deis/helm-dm/format" "github.com/deis/helm-dm/kubectl" ) -func install() error { - runner := &kubectl.PrintRunner{} +var ErrAlreadyInstalled error = errors.New("Already Installed") + +func install(dryRun bool) error { + var runner kubectl.Runner + if dryRun { + runner = &kubectl.PrintRunner{} + } else { + runner = &kubectl.RealRunner{} + if dm.IsInstalled(runner) { + return ErrAlreadyInstalled + } + } out, err := dm.Install(runner) if err != nil { format.Error("Error installing: %s %s", out, err) diff --git a/dm/install.go b/dm/install.go index 65899bb61..ad2aabb75 100644 --- a/dm/install.go +++ b/dm/install.go @@ -1,6 +1,7 @@ package dm import ( + "github.com/deis/helm-dm/format" "github.com/deis/helm-dm/kubectl" ) @@ -13,6 +14,18 @@ func Install(runner kubectl.Runner) (string, error) { return string(o), err } +// IsInstalled checks whether DM has been installed. +func IsInstalled(runner kubectl.Runner) bool { + // Basically, we test "all-or-nothing" here: if this returns without error + // we know that we have both the namespace and the manager API server. + out, err := runner.GetByKind("rc", "manager-rc", "dm") + if err != nil { + format.Error("Installation not found: %s %s", out, err) + return false + } + return true +} + // InstallYAML is the installation YAML for DM. const InstallYAML = ` ###################################################################### diff --git a/format/messages.go b/format/messages.go index 0eec683e1..b90d90851 100644 --- a/format/messages.go +++ b/format/messages.go @@ -8,12 +8,12 @@ import ( // This is all just placeholder. func Error(msg string, v ...interface{}) { - msg = "[ERROR]" + msg + "\n" + msg = "[ERROR] " + msg + "\n" fmt.Fprintf(os.Stderr, msg, v...) } func Info(msg string, v ...interface{}) { - msg = "[INFO]" + msg + "\n" + msg = "[INFO] " + msg + "\n" fmt.Fprintf(os.Stdout, msg, v...) } diff --git a/kubectl/get.go b/kubectl/get.go index bacef13d5..6bdc0e433 100644 --- a/kubectl/get.go +++ b/kubectl/get.go @@ -13,6 +13,17 @@ func (r RealRunner) Get(stdin []byte, ns string) ([]byte, error) { return cmd.CombinedOutput() } +func (r RealRunner) GetByKind(kind, name, ns string) (string, error) { + args := []string{"get", kind, name} + + if ns != "" { + args = append([]string{"--namespace=" + ns}, args...) + } + cmd := command(args...) + o, err := cmd.CombinedOutput() + return string(o), err +} + // Get returns the commands to kubectl func (r PrintRunner) Get(stdin []byte, ns string) ([]byte, error) { args := []string{"get", "-f", "-"} @@ -25,3 +36,13 @@ func (r PrintRunner) Get(stdin []byte, ns string) ([]byte, error) { return []byte(cmd.String()), nil } + +func (r PrintRunner) GetByKind(kind, name, ns string) (string, error) { + args := []string{"get", kind, name} + + if ns != "" { + args = append([]string{"--namespace=" + ns}, args...) + } + cmd := command(args...) + return cmd.String(), nil +} diff --git a/kubectl/kubectl.go b/kubectl/kubectl.go index 466944398..0e51169a4 100644 --- a/kubectl/kubectl.go +++ b/kubectl/kubectl.go @@ -13,6 +13,13 @@ type Runner interface { Delete(string, string, string) ([]byte, error) // Get returns Kubernetes resources Get([]byte, string) ([]byte, error) + + // GetByKind gets an entry by kind, name, and namespace. + // + // If name is omitted, all entries of that kind are returned. + // + // If NS is omitted, the default NS is assumed. + GetByKind(kind, name, ns string) (string, error) } // RealRunner implements Runner to execute kubectl commands From b5ce6939dff1a94b99744ec0525d7c9db92840e2 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 6 Jan 2016 17:14:24 -0800 Subject: [PATCH 08/73] feat(*): add target command --- cmd/helm.go | 16 +++++++++++++++- cmd/target.go | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 cmd/target.go diff --git a/cmd/helm.go b/cmd/helm.go index 8821160bf..d69ebd667 100644 --- a/cmd/helm.go +++ b/cmd/helm.go @@ -39,7 +39,21 @@ func commands() []cli.Command { }, }, { - Name: "target", + Name: "target", + Usage: "Displays information about cluster.", + ArgsUsage: "", + Action: func(c *cli.Context) { + if err := target(c.Bool("dry-run")); err != nil { + format.Error(err.Error()) + os.Exit(1) + } + }, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Only display the underlying kubectl commands.", + }, + }, }, { Name: "doctor", diff --git a/cmd/target.go b/cmd/target.go new file mode 100644 index 000000000..cb06c8e77 --- /dev/null +++ b/cmd/target.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + + "github.com/deis/helm-dm/format" + "github.com/deis/helm-dm/kubectl" +) + +func target(dryRun bool) error { + client := kubectl.Client + if dryRun { + client = kubectl.PrintRunner{} + } + out, err := client.ClusterInfo() + if err != nil { + return fmt.Errorf("%s (%s)", out, err) + } + format.Msg(string(out)) + return nil +} From 063e37525cb8e66a440cdf3b2b0b1e00aa80266a Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 15 Jan 2016 12:53:31 -0700 Subject: [PATCH 09/73] feat(*): add install/deploy command --- cmd/deploy.go | 24 ++++++++ cmd/helm.go | 68 +++++++++++++++++++-- cmd/properties.go | 40 +++++++++++++ deploy/deploy.go | 148 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 276 insertions(+), 4 deletions(-) create mode 100644 cmd/deploy.go create mode 100644 cmd/properties.go create mode 100644 deploy/deploy.go diff --git a/cmd/deploy.go b/cmd/deploy.go new file mode 100644 index 000000000..8126ca4e4 --- /dev/null +++ b/cmd/deploy.go @@ -0,0 +1,24 @@ +package main + +import ( + "errors" + + dep "github.com/deis/helm-dm/deploy" + "github.com/deis/helm-dm/format" +) + +func deploy(cfg *dep.Deployment, dry bool) error { + if dry { + format.Error("Not implemented: --dry-run") + } + if cfg.Filename == "" { + 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.Commit(); err != nil { + format.Error("Failed to commit deployment: %s", err) + return err + } + + return nil +} diff --git a/cmd/helm.go b/cmd/helm.go index d69ebd667..d0edde4bb 100644 --- a/cmd/helm.go +++ b/cmd/helm.go @@ -4,6 +4,7 @@ import ( "os" "github.com/codegangsta/cli" + dep "github.com/deis/helm-dm/deploy" "github.com/deis/helm-dm/format" ) @@ -22,7 +23,7 @@ func main() { func commands() []cli.Command { return []cli.Command{ { - Name: "install", + Name: "init", Usage: "Initialize the client and install DM on Kubernetes.", Description: ``, Flags: []cli.Flag{ @@ -33,7 +34,7 @@ func commands() []cli.Command { }, Action: func(c *cli.Context) { if err := install(c.Bool("dry-run")); err != nil { - format.Error(err.Error()) + format.Error("%s (Run 'helm doctor' for more information)", err) os.Exit(1) } }, @@ -44,7 +45,7 @@ func commands() []cli.Command { ArgsUsage: "", Action: func(c *cli.Context) { if err := target(c.Bool("dry-run")); err != nil { - format.Error(err.Error()) + format.Error("%s (Is the cluster running?)", err) os.Exit(1) } }, @@ -59,7 +60,66 @@ func commands() []cli.Command { Name: "doctor", }, { - Name: "deploy", + Name: "deploy", + Aliases: []string{"install"}, + Usage: "Deploy a chart into the cluster.", + Action: func(c *cli.Context) { + + args := c.Args() + if len(args) < 1 { + format.Error("First argument, filename, is required. Try 'helm deploy --help'") + os.Exit(1) + } + + props, err := parseProperties(c.String("properties")) + if err != nil { + format.Error("Failed to parse properties: %s", err) + os.Exit(1) + } + + d := &dep.Deployment{ + Name: c.String("Name"), + Properties: props, + Filename: args[0], + Imports: args[1:], + Repository: c.String("repository"), + } + + if c.Bool("stdin") { + d.Input = os.Stdin + } + + if err := deploy(d, c.Bool("dry-run")); err != nil { + format.Error("%s (Try running 'helm doctor')", err) + os.Exit(1) + } + }, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Only display the underlying kubectl commands.", + }, + cli.BoolFlag{ + Name: "stdin,i", + Usage: "Read a configuration from STDIN.", + }, + cli.StringFlag{ + Name: "name", + Usage: "Name of deployment, used for deploy and update commands (defaults to template name)", + }, + // TODO: I think there is a Generic flag type that we can implement parsing with. + cli.StringFlag{ + Name: "properties,p", + Usage: "A comma-separated list of key=value pairs: 'foo=bar,foo2=baz'.", + }, + cli.StringFlag{ + // FIXME: This is not right. It's sort of a half-baked forward + // port of dm.go. + Name: "repository", + Usage: "The default repository", + Value: "kubernetes/application-dm-templates", + }, + }, }, { Name: "search", diff --git a/cmd/properties.go b/cmd/properties.go new file mode 100644 index 000000000..9632c95f6 --- /dev/null +++ b/cmd/properties.go @@ -0,0 +1,40 @@ +package main + +import ( + "errors" + "strconv" + "strings" +) + +// TODO: The concept of property here is really simple. We could definitely get +// better about the values we allow. Also, we need some validation on the names. + +var errInvalidProperty = errors.New("property is not in name=value format") + +// parseProperties is a utility for parsing a comma-separated key=value string. +func parseProperties(kvstr string) (map[string]interface{}, error) { + properties := map[string]interface{}{} + + if len(kvstr) == 0 { + return properties, nil + } + + pairs := strings.Split(kvstr, ",") + for _, p := range pairs { + // Allow for "k=v, k=v" + p = strings.TrimSpace(p) + pair := strings.Split(p, "=") + if len(pair) == 1 { + return properties, errInvalidProperty + } + + // If the value looks int-like, convert it. + if i, err := strconv.Atoi(pair[1]); err == nil { + properties[pair[0]] = pair[1] + } else { + properties[pair[0]] = i + } + } + + return properties, nil +} diff --git a/deploy/deploy.go b/deploy/deploy.go new file mode 100644 index 000000000..038c7eafa --- /dev/null +++ b/deploy/deploy.go @@ -0,0 +1,148 @@ +package deploy + +import ( + "archive/tar" + "errors" + "fmt" + "os" + "strings" + + "github.com/ghodss/yaml" + "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/expandybird/expander" + "github.com/kubernetes/deployment-manager/registry" +) + +type Deployer interface { + Commit() error +} + +// Deployment describes a deployment of a package. +type Deployment struct { + // Name is the Deployment name. Autogenerated if empty. + Name string + // Filename is the filename for the base deployment. + Filename string + // Imports is a list of imported files. + Imports []string + // Properties to pass into the template. + Properties map[string]interface{} + // Input is a file containing templates. It may be os.Stdin. + Input *os.File + // Repository is the location of the templates. + Repository string +} + +// Commit prepares the Deployment and then commits it to the remote processor. +func (d *Deployment) Commit() error { + tpl, err := d.resolveTemplate() + if err != nil { + return err + } + + // If a deployment Name is specified, set that explicitly. + if d.Name != "" { + tpl.Name = d.Name + } + + return nil +} + +// resolveTemplate resolves what kind of template is being loaded, and then returns the template. +func (d *Deployment) resolveTemplate() (*common.Template, error) { + // If some input has been specified, read it. + if d.Input != nil { + // Assume this is a tar archive. + tpl, err := expander.NewTemplateFromArchive(d.Filename, d.Input, d.Imports) + if err == nil { + return tpl, err + } else if err != tar.ErrHeader { + return nil, err + } + + // If we get here, the file is not a tar archive. + if _, err := os.Stdin.Seek(0, 0); err != nil { + return nil, err + } + return expander.NewTemplateFromReader(d.Filename, d.Input, d.Imports) + } + + // Non-Stdin case + if len(d.Imports) > 0 { + if t, err := registryType(d.Filename); err != nil { + return expander.NewTemplateFromRootTemplate(d.Filename) + } else { + return buildTemplateFromType(t, d.Repository, d.Properties) + } + } + return expander.NewTemplateFromFileNames(d.Filename, d.Imports) +} + +// registryType is a placeholder until registry.ParseType() is merged. +func registryType(name string) (*registry.Type, error) { + tList := strings.Split(name, ":") + if len(tList) != 2 { + return nil, errors.New("No version") + } + + tt := registry.Type{Version: tList[1]} + + cList := strings.Split(tList[0], "/") + + if len(cList) == 1 { + tt.Name = tList[0] + } else { + tt.Collection = cList[0] + tt.Name = cList[1] + } + return &tt, nil +} + +// buildTemplateFromType is a straight lift-n-shift from dm.go. +func buildTemplateFromType(t *registry.Type, reg string, props map[string]interface{}) (*common.Template, error) { + // Name the deployment after the type name. + name := fmt.Sprintf("%s:%s", t.Name, t.Version) + git, err := getGitRegistry(reg) + if err != nil { + return nil, err + } + gurls, err := git.GetURLs(*t) + if err != nil { + return nil, err + } + + config := common.Configuration{Resources: []*common.Resource{&common.Resource{ + Name: name, + Type: gurls[0], + Properties: props, + }}} + + y, err := yaml.Marshal(config) + if err != nil { + return nil, fmt.Errorf("error: %s\ncannot create configuration for deployment: %v\n", err, config) + } + + return &common.Template{ + Name: name, + Content: string(y), + // No imports, as this is a single type from repository. + }, nil +} + +func getGitRegistry(reg string) (registry.Registry, error) { + s := strings.SplitN(reg, "/", 3) + if len(s) < 2 { + return nil, fmt.Errorf("invalid template registry: %s", reg) + } + + path := "" + if len(s) > 2 { + path = s[3] + } + + if s[0] == "helm" { + return registry.NewGithubPackageRegistry(s[0], s[1]), nil + } else { + return registry.NewGithubRegistry(s[0], s[1], path), nil + } +} From 9763a8933577be732f2eb1787ccb80401384930a Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 15 Jan 2016 17:26:00 -0700 Subject: [PATCH 10/73] feat(*): deploy dry-run now works --- cmd/deploy.go | 24 ++++-- cmd/helm.go | 8 +- deploy/deploy.go | 27 ++++++- testdata/guestbook/README.md | 127 ++++++++++++++++++++++++++++++ testdata/guestbook/guestbook.yaml | 12 +++ 5 files changed, 189 insertions(+), 9 deletions(-) create mode 100644 testdata/guestbook/README.md create mode 100644 testdata/guestbook/guestbook.yaml diff --git a/cmd/deploy.go b/cmd/deploy.go index 8126ca4e4..80faeea6d 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -1,21 +1,35 @@ package main import ( + "encoding/json" "errors" dep "github.com/deis/helm-dm/deploy" "github.com/deis/helm-dm/format" ) -func deploy(cfg *dep.Deployment, dry bool) error { - if dry { - format.Error("Not implemented: --dry-run") - } +func deploy(cfg *dep.Deployment, host string, dry bool) error { if cfg.Filename == "" { 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.Commit(); err != nil { + if err := cfg.Prepare(); err != nil { + format.Error("Failed to prepare deployment: %s", err) + 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 err != nil { + return err + } + format.Msg(string(data)) + return nil + } + + if err := cfg.Commit(host); err != nil { format.Error("Failed to commit deployment: %s", err) return err } diff --git a/cmd/helm.go b/cmd/helm.go index d0edde4bb..946b67eb7 100644 --- a/cmd/helm.go +++ b/cmd/helm.go @@ -89,7 +89,7 @@ func commands() []cli.Command { d.Input = os.Stdin } - if err := deploy(d, c.Bool("dry-run")); err != nil { + if err := deploy(d, c.String("host"), c.Bool("dry-run")); err != nil { format.Error("%s (Try running 'helm doctor')", err) os.Exit(1) } @@ -119,6 +119,12 @@ func commands() []cli.Command { Usage: "The default repository", Value: "kubernetes/application-dm-templates", }, + cli.StringFlag{ + Name: "host,u", + Usage: "The URL of the DM server.", + EnvVar: "HELM_HOST", + Value: "https://localhost:8181/FIXME_NOT_RIGHT", + }, }, }, { diff --git a/deploy/deploy.go b/deploy/deploy.go index 038c7eafa..09e6c375f 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -13,8 +13,15 @@ import ( "github.com/kubernetes/deployment-manager/registry" ) +// Deployer is capable of deploying an object to a back-end. type Deployer interface { - Commit() error + // Prepare prepares the local side of a deployment. + Prepare() error + + // Commit pushes a deployment and checks that it is completed. + // + // This sends the data to the given host. + Commit(host string) error } // Deployment describes a deployment of a package. @@ -31,10 +38,16 @@ type Deployment struct { Input *os.File // Repository is the location of the templates. Repository string + + // The template, typically generated by the Deployment. + Template *common.Template } -// Commit prepares the Deployment and then commits it to the remote processor. -func (d *Deployment) Commit() error { +// Prepare loads templates and checks for client-side errors. +// +// This will generate the Template based on other information. +func (d *Deployment) Prepare() error { + tpl, err := d.resolveTemplate() if err != nil { return err @@ -45,6 +58,13 @@ func (d *Deployment) Commit() error { tpl.Name = d.Name } + d.Template = tpl + + return nil +} + +// Commit prepares the Deployment and then commits it to the remote processor. +func (d *Deployment) Commit(host string) error { return nil } @@ -129,6 +149,7 @@ func buildTemplateFromType(t *registry.Type, reg string, props map[string]interf }, nil } +// getGitRegistry returns a registry object for a name. func getGitRegistry(reg string) (registry.Registry, error) { s := strings.SplitN(reg, "/", 3) if len(s) < 2 { diff --git a/testdata/guestbook/README.md b/testdata/guestbook/README.md new file mode 100644 index 000000000..b48dd5933 --- /dev/null +++ b/testdata/guestbook/README.md @@ -0,0 +1,127 @@ +T**Testing fork of the guestbook example.** + +# Guestbook Example + +Welcome to the Guestbook example. It shows you how to build and reuse +parameterized templates. + +## Prerequisites + +First, make sure DM is installed in your Kubernetes cluster and that the +Guestbook example is deployed by following the instructions in the top level +[README.md](../../README.md). + +## Understanding the Guestbook example + +Let's take a closer look at the configuration used by the Guestbook example. + +### Replicated services + +The typical design pattern for microservices in Kubernetes is to create a +replication controller and a service with the same selector, so that the service +exposes ports from the pods managed by the replication controller. + +We have created a parameterized template for this kind of replicated service +called [Replicated Service](../../templates/replicatedservice/v1), and we use it +three times in the Guestbook example. + +The template is defined by a +[Python script](../../templates/replicatedservice/v1/replicatedservice.py). It +also has a [schema](../../templates/replicatedservice/v1/replicatedservice.py.schema). +Schemas are optional. If provided, they are used to validate template invocations +that appear in configurations. + +For more information about templates and schemas, see the +[design document](../../docs/design/design.md#templates). + +### The Guestbook application +The Guestbook application consists of 2 microservices: a front end and a Redis +cluster. + +#### The front end + +The front end is a replicated service with 3 replicas: + +``` +- name: frontend + type: https://raw.githubusercontent.com/kubernetes/deployment-manager/master/templates/replicatedservice/v1/replicatedservice.py + properties: + service_port: 80 + container_port: 80 + external_service: true + replicas: 3 + image: gcr.io/google_containers/example-guestbook-php-redis:v3 +``` + +(Note that we use the URL for a specific version of the template replicatedservice.py, +not just the template name.) + +#### The Redis cluster + +The Redis cluster consists of two replicated services: a master with a single replica +and the slaves with 2 replicas. It's defined by [this template](../../templates/redis/v1/redis.jinja), +which is a [Jinja](http://jinja.pocoo.org/) file with a [schema](../../templates/redis/v1/redis.jinja.schema). + +``` +{% set REDIS_PORT = 6379 %} +{% set WORKERS = properties['workers'] or 2 %} + +resources: +- name: redis-master + type: https://raw.githubusercontent.com/kubernetes/deployment-manager/master/templates/replicatedservice/v1/replicatedservice.py + properties: + # This has to be overwritten since service names are hard coded in the code + service_name: redis-master + service_port: {{ REDIS_PORT }} + target_port: {{ REDIS_PORT }} + container_port: {{ REDIS_PORT }} + replicas: 1 + container_name: master + image: redis + +- name: redis-slave + type: https://raw.githubusercontent.com/kubernetes/deployment-manager/master/templates/replicatedservice/v1/replicatedservice.py + properties: + # This has to be overwritten since service names are hard coded in the code + service_name: redis-slave + service_port: {{ REDIS_PORT }} + container_port: {{ REDIS_PORT }} + replicas: {{ WORKERS }} + container_name: worker + image: kubernetes/redis-slave:v2 + # An example of how to specify env variables. + env: + - name: GET_HOSTS_FROM + value: env + - name: REDIS_MASTER_SERVICE_HOST + value: redis-master +``` + +### Displaying types + +You can see both the both primitive types and the templates you've deployed to the +cluster using the `deployed-types` command: + +``` +dm deployed-types + +["Service","ReplicationController","redis.jinja","https://raw.githubusercontent.com/kubernetes/deployment-manager/master/templates/replicatedservice/v1/replicatedservice.py"] +``` + +This output shows 2 primitive types (Service and ReplicationController), and 2 +templates (redis.jinja and one imported from github named replicatedservice.py). + +You can also see where a specific type is being used with the `deployed-instances` command: + +``` +dm deployed-instances Service +[{"name":"frontend-service","type":"Service","deployment":"guestbook4","manifest":"manifest-1446682551242763329","path":"$.resources[0].resources[0]"},{"name":"redis-master","type":"Service","deployment":"guestbook4","manifest":"manifest-1446682551242763329","path":"$.resources[1].resources[0].resources[0]"},{"name":"redis-slave","type":"Service","deployment":"guestbook4","manifest":"manifest-1446682551242763329","path":"$.resources[1].resources[1].resources[0]"}] +``` + +This output describes the deployment and manifest, as well as the JSON paths to +the instances of the type within the layout. + +For more information about deployments, manifests and layouts, see the +[design document](../../docs/design/design.md#api-model). + + diff --git a/testdata/guestbook/guestbook.yaml b/testdata/guestbook/guestbook.yaml new file mode 100644 index 000000000..9a31d2489 --- /dev/null +++ b/testdata/guestbook/guestbook.yaml @@ -0,0 +1,12 @@ +resources: +- name: frontend + type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v1 + properties: + service_port: 80 + container_port: 80 + external_service: true + replicas: 3 + image: gcr.io/google_containers/example-guestbook-php-redis:v3 +- name: redis + type: github.com/kubernetes/application-dm-templates/storage/redis:v1 + properties: null From 145d5e0c1167c690f451dc581d0a939e5b5ed816 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Fri, 29 Jan 2016 10:37:40 -0800 Subject: [PATCH 11/73] (fix): broken registry api --- deploy/deploy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/deploy.go b/deploy/deploy.go index 09e6c375f..efd89ddf7 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -162,8 +162,8 @@ func getGitRegistry(reg string) (registry.Registry, error) { } if s[0] == "helm" { - return registry.NewGithubPackageRegistry(s[0], s[1]), nil + return registry.NewGithubPackageRegistry(s[0], s[1], nil), nil } else { - return registry.NewGithubRegistry(s[0], s[1], path), nil + return registry.NewGithubRegistry(s[0], s[1], path, nil), nil } } From db9ab4aa4d79ae6eb6224c2be8dc9904c9e5b304 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Fri, 29 Jan 2016 10:40:20 -0800 Subject: [PATCH 12/73] (feat): http request logging --- dm/client.go | 6 +++- dm/transport.go | 65 ++++++++++++++++++++++++++++++++++++++++++++ dm/transport_test.go | 49 +++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 dm/transport.go create mode 100644 dm/transport_test.go diff --git a/dm/client.go b/dm/client.go index b32bb828e..303f17a40 100644 --- a/dm/client.go +++ b/dm/client.go @@ -22,6 +22,8 @@ type Client struct { Host string // The protocol. Currently only http and https are supported. Protocol string + // Transport + Transport http.RoundTripper } // NewClient creates a new DM client. Host name is required. @@ -30,6 +32,7 @@ func NewClient(host string) *Client { HTTPTimeout: DefaultHTTPTimeout, Protocol: "https", Host: host, + Transport: NewDebugTransport(nil), } } @@ -70,7 +73,8 @@ func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (st request.Header.Add("Content-Type", "application/json") client := http.Client{ - Timeout: time.Duration(time.Duration(DefaultHTTPTimeout) * time.Second), + Timeout: time.Duration(time.Duration(DefaultHTTPTimeout) * time.Second), + Transport: c.Transport, } response, err := client.Do(request) diff --git a/dm/transport.go b/dm/transport.go new file mode 100644 index 000000000..588f7f96d --- /dev/null +++ b/dm/transport.go @@ -0,0 +1,65 @@ +package dm + +import ( + "fmt" + "io" + "net/http" + "net/http/httputil" + "os" +) + +type debugTransport struct { + // Writer is the logging destination + Writer io.Writer + + http.RoundTripper +} + +func NewDebugTransport(rt http.RoundTripper) http.RoundTripper { + return debugTransport{ + RoundTripper: rt, + Writer: os.Stderr, + } +} + +func (tr debugTransport) CancelRequest(req *http.Request) { + type canceler interface { + CancelRequest(*http.Request) + } + if cr, ok := tr.transport().(canceler); ok { + cr.CancelRequest(req) + } +} + +func (tr debugTransport) RoundTrip(req *http.Request) (*http.Response, error) { + tr.logRequest(req) + resp, err := tr.transport().RoundTrip(req) + if err != nil { + return nil, err + } + tr.logResponse(resp) + return resp, err +} + +func (tr debugTransport) transport() http.RoundTripper { + if tr.RoundTripper != nil { + return tr.RoundTripper + } + return http.DefaultTransport +} + +func (tr debugTransport) logRequest(req *http.Request) { + dump, err := httputil.DumpRequestOut(req, true) + if err != nil { + fmt.Fprintf(tr.Writer, "%s: %s\n", "could not dump request", err) + } + fmt.Fprint(tr.Writer, string(dump)) +} + +func (tr debugTransport) logResponse(resp *http.Response) { + dump, err := httputil.DumpResponse(resp, true) + if err != nil { + fmt.Fprintf(tr.Writer, "%s: %s\n", "could not dump response", err) + } + fmt.Fprint(tr.Writer, string(dump)) +} diff --git a/dm/transport_test.go b/dm/transport_test.go new file mode 100644 index 000000000..d563d3eab --- /dev/null +++ b/dm/transport_test.go @@ -0,0 +1,49 @@ +package dm + +import ( + "bytes" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +func TestDebugTransport(t *testing.T) { + handler := func(w http.ResponseWriter, req *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + w.Write([]byte(`{"status":"awesome"}`)) + } + + server := httptest.NewServer(http.HandlerFunc(handler)) + defer server.Close() + + var output bytes.Buffer + + client := &http.Client{ + Transport: debugTransport{ + Writer: &output, + }, + } + + _, err := client.Get(server.URL) + if err != nil { + t.Fatal(err.Error()) + } + + expected := []string{ + "GET / HTTP/1.1", + "Accept-Encoding: gzip", + "HTTP/1.1 200 OK", + "Content-Length: 20", + "Content-Type: application/json", + `{"status":"awesome"}`, + } + actual := output.String() + + for _, match := range expected { + if !strings.Contains(actual, match) { + t.Errorf("Expected %s to contain %s", actual, match) + } + } +} From f76a17acb47eee093c05ca6ae3ba0a08a6f4114c Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Fri, 29 Jan 2016 11:38:43 -0800 Subject: [PATCH 13/73] feat(list): add list command --- cmd/helm.go | 19 ++++++++++++------- cmd/list.go | 28 ++++++++++++++++++++++++++++ dm/client.go | 10 ++++++++++ 3 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 cmd/list.go diff --git a/cmd/helm.go b/cmd/helm.go index 946b67eb7..e044b8be8 100644 --- a/cmd/helm.go +++ b/cmd/helm.go @@ -17,6 +17,16 @@ func main() { app.Usage = `Deploy and manage packages.` app.Commands = commands() + // TODO: make better + app.Flags = []cli.Flag{ + cli.StringFlag{ + Name: "host,u", + Usage: "The URL of the DM server.", + EnvVar: "HELM_HOST", + Value: "https://localhost:8181/FIXME_NOT_RIGHT", + }, + } + app.Run(os.Args) } @@ -89,7 +99,7 @@ func commands() []cli.Command { d.Input = os.Stdin } - if err := deploy(d, c.String("host"), c.Bool("dry-run")); err != nil { + if err := deploy(d, c.GlobalString("host"), c.Bool("dry-run")); err != nil { format.Error("%s (Try running 'helm doctor')", err) os.Exit(1) } @@ -119,16 +129,11 @@ func commands() []cli.Command { Usage: "The default repository", Value: "kubernetes/application-dm-templates", }, - cli.StringFlag{ - Name: "host,u", - Usage: "The URL of the DM server.", - EnvVar: "HELM_HOST", - Value: "https://localhost:8181/FIXME_NOT_RIGHT", - }, }, }, { Name: "search", }, + listCmd(), } } diff --git a/cmd/list.go b/cmd/list.go new file mode 100644 index 000000000..b5eb7446d --- /dev/null +++ b/cmd/list.go @@ -0,0 +1,28 @@ +package main + +import ( + "os" + + "github.com/codegangsta/cli" + "github.com/deis/helm-dm/dm" + "github.com/deis/helm-dm/format" +) + +func listCmd() cli.Command { + return cli.Command{ + Name: "list", + Usage: "Lists the deployments in the cluster", + Action: func(c *cli.Context) { + if err := list(c.GlobalString("host")); err != nil { + format.Error("%s (Is the cluster running?)", err) + os.Exit(1) + } + }, + } +} + +func list(host string) error { + client := dm.NewClient(host) + client.Protocol = "http" + return client.ListDeployments() +} diff --git a/dm/client.go b/dm/client.go index 303f17a40..27a01c203 100644 --- a/dm/client.go +++ b/dm/client.go @@ -96,3 +96,13 @@ func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (st return string(body), nil } + +func (c *Client) ListDeployments() error { + var d interface{} + if err := c.CallService("deployments", "GET", "foo", &d, nil); err != nil { + return err + } + + fmt.Printf("%#v\n", d) + return nil +} From defc31a7829cd64aad5e203c663177561b48b2e9 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Sat, 30 Jan 2016 14:28:27 -0800 Subject: [PATCH 14/73] chore(*): move /cmd to /cmd/helm --- cmd/{ => helm}/deploy.go | 0 cmd/{ => helm}/helm.go | 0 cmd/{ => helm}/install.go | 0 cmd/{ => helm}/list.go | 0 cmd/{ => helm}/properties.go | 0 cmd/{ => helm}/target.go | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename cmd/{ => helm}/deploy.go (100%) rename cmd/{ => helm}/helm.go (100%) rename cmd/{ => helm}/install.go (100%) rename cmd/{ => helm}/list.go (100%) rename cmd/{ => helm}/properties.go (100%) rename cmd/{ => helm}/target.go (100%) diff --git a/cmd/deploy.go b/cmd/helm/deploy.go similarity index 100% rename from cmd/deploy.go rename to cmd/helm/deploy.go diff --git a/cmd/helm.go b/cmd/helm/helm.go similarity index 100% rename from cmd/helm.go rename to cmd/helm/helm.go diff --git a/cmd/install.go b/cmd/helm/install.go similarity index 100% rename from cmd/install.go rename to cmd/helm/install.go diff --git a/cmd/list.go b/cmd/helm/list.go similarity index 100% rename from cmd/list.go rename to cmd/helm/list.go diff --git a/cmd/properties.go b/cmd/helm/properties.go similarity index 100% rename from cmd/properties.go rename to cmd/helm/properties.go diff --git a/cmd/target.go b/cmd/helm/target.go similarity index 100% rename from cmd/target.go rename to cmd/helm/target.go From ba5500d6006cd7f186cbcf9e8d578f490f5d7692 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Sat, 30 Jan 2016 14:37:35 -0800 Subject: [PATCH 15/73] fix(Makefile): fix make tagrets --- .gitignore | 4 ++-- Makefile | 27 ++++++++------------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 0f34b7d2d..6c1ce6f06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -vendor/ -bin/helm +/vendor/ +/bin/ diff --git a/Makefile b/Makefile index 974e04d5e..94307ab20 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ endif BIN_DIR := bin DIST_DIR := _dist -GO_PACKAGES := cmd dm -MAIN_GO := cmd/helm.go -HELM_BIN := $(BIN_DIR)/helm -PATH_WITH_HELM = PATH="$(shell pwd)/$(BIN_DIR):$(PATH)" +GO_PACKAGES := cmd/helm dm +MAIN_GO := github.com/deis/helm-dm/cmd/helm +HELM_BIN := helm-dm +PATH_WITH_HELM = PATH="$(shell pwd)/$(BIN_DIR)/helm:$(PATH)" VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null)+$(shell git rev-parse --short HEAD) @@ -17,8 +17,8 @@ ifndef VERSION VERSION := git-$(shell git rev-parse --short HEAD) endif -build: $(MAIN_GO) - go build -o $(HELM_BIN) -ldflags "-X github.com/helm/helm/cmd.version=${VERSION}" $< +build: + go build -o bin/${HELM_BIN} -ldflags "-s -X main.version=${VERSION}" $(MAIN_GO) bootstrap: go get -u github.com/golang/lint/golint github.com/mitchellh/gox @@ -41,17 +41,7 @@ dist: build-all install: build install -d ${DESTDIR}/usr/local/bin/ - install -m 755 $(HELM_BIN) ${DESTDIR}/usr/local/bin/helm - -prep-bintray-json: -# TRAVIS_TAG is set to the tag name if the build is a tag -ifdef TRAVIS_TAG - @jq '.version.name |= "$(VERSION)"' _scripts/ci/bintray-template.json | \ - jq '.package.repo |= "helm"' > _scripts/ci/bintray-ci.json -else - @jq '.version.name |= "$(VERSION)"' _scripts/ci/bintray-template.json \ - > _scripts/ci/bintray-ci.json -endif + install -m 755 bin/${HELM_BIN} ${DESTDIR}/usr/local/bin/${HELM_BIN} quicktest: $(PATH_WITH_HELM) go test -short $(addprefix ./,$(GO_PACKAGES)) @@ -67,7 +57,7 @@ test-style: golint $$i; \ done @for i in . $(GO_PACKAGES); do \ - go vet github.com/helm/helm/$$i; \ + go vet github.com/deis/helm-dm/$$i; \ done .PHONY: bootstrap \ @@ -76,7 +66,6 @@ test-style: clean \ dist \ install \ - prep-bintray-json \ quicktest \ test \ test-charts \ From 73e2f7bc8d4aa3fa7be5c384c24bac825e0c222a Mon Sep 17 00:00:00 2001 From: Michelle Noorali Date: Mon, 1 Feb 2016 10:19:44 -0500 Subject: [PATCH 16/73] ref(deploy): adjusting to new dm registry interface --- deploy/deploy.go | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/deploy/deploy.go b/deploy/deploy.go index efd89ddf7..1ba09e394 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -105,7 +105,11 @@ func registryType(name string) (*registry.Type, error) { return nil, errors.New("No version") } - tt := registry.Type{Version: tList[1]} + semver, err := registry.ParseSemVer(tList[1]) + if err != nil { + return nil, err + } + tt := registry.Type{Version: semver} cList := strings.Split(tList[0], "/") @@ -126,14 +130,14 @@ func buildTemplateFromType(t *registry.Type, reg string, props map[string]interf if err != nil { return nil, err } - gurls, err := git.GetURLs(*t) + gurls, err := git.GetDownloadURLs(*t) if err != nil { return nil, err } config := common.Configuration{Resources: []*common.Resource{&common.Resource{ Name: name, - Type: gurls[0], + Type: gurls[0].Host, Properties: props, }}} @@ -156,14 +160,22 @@ func getGitRegistry(reg string) (registry.Registry, error) { return nil, fmt.Errorf("invalid template registry: %s", reg) } - path := "" - if len(s) > 2 { - path = s[3] - } + //path := "" + //if len(s) > 2 { + //path = s[3] + //} if s[0] == "helm" { - return registry.NewGithubPackageRegistry(s[0], s[1], nil), nil + r, err := registry.NewGithubPackageRegistry(s[0], s[1], nil, nil) + if err != nil { + return nil, err + } + return r, nil } else { - return registry.NewGithubRegistry(s[0], s[1], path, nil), nil + r, err := registry.NewGithubTemplateRegistry(s[0], s[1], nil, nil) + if err != nil { + return nil, err + } + return r, nil } } From 5884ff12a4348644103d3acead050c0d305a975a Mon Sep 17 00:00:00 2001 From: Michelle Noorali Date: Tue, 19 Jan 2016 09:36:12 -0700 Subject: [PATCH 17/73] feat(*): add doctor cmd --- cmd/doctor.go | 18 ++++++++++++++++++ cmd/helm/helm.go | 10 +++++++++- format/messages.go | 10 ++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 cmd/doctor.go diff --git a/cmd/doctor.go b/cmd/doctor.go new file mode 100644 index 000000000..ebf66099a --- /dev/null +++ b/cmd/doctor.go @@ -0,0 +1,18 @@ +package main + +import ( + "github.com/deis/helm-dm/dm" + "github.com/deis/helm-dm/kubectl" +) + +func doctor() error { + var runner kubectl.Runner + runner = &kubectl.RealRunner{} + if dm.IsInstalled(runner) { + format.Success("You have everything you need. Go forth my friend!") + } else { + format.Warning("Looks like you don't have DM installed.\nRun: `helm install`") + } + + return nil +} diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index e044b8be8..0b6816c86 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -67,7 +67,15 @@ func commands() []cli.Command { }, }, { - Name: "doctor", + Name: "doctor", + Usage: "Run a series of checks for necessary prerequisites.", + ArgsUsage: "", + Action: func(c *cli.Context) { + if err := doctor(); err != nil { + format.Error("%s", err) + os.Exit(1) + } + }, }, { Name: "deploy", diff --git a/format/messages.go b/format/messages.go index b90d90851..dcf26736a 100644 --- a/format/messages.go +++ b/format/messages.go @@ -20,3 +20,13 @@ func Info(msg string, v ...interface{}) { func Msg(msg string, v ...interface{}) { fmt.Fprintf(os.Stdout, msg, v...) } + +func Success(msg string, v ...interface{}) { + msg = "[Success] " + msg + "\n" + fmt.Fprintf(os.Stdout, msg, v...) +} + +func Warning(msg string, v ...interface{}) { + msg = "[Warning] " + msg + "\n" + fmt.Fprintf(os.Stdout, msg, v...) +} From 1e37113c398efeeaa0ee89f6a743950597272649 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Wed, 3 Feb 2016 12:04:42 -0800 Subject: [PATCH 18/73] feat(dm-delete): add dm-delete command --- cmd/helm/{install.go => dm.go} | 29 ++++++++---- cmd/{ => helm}/doctor.go | 0 cmd/helm/helm.go | 82 +++++++++++++++++++++++++++------- dm/uninstall.go | 14 ++++++ 4 files changed, 99 insertions(+), 26 deletions(-) rename cmd/helm/{install.go => dm.go} (51%) rename cmd/{ => helm}/doctor.go (100%) create mode 100644 dm/uninstall.go diff --git a/cmd/helm/install.go b/cmd/helm/dm.go similarity index 51% rename from cmd/helm/install.go rename to cmd/helm/dm.go index 1d44be082..a1e60e3a5 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/dm.go @@ -11,15 +11,8 @@ import ( var ErrAlreadyInstalled error = errors.New("Already Installed") func install(dryRun bool) error { - var runner kubectl.Runner - if dryRun { - runner = &kubectl.PrintRunner{} - } else { - runner = &kubectl.RealRunner{} - if dm.IsInstalled(runner) { - return ErrAlreadyInstalled - } - } + runner := getKubectlRunner(dryRun) + out, err := dm.Install(runner) if err != nil { format.Error("Error installing: %s %s", out, err) @@ -27,3 +20,21 @@ func install(dryRun bool) error { format.Msg(out) return nil } + +func uninstall(dryRun bool) error { + runner := getKubectlRunner(dryRun) + + out, err := dm.Uninstall(runner) + if err != nil { + format.Error("Error uninstalling: %s %s", out, err) + } + format.Msg(out) + return nil +} + +func getKubectlRunner(dryRun bool) kubectl.Runner { + if dryRun { + return &kubectl.PrintRunner{} + } + return &kubectl.RealRunner{} +} diff --git a/cmd/doctor.go b/cmd/helm/doctor.go similarity index 100% rename from cmd/doctor.go rename to cmd/helm/doctor.go diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 0b6816c86..bbae7554b 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -32,6 +32,71 @@ func main() { func commands() []cli.Command { return []cli.Command{ + { + Name: "dm", + Usage: "Manage DM on Kubernetes", + Subcommands: []cli.Command{ + { + Name: "install", + Usage: "Install DM on Kubernetes.", + Description: ``, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Show what would be installed, but don't install anything.", + }, + }, + Action: func(c *cli.Context) { + if err := install(c.Bool("dry-run")); err != nil { + format.Error("%s (Run 'helm doctor' for more information)", err) + os.Exit(1) + } + }, + }, + { + Name: "uninstall", + Usage: "Uninstall the DM from Kubernetes.", + Description: ``, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Show what would be installed, but don't install anything.", + }, + }, + Action: func(c *cli.Context) { + if err := uninstall(c.Bool("dry-run")); err != nil { + format.Error("%s (Run 'helm doctor' for more information)", err) + os.Exit(1) + } + }, + }, + { + Name: "status", + Usage: "Show status of DM.", + Action: func(c *cli.Context) { + format.Error("Not yet implemented") + os.Exit(1) + }, + }, + { + Name: "target", + Usage: "Displays information about cluster.", + ArgsUsage: "", + Action: func(c *cli.Context) { + if err := target(c.Bool("dry-run")); err != nil { + format.Error("%s (Is the cluster running?)", err) + os.Exit(1) + } + }, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Only display the underlying kubectl commands.", + }, + }, + }, + }, + }, { Name: "init", Usage: "Initialize the client and install DM on Kubernetes.", @@ -49,23 +114,6 @@ func commands() []cli.Command { } }, }, - { - Name: "target", - Usage: "Displays information about cluster.", - ArgsUsage: "", - Action: func(c *cli.Context) { - if err := target(c.Bool("dry-run")); err != nil { - format.Error("%s (Is the cluster running?)", err) - os.Exit(1) - } - }, - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "dry-run", - Usage: "Only display the underlying kubectl commands.", - }, - }, - }, { Name: "doctor", Usage: "Run a series of checks for necessary prerequisites.", diff --git a/dm/uninstall.go b/dm/uninstall.go new file mode 100644 index 000000000..277ff1c10 --- /dev/null +++ b/dm/uninstall.go @@ -0,0 +1,14 @@ +package dm + +import ( + "github.com/deis/helm-dm/kubectl" +) + +// uninstall uses kubectl to uninstall the base DM. +// +// Returns the string output received from the operation, and an error if the +// command failed. +func Uninstall(runner kubectl.Runner) (string, error) { + o, err := runner.Delete("dm", "Namespace", "dm") + return string(o), err +} From ade66d83138d4008be3afa592cf3652e4a0f6e25 Mon Sep 17 00:00:00 2001 From: Seth Goings Date: Fri, 5 Feb 2016 11:02:02 -0700 Subject: [PATCH 19/73] feat(travis): add travis build --- .travis.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..20224a711 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: go + +env: + - GO15VENDOREXPERIMENT=1 + +branches: + only: + - master + - /^v?(?:[0-9]+\.){2}[0-9]+.*$/ + +cache: + directories: + - $GOPATH/src/github.com/deis/helm-dm/vendor + +go: + - 1.5 + +install: + - wget "https://github.com/Masterminds/glide/releases/download/0.8.3/glide-0.8.3-linux-amd64.tar.gz" + - mkdir -p $HOME/bin + - tar -vxz -C $HOME/bin --strip=1 -f glide-0.8.3-linux-amd64.tar.gz + - export PATH="$HOME/bin:$PATH" GLIDE_HOME="$HOME/.glide" + +script: make bootstrap build test From 9b9705e7a1e0be11fdc8d2224489cb78aa4a48e6 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Tue, 2 Feb 2016 18:16:23 -0700 Subject: [PATCH 20/73] feat(create): add create and pack verbs. This adds `helm create CHART` and `helm pack CHART`. Both are really basic. NOTE: This is running off of my fork of dm until they get the new chart stuff merged. --- cmd/helm/create.go | 24 ++++++++++++++++++++++ cmd/helm/deploy.go | 33 +++++++++++++++++++++++++++++- cmd/helm/helm.go | 51 +++++++++++++++++----------------------------- cmd/helm/pack.go | 33 ++++++++++++++++++++++++++++++ deploy/deploy.go | 36 +++++++++++++++++--------------- glide.lock | 43 ++++++++++++++++++++------------------ glide.yaml | 6 ++++++ 7 files changed, 157 insertions(+), 69 deletions(-) create mode 100644 cmd/helm/create.go create mode 100644 cmd/helm/pack.go diff --git a/cmd/helm/create.go b/cmd/helm/create.go new file mode 100644 index 000000000..95bd3016f --- /dev/null +++ b/cmd/helm/create.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + + "github.com/codegangsta/cli" + "github.com/kubernetes/deployment-manager/chart" +) + +func create(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + return fmt.Errorf("'helm create' requires a chart name as an argument.") + } + + cf := &chart.Chartfile{ + Name: args[0], + Description: "Created by Helm", + Version: "0.1.0", + } + + _, err := chart.Create(cf, ".") + return err +} diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index 80faeea6d..e8776c290 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -3,12 +3,43 @@ package main import ( "encoding/json" "errors" + "os" + "github.com/codegangsta/cli" dep "github.com/deis/helm-dm/deploy" "github.com/deis/helm-dm/format" ) -func deploy(cfg *dep.Deployment, host string, dry bool) error { +func deploy(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + format.Error("First argument, filename, is required. Try 'helm deploy --help'") + os.Exit(1) + } + + props, err := parseProperties(c.String("properties")) + if err != nil { + format.Error("Failed to parse properties: %s", err) + os.Exit(1) + } + + d := &dep.Deployment{ + Name: c.String("Name"), + Properties: props, + Filename: args[0], + Imports: args[1:], + Repository: c.String("repository"), + } + + if c.Bool("stdin") { + d.Input = os.Stdin + } + + //return doDeploy(d, c.GlobalString("host"), c.Bool("dry-run")) + return nil +} + +func doDeploy(cfg *dep.Deployment, host string, dry bool) error { if cfg.Filename == "" { return errors.New("A filename must be specified. For a tar archive, this is the name of the root template in the archive.") } diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index bbae7554b..8ae38aa87 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -4,7 +4,6 @@ import ( "os" "github.com/codegangsta/cli" - dep "github.com/deis/helm-dm/deploy" "github.com/deis/helm-dm/format" ) @@ -125,41 +124,22 @@ func commands() []cli.Command { } }, }, + { + Name: "create", + Usage: "Create a new local chart for editing.", + Action: func(c *cli.Context) { run(c, create) }, + }, + { + Name: "package", + Aliases: []string{"pack"}, + Usage: "Given a chart directory, package it into a release.", + Action: func(c *cli.Context) { run(c, pack) }, + }, { Name: "deploy", Aliases: []string{"install"}, Usage: "Deploy a chart into the cluster.", - Action: func(c *cli.Context) { - - args := c.Args() - if len(args) < 1 { - format.Error("First argument, filename, is required. Try 'helm deploy --help'") - os.Exit(1) - } - - props, err := parseProperties(c.String("properties")) - if err != nil { - format.Error("Failed to parse properties: %s", err) - os.Exit(1) - } - - d := &dep.Deployment{ - Name: c.String("Name"), - Properties: props, - Filename: args[0], - Imports: args[1:], - Repository: c.String("repository"), - } - - if c.Bool("stdin") { - d.Input = os.Stdin - } - - if err := deploy(d, c.GlobalString("host"), c.Bool("dry-run")); err != nil { - format.Error("%s (Try running 'helm doctor')", err) - os.Exit(1) - } - }, + Action: func(c *cli.Context) { run(c, deploy) }, Flags: []cli.Flag{ cli.BoolFlag{ Name: "dry-run", @@ -193,3 +173,10 @@ func commands() []cli.Command { listCmd(), } } + +func run(c *cli.Context, f func(c *cli.Context) error) { + if err := f(c); err != nil { + os.Stderr.Write([]byte(err.Error())) + os.Exit(1) + } +} diff --git a/cmd/helm/pack.go b/cmd/helm/pack.go new file mode 100644 index 000000000..dea528f61 --- /dev/null +++ b/cmd/helm/pack.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "os" + + "github.com/codegangsta/cli" + "github.com/deis/helm-dm/format" + "github.com/kubernetes/deployment-manager/chart" +) + +func pack(cxt *cli.Context) error { + args := cxt.Args() + if len(args) < 1 { + return fmt.Errorf("'helm package' requires a path to a chart directory as an argument.") + } + + dir := args[0] + if fi, err := os.Stat(dir); err != nil { + return fmt.Errorf("Could not find directory %s: %s", dir, err) + } else if !fi.IsDir() { + return fmt.Errorf("Not a directory: %s", dir) + } + + c, err := chart.LoadDir(dir) + if err != nil { + return fmt.Errorf("Failed to load %s: %s", dir, err) + } + + fname, err := chart.Save(c, ".") + format.Msg(fname) + return nil +} diff --git a/deploy/deploy.go b/deploy/deploy.go index 1ba09e394..43c45aefe 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -1,16 +1,16 @@ package deploy import ( - "archive/tar" - "errors" - "fmt" + //"archive/tar" + //"errors" + //"fmt" "os" - "strings" + //"strings" - "github.com/ghodss/yaml" + //"github.com/ghodss/yaml" "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/expandybird/expander" - "github.com/kubernetes/deployment-manager/registry" + //"github.com/kubernetes/deployment-manager/expandybird/expander" + //"github.com/kubernetes/deployment-manager/registry" ) // Deployer is capable of deploying an object to a back-end. @@ -48,17 +48,19 @@ type Deployment struct { // This will generate the Template based on other information. func (d *Deployment) Prepare() error { - tpl, err := d.resolveTemplate() - if err != nil { - return err - } + /* + tpl, err := d.resolveTemplate() + if err != nil { + return err + } - // If a deployment Name is specified, set that explicitly. - if d.Name != "" { - tpl.Name = d.Name - } + // If a deployment Name is specified, set that explicitly. + if d.Name != "" { + tpl.Name = d.Name + } - d.Template = tpl + d.Template = tpl + */ return nil } @@ -68,6 +70,7 @@ func (d *Deployment) Commit(host string) error { return nil } +/* // resolveTemplate resolves what kind of template is being loaded, and then returns the template. func (d *Deployment) resolveTemplate() (*common.Template, error) { // If some input has been specified, read it. @@ -179,3 +182,4 @@ func getGitRegistry(reg string) (registry.Registry, error) { return r, nil } } +*/ diff --git a/glide.lock b/glide.lock index ddd774cc4..d34eae154 100644 --- a/glide.lock +++ b/glide.lock @@ -1,53 +1,56 @@ -hash: 4cc1aba06a344d43c0c1005d71dc0659ada5d90f0b2235b1d8e8c7352d1251a7 -updated: 2016-01-06T14:30:55.041267875-08:00 +hash: fce0581223b80f7a04fbb4ad4bd7ff8fa3d12e879dba894ba448770933731887 +updated: 2016-02-02T17:30:13.283644703-07:00 imports: - name: github.com/codegangsta/cli - version: c31a7975863e7810c92e2e288a9ab074f9a88f29 + version: cf1f63a7274872768d4037305d572b70b1199397 - name: github.com/emicklei/go-restful - version: ce94a9f819d7dd2b5599ff0c017b1124595a64fb + version: b86acf97a74ed7603ac78d012f5535b4d587b156 - name: github.com/ghodss/yaml version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee - name: github.com/golang/glog - version: fca8c8854093a154ff1eb580aae10276ad6b1b5f + version: 23def4e6c14b4da8ac2ed8007337bc5eb5007998 - name: github.com/golang/protobuf - version: 2402d76f3d41f928c7902a765dfc872356dd3aad + version: 45bba206dd5270d96bac4942dcfe515726613249 - name: github.com/google/go-github - version: 63fbbb283ce4913a5ac1b6de7abae50dbf594a04 + version: b8b4ac742977310ff6e75140a403a38dab109977 + subpackages: + - /github - name: github.com/google/go-querystring version: 2a60fc2ba6c19de80291203597d752e9ba58e4c0 - name: github.com/gorilla/context version: 1c83b3eabd45b6d76072b66b746c20815fb2872d - name: github.com/gorilla/handlers - version: 1af6d56d7cd39d982856bc0cee11142baf392c52 + version: b3aff83722cb2ae031a70cae984650e3a16cd20e - name: github.com/gorilla/mux version: 26a6070f849969ba72b72256e9f14cf519751690 - name: github.com/gorilla/schema version: 14c555599c2a4f493c1e13fd1ea6fdf721739028 - name: github.com/kubernetes/deployment-manager - version: 62f19486073edd020a11922304130f0c5c1dff20 + version: "" + repo: https://github.com/technosophos/deployment-manager + vcs: git subpackages: - /common +- name: github.com/Masterminds/semver + version: c4f7ef0702f269161a60489ccbbc9f1241ad1265 - name: github.com/mjibson/appstats version: 0542d5f0e87ea3a8fa4174322b9532f5d04f9fa8 - name: golang.org/x/crypto - version: 552e9d568fde9701ea1944fb01c8aadaceaa7353 + version: 1f22c0103821b9390939b6776727195525381532 - name: golang.org/x/net - version: 1ade16a5450925b7496e1031938175d1f5d30d31 + version: 6c581b96a7d38dd755f986fcf4f29665597694c0 - name: golang.org/x/oauth2 - version: 2baa8a1b9338cf13d9eeb27696d761155fa480be + version: 8a57ed94ffd43444c0879fe75701732a38afc985 - name: golang.org/x/text - version: cf4986612c83df6c55578ba198316d1684a9a287 -- name: google.golang.com/appengine - version: "" - repo: https://google.golang.com/appengine + version: 5aaa1a807bf8a2f763540b140e7805973476eb88 - name: google.golang.org/api - version: f5b7ec483f357a211c03c6722a840444c2d395dc + version: 8fa1015948e6fc21c025050624e4c4e2f4f405c4 - name: google.golang.org/appengine - version: 54bf9150c922186bfc45a00bf9dfcb91a5063275 + version: 6bde959377a90acb53366051d7d587bfd7171354 - name: google.golang.org/cloud - version: 1bff51b8fae8d33cb3dab8f7858c266ce001ee3e + version: 5a3b06f8b5da3b7c3a93da43163b872c86c509ef - name: google.golang.org/grpc - version: 78905999da08d7f87d5dd11608fa79ff8700daa8 + version: 5d64098b94ee9dbbea8ddc130208696bcd199ba4 - name: gopkg.in/yaml.v2 version: f7716cbe52baa25d2e9b0d0da546fcf909fc16b4 devImports: [] diff --git a/glide.yaml b/glide.yaml index 35922b0fc..dd229737b 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,7 +1,13 @@ package: github.com/deis/helm-dm +ignore: +- google.golang.com/appengine import: - package: github.com/codegangsta/cli - package: github.com/kubernetes/deployment-manager + version: feat/chartfile + repo: https://github.com/technosophos/deployment-manager + vcs: git subpackages: - /common - package: github.com/ghodss/yaml +- package: github.com/Masterminds/semver From 9b494f5546ade77928725886d3543b8351eecabb Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 5 Feb 2016 13:10:49 -0700 Subject: [PATCH 21/73] feat(deploy): deploy charts instead of templates --- cmd/helm/deploy.go | 43 +++++++++++++++++++++++++++++------------- deploy/deploy.go | 33 ++++++++++++++++++++++++-------- dm/client.go | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 21 deletions(-) diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index e8776c290..14447fa85 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -1,13 +1,13 @@ 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 +} diff --git a/deploy/deploy.go b/deploy/deploy.go index 43c45aefe..53d88bd0d 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -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 diff --git a/dm/client.go b/dm/client.go index 27a01c203..8f49669ea 100644 --- a/dm/client.go +++ b/dm/client.go @@ -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 +} From be2a09d612c454d75924094d6edb883339ab1c8a Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 5 Feb 2016 14:02:59 -0700 Subject: [PATCH 22/73] fix(lint): correct several formatting issues --- Makefile | 4 ++-- cmd/helm/create.go | 4 ++-- cmd/helm/deploy.go | 5 ++--- cmd/helm/dm.go | 5 +++-- cmd/helm/helm.go | 12 ++++++------ cmd/helm/list.go | 2 +- cmd/helm/pack.go | 3 ++- deploy/deploy.go | 1 + dm/client.go | 10 ++++++---- dm/install.go | 2 +- dm/transport.go | 1 + format/messages.go | 5 ++++- kubectl/get.go | 2 ++ 13 files changed, 33 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 94307ab20..badddd90c 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ endif BIN_DIR := bin DIST_DIR := _dist -GO_PACKAGES := cmd/helm dm +GO_PACKAGES := cmd/helm dm deploy format kubectl MAIN_GO := github.com/deis/helm-dm/cmd/helm HELM_BIN := helm-dm PATH_WITH_HELM = PATH="$(shell pwd)/$(BIN_DIR)/helm:$(PATH)" @@ -47,7 +47,7 @@ quicktest: $(PATH_WITH_HELM) go test -short $(addprefix ./,$(GO_PACKAGES)) test: test-style - $(PATH_WITH_HELM) go test -v ./ $(addprefix ./,$(GO_PACKAGES)) + $(PATH_WITH_HELM) go test -v $(addprefix ./,$(GO_PACKAGES)) test-style: @if [ $(shell gofmt -e -l -s *.go $(GO_PACKAGES)) ]; then \ diff --git a/cmd/helm/create.go b/cmd/helm/create.go index 95bd3016f..177f5e25b 100644 --- a/cmd/helm/create.go +++ b/cmd/helm/create.go @@ -1,7 +1,7 @@ package main import ( - "fmt" + "errors" "github.com/codegangsta/cli" "github.com/kubernetes/deployment-manager/chart" @@ -10,7 +10,7 @@ import ( func create(c *cli.Context) error { args := c.Args() if len(args) < 1 { - return fmt.Errorf("'helm create' requires a chart name as an argument.") + return errors.New("'helm create' requires a chart name as an argument") } cf := &chart.Chartfile{ diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index 14447fa85..12c5f2c97 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -13,13 +13,13 @@ import ( func deploy(c *cli.Context) error { args := c.Args() if len(args) < 1 { - format.Error("First argument, filename, is required. Try 'helm deploy --help'") + format.Err("First argument, filename, is required. Try 'helm deploy --help'") os.Exit(1) } props, err := parseProperties(c.String("properties")) if err != nil { - format.Error("Failed to parse properties: %s", err) + format.Err("Failed to parse properties: %s", err) os.Exit(1) } @@ -36,7 +36,6 @@ func deploy(c *cli.Context) error { } return doDeploy(d, c.GlobalString("host"), c.Bool("dry-run")) - return nil } func doDeploy(cfg *dep.Deployment, host string, dry bool) error { diff --git a/cmd/helm/dm.go b/cmd/helm/dm.go index a1e60e3a5..c5069900a 100644 --- a/cmd/helm/dm.go +++ b/cmd/helm/dm.go @@ -8,14 +8,15 @@ import ( "github.com/deis/helm-dm/kubectl" ) -var ErrAlreadyInstalled error = errors.New("Already Installed") +// ErrAlreadyInstalled indicates that DM is already installed. +var ErrAlreadyInstalled = errors.New("Already Installed") func install(dryRun bool) error { runner := getKubectlRunner(dryRun) out, err := dm.Install(runner) if err != nil { - format.Error("Error installing: %s %s", out, err) + format.Err("Error installing: %s %s", out, err) } format.Msg(out) return nil diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 8ae38aa87..a08514c2a 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -47,7 +47,7 @@ func commands() []cli.Command { }, Action: func(c *cli.Context) { if err := install(c.Bool("dry-run")); err != nil { - format.Error("%s (Run 'helm doctor' for more information)", err) + format.Err("%s (Run 'helm doctor' for more information)", err) os.Exit(1) } }, @@ -64,7 +64,7 @@ func commands() []cli.Command { }, Action: func(c *cli.Context) { if err := uninstall(c.Bool("dry-run")); err != nil { - format.Error("%s (Run 'helm doctor' for more information)", err) + format.Err("%s (Run 'helm doctor' for more information)", err) os.Exit(1) } }, @@ -73,7 +73,7 @@ func commands() []cli.Command { Name: "status", Usage: "Show status of DM.", Action: func(c *cli.Context) { - format.Error("Not yet implemented") + format.Err("Not yet implemented") os.Exit(1) }, }, @@ -83,7 +83,7 @@ func commands() []cli.Command { ArgsUsage: "", Action: func(c *cli.Context) { if err := target(c.Bool("dry-run")); err != nil { - format.Error("%s (Is the cluster running?)", err) + format.Err("%s (Is the cluster running?)", err) os.Exit(1) } }, @@ -108,7 +108,7 @@ func commands() []cli.Command { }, Action: func(c *cli.Context) { if err := install(c.Bool("dry-run")); err != nil { - format.Error("%s (Run 'helm doctor' for more information)", err) + format.Err("%s (Run 'helm doctor' for more information)", err) os.Exit(1) } }, @@ -119,7 +119,7 @@ func commands() []cli.Command { ArgsUsage: "", Action: func(c *cli.Context) { if err := doctor(); err != nil { - format.Error("%s", err) + format.Err("%s", err) os.Exit(1) } }, diff --git a/cmd/helm/list.go b/cmd/helm/list.go index b5eb7446d..eadb25757 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -14,7 +14,7 @@ func listCmd() cli.Command { Usage: "Lists the deployments in the cluster", Action: func(c *cli.Context) { if err := list(c.GlobalString("host")); err != nil { - format.Error("%s (Is the cluster running?)", err) + format.Err("%s (Is the cluster running?)", err) os.Exit(1) } }, diff --git a/cmd/helm/pack.go b/cmd/helm/pack.go index dea528f61..04ab391cf 100644 --- a/cmd/helm/pack.go +++ b/cmd/helm/pack.go @@ -1,6 +1,7 @@ package main import ( + "errors" "fmt" "os" @@ -12,7 +13,7 @@ import ( func pack(cxt *cli.Context) error { args := cxt.Args() if len(args) < 1 { - return fmt.Errorf("'helm package' requires a path to a chart directory as an argument.") + return errors.New("'helm package' requires a path to a chart directory as an argument") } dir := args[0] diff --git a/deploy/deploy.go b/deploy/deploy.go index 53d88bd0d..41a9188d9 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -78,6 +78,7 @@ func (d *Deployment) Prepare() error { return nil } +// Chart retrieves the chart from teh deployment. func (d *Deployment) Chart() *chart.Chart { return d.lchart } diff --git a/dm/client.go b/dm/client.go index 8f49669ea..301d1f564 100644 --- a/dm/client.go +++ b/dm/client.go @@ -14,7 +14,7 @@ import ( ) // The default HTTP timeout -var DefaultHTTPTimeout time.Duration = time.Second * 10 +var DefaultHTTPTimeout = time.Second * 10 // Client is a DM client. type Client struct { @@ -50,7 +50,7 @@ func (c *Client) url(path string) string { func (c *Client) CallService(path, method, action string, dest interface{}, reader io.ReadCloser) error { u := c.url(path) - resp, err := c.callHttp(u, method, action, reader) + resp, err := c.callHTTP(u, method, action, reader) if err != nil { return err } @@ -69,8 +69,8 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read return nil } -// callHttp is a low-level primative for executing HTTP operations. -func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (string, error) { +// callHTTP is a low-level primative for executing HTTP operations. +func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (string, error) { request, err := http.NewRequest(method, path, reader) request.Header.Add("Content-Type", "application/json") @@ -99,6 +99,7 @@ func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (st return string(body), nil } +// ListDeployments lists the deployments in DM. func (c *Client) ListDeployments() error { var d interface{} if err := c.CallService("deployments", "GET", "foo", &d, nil); err != nil { @@ -109,6 +110,7 @@ func (c *Client) ListDeployments() error { return nil } +// DeployChart sends a chart to DM for deploying. func (c *Client) DeployChart(filename, deployname string) error { f, err := os.Open(filename) if err != nil { diff --git a/dm/install.go b/dm/install.go index ad2aabb75..f2a70163d 100644 --- a/dm/install.go +++ b/dm/install.go @@ -20,7 +20,7 @@ func IsInstalled(runner kubectl.Runner) bool { // we know that we have both the namespace and the manager API server. out, err := runner.GetByKind("rc", "manager-rc", "dm") if err != nil { - format.Error("Installation not found: %s %s", out, err) + format.Err("Installation not found: %s %s", out, err) return false } return true diff --git a/dm/transport.go b/dm/transport.go index 588f7f96d..345cbfa61 100644 --- a/dm/transport.go +++ b/dm/transport.go @@ -15,6 +15,7 @@ type debugTransport struct { http.RoundTripper } +// NewDebugTransport returns a debugging implementation of a RoundTripper. func NewDebugTransport(rt http.RoundTripper) http.RoundTripper { return debugTransport{ RoundTripper: rt, diff --git a/format/messages.go b/format/messages.go index dcf26736a..59de3e6cb 100644 --- a/format/messages.go +++ b/format/messages.go @@ -7,16 +7,19 @@ import ( // This is all just placeholder. -func Error(msg string, v ...interface{}) { +// Err prints an error message to Stderr. +func Err(msg string, v ...interface{}) { msg = "[ERROR] " + msg + "\n" fmt.Fprintf(os.Stderr, msg, v...) } +// Info prints an informational message to Stdout. func Info(msg string, v ...interface{}) { msg = "[INFO] " + msg + "\n" fmt.Fprintf(os.Stdout, msg, v...) } +// Msg prints a raw message to Stdout. func Msg(msg string, v ...interface{}) { fmt.Fprintf(os.Stdout, msg, v...) } diff --git a/kubectl/get.go b/kubectl/get.go index 6bdc0e433..d80dd385d 100644 --- a/kubectl/get.go +++ b/kubectl/get.go @@ -13,6 +13,7 @@ func (r RealRunner) Get(stdin []byte, ns string) ([]byte, error) { return cmd.CombinedOutput() } +// GetByKind gets a named thing by kind. func (r RealRunner) GetByKind(kind, name, ns string) (string, error) { args := []string{"get", kind, name} @@ -37,6 +38,7 @@ func (r PrintRunner) Get(stdin []byte, ns string) ([]byte, error) { return []byte(cmd.String()), nil } +// GetByKind gets a named thing by kind. func (r PrintRunner) GetByKind(kind, name, ns string) (string, error) { args := []string{"get", kind, name} From e7445a463298f65a5468e65e0b910ffb96479755 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 5 Feb 2016 14:13:05 -0700 Subject: [PATCH 23/73] fix(vet): fix a number of lint/vet warnings --- cmd/helm/dm.go | 2 +- cmd/helm/doctor.go | 1 + dm/uninstall.go | 2 +- format/messages.go | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/helm/dm.go b/cmd/helm/dm.go index c5069900a..b331e62c7 100644 --- a/cmd/helm/dm.go +++ b/cmd/helm/dm.go @@ -27,7 +27,7 @@ func uninstall(dryRun bool) error { out, err := dm.Uninstall(runner) if err != nil { - format.Error("Error uninstalling: %s %s", out, err) + format.Err("Error uninstalling: %s %s", out, err) } format.Msg(out) return nil diff --git a/cmd/helm/doctor.go b/cmd/helm/doctor.go index ebf66099a..15f068a25 100644 --- a/cmd/helm/doctor.go +++ b/cmd/helm/doctor.go @@ -2,6 +2,7 @@ package main import ( "github.com/deis/helm-dm/dm" + "github.com/deis/helm-dm/format" "github.com/deis/helm-dm/kubectl" ) diff --git a/dm/uninstall.go b/dm/uninstall.go index 277ff1c10..675ebdb73 100644 --- a/dm/uninstall.go +++ b/dm/uninstall.go @@ -4,7 +4,7 @@ import ( "github.com/deis/helm-dm/kubectl" ) -// uninstall uses kubectl to uninstall the base DM. +// Uninstall uses kubectl to uninstall the base DM. // // Returns the string output received from the operation, and an error if the // command failed. diff --git a/format/messages.go b/format/messages.go index 59de3e6cb..b1c63d510 100644 --- a/format/messages.go +++ b/format/messages.go @@ -24,11 +24,13 @@ func Msg(msg string, v ...interface{}) { fmt.Fprintf(os.Stdout, msg, v...) } +// Success is an achievement marked by pretty output. func Success(msg string, v ...interface{}) { msg = "[Success] " + msg + "\n" fmt.Fprintf(os.Stdout, msg, v...) } +// Warning emits a warning message. func Warning(msg string, v ...interface{}) { msg = "[Warning] " + msg + "\n" fmt.Fprintf(os.Stdout, msg, v...) From 1ab3cd135fdaeed6e0ee277ff7ccaf75961443c5 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 5 Feb 2016 14:32:30 -0700 Subject: [PATCH 24/73] fix(travis): add badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 83afcc1bc..f82b966f5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Helm +[![Build Status](https://travis-ci.com/deis/helm-dm.svg?token=squRCxmMZdFNSQ9qAtbQ&branch=master)](https://travis-ci.com/deis/helm-dm) Experimental Helm fork. From 6fd1680b9f0a453084b9c7baafd2f9672616b6bf Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Sat, 6 Feb 2016 15:43:16 -0800 Subject: [PATCH 25/73] ref(client): refactor url parsing --- cmd/helm/list.go | 3 +- dm/client.go | 77 ++++++++++++++++++++++++++++++++++++++++++----- dm/client_test.go | 60 ++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+), 10 deletions(-) create mode 100644 dm/client_test.go diff --git a/cmd/helm/list.go b/cmd/helm/list.go index eadb25757..afc26c090 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -22,7 +22,6 @@ func listCmd() cli.Command { } func list(host string) error { - client := dm.NewClient(host) - client.Protocol = "http" + client := dm.NewClient(host).SetDebug(true) return client.ListDeployments() } diff --git a/dm/client.go b/dm/client.go index 301d1f564..74dcf594c 100644 --- a/dm/client.go +++ b/dm/client.go @@ -6,8 +6,10 @@ import ( "io" "io/ioutil" "net/http" + "net/url" "os" "path/filepath" + "strings" "time" "github.com/ghodss/yaml" @@ -16,6 +18,9 @@ import ( // The default HTTP timeout var DefaultHTTPTimeout = time.Second * 10 +// The default HTTP Protocol +var DefaultHTTPProtocol = "http" + // Client is a DM client. type Client struct { // Timeout on HTTP connections. @@ -26,29 +31,61 @@ type Client struct { Protocol string // Transport Transport http.RoundTripper + // Debug enables http logging + Debug bool + + // Base URL for remote service + baseURL *url.URL } // NewClient creates a new DM client. Host name is required. func NewClient(host string) *Client { + url, _ := DefaultServerURL(host) + return &Client{ HTTPTimeout: DefaultHTTPTimeout, - Protocol: "https", - Host: host, - Transport: NewDebugTransport(nil), + baseURL: url, + Transport: http.DefaultTransport, + } +} + +// SetDebug enables debug mode which logs http +func (c *Client) SetDebug(enable bool) *Client { + c.Debug = enable + return c +} + +// transport wraps client transport if debug is enabled +func (c *Client) transport() http.RoundTripper { + if c.Debug { + return NewDebugTransport(c.Transport) } + return c.Transport +} + +// SetTransport sets a custom Transport. Defaults to http.DefaultTransport +func (c *Client) SetTransport(tr http.RoundTripper) *Client { + c.Transport = tr + return c } // url constructs the URL. -func (c *Client) url(path string) string { - // TODO: Switch to net.URL - return c.Protocol + "://" + c.Host + "/" + path +func (c *Client) url(rawurl string) (string, error) { + u, err := url.Parse(rawurl) + if err != nil { + return "", err + } + return c.baseURL.ResolveReference(u).String(), nil } // CallService is a low-level function for making an API call. // // This calls the service and then unmarshals the returned data into dest. func (c *Client) CallService(path, method, action string, dest interface{}, reader io.ReadCloser) error { - u := c.url(path) + u, err := c.url(path) + if err != nil { + return err + } resp, err := c.callHTTP(u, method, action, reader) if err != nil { @@ -76,7 +113,7 @@ func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (st client := http.Client{ Timeout: time.Duration(time.Duration(DefaultHTTPTimeout) * time.Second), - Transport: c.Transport, + Transport: c.transport(), } response, err := client.Do(request) @@ -155,3 +192,27 @@ func (c *Client) DeployChart(filename, deployname string) error { return nil } + +// DefaultServerURL converts a host, host:port, or URL string to the default base server API path +// to use with a Client +func DefaultServerURL(host string) (*url.URL, error) { + if host == "" { + return nil, fmt.Errorf("host must be a URL or a host:port pair") + } + base := host + hostURL, err := url.Parse(base) + if err != nil { + return nil, err + } + if hostURL.Scheme == "" { + hostURL, err = url.Parse(DefaultHTTPProtocol + "://" + base) + if err != nil { + return nil, err + } + } + if len(hostURL.Path) > 0 && !strings.HasSuffix(hostURL.Path, "/") { + hostURL.Path = hostURL.Path + "/" + } + + return hostURL, nil +} diff --git a/dm/client_test.go b/dm/client_test.go new file mode 100644 index 000000000..f6b1d0dfe --- /dev/null +++ b/dm/client_test.go @@ -0,0 +1,60 @@ +package dm + +import ( + "testing" +) + +func TestDefaultServerURL(t *testing.T) { + tt := []struct { + host string + url string + }{ + {"127.0.0.1", "http://127.0.0.1"}, + {"127.0.0.1:8080", "http://127.0.0.1:8080"}, + {"foo.bar.com", "http://foo.bar.com"}, + {"foo.bar.com/prefix", "http://foo.bar.com/prefix/"}, + {"http://host/prefix", "http://host/prefix/"}, + {"https://host/prefix", "https://host/prefix/"}, + {"http://host", "http://host"}, + {"http://host/other", "http://host/other/"}, + } + + for _, tc := range tt { + u, err := DefaultServerURL(tc.host) + if err != nil { + t.Fatal(err) + } + + if tc.url != u.String() { + t.Errorf("%s, expected host %s, got %s", tc.host, tc.url, u.String()) + } + } +} + +func TestURL(t *testing.T) { + tt := []struct { + host string + path string + url string + }{ + {"127.0.0.1", "foo", "http://127.0.0.1/foo"}, + {"127.0.0.1:8080", "foo", "http://127.0.0.1:8080/foo"}, + {"foo.bar.com", "foo", "http://foo.bar.com/foo"}, + {"foo.bar.com/prefix", "foo", "http://foo.bar.com/prefix/foo"}, + {"http://host/prefix", "foo", "http://host/prefix/foo"}, + {"http://host", "foo", "http://host/foo"}, + {"http://host/other", "/foo", "http://host/foo"}, + } + + for _, tc := range tt { + c := NewClient(tc.host) + p, err := c.url(tc.path) + if err != nil { + t.Fatal(err) + } + + if tc.url != p { + t.Errorf("expected %s, got %s", tc.url, p) + } + } +} From bb9c5fcad63846896a048c3e1e671777c13ce0a6 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Sat, 6 Feb 2016 15:53:22 -0800 Subject: [PATCH 26/73] fix(glide): use master branch of deployment-manager --- glide.lock | 17 +++++++++++------ glide.yaml | 3 --- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/glide.lock b/glide.lock index d34eae154..7efa51c8a 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: fce0581223b80f7a04fbb4ad4bd7ff8fa3d12e879dba894ba448770933731887 -updated: 2016-02-02T17:30:13.283644703-07:00 +hash: 71e9a5a2d1f27a0ecfa70595154f87fee9f5519ba6bdea4d01834bab5aa29074 +updated: 2016-02-06T17:26:31.257079434-08:00 imports: - name: github.com/codegangsta/cli version: cf1f63a7274872768d4037305d572b70b1199397 @@ -13,8 +13,6 @@ imports: version: 45bba206dd5270d96bac4942dcfe515726613249 - name: github.com/google/go-github version: b8b4ac742977310ff6e75140a403a38dab109977 - subpackages: - - /github - name: github.com/google/go-querystring version: 2a60fc2ba6c19de80291203597d752e9ba58e4c0 - name: github.com/gorilla/context @@ -27,8 +25,6 @@ imports: version: 14c555599c2a4f493c1e13fd1ea6fdf721739028 - name: github.com/kubernetes/deployment-manager version: "" - repo: https://github.com/technosophos/deployment-manager - vcs: git subpackages: - /common - name: github.com/Masterminds/semver @@ -43,6 +39,15 @@ imports: version: 8a57ed94ffd43444c0879fe75701732a38afc985 - name: golang.org/x/text version: 5aaa1a807bf8a2f763540b140e7805973476eb88 +- name: google.golang.com/appengine/datastore + version: "" + repo: https://google.golang.com/appengine/datastore +- name: google.golang.com/appengine/memcache + version: "" + repo: https://google.golang.com/appengine/memcache +- name: google.golang.com/appengine/user + version: "" + repo: https://google.golang.com/appengine/user - name: google.golang.org/api version: 8fa1015948e6fc21c025050624e4c4e2f4f405c4 - name: google.golang.org/appengine diff --git a/glide.yaml b/glide.yaml index dd229737b..6a6b34b16 100644 --- a/glide.yaml +++ b/glide.yaml @@ -4,9 +4,6 @@ ignore: import: - package: github.com/codegangsta/cli - package: github.com/kubernetes/deployment-manager - version: feat/chartfile - repo: https://github.com/technosophos/deployment-manager - vcs: git subpackages: - /common - package: github.com/ghodss/yaml From 4fc6a7b6c0dd8e4a620a1c089c2f4fb6d75ddb74 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 8 Feb 2016 09:55:50 -0800 Subject: [PATCH 27/73] test(dm): add unit tests for dm client --- cmd/helm/list.go | 8 +++++++- dm/client.go | 22 +++++----------------- dm/client_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/cmd/helm/list.go b/cmd/helm/list.go index afc26c090..ec321952d 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "github.com/codegangsta/cli" @@ -23,5 +24,10 @@ func listCmd() cli.Command { func list(host string) error { client := dm.NewClient(host).SetDebug(true) - return client.ListDeployments() + list, err := client.ListDeployments() + if err != nil { + return err + } + fmt.Println(list) + return nil } diff --git a/dm/client.go b/dm/client.go index 74dcf594c..3749451c0 100644 --- a/dm/client.go +++ b/dm/client.go @@ -11,8 +11,6 @@ import ( "path/filepath" "strings" "time" - - "github.com/ghodss/yaml" ) // The default HTTP timeout @@ -94,15 +92,6 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read if err := json.Unmarshal([]byte(resp), dest); err != nil { return fmt.Errorf("Failed to parse JSON response from service: %s", resp) } - - // From here down is just printing the data. - - y, err := yaml.Marshal(dest) - if err != nil { - return fmt.Errorf("Failed to serialize JSON response from service: %s", resp) - } - - fmt.Println(string(y)) return nil } @@ -137,14 +126,13 @@ func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (st } // ListDeployments lists the deployments in DM. -func (c *Client) ListDeployments() error { - var d interface{} - if err := c.CallService("deployments", "GET", "foo", &d, nil); err != nil { - return err +func (c *Client) ListDeployments() ([]string, error) { + var l []string + if err := c.CallService("deployments", "GET", "foo", &l, nil); err != nil { + return nil, err } - fmt.Printf("%#v\n", d) - return nil + return l, nil } // DeployChart sends a chart to DM for deploying. diff --git a/dm/client_test.go b/dm/client_test.go index f6b1d0dfe..d4660e4ab 100644 --- a/dm/client_test.go +++ b/dm/client_test.go @@ -1,6 +1,8 @@ package dm import ( + "net/http" + "net/http/httptest" "testing" ) @@ -58,3 +60,39 @@ func TestURL(t *testing.T) { } } } + +type fakeClient struct { + *Client + server *httptest.Server + handler http.HandlerFunc + response []byte +} + +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.Client = NewClient(c.server.URL) + return c +} + +func (c *fakeClient) teardown() { + c.server.Close() +} + +func TestListDeployments(t *testing.T) { + fc := &fakeClient{ + response: []byte(`["guestbook.yaml"]`), + } + defer fc.teardown() + + l, err := fc.setup().ListDeployments() + if err != nil { + t.Fatal(err) + } + + if len(l) != 1 { + t.Fatal("expected a single deployment") + } +} From fe60ff17c1ec85d75c91af1eada1e7b9252102fb Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 8 Feb 2016 09:57:09 -0800 Subject: [PATCH 28/73] feat(debug): add debug flag --- cmd/helm/helm.go | 10 ++++++++++ cmd/helm/list.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index a08514c2a..498693b55 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -8,6 +8,7 @@ import ( ) var version = "0.0.1" +var isDebugging bool func main() { app := cli.NewApp() @@ -24,6 +25,15 @@ func main() { EnvVar: "HELM_HOST", Value: "https://localhost:8181/FIXME_NOT_RIGHT", }, + cli.BoolFlag{ + Name: "debug", + Usage: "Enable verbose debugging output", + }, + } + + app.Before = func(ctx *cli.Context) error { + isDebugging = ctx.Bool("debug") + return nil } app.Run(os.Args) diff --git a/cmd/helm/list.go b/cmd/helm/list.go index ec321952d..50d54c363 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -23,7 +23,7 @@ func listCmd() cli.Command { } func list(host string) error { - client := dm.NewClient(host).SetDebug(true) + client := dm.NewClient(host).SetDebug(isDebugging) list, err := client.ListDeployments() if err != nil { return err From fd7e9b96240d7ec967a75b6fc279051b7d3e7d84 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 8 Feb 2016 10:53:51 -0800 Subject: [PATCH 29/73] feat(test): add test coverage to Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index badddd90c..b79e1a6f1 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ quicktest: $(PATH_WITH_HELM) go test -short $(addprefix ./,$(GO_PACKAGES)) test: test-style - $(PATH_WITH_HELM) go test -v $(addprefix ./,$(GO_PACKAGES)) + $(PATH_WITH_HELM) go test -v -cover $(addprefix ./,$(GO_PACKAGES)) test-style: @if [ $(shell gofmt -e -l -s *.go $(GO_PACKAGES)) ]; then \ From 570083361d727ae1eb38df68a1911f03f13e3bf9 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 8 Feb 2016 12:21:02 -0800 Subject: [PATCH 30/73] feat(format): add yaml output format --- cmd/helm/list.go | 4 +--- format/messages.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 50d54c363..a9cd6d996 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "github.com/codegangsta/cli" @@ -28,6 +27,5 @@ func list(host string) error { if err != nil { return err } - fmt.Println(list) - return nil + return format.YAML(list) } diff --git a/format/messages.go b/format/messages.go index b1c63d510..1d2a8b0e1 100644 --- a/format/messages.go +++ b/format/messages.go @@ -3,6 +3,8 @@ package format import ( "fmt" "os" + + "github.com/ghodss/yaml" ) // This is all just placeholder. @@ -35,3 +37,13 @@ func Warning(msg string, v ...interface{}) { msg = "[Warning] " + msg + "\n" fmt.Fprintf(os.Stdout, msg, v...) } + +func YAML(v interface{}) error { + y, err := yaml.Marshal(v) + if err != nil { + return fmt.Errorf("Failed to serialize to yaml: %s", v.(string)) + } + + Msg(string(y)) + return nil +} From 1e741afb58414720e0fcef33c036bcb27e7e8be7 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 8 Feb 2016 12:38:32 -0800 Subject: [PATCH 31/73] feat(get): add get verb --- cmd/helm/get.go | 33 +++++++++++++++++++++++++++++ cmd/helm/helm.go | 1 + cmd/helm/list.go | 18 ++++++---------- dm/client.go | 53 ++++++++++++++++++++++++++++------------------- dm/client_test.go | 22 ++++++++++++++++++++ 5 files changed, 94 insertions(+), 33 deletions(-) create mode 100644 cmd/helm/get.go diff --git a/cmd/helm/get.go b/cmd/helm/get.go new file mode 100644 index 000000000..e5dcfe921 --- /dev/null +++ b/cmd/helm/get.go @@ -0,0 +1,33 @@ +package main + +import ( + "errors" + + "github.com/codegangsta/cli" + "github.com/deis/helm-dm/dm" + "github.com/deis/helm-dm/format" +) + +func getCmd() cli.Command { + return cli.Command{ + Name: "get", + Usage: "Retrieves the supplied deployment", + Action: func(c *cli.Context) { run(c, get) }, + } +} + +func get(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + 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) + if err != nil { + return err + } + return format.YAML(deployment) +} diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 498693b55..aeb04e51f 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -181,6 +181,7 @@ func commands() []cli.Command { Name: "search", }, listCmd(), + getCmd(), } } diff --git a/cmd/helm/list.go b/cmd/helm/list.go index a9cd6d996..24f200a5b 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -1,8 +1,6 @@ package main import ( - "os" - "github.com/codegangsta/cli" "github.com/deis/helm-dm/dm" "github.com/deis/helm-dm/format" @@ -10,19 +8,15 @@ import ( func listCmd() cli.Command { return cli.Command{ - Name: "list", - Usage: "Lists the deployments in the cluster", - Action: func(c *cli.Context) { - if err := list(c.GlobalString("host")); err != nil { - format.Err("%s (Is the cluster running?)", err) - os.Exit(1) - } - }, + Name: "list", + Usage: "Lists the deployments in the cluster", + Action: func(c *cli.Context) { run(c, list) }, } } -func list(host string) error { - client := dm.NewClient(host).SetDebug(isDebugging) +func list(c *cli.Context) error { + host := c.GlobalString("host") + client := dm.NewClient(host).SetDebug(c.GlobalBool("debug")) list, err := client.ListDeployments() if err != nil { return err diff --git a/dm/client.go b/dm/client.go index 3749451c0..7fa57d303 100644 --- a/dm/client.go +++ b/dm/client.go @@ -11,6 +11,8 @@ import ( "path/filepath" "strings" "time" + + "github.com/kubernetes/deployment-manager/common" ) // The default HTTP timeout @@ -125,10 +127,34 @@ func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (st return string(body), nil } +// DefaultServerURL converts a host, host:port, or URL string to the default base server API path +// to use with a Client +func DefaultServerURL(host string) (*url.URL, error) { + if host == "" { + return nil, fmt.Errorf("host must be a URL or a host:port pair") + } + base := host + hostURL, err := url.Parse(base) + if err != nil { + return nil, err + } + if hostURL.Scheme == "" { + hostURL, err = url.Parse(DefaultHTTPProtocol + "://" + base) + if err != nil { + return nil, err + } + } + if len(hostURL.Path) > 0 && !strings.HasSuffix(hostURL.Path, "/") { + hostURL.Path = hostURL.Path + "/" + } + + return hostURL, nil +} + // ListDeployments lists the deployments in DM. func (c *Client) ListDeployments() ([]string, error) { var l []string - if err := c.CallService("deployments", "GET", "foo", &l, nil); err != nil { + if err := c.CallService("deployments", "GET", "list deployments", &l, nil); err != nil { return nil, err } @@ -181,26 +207,11 @@ func (c *Client) DeployChart(filename, deployname string) error { return nil } -// DefaultServerURL converts a host, host:port, or URL string to the default base server API path -// to use with a Client -func DefaultServerURL(host string) (*url.URL, error) { - if host == "" { - return nil, fmt.Errorf("host must be a URL or a host:port pair") - } - base := host - hostURL, err := url.Parse(base) - if err != nil { +// GetDeployment retrieves the supplied deployment +func (c *Client) GetDeployment(name string) (*common.Deployment, error) { + var deployment *common.Deployment + if err := c.CallService(filepath.Join("deployments", name), "GET", "get deployment", &deployment, nil); err != nil { return nil, err } - if hostURL.Scheme == "" { - hostURL, err = url.Parse(DefaultHTTPProtocol + "://" + base) - if err != nil { - return nil, err - } - } - if len(hostURL.Path) > 0 && !strings.HasSuffix(hostURL.Path, "/") { - hostURL.Path = hostURL.Path + "/" - } - - return hostURL, nil + return deployment, nil } diff --git a/dm/client_test.go b/dm/client_test.go index d4660e4ab..61e2e0036 100644 --- a/dm/client_test.go +++ b/dm/client_test.go @@ -4,6 +4,8 @@ import ( "net/http" "net/http/httptest" "testing" + + "github.com/kubernetes/deployment-manager/common" ) func TestDefaultServerURL(t *testing.T) { @@ -96,3 +98,23 @@ func TestListDeployments(t *testing.T) { t.Fatal("expected a single deployment") } } + +func TestGetDeployment(t *testing.T) { + 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"}`), + } + defer fc.teardown() + + d, err := fc.setup().GetDeployment("guestbook.yaml") + if err != nil { + t.Fatal(err) + } + + if d.Name != "guestbook.yaml" { + t.Fatalf("expected deployment name 'guestbook.yaml', got '%s'", d.Name) + } + + if d.State.Status != common.DeployedStatus { + t.Fatalf("expected deployment status 'Deployed', got '%s'", d.State.Status) + } +} From 927c084f631f1e40f4907fb287365f6450f5d9c6 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 8 Feb 2016 22:22:30 -0800 Subject: [PATCH 32/73] feat(client): add helm user agent --- dm/client.go | 3 +++ dm/client_test.go | 28 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/dm/client.go b/dm/client.go index 7fa57d303..fbc6b46f4 100644 --- a/dm/client.go +++ b/dm/client.go @@ -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. func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (string, error) { 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") client := http.Client{ diff --git a/dm/client_test.go b/dm/client_test.go index 61e2e0036..2786e820b 100644 --- a/dm/client_test.go +++ b/dm/client_test.go @@ -3,6 +3,7 @@ package dm import ( "net/http" "net/http/httptest" + "strings" "testing" "github.com/kubernetes/deployment-manager/common" @@ -65,15 +66,11 @@ func TestURL(t *testing.T) { type fakeClient struct { *Client - server *httptest.Server - handler http.HandlerFunc - response []byte + server *httptest.Server + handler http.HandlerFunc } 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.Client = NewClient(c.server.URL) return c @@ -83,9 +80,22 @@ func (c *fakeClient) teardown() { 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) { fc := &fakeClient{ - response: []byte(`["guestbook.yaml"]`), + handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte(`["guestbook.yaml"]`)) + }), } defer fc.teardown() @@ -101,7 +111,9 @@ func TestListDeployments(t *testing.T) { func TestGetDeployment(t *testing.T) { 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() From 8cf1f350592dfa32b1d3a6ddd0ed952ceb5bf50d Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 8 Feb 2016 22:59:49 -0800 Subject: [PATCH 33/73] chore(*): remove global debug variable --- cmd/helm/helm.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index aeb04e51f..b84d03fbc 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -8,7 +8,6 @@ import ( ) var version = "0.0.1" -var isDebugging bool func main() { app := cli.NewApp() @@ -30,12 +29,6 @@ func main() { Usage: "Enable verbose debugging output", }, } - - app.Before = func(ctx *cli.Context) error { - isDebugging = ctx.Bool("debug") - return nil - } - app.Run(os.Args) } From 6058cad0a1649a98038cacc6d4fd4ff5ca31501c Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 8 Feb 2016 23:54:59 -0800 Subject: [PATCH 34/73] feat(client): add timeout cli option --- cmd/helm/get.go | 6 +----- cmd/helm/helm.go | 13 +++++++++++++ cmd/helm/list.go | 5 +---- dm/client.go | 6 ++++++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/cmd/helm/get.go b/cmd/helm/get.go index e5dcfe921..4fd0d5c5e 100644 --- a/cmd/helm/get.go +++ b/cmd/helm/get.go @@ -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 } diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index b84d03fbc..268498ea6 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -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) +} diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 24f200a5b..70d2abb30 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -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 } diff --git a/dm/client.go b/dm/client.go index fbc6b46f4..b95a59356 100644 --- a/dm/client.go +++ b/dm/client.go @@ -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) From 3c62cd9fc8bdf7826c87c961db69a14658d821bf Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Tue, 9 Feb 2016 13:04:57 -0800 Subject: [PATCH 35/73] ref(cmd): break up command definitions --- cmd/helm/create.go | 12 ++++ cmd/helm/deploy.go | 39 +++++++++++++ cmd/helm/dm.go | 74 +++++++++++++++++++++++++ cmd/helm/doctor.go | 16 +++++- cmd/helm/get.go | 4 ++ cmd/helm/helm.go | 135 ++++----------------------------------------- cmd/helm/list.go | 4 ++ cmd/helm/pack.go | 13 +++++ 8 files changed, 173 insertions(+), 124 deletions(-) diff --git a/cmd/helm/create.go b/cmd/helm/create.go index 177f5e25b..3cbaa11fc 100644 --- a/cmd/helm/create.go +++ b/cmd/helm/create.go @@ -7,6 +7,18 @@ import ( "github.com/kubernetes/deployment-manager/chart" ) +func init() { + addCommands(createCmd()) +} + +func createCmd() cli.Command { + return cli.Command{ + Name: "create", + Usage: "Create a new local chart for editing.", + Action: func(c *cli.Context) { run(c, create) }, + } +} + func create(c *cli.Context) error { args := c.Args() if len(args) < 1 { diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index 12c5f2c97..e21bdc712 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -10,6 +10,45 @@ import ( "github.com/kubernetes/deployment-manager/chart" ) +func init() { + addCommands(deployCmd()) +} + +func deployCmd() cli.Command { + return cli.Command{ + Name: "deploy", + Aliases: []string{"install"}, + Usage: "Deploy a chart into the cluster.", + Action: func(c *cli.Context) { run(c, deploy) }, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Only display the underlying kubectl commands.", + }, + cli.BoolFlag{ + Name: "stdin,i", + Usage: "Read a configuration from STDIN.", + }, + cli.StringFlag{ + Name: "name", + Usage: "Name of deployment, used for deploy and update commands (defaults to template name)", + }, + // TODO: I think there is a Generic flag type that we can implement parsing with. + cli.StringFlag{ + Name: "properties,p", + Usage: "A comma-separated list of key=value pairs: 'foo=bar,foo2=baz'.", + }, + cli.StringFlag{ + // FIXME: This is not right. It's sort of a half-baked forward + // port of dm.go. + Name: "repository", + Usage: "The default repository", + Value: "kubernetes/application-dm-templates", + }, + }, + } +} + func deploy(c *cli.Context) error { args := c.Args() if len(args) < 1 { diff --git a/cmd/helm/dm.go b/cmd/helm/dm.go index b331e62c7..97592b48d 100644 --- a/cmd/helm/dm.go +++ b/cmd/helm/dm.go @@ -2,7 +2,9 @@ package main import ( "errors" + "os" + "github.com/codegangsta/cli" "github.com/deis/helm-dm/dm" "github.com/deis/helm-dm/format" "github.com/deis/helm-dm/kubectl" @@ -11,6 +13,78 @@ import ( // ErrAlreadyInstalled indicates that DM is already installed. var ErrAlreadyInstalled = errors.New("Already Installed") +func init() { + addCommands(dmCmd()) +} + +func dmCmd() cli.Command { + return cli.Command{ + Name: "dm", + Usage: "Manage DM on Kubernetes", + Subcommands: []cli.Command{ + { + Name: "install", + Usage: "Install DM on Kubernetes.", + Description: ``, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Show what would be installed, but don't install anything.", + }, + }, + Action: func(c *cli.Context) { + if err := install(c.Bool("dry-run")); err != nil { + format.Err("%s (Run 'helm doctor' for more information)", err) + os.Exit(1) + } + }, + }, + { + Name: "uninstall", + Usage: "Uninstall the DM from Kubernetes.", + Description: ``, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Show what would be installed, but don't install anything.", + }, + }, + Action: func(c *cli.Context) { + if err := uninstall(c.Bool("dry-run")); err != nil { + format.Err("%s (Run 'helm doctor' for more information)", err) + os.Exit(1) + } + }, + }, + { + Name: "status", + Usage: "Show status of DM.", + Action: func(c *cli.Context) { + format.Err("Not yet implemented") + os.Exit(1) + }, + }, + { + Name: "target", + Usage: "Displays information about cluster.", + ArgsUsage: "", + Action: func(c *cli.Context) { + if err := target(c.Bool("dry-run")); err != nil { + format.Err("%s (Is the cluster running?)", err) + os.Exit(1) + } + }, + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "dry-run", + Usage: "Only display the underlying kubectl commands.", + }, + }, + }, + }, + } +} + func install(dryRun bool) error { runner := getKubectlRunner(dryRun) diff --git a/cmd/helm/doctor.go b/cmd/helm/doctor.go index 15f068a25..8568b6972 100644 --- a/cmd/helm/doctor.go +++ b/cmd/helm/doctor.go @@ -1,12 +1,26 @@ package main import ( + "github.com/codegangsta/cli" "github.com/deis/helm-dm/dm" "github.com/deis/helm-dm/format" "github.com/deis/helm-dm/kubectl" ) -func doctor() error { +func init() { + addCommands(doctorCmd()) +} + +func doctorCmd() cli.Command { + return cli.Command{ + Name: "doctor", + Usage: "Run a series of checks for necessary prerequisites.", + ArgsUsage: "", + Action: func(c *cli.Context) { run(c, doctor) }, + } +} + +func doctor(c *cli.Context) error { var runner kubectl.Runner runner = &kubectl.RealRunner{} if dm.IsInstalled(runner) { diff --git a/cmd/helm/get.go b/cmd/helm/get.go index 4fd0d5c5e..ddff95eac 100644 --- a/cmd/helm/get.go +++ b/cmd/helm/get.go @@ -7,6 +7,10 @@ import ( "github.com/deis/helm-dm/format" ) +func init() { + addCommands(getCmd()) +} + func getCmd() cli.Command { return cli.Command{ Name: "get", diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 268498ea6..55b6c0ebb 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -10,12 +10,18 @@ import ( var version = "0.0.1" +var commands []cli.Command + +func init() { + commands = cmds() +} + func main() { app := cli.NewApp() app.Name = "helm" app.Version = version app.Usage = `Deploy and manage packages.` - app.Commands = commands() + app.Commands = commands // TODO: make better app.Flags = []cli.Flag{ @@ -38,73 +44,8 @@ func main() { app.Run(os.Args) } -func commands() []cli.Command { +func cmds() []cli.Command { return []cli.Command{ - { - Name: "dm", - Usage: "Manage DM on Kubernetes", - Subcommands: []cli.Command{ - { - Name: "install", - Usage: "Install DM on Kubernetes.", - Description: ``, - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "dry-run", - Usage: "Show what would be installed, but don't install anything.", - }, - }, - Action: func(c *cli.Context) { - if err := install(c.Bool("dry-run")); err != nil { - format.Err("%s (Run 'helm doctor' for more information)", err) - os.Exit(1) - } - }, - }, - { - Name: "uninstall", - Usage: "Uninstall the DM from Kubernetes.", - Description: ``, - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "dry-run", - Usage: "Show what would be installed, but don't install anything.", - }, - }, - Action: func(c *cli.Context) { - if err := uninstall(c.Bool("dry-run")); err != nil { - format.Err("%s (Run 'helm doctor' for more information)", err) - os.Exit(1) - } - }, - }, - { - Name: "status", - Usage: "Show status of DM.", - Action: func(c *cli.Context) { - format.Err("Not yet implemented") - os.Exit(1) - }, - }, - { - Name: "target", - Usage: "Displays information about cluster.", - ArgsUsage: "", - Action: func(c *cli.Context) { - if err := target(c.Bool("dry-run")); err != nil { - format.Err("%s (Is the cluster running?)", err) - os.Exit(1) - } - }, - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "dry-run", - Usage: "Only display the underlying kubectl commands.", - }, - }, - }, - }, - }, { Name: "init", Usage: "Initialize the client and install DM on Kubernetes.", @@ -122,68 +63,16 @@ func commands() []cli.Command { } }, }, - { - Name: "doctor", - Usage: "Run a series of checks for necessary prerequisites.", - ArgsUsage: "", - Action: func(c *cli.Context) { - if err := doctor(); err != nil { - format.Err("%s", err) - os.Exit(1) - } - }, - }, - { - Name: "create", - Usage: "Create a new local chart for editing.", - Action: func(c *cli.Context) { run(c, create) }, - }, - { - Name: "package", - Aliases: []string{"pack"}, - Usage: "Given a chart directory, package it into a release.", - Action: func(c *cli.Context) { run(c, pack) }, - }, - { - Name: "deploy", - Aliases: []string{"install"}, - Usage: "Deploy a chart into the cluster.", - Action: func(c *cli.Context) { run(c, deploy) }, - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "dry-run", - Usage: "Only display the underlying kubectl commands.", - }, - cli.BoolFlag{ - Name: "stdin,i", - Usage: "Read a configuration from STDIN.", - }, - cli.StringFlag{ - Name: "name", - Usage: "Name of deployment, used for deploy and update commands (defaults to template name)", - }, - // TODO: I think there is a Generic flag type that we can implement parsing with. - cli.StringFlag{ - Name: "properties,p", - Usage: "A comma-separated list of key=value pairs: 'foo=bar,foo2=baz'.", - }, - cli.StringFlag{ - // FIXME: This is not right. It's sort of a half-baked forward - // port of dm.go. - Name: "repository", - Usage: "The default repository", - Value: "kubernetes/application-dm-templates", - }, - }, - }, { Name: "search", }, - listCmd(), - getCmd(), } } +func addCommands(cmds ...cli.Command) { + commands = append(commands, cmds...) +} + func run(c *cli.Context, f func(c *cli.Context) error) { if err := f(c); err != nil { os.Stderr.Write([]byte(err.Error())) diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 70d2abb30..a3ea2f0df 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -5,6 +5,10 @@ import ( "github.com/deis/helm-dm/format" ) +func init() { + addCommands(listCmd()) +} + func listCmd() cli.Command { return cli.Command{ Name: "list", diff --git a/cmd/helm/pack.go b/cmd/helm/pack.go index 04ab391cf..dda22a291 100644 --- a/cmd/helm/pack.go +++ b/cmd/helm/pack.go @@ -10,6 +10,19 @@ import ( "github.com/kubernetes/deployment-manager/chart" ) +func init() { + addCommands(packageCmd()) +} + +func packageCmd() cli.Command { + return cli.Command{ + Name: "package", + Aliases: []string{"pack"}, + Usage: "Given a chart directory, package it into a release.", + Action: func(c *cli.Context) { run(c, pack) }, + } +} + func pack(cxt *cli.Context) error { args := cxt.Args() if len(args) < 1 { From bf8d4b371dc642a50d88b251aa34c2f87ee4d1e2 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Wed, 10 Feb 2016 09:19:13 -0800 Subject: [PATCH 36/73] fix(cmd): prevent cmd init functions from racing No running in the halls! --- cmd/helm/helm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 55b6c0ebb..693e192eb 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -13,7 +13,7 @@ var version = "0.0.1" var commands []cli.Command func init() { - commands = cmds() + addCommands(cmds()...) } func main() { From bbb3229da17b44d282a5eb7c9b1029cc6648877a Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Tue, 9 Feb 2016 12:26:40 -0700 Subject: [PATCH 37/73] fix(deploy): add tests --- cmd/helm/deploy.go | 44 +++++++++-- dm/client.go | 27 ++++--- dm/client_test.go | 39 ++++++++++ glide.lock | 58 +++----------- glide.yaml | 1 + testdata/charts/README.md | 9 +++ testdata/charts/frobnitz-0.0.1.tgz | Bin 0 -> 6246 bytes testdata/charts/frobnitz/Chart.yaml | 27 +++++++ testdata/charts/frobnitz/LICENSE | 1 + testdata/charts/frobnitz/README.md | 11 +++ testdata/charts/frobnitz/docs/README.md | 1 + testdata/charts/frobnitz/hooks/pre-install.py | 1 + testdata/charts/frobnitz/icon.svg | 8 ++ .../templates/wordpress-resources.yaml | 12 +++ .../charts/frobnitz/templates/wordpress.jinja | 72 ++++++++++++++++++ .../frobnitz/templates/wordpress.jinja.schema | 69 +++++++++++++++++ .../charts/frobnitz/templates/wordpress.yaml | 6 ++ 17 files changed, 315 insertions(+), 71 deletions(-) create mode 100644 testdata/charts/README.md create mode 100644 testdata/charts/frobnitz-0.0.1.tgz create mode 100644 testdata/charts/frobnitz/Chart.yaml create mode 100644 testdata/charts/frobnitz/LICENSE create mode 100644 testdata/charts/frobnitz/README.md create mode 100644 testdata/charts/frobnitz/docs/README.md create mode 100644 testdata/charts/frobnitz/hooks/pre-install.py create mode 100644 testdata/charts/frobnitz/icon.svg create mode 100644 testdata/charts/frobnitz/templates/wordpress-resources.yaml create mode 100644 testdata/charts/frobnitz/templates/wordpress.jinja create mode 100644 testdata/charts/frobnitz/templates/wordpress.jinja.schema create mode 100644 testdata/charts/frobnitz/templates/wordpress.yaml diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index e21bdc712..aa21e5b37 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -2,10 +2,15 @@ package main import ( "errors" + "fmt" "os" + "regexp" + "strings" + "github.com/aokoli/goutils" "github.com/codegangsta/cli" dep "github.com/deis/helm-dm/deploy" + "github.com/deis/helm-dm/dm" "github.com/deis/helm-dm/format" "github.com/kubernetes/deployment-manager/chart" ) @@ -93,7 +98,12 @@ func doDeploy(cfg *dep.Deployment, host string, dry bool) error { if err != nil { return err } + if cfg.Name == "" { + cfg.Name = genName(c.Chartfile().Name) + } + // TODO: Is it better to generate the file in temp dir like this, or + // just put it in the CWD? //tdir, err := ioutil.TempDir("", "helm-") //if err != nil { //format.Warn("Could not create temporary directory. Using .") @@ -107,18 +117,36 @@ func doDeploy(cfg *dep.Deployment, host string, dry bool) error { return err } cfg.Filename = tfile - + } else if cfg.Name == "" { + n, _, e := parseTarName(cfg.Filename) + if e != nil { + return e + } + cfg.Name = n } - if !dry { - if err := uploadTar(cfg.Filename); err != nil { - return err - } + if dry { + format.Info("Prepared deploy %q using file %q", cfg.Name, cfg.Filename) + return nil } - return nil + c := dm.NewClient(host) + return c.DeployChart(cfg.Filename, cfg.Name) } -func uploadTar(filename string) error { - return nil +func genName(pname string) string { + s, _ := goutils.RandomAlphaNumeric(8) + return fmt.Sprintf("%s-%s", pname, s) +} + +func parseTarName(name string) (string, string, error) { + tnregexp := regexp.MustCompile(chart.TarNameRegex) + if strings.HasSuffix(name, ".tgz") { + name = strings.TrimSuffix(name, ".tgz") + } + v := tnregexp.FindStringSubmatch(name) + if v == nil { + return name, "", fmt.Errorf("invalid name %s", name) + } + return v[1], v[2], nil } diff --git a/dm/client.go b/dm/client.go index b95a59356..087d0672b 100644 --- a/dm/client.go +++ b/dm/client.go @@ -8,6 +8,7 @@ import ( "net/http" "net/url" "os" + "path" "path/filepath" "strings" "time" @@ -178,7 +179,8 @@ func (c *Client) DeployChart(filename, deployname string) error { } defer f.Close() - request, err := http.NewRequest("POST", "/v2/deployments/", f) + u, err := c.url("/v2/deployments") + request, err := http.NewRequest("POST", u, 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. @@ -192,7 +194,7 @@ func (c *Client) DeployChart(filename, deployname string) error { client := http.Client{ Timeout: time.Duration(time.Duration(DefaultHTTPTimeout) * time.Second), - Transport: c.Transport, + Transport: c.transport(), } response, err := client.Do(request) @@ -200,17 +202,14 @@ func (c *Client) DeployChart(filename, deployname string) error { 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) + // We only want 201 CREATED. Admittedly, we could accept 200 and 202. + if response.StatusCode < http.StatusCreated { + body, err := ioutil.ReadAll(response.Body) + response.Body.Close() + if err != nil { + return err + } + return fmt.Errorf("Failed to post: %d %s - %s", response.StatusCode, response.Status, body) } return nil @@ -219,7 +218,7 @@ func (c *Client) DeployChart(filename, deployname string) error { // GetDeployment retrieves the supplied deployment func (c *Client) GetDeployment(name string) (*common.Deployment, error) { var deployment *common.Deployment - if err := c.CallService(filepath.Join("deployments", name), "GET", "get deployment", &deployment, nil); err != nil { + if err := c.CallService(path.Join("deployments", name), "GET", "get deployment", &deployment, nil); err != nil { return nil, err } return deployment, nil diff --git a/dm/client_test.go b/dm/client_test.go index 2786e820b..b7b6a816b 100644 --- a/dm/client_test.go +++ b/dm/client_test.go @@ -1,8 +1,10 @@ package dm import ( + "io/ioutil" "net/http" "net/http/httptest" + "os" "strings" "testing" @@ -130,3 +132,40 @@ func TestGetDeployment(t *testing.T) { t.Fatalf("expected deployment status 'Deployed', got '%s'", d.State.Status) } } + +func TestDeployChart(t *testing.T) { + testfile := "../testdata/charts/frobnitz-0.0.1.tgz" + testname := "sparkles" + + fi, err := os.Stat(testfile) + if err != nil { + t.Fatalf("could not stat file %s: %s", testfile, err) + } + expectedSize := int(fi.Size()) + + fc := &fakeClient{ + handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + data, err := ioutil.ReadAll(r.Body) + if err != nil { + t.Errorf("Failed to read data off of request: %s", err) + } + if len(data) != expectedSize { + t.Errorf("Expected content length %d, got %d", expectedSize, len(data)) + } + + if cn := r.Header.Get("x-chart-name"); cn != "frobnitz-0.0.1.tgz" { + t.Errorf("Expected frobnitz-0.0.1.tgz, got %q", cn) + } + if dn := r.Header.Get("x-deployment-name"); dn != "sparkles" { + t.Errorf("Expected sparkles, got %q", dn) + } + + w.WriteHeader(201) + }), + } + defer fc.teardown() + + if err := fc.setup().DeployChart(testfile, testname); err != nil { + t.Fatal(err) + } +} diff --git a/glide.lock b/glide.lock index 7efa51c8a..08cc2df8f 100644 --- a/glide.lock +++ b/glide.lock @@ -1,61 +1,21 @@ -hash: 71e9a5a2d1f27a0ecfa70595154f87fee9f5519ba6bdea4d01834bab5aa29074 -updated: 2016-02-06T17:26:31.257079434-08:00 +hash: c54a5f678965132636637023cd71e4d4065360b229242718f7f6e7674ac8d1c1 +updated: 2016-02-09T16:35:44.56035745-07:00 imports: +- name: github.com/aokoli/goutils + version: 9c37978a95bd5c709a15883b6242714ea6709e64 - name: github.com/codegangsta/cli - version: cf1f63a7274872768d4037305d572b70b1199397 -- name: github.com/emicklei/go-restful - version: b86acf97a74ed7603ac78d012f5535b4d587b156 + version: 8cea2901d4b2c28b97001e67a7d2d60e227f3da6 - name: github.com/ghodss/yaml version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee -- name: github.com/golang/glog - version: 23def4e6c14b4da8ac2ed8007337bc5eb5007998 -- name: github.com/golang/protobuf - version: 45bba206dd5270d96bac4942dcfe515726613249 -- name: github.com/google/go-github - version: b8b4ac742977310ff6e75140a403a38dab109977 -- name: github.com/google/go-querystring - version: 2a60fc2ba6c19de80291203597d752e9ba58e4c0 -- name: github.com/gorilla/context - version: 1c83b3eabd45b6d76072b66b746c20815fb2872d -- name: github.com/gorilla/handlers - version: b3aff83722cb2ae031a70cae984650e3a16cd20e -- name: github.com/gorilla/mux - version: 26a6070f849969ba72b72256e9f14cf519751690 -- name: github.com/gorilla/schema - version: 14c555599c2a4f493c1e13fd1ea6fdf721739028 - name: github.com/kubernetes/deployment-manager - version: "" + version: 4fe37ea6342991e4d0519e48d1fd6fca061baf5c subpackages: - /common + - chart + - common + - log - name: github.com/Masterminds/semver version: c4f7ef0702f269161a60489ccbbc9f1241ad1265 -- name: github.com/mjibson/appstats - version: 0542d5f0e87ea3a8fa4174322b9532f5d04f9fa8 -- name: golang.org/x/crypto - version: 1f22c0103821b9390939b6776727195525381532 -- name: golang.org/x/net - version: 6c581b96a7d38dd755f986fcf4f29665597694c0 -- name: golang.org/x/oauth2 - version: 8a57ed94ffd43444c0879fe75701732a38afc985 -- name: golang.org/x/text - version: 5aaa1a807bf8a2f763540b140e7805973476eb88 -- name: google.golang.com/appengine/datastore - version: "" - repo: https://google.golang.com/appengine/datastore -- name: google.golang.com/appengine/memcache - version: "" - repo: https://google.golang.com/appengine/memcache -- name: google.golang.com/appengine/user - version: "" - repo: https://google.golang.com/appengine/user -- name: google.golang.org/api - version: 8fa1015948e6fc21c025050624e4c4e2f4f405c4 -- name: google.golang.org/appengine - version: 6bde959377a90acb53366051d7d587bfd7171354 -- name: google.golang.org/cloud - version: 5a3b06f8b5da3b7c3a93da43163b872c86c509ef -- name: google.golang.org/grpc - version: 5d64098b94ee9dbbea8ddc130208696bcd199ba4 - name: gopkg.in/yaml.v2 version: f7716cbe52baa25d2e9b0d0da546fcf909fc16b4 devImports: [] diff --git a/glide.yaml b/glide.yaml index 6a6b34b16..80542316f 100644 --- a/glide.yaml +++ b/glide.yaml @@ -8,3 +8,4 @@ import: - /common - package: github.com/ghodss/yaml - package: github.com/Masterminds/semver +- package: github.com/aokoli/goutils diff --git a/testdata/charts/README.md b/testdata/charts/README.md new file mode 100644 index 000000000..6ddc704f5 --- /dev/null +++ b/testdata/charts/README.md @@ -0,0 +1,9 @@ +The testdata directory here holds charts that match the specification. + +The `fromnitz/` directory contains a chart that matches the chart +specification. + +The `frobnitz-0.0.1.tgz` file is an archive of the `frobnitz` directory. + +The `ill` chart and directory is a chart that is not 100% compatible, +but which should still be parseable. diff --git a/testdata/charts/frobnitz-0.0.1.tgz b/testdata/charts/frobnitz-0.0.1.tgz new file mode 100644 index 0000000000000000000000000000000000000000..78fb3bc176af80192b52fb4fec619249905dda80 GIT binary patch literal 6246 zcmV-s7@6lEiwFQ3{I6C31MNL)bK6Fe`K(_tN7t66I*JlSNsg5`yNX5I+}M(il;cgg za;_mUBqs(i3uG z&fZsS_mfky;`%q2|AVQBlcR}9MaFZ%#!79ZJP}9CDaJ-5^eB_FT&nblT}-8B@DI1o zKeRS3MW*RlquttTb+&mtoAOrsKihkq{e#BFd$E|SEYe3CjBS@t@rRyeYV=;@^dnLc zk2Vr6(;WT~DJDiJCbtQ%_) zPD#~JMT^QLt%__U48m!i&-BsGPVjsOxUw_k*~U~MU>s2$06dzBG!p4ZiVEHNRHhS= z4b_k+h}DQ2KCZ$tLJQP8<(%yfFtpvuCm(3GXY_w}HbigTlWa70Q+}pWq4@J(~H$2*jxJckPNsTc+lg~3%%mQ$oEINmUEH=Kh zYOk+5T;BgjYNS6?5^(qU@BBaf@n{|Y@8k0FpDOkKGbzA7A^!u6|7-bw{>#f>j#S#x zmy^$c4>#MPTp%(ggV1lZH)s z=JR=L-f5|9va<(^+<|8eGwjA8lo}XlSFudruNvHb{P^(>J#B=ki=l|kWt2~!H1-Y- z8<6tJ$uze=Wb~u~*-qa04rYCesp@xKlTtBM=x=xE7Cy_wD5v3LnZbB=1rQo+LI1Vj z_jgO^hw%5YjN>PblwU3yJ5?B30Pu)_v=0c%{w+{45h0Loks;sxiBcnP|1Wz_yQhQh z=fH8Z{qG&NJBM}uzrVM?w*ULMY}$Uqbv)z16!ub%pcD`{jsMZuEZb}CHrd~KTJUVa zzzghOJ1Ou3oY0Ujhz%;evw;&Yy8TxJc6@rmo}Qha^e%d5rvvuvtj}H#x=q&ap7+mA zUO&a#O&WF58(j2z-@nE?1fbnwCt@r?%dwDYZCGj=c0~=Qr#y~XB6tb~n_#)f5~y&~ zh@p|2Sx^{ftk9y#G67XGkNE_fowKSQs z$4rf}I)rg*RA3obr%Po^gpJf}k)dN@Y7P}L1Cn5(%omIo`BY`{1L3o9R?Wz#Jje2V zl5v=rPH2$jLqLF-@R)T8^b!$8iVGy_1>+-v;-~;Nz*q}L!2nAjRK*50Ff`9p++;ix z?ng{SH*qz1w}3i2gJ%g;nHG{A2o5%%8aM`Fi#<~r(J?EsnF5U|x#|V(WYn-w8nhJ6 zHszL?s^%hVg80a}13a0Uzc*Q~*ocGBah!!>9uWsJmhhBM1PTxF>S8ptgf-cGDros2 zeZtELcF38zL~Q~nn-VA?@#v|XA*8V!12<|>nN|-7B?9g{+ao|0j2X~$_CJ=BBBSRR$VK2j&W68$ zDlC)E(}lSQ;wWOW4+ydeJRD7V3RF7-0j)?ij^s|E=uT{Zju~f$Jp`^+G@;9)TmdN*x7&JmzwBJQ2|HXsuK5p!Fe}e0}S@=&2S0^OJXZTc8o2= zAxEtRu?Y(hE@9N5athSkOvI7LGwkchD=?;5&9_P}oQO}uuY983t zTS$fnj_@JZD7=(RF+v=u{h&R@S0O4A7uv#nDo4}68Gx{Ihyh@knYffBO4MRtjkOad zfWs~iA({@vdowLvGY^oiupHLoqd*jsLfV( z1l~rC3_G{pKE;e@q$$W3T1Fx=5ib}P55%}3Xbb8I_C&Xw&?PvcY|KX#B$`2t^h{kM z3b`ZHxRm-+bmcb2uatP*2E54z_&fux!MRxK=|Er=nUD@gHWP7>l;I7{g6G!}-wcc* zN3X8{b?n@>E{5Pctn+Yr2Wb~kPUKlrAVlQHm(mI+WeRsUMvE{}L9a~cQQwCGm^lVk zT%Ww$E!wk&UsJ=vGV$KKWtb#lFu+WKGj5_3hCC)cnrApKrR1YXE%zB(LCADbG79;W z>(W?=|GIf&DDu85!~y@5G%?(#z{xSBlmIOVSw0og3!RHZhb|mqZXqy)j3`Fh5k~wN z`AoLrbFGl+&A^RRv>@O%@(ps_QK2cy6UK!6rA;H>kjE=SleltBsIJxNBP>PFQu6(viYOyu>`F~UXVo|besdPuYOAqq!nOR`FWXt*ttn5) zK=hAE4Jn%fF+&0R1Sz8+PYy(fcuFJG;@1N7Cq}d*1^hPQ8WY~Y{EQ>oYq95;Rw3G_ ze)%r5VuQj2SF5Wli z8mUURN%9(2j6b(=TWf-alUndNUu=&v0ly?9c9&{|j(jPa+xia?x@rq%fQ`*ikC!}M z>CR`x5at3GK~ZNh2SxXHfMyeFHQlj^MOe3mX}oBI6cY^L+LqcSoKY#9gg$O>?Bq(_+1z@N%T0?e7f z11wFKHwPs=RR=&(eQ^O|kFZpTCR$h-9h+9Wo9GrJfq7FiNG3={^U~bx+Dr>#1wD0_ zidUJr8Sm*}5OI;BgchOV!<_*Q(>3hPARPw5+gu*1QxxPRajhmdTN|w4(zs?Rlt4fQXoLj-vuGO^x$v?{ zu|Ed|GbR>-LlJs0HB}h;uVpp|@}}g$l+wP*2Q@@lykdq@CCAzpd8|dHH}As+k0Shg zhV@RUkpUD(y5-PaETL(*uR##uny8+__C^$mG%6C8wpKL8ITlm@IdRr~8Zp>4F@Oy# zjfuKdP&1i4AS>$nXBczczQsxwl~o0$t<_GOS7h*I zYj4GtkpUCz6{+zGYMQ0ljHy^$TvLjK-8pYc1P@UM-Mo^3rQNDZ6!uv+_L3=;Mm?&u zWqhSls{|?nIiO<4?gW@xwafx_i@i=EifR&?xB^5YiRCXr3^qu7e`8V4B7^}dV(#)n=L}s8c282mnBe(l#=AWt@C;8nQiZ4TDiZVI@O647f z5h6_&5Dv76gxLr}GYCXt5t;15G)RGqz9gDJO-G8quoglUnYa?8z{Qi}^$f|xglA@7 zsa|{7y?{e-g)RZnEpsr~<WxctWPfb|9q_WkjoH*m~-)4O;PY3cT|@vk>ppRpiNp@5cNs9^HU2ba*0(` z5M|3Q7MOX_yLj1c0@qKsd#BI(z0>F2SKZT#CVSQGKYamI9)I6^*}M3OROngn;36%E zl~%6r{M@SVnV=m(&Gtr30<037S8w!FePJ-Yr04i_D4}(}}P#n}lOwj9%I19r!(|L3$X_Itp zk8gklSSGl`4HmqyfX6L%Ji?fOTyUNjF&~$KIxvbiQ%v2f=33t@ym7nDWuc>~Ql<+^ zozBW;JM~=g9U4LY1Y8|a$kUN9i>%gt2ClW8Q9Ia@b^DH4xLJ?B806gl#9$yHL?%^{cW$yQq;JUcugr+@4QSBzUv|54HWKf3Z zuB*{3EBUb$aikdp2rzcz^oO`hDL^wDZ+~uh$48wB8|@ZOnaHc!sxPRdTWs@0r4Rji zfxt!`@c-CiRIO8)sv*4qO@I{N(_yQFAZ!PFvuG=N0sj2TZ-i1&ZwLTC0TW}58&qbr z?UOn$PGgPUfR3c58Jg$|EbZL+U8eII#i5QR5nYa06pSb?4I_enB!p z@uc66x14kPuD(4}HaU1Un&OVNQHF9e@$CYxpV?cY8|bXkJa_7T+mTay z40;<#rYU#H(67rq?3ptJ6SUNpPdMSGK{(*L4EztK-!Abcwhe@+kl>V@(i+eiSXw$M zK;a-IfUuC(PxjevNtv(f<#o0GMCaVs*Xqlk|L=E?PhNFfN%ZM)-1h#@UZ-6@|9^P6 ze*gPkt_SRydnJ3rzuaA(iKKUuAv`>Iz+P+c2CD`^C7Dxxo?;OKgUt97NGD@8!$`WZ z@r+=OUr}?K8Xs`upGiJlx+sSik>y zAJ+=`$8n4OAM8SK zsM>#f|KQQu{_o?eeg7v)-g$ff?Jtm`_36`bX) zcfE6%SpI(dP|hsU_HJvp1)9~`+kdng<-7B<{zYv%c3=&Fz1{uCtEZjx20zrMp;NMW zopZbfCr*C%Y;f_@dA9~*tkKt5DB>#LuRwU-JN-wUM-!P|tzr+3b&LCYcj-yLd;YTb z^cV$8H{L$PCY&5`ZC4)5cyrc2Iq!D|gLmgI&TII~jA1sNt)QbaH^f?baA)jpMYY+b z#2%vsmXlxoH2ANVHIgZ`tRR)fIt2711l;ND9xe|)9t@C_U;@_~d16Iq!kE9g1i-41 zog8RT8UI#KD%Ho%U9CCSL~b8bCo-QFL;42Qd;bBc9oy!@-p)4IZ5bal6ljnc>;Q

l58sp29L!H2sNJmdXt#`EbB+qvW!_DFZ8dE&P5=t!d7 zNBWT_KgC^Y}SxDX*e=Qu3R+a(gq;f`abxh5lV?xk{q#uFYPjf^Zj#?X@NMuonx_O!yU z1h!Oh@%Jmr)dZ{%^@<>Iy~wX0T#9}#6ul?lXgo`<6MqTy+6$Wx7U9y4K-2nN6Nrk>c7rmyVn2P+k4b*uj{}2xUdzE7N5&JM!(}^ zzrk4L!>|8CUV*-&L$7G~fov{@T0-eKT-f)p@q-t*dtbVF=c>V_@)R>WcZ0qtK$%H! zr|Rm%p%FZMwZLTF-n6F}aF@RVg~r)wkdGsKy~%z#6Y; zq8{$l+M^G!VqU}$QL2@#eHQTV+<@_)fJL;i;)Y6T4`O91!OdA$@=EhfT8CDZ-;Jn; zO3Jyt-(I4!LTOkI2Tv;>`4tQ@c6Xk&6qh@_OhL4UPNw-XE-am|$AMsOz!FumnVT0C zG$OA-=FT$Ep)nu#2uYm)R1JSp+ZG&mqyuZN>uDejqxbU73xtS!dHo)}N!jnJ0X}WH zlVEOORFMqLIb{dY9}cM47*bfV)ISrYD_zL%R$uHR+@ikMB4b&BFASuJ)Km?3WzU_- z!*0YK$g6nFkSs!GyApR*@Ml^dGPxOBSxNZNhz4xfz|L^Rr^S^t!%oi7^F=#5qTK2!Pc{mTUL}MiNSzmft z>+6nJ?fc&#!)-j+%;UH + + Example icon + + + diff --git a/testdata/charts/frobnitz/templates/wordpress-resources.yaml b/testdata/charts/frobnitz/templates/wordpress-resources.yaml new file mode 100644 index 000000000..00f709de0 --- /dev/null +++ b/testdata/charts/frobnitz/templates/wordpress-resources.yaml @@ -0,0 +1,12 @@ +# Google Cloud Deployment Manager template +resources: +- name: nfs-disk + type: compute.v1.disk + properties: + zone: us-central1-b + sizeGb: 200 +- name: mysql-disk + type: compute.v1.disk + properties: + zone: us-central1-b + sizeGb: 200 diff --git a/testdata/charts/frobnitz/templates/wordpress.jinja b/testdata/charts/frobnitz/templates/wordpress.jinja new file mode 100644 index 000000000..f34e4fec9 --- /dev/null +++ b/testdata/charts/frobnitz/templates/wordpress.jinja @@ -0,0 +1,72 @@ +#helm:generate dm_template +{% set PROPERTIES = properties or {} %} +{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-testing' %} +{% set NFS_SERVER = PROPERTIES['nfs-server'] or {} %} +{% set NFS_SERVER_IP = NFS_SERVER['ip'] or '10.0.253.247' %} +{% set NFS_SERVER_PORT = NFS_SERVER['port'] or 2049 %} +{% set NFS_SERVER_DISK = NFS_SERVER['disk'] or 'nfs-disk' %} +{% set NFS_SERVER_DISK_FSTYPE = NFS_SERVER['fstype'] or 'ext4' %} +{% set NGINX = PROPERTIES['nginx'] or {} %} +{% set NGINX_PORT = 80 %} +{% set NGINX_REPLICAS = NGINX['replicas'] or 2 %} +{% set WORDPRESS_PHP = PROPERTIES['wordpress-php'] or {} %} +{% set WORDPRESS_PHP_REPLICAS = WORDPRESS_PHP['replicas'] or 2 %} +{% set WORDPRESS_PHP_PORT = WORDPRESS_PHP['port'] or 9000 %} +{% set MYSQL = PROPERTIES['mysql'] or {} %} +{% set MYSQL_PORT = MYSQL['port'] or 3306 %} +{% set MYSQL_PASSWORD = MYSQL['password'] or 'mysql-password' %} +{% set MYSQL_DISK = MYSQL['disk'] or 'mysql-disk' %} +{% set MYSQL_DISK_FSTYPE = MYSQL['fstype'] or 'ext4' %} + +resources: +- name: nfs + type: github.com/kubernetes/application-dm-templates/storage/nfs:v1 + properties: + ip: {{ NFS_SERVER_IP }} + port: {{ NFS_SERVER_PORT }} + disk: {{ NFS_SERVER_DISK }} + fstype: {{NFS_SERVER_DISK_FSTYPE }} +- name: nginx + type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v2 + properties: + service_port: {{ NGINX_PORT }} + container_port: {{ NGINX_PORT }} + replicas: {{ NGINX_REPLICAS }} + external_service: true + image: gcr.io/{{ PROJECT }}/nginx:latest + volumes: + - mount_path: /var/www/html + persistentVolumeClaim: + claimName: nfs +- name: mysql + type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v2 + properties: + service_port: {{ MYSQL_PORT }} + container_port: {{ MYSQL_PORT }} + replicas: 1 + image: mysql:5.6 + env: + - name: MYSQL_ROOT_PASSWORD + value: {{ MYSQL_PASSWORD }} + volumes: + - mount_path: /var/lib/mysql + gcePersistentDisk: + pdName: {{ MYSQL_DISK }} + fsType: {{ MYSQL_DISK_FSTYPE }} +- name: wordpress-php + type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v2 + properties: + service_name: wordpress-php + service_port: {{ WORDPRESS_PHP_PORT }} + container_port: {{ WORDPRESS_PHP_PORT }} + replicas: 2 + image: wordpress:fpm + env: + - name: WORDPRESS_DB_PASSWORD + value: {{ MYSQL_PASSWORD }} + - name: WORDPRESS_DB_HOST + value: mysql-service + volumes: + - mount_path: /var/www/html + persistentVolumeClaim: + claimName: nfs diff --git a/testdata/charts/frobnitz/templates/wordpress.jinja.schema b/testdata/charts/frobnitz/templates/wordpress.jinja.schema new file mode 100644 index 000000000..215b47e1e --- /dev/null +++ b/testdata/charts/frobnitz/templates/wordpress.jinja.schema @@ -0,0 +1,69 @@ +info: + title: Wordpress + description: | + Defines a Wordpress website by defining four replicated services: an NFS service, an nginx service, a wordpress-php service, and a MySQL service. + + The nginx service and the Wordpress-php service both use NFS to share files. + +properties: + project: + type: string + default: dm-k8s-testing + description: Project location to load the images from. + nfs-service: + type: object + properties: + ip: + type: string + default: 10.0.253.247 + description: The IP of the NFS service. + port: + type: int + default: 2049 + description: The port of the NFS service. + disk: + type: string + default: nfs-disk + description: The name of the persistent disk the NFS service uses. + fstype: + type: string + default: ext4 + description: The filesystem the disk of the NFS service uses. + nginx: + type: object + properties: + replicas: + type: int + default: 2 + description: The number of replicas for the nginx service. + wordpress-php: + type: object + properties: + replicas: + type: int + default: 2 + description: The number of replicas for the wordpress-php service. + port: + type: int + default: 9000 + description: The port the wordpress-php service runs on. + mysql: + type: object + properties: + port: + type: int + default: 3306 + description: The port the MySQL service runs on. + password: + type: string + default: mysql-password + description: The root password of the MySQL service. + disk: + type: string + default: mysql-disk + description: The name of the persistent disk the MySQL service uses. + fstype: + type: string + default: ext4 + description: The filesystem the disk of the MySQL service uses. + diff --git a/testdata/charts/frobnitz/templates/wordpress.yaml b/testdata/charts/frobnitz/templates/wordpress.yaml new file mode 100644 index 000000000..b401897ab --- /dev/null +++ b/testdata/charts/frobnitz/templates/wordpress.yaml @@ -0,0 +1,6 @@ +imports: +- path: wordpress.jinja + +resources: +- name: wordpress + type: wordpress.jinja From 1058fb9ccf1931cdd6a2be6f1384b4c04a88c994 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Tue, 9 Feb 2016 17:36:39 -0700 Subject: [PATCH 38/73] feat(deploy): Create dm.Client from cli.Context Also, remove a whole bunch of unused functions. --- cmd/helm/deploy.go | 9 +-- deploy/deploy.go | 177 --------------------------------------------- dm/client.go | 11 ++- 3 files changed, 11 insertions(+), 186 deletions(-) diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index aa21e5b37..e436ae46c 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -10,7 +10,6 @@ import ( "github.com/aokoli/goutils" "github.com/codegangsta/cli" dep "github.com/deis/helm-dm/deploy" - "github.com/deis/helm-dm/dm" "github.com/deis/helm-dm/format" "github.com/kubernetes/deployment-manager/chart" ) @@ -79,10 +78,10 @@ func deploy(c *cli.Context) error { d.Input = os.Stdin } - return doDeploy(d, c.GlobalString("host"), c.Bool("dry-run")) + return doDeploy(d, c) } -func doDeploy(cfg *dep.Deployment, host string, dry bool) error { +func doDeploy(cfg *dep.Deployment, cxt *cli.Context) error { if cfg.Filename == "" { return errors.New("A filename must be specified. For a tar archive, this is the name of the root template in the archive.") } @@ -125,12 +124,12 @@ func doDeploy(cfg *dep.Deployment, host string, dry bool) error { cfg.Name = n } - if dry { + if cxt.Bool("dry-run") { format.Info("Prepared deploy %q using file %q", cfg.Name, cfg.Filename) return nil } - c := dm.NewClient(host) + c := client(cxt) return c.DeployChart(cfg.Filename, cfg.Name) } diff --git a/deploy/deploy.go b/deploy/deploy.go index 41a9188d9..a29b2b275 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -1,30 +1,11 @@ package deploy import ( - //"archive/tar" - //"errors" - //"fmt" "os" - //"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" ) -// Deployer is capable of deploying an object to a back-end. -type Deployer interface { - // Prepare prepares the local side of a deployment. - Prepare() error - - // Commit pushes a deployment and checks that it is completed. - // - // This sends the data to the given host. - Commit(host string) error -} - // Deployment describes a deployment of a package. type Deployment struct { // Name is the Deployment name. Autogenerated if empty. @@ -42,162 +23,4 @@ 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. -// -// This will generate the Template based on other information. -func (d *Deployment) Prepare() error { - - // 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 - } - } else { - c, err = chart.Load(d.Filename) - if err != nil { - return err - } - } - - // Override name if we need to - - // Properties - - d.lchart = c - return nil -} - -// Chart retrieves the chart from teh deployment. -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 -} - -/* -// resolveTemplate resolves what kind of template is being loaded, and then returns the template. -func (d *Deployment) resolveTemplate() (*common.Template, error) { - // If some input has been specified, read it. - if d.Input != nil { - // Assume this is a tar archive. - tpl, err := expander.NewTemplateFromArchive(d.Filename, d.Input, d.Imports) - if err == nil { - return tpl, err - } else if err != tar.ErrHeader { - return nil, err - } - - // If we get here, the file is not a tar archive. - if _, err := os.Stdin.Seek(0, 0); err != nil { - return nil, err - } - return expander.NewTemplateFromReader(d.Filename, d.Input, d.Imports) - } - - // Non-Stdin case - if len(d.Imports) > 0 { - if t, err := registryType(d.Filename); err != nil { - return expander.NewTemplateFromRootTemplate(d.Filename) - } else { - return buildTemplateFromType(t, d.Repository, d.Properties) - } - } - return expander.NewTemplateFromFileNames(d.Filename, d.Imports) -} - -// registryType is a placeholder until registry.ParseType() is merged. -func registryType(name string) (*registry.Type, error) { - tList := strings.Split(name, ":") - if len(tList) != 2 { - return nil, errors.New("No version") - } - - semver, err := registry.ParseSemVer(tList[1]) - if err != nil { - return nil, err - } - tt := registry.Type{Version: semver} - - cList := strings.Split(tList[0], "/") - - if len(cList) == 1 { - tt.Name = tList[0] - } else { - tt.Collection = cList[0] - tt.Name = cList[1] - } - return &tt, nil -} - -// buildTemplateFromType is a straight lift-n-shift from dm.go. -func buildTemplateFromType(t *registry.Type, reg string, props map[string]interface{}) (*common.Template, error) { - // Name the deployment after the type name. - name := fmt.Sprintf("%s:%s", t.Name, t.Version) - git, err := getGitRegistry(reg) - if err != nil { - return nil, err - } - gurls, err := git.GetDownloadURLs(*t) - if err != nil { - return nil, err - } - - config := common.Configuration{Resources: []*common.Resource{&common.Resource{ - Name: name, - Type: gurls[0].Host, - Properties: props, - }}} - - y, err := yaml.Marshal(config) - if err != nil { - return nil, fmt.Errorf("error: %s\ncannot create configuration for deployment: %v\n", err, config) - } - - return &common.Template{ - Name: name, - Content: string(y), - // No imports, as this is a single type from repository. - }, nil -} - -// getGitRegistry returns a registry object for a name. -func getGitRegistry(reg string) (registry.Registry, error) { - s := strings.SplitN(reg, "/", 3) - if len(s) < 2 { - return nil, fmt.Errorf("invalid template registry: %s", reg) - } - - //path := "" - //if len(s) > 2 { - //path = s[3] - //} - - if s[0] == "helm" { - r, err := registry.NewGithubPackageRegistry(s[0], s[1], nil, nil) - if err != nil { - return nil, err - } - return r, nil - } else { - r, err := registry.NewGithubTemplateRegistry(s[0], s[1], nil, nil) - if err != nil { - return nil, err - } - return r, nil - } } -*/ diff --git a/dm/client.go b/dm/client.go index 087d0672b..e03989538 100644 --- a/dm/client.go +++ b/dm/client.go @@ -8,7 +8,7 @@ import ( "net/http" "net/url" "os" - "path" + fancypath "path" "path/filepath" "strings" "time" @@ -177,10 +177,13 @@ func (c *Client) DeployChart(filename, deployname string) error { if err != nil { return err } - defer f.Close() u, err := c.url("/v2/deployments") request, err := http.NewRequest("POST", u, f) + if err != nil { + f.Close() + return err + } // 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. @@ -209,7 +212,7 @@ func (c *Client) DeployChart(filename, deployname string) error { if err != nil { return err } - return fmt.Errorf("Failed to post: %d %s - %s", response.StatusCode, response.Status, body) + return fmt.Errorf("failed to post: %d %s - %s", response.StatusCode, response.Status, body) } return nil @@ -218,7 +221,7 @@ func (c *Client) DeployChart(filename, deployname string) error { // GetDeployment retrieves the supplied deployment func (c *Client) GetDeployment(name string) (*common.Deployment, error) { var deployment *common.Deployment - if err := c.CallService(path.Join("deployments", name), "GET", "get deployment", &deployment, nil); err != nil { + if err := c.CallService(fancypath.Join("deployments", name), "GET", "get deployment", &deployment, nil); err != nil { return nil, err } return deployment, nil From 73bfdf949eba3ecb79c8b9a0066ae2336acd1222 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Wed, 10 Feb 2016 12:26:46 -0800 Subject: [PATCH 39/73] fix(dm-install): do not require a namespace on kubectl create When trying to create a new namespace, specifying a namespace will error --- dm/install.go | 2 +- dm/uninstall.go | 2 +- kubectl/create.go | 12 ++---------- kubectl/create_test.go | 4 ++-- kubectl/delete.go | 11 ++--------- kubectl/kubectl.go | 6 +++--- 6 files changed, 11 insertions(+), 26 deletions(-) diff --git a/dm/install.go b/dm/install.go index f2a70163d..e1290b29d 100644 --- a/dm/install.go +++ b/dm/install.go @@ -10,7 +10,7 @@ import ( // Returns the string output received from the operation, and an error if the // command failed. func Install(runner kubectl.Runner) (string, error) { - o, err := runner.Create([]byte(InstallYAML), "dm") + o, err := runner.Create([]byte(InstallYAML)) return string(o), err } diff --git a/dm/uninstall.go b/dm/uninstall.go index 675ebdb73..4bd6b8c71 100644 --- a/dm/uninstall.go +++ b/dm/uninstall.go @@ -9,6 +9,6 @@ import ( // Returns the string output received from the operation, and an error if the // command failed. func Uninstall(runner kubectl.Runner) (string, error) { - o, err := runner.Delete("dm", "Namespace", "dm") + o, err := runner.Delete("dm", "Namespace") return string(o), err } diff --git a/kubectl/create.go b/kubectl/create.go index bd903b740..af9297aa9 100644 --- a/kubectl/create.go +++ b/kubectl/create.go @@ -1,13 +1,9 @@ package kubectl // Create uploads a chart to Kubernetes -func (r RealRunner) Create(stdin []byte, ns string) ([]byte, error) { +func (r RealRunner) Create(stdin []byte) ([]byte, error) { args := []string{"create", "-f", "-"} - if ns != "" { - args = append([]string{"--namespace=" + ns}, args...) - } - cmd := command(args...) assignStdin(cmd, stdin) @@ -15,13 +11,9 @@ func (r RealRunner) Create(stdin []byte, ns string) ([]byte, error) { } // Create returns the commands to kubectl -func (r PrintRunner) Create(stdin []byte, ns string) ([]byte, error) { +func (r PrintRunner) Create(stdin []byte) ([]byte, error) { args := []string{"create", "-f", "-"} - if ns != "" { - args = append([]string{"--namespace=" + ns}, args...) - } - cmd := command(args...) assignStdin(cmd, stdin) diff --git a/kubectl/create_test.go b/kubectl/create_test.go index 0623769d7..bca94f6e5 100644 --- a/kubectl/create_test.go +++ b/kubectl/create_test.go @@ -7,9 +7,9 @@ import ( func TestPrintCreate(t *testing.T) { var client Runner = PrintRunner{} - expected := `[CMD] kubectl --namespace=default-namespace create -f - < some stdin data` + expected := `[CMD] kubectl create -f - < some stdin data` - out, err := client.Create([]byte("some stdin data"), "default-namespace") + out, err := client.Create([]byte("some stdin data")) if err != nil { t.Error(err) } diff --git a/kubectl/delete.go b/kubectl/delete.go index 903442585..52874cfbb 100644 --- a/kubectl/delete.go +++ b/kubectl/delete.go @@ -1,25 +1,18 @@ package kubectl // Delete removes a chart from Kubernetes. -func (r RealRunner) Delete(name, ktype, ns string) ([]byte, error) { +func (r RealRunner) Delete(name, ktype string) ([]byte, error) { args := []string{"delete", ktype, name} - if ns != "" { - args = append([]string{"--namespace=" + ns}, args...) - } return command(args...).CombinedOutput() } // Delete returns the commands to kubectl -func (r PrintRunner) Delete(name, ktype, ns string) ([]byte, error) { +func (r PrintRunner) Delete(name, ktype string) ([]byte, error) { args := []string{"delete", ktype, name} - if ns != "" { - args = append([]string{"--namespace=" + ns}, args...) - } - cmd := command(args...) return []byte(cmd.String()), nil } diff --git a/kubectl/kubectl.go b/kubectl/kubectl.go index 0e51169a4..a85ca6128 100644 --- a/kubectl/kubectl.go +++ b/kubectl/kubectl.go @@ -8,11 +8,11 @@ type Runner interface { // ClusterInfo returns Kubernetes cluster info ClusterInfo() ([]byte, error) // Create uploads a chart to Kubernetes - Create([]byte, string) ([]byte, error) + Create(stdin []byte) ([]byte, error) // Delete removes a chart from Kubernetes. - Delete(string, string, string) ([]byte, error) + Delete(name string, ktype string) ([]byte, error) // Get returns Kubernetes resources - Get([]byte, string) ([]byte, error) + Get(stdin []byte, ns string) ([]byte, error) // GetByKind gets an entry by kind, name, and namespace. // From 838d5c0401dcedf9d54da73a1bb56129016f3fb7 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Wed, 10 Feb 2016 12:30:46 -0800 Subject: [PATCH 40/73] chore(spelling): s/primative/primitive/ --- dm/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm/client.go b/dm/client.go index b95a59356..217508b05 100644 --- a/dm/client.go +++ b/dm/client.go @@ -103,7 +103,7 @@ func (c *Client) CallService(path, method, action string, dest interface{}, read return nil } -// callHTTP is a low-level primative for executing HTTP operations. +// callHTTP is a low-level primitive for executing HTTP operations. func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (string, error) { request, err := http.NewRequest(method, path, reader) From dbd90b5cca188be71eef1943e1d53af5528df02f Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Tue, 9 Feb 2016 21:33:21 -0800 Subject: [PATCH 41/73] feat(delete): add delete verb --- cmd/helm/delete.go | 33 +++++++++++++++++++++++++++++++++ cmd/helm/helm.go | 2 +- dm/client.go | 9 +++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 cmd/helm/delete.go diff --git a/cmd/helm/delete.go b/cmd/helm/delete.go new file mode 100644 index 000000000..b954dfe03 --- /dev/null +++ b/cmd/helm/delete.go @@ -0,0 +1,33 @@ +package main + +import ( + "errors" + + "github.com/codegangsta/cli" + "github.com/deis/helm-dm/format" +) + +func init() { + addCommands(deleteCmd()) +} + +func deleteCmd() cli.Command { + return cli.Command{ + Name: "delete", + Usage: "Deletes the supplied deployment", + Action: func(c *cli.Context) { run(c, deleteDeployment) }, + } +} + +func deleteDeployment(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + return errors.New("First argument, deployment name, is required. Try 'helm get --help'") + } + name := args[0] + deployment, err := client(c).DeleteDeployment(name) + if err != nil { + return err + } + return format.YAML(deployment) +} diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 55b6c0ebb..693e192eb 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -13,7 +13,7 @@ var version = "0.0.1" var commands []cli.Command func init() { - commands = cmds() + addCommands(cmds()...) } func main() { diff --git a/dm/client.go b/dm/client.go index b95a59356..f0e93ba52 100644 --- a/dm/client.go +++ b/dm/client.go @@ -224,3 +224,12 @@ func (c *Client) GetDeployment(name string) (*common.Deployment, error) { } return deployment, nil } + +// DeleteDeployment deletes the supplied deployment +func (c *Client) DeleteDeployment(name string) (*common.Deployment, error) { + var deployment *common.Deployment + if err := c.CallService(filepath.Join("deployments", name), "DELETE", "delete deployment", &deployment, nil); err != nil { + return nil, err + } + return deployment, nil +} From 0cdd07711463084ad3c11255ebf3baad57c16526 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 10 Feb 2016 15:15:11 -0700 Subject: [PATCH 42/73] fix(*): minor codebase cleanups Cleaned up some of the code we inherited from DM. --- cmd/helm/helm.go | 2 +- dm/client.go | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 693e192eb..84ce287e0 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -29,7 +29,7 @@ func main() { Name: "host,u", Usage: "The URL of the DM server.", EnvVar: "HELM_HOST", - Value: "https://localhost:8181/FIXME_NOT_RIGHT", + Value: "https://localhost:8000/", }, cli.IntFlag{ Name: "timeout", diff --git a/dm/client.go b/dm/client.go index e03989538..acb824ffd 100644 --- a/dm/client.go +++ b/dm/client.go @@ -85,6 +85,10 @@ func (c *Client) url(rawurl string) (string, error) { 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. // // 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 request, err := http.NewRequest(method, path, reader) // 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") - client := http.Client{ - Timeout: time.Duration(time.Duration(DefaultHTTPTimeout) * time.Second), + client := &http.Client{ + Timeout: c.HTTPTimeout, Transport: c.transport(), } response, err := client.Do(request) if err != nil { - return "", fmt.Errorf("cannot %s: %s\n", action, err) + return "", err } defer response.Body.Close() body, err := ioutil.ReadAll(response.Body) if err != nil { - return "", fmt.Errorf("cannot %s: %s\n", action, err) + return "", err } - 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("cannot %s: %s\n", action, message) + s := response.StatusCode + if s < http.StatusOK || s >= http.StatusMultipleChoices { + return "", fmt.Errorf("request '%s %s' failed with %d: %s\n", action, path, s, body) } return string(body), nil @@ -194,9 +197,10 @@ func (c *Client) DeployChart(filename, deployname string) error { request.Header.Add("Content-Encoding", "gzip") request.Header.Add("X-Deployment-Name", deployname) request.Header.Add("X-Chart-Name", filepath.Base(filename)) + request.Header.Set("User-Agent", c.agent()) - client := http.Client{ - Timeout: time.Duration(time.Duration(DefaultHTTPTimeout) * time.Second), + client := &http.Client{ + Timeout: c.HTTPTimeout, Transport: c.transport(), } From 52ae1c18979b79fccfd3f7f0b6e45475ea6cfebc Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Thu, 11 Feb 2016 17:29:05 -0700 Subject: [PATCH 43/73] fix(dm): correct error in status code check Also made an HTTPError error type to make it easier to type switch on errors. --- dm/client.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/dm/client.go b/dm/client.go index 15b64518a..cf50636dd 100644 --- a/dm/client.go +++ b/dm/client.go @@ -134,7 +134,7 @@ func (c *Client) callHTTP(path, method, action string, reader io.ReadCloser) (st s := response.StatusCode if s < http.StatusOK || s >= http.StatusMultipleChoices { - return "", fmt.Errorf("request '%s %s' failed with %d: %s\n", action, path, s, body) + return "", &HTTPError{StatusCode: s, Message: string(body), URL: request.URL} } return string(body), nil @@ -210,18 +210,38 @@ func (c *Client) DeployChart(filename, deployname string) error { } // We only want 201 CREATED. Admittedly, we could accept 200 and 202. - if response.StatusCode < http.StatusCreated { + if response.StatusCode != http.StatusCreated { body, err := ioutil.ReadAll(response.Body) response.Body.Close() if err != nil { return err } - return fmt.Errorf("failed to post: %d %s - %s", response.StatusCode, response.Status, body) + return &HTTPError{StatusCode: response.StatusCode, Message: string(body), URL: request.URL} } return nil } +// HTTPError is an error caused by an unexpected HTTP status code. +// +// The StatusCode will not necessarily be a 4xx or 5xx. Any unexpected code +// may be returned. +type HTTPError struct { + StatusCode int + Message string + URL *url.URL +} + +// Error implements the error interface. +func (e *HTTPError) Error() string { + return e.Message +} + +// String implmenets the io.Stringer interface. +func (e *HTTPError) String() string { + return e.Error() +} + // GetDeployment retrieves the supplied deployment func (c *Client) GetDeployment(name string) (*common.Deployment, error) { var deployment *common.Deployment From 61b2e875cd400af450eac40ac5ed8d034f50af02 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Mon, 22 Feb 2016 17:13:07 -0700 Subject: [PATCH 44/73] fix(Makefile): improve gofmt output on errors --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b79e1a6f1..da844291f 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,8 @@ test: test-style $(PATH_WITH_HELM) go test -v -cover $(addprefix ./,$(GO_PACKAGES)) test-style: - @if [ $(shell gofmt -e -l -s *.go $(GO_PACKAGES)) ]; then \ - echo "gofmt check failed:"; gofmt -e -l -s *.go $(GO_PACKAGES); exit 1; \ + @if [ $(shell gofmt -e -l -s $(GO_PACKAGES)) ]; then \ + echo "gofmt check failed:"; gofmt -e -d -s $(GO_PACKAGES); exit 1; \ fi @for i in . $(GO_PACKAGES); do \ golint $$i; \ From 436b7f03780ae543f0a8dfa25091de531214f978 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Mon, 22 Feb 2016 17:13:48 -0700 Subject: [PATCH 45/73] feat(deploy): deploy using Configuration This re-jiggers the deployment to use common.Configuration. Right now it will not work, since the remote server expects a common.Template instead of a common.Configuration. Still trying to figure out which side to change. --- cmd/helm/deploy.go | 139 +++++++++++++-------------------------------- dm/client.go | 10 +++- dm/client_test.go | 44 ++++++-------- 3 files changed, 63 insertions(+), 130 deletions(-) diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index e436ae46c..bbb2576b9 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -1,17 +1,11 @@ package main import ( - "errors" - "fmt" - "os" - "regexp" - "strings" + "io/ioutil" - "github.com/aokoli/goutils" "github.com/codegangsta/cli" - dep "github.com/deis/helm-dm/deploy" - "github.com/deis/helm-dm/format" - "github.com/kubernetes/deployment-manager/chart" + "github.com/kubernetes/deployment-manager/common" + "gopkg.in/yaml.v2" ) func init() { @@ -29,9 +23,9 @@ func deployCmd() cli.Command { Name: "dry-run", Usage: "Only display the underlying kubectl commands.", }, - cli.BoolFlag{ - Name: "stdin,i", - Usage: "Read a configuration from STDIN.", + cli.StringFlag{ + Name: "config,c", + Usage: "The configuration YAML file for this deployment.", }, cli.StringFlag{ Name: "name", @@ -42,110 +36,57 @@ func deployCmd() cli.Command { Name: "properties,p", Usage: "A comma-separated list of key=value pairs: 'foo=bar,foo2=baz'.", }, - cli.StringFlag{ - // FIXME: This is not right. It's sort of a half-baked forward - // port of dm.go. - Name: "repository", - Usage: "The default repository", - Value: "kubernetes/application-dm-templates", - }, }, } } func deploy(c *cli.Context) error { - args := c.Args() - if len(args) < 1 { - format.Err("First argument, filename, is required. Try 'helm deploy --help'") - os.Exit(1) - } - - props, err := parseProperties(c.String("properties")) - if err != nil { - format.Err("Failed to parse properties: %s", err) - os.Exit(1) - } - d := &dep.Deployment{ - Name: c.String("Name"), - Properties: props, - Filename: args[0], - Imports: args[1:], - Repository: c.String("repository"), + // If there is a configuration file, use it. + cfg := &common.Configuration{} + if c.String("config") != "" { + if err := loadConfig(cfg, c.String("config")); err != nil { + return err + } + } else { + cfg.Resources = []*common.Resource{ + { + Properties: map[string]interface{}{}, + }, + } } - if c.Bool("stdin") { - d.Input = os.Stdin + // If there is a chart specified on the commandline, override the config + // file with it. + args := c.Args() + if len(args) > 0 { + cfg.Resources[0].Type = args[0] } - return doDeploy(d, c) -} - -func doDeploy(cfg *dep.Deployment, cxt *cli.Context) error { - if cfg.Filename == "" { - return errors.New("A filename must be specified. For a tar archive, this is the name of the root template in the archive.") + // Override the name if one is passed in. + if name := c.String("name"); len(name) > 0 { + cfg.Resources[0].Name = name } - fi, err := os.Stat(cfg.Filename) - if err != nil { + if props, err := parseProperties(c.String("properties")); err != nil { return err - } - - if fi.IsDir() { - format.Info("Chart is directory") - c, err := chart.LoadDir(cfg.Filename) - if err != nil { - return err - } - if cfg.Name == "" { - cfg.Name = genName(c.Chartfile().Name) - } - - // TODO: Is it better to generate the file in temp dir like this, or - // just put it in the CWD? - //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 + } else if len(props) > 0 { + // Coalesce the properties into the first props. We have no way of + // knowing which resource the properties are supposed to be part + // of. + for n, v := range props { + cfg.Resources[0].Properties[n] = v } - cfg.Filename = tfile - } else if cfg.Name == "" { - n, _, e := parseTarName(cfg.Filename) - if e != nil { - return e - } - cfg.Name = n - } - - if cxt.Bool("dry-run") { - format.Info("Prepared deploy %q using file %q", cfg.Name, cfg.Filename) - return nil } - c := client(cxt) - return c.DeployChart(cfg.Filename, cfg.Name) -} - -func genName(pname string) string { - s, _ := goutils.RandomAlphaNumeric(8) - return fmt.Sprintf("%s-%s", pname, s) + return client(c).PostDeployment(cfg) } -func parseTarName(name string) (string, string, error) { - tnregexp := regexp.MustCompile(chart.TarNameRegex) - if strings.HasSuffix(name, ".tgz") { - name = strings.TrimSuffix(name, ".tgz") - } - v := tnregexp.FindStringSubmatch(name) - if v == nil { - return name, "", fmt.Errorf("invalid name %s", name) +// loadConfig loads a file into a common.Configuration. +func loadConfig(c *common.Configuration, filename string) error { + data, err := ioutil.ReadFile(filename) + if err != nil { + return err } - return v[1], v[2], nil + return yaml.Unmarshal(data, c) } diff --git a/dm/client.go b/dm/client.go index 15b64518a..0d2606b56 100644 --- a/dm/client.go +++ b/dm/client.go @@ -174,14 +174,14 @@ func (c *Client) ListDeployments() ([]string, error) { return l, nil } -// DeployChart sends a chart to DM for deploying. -func (c *Client) DeployChart(filename, deployname string) error { +// UploadChart sends a chart to DM for deploying. +func (c *Client) PostChart(filename, deployname string) error { f, err := os.Open(filename) if err != nil { return err } - u, err := c.url("/v2/deployments") + u, err := c.url("/v2/charts") request, err := http.NewRequest("POST", u, f) if err != nil { f.Close() @@ -239,3 +239,7 @@ func (c *Client) DeleteDeployment(name string) (*common.Deployment, error) { } return deployment, nil } + +func (c *Client) PostDeployment(cfg *common.Configuration) error { + return c.CallService("/deployments", "POST", "post deployment", cfg, nil) +} diff --git a/dm/client_test.go b/dm/client_test.go index b7b6a816b..6c1473a28 100644 --- a/dm/client_test.go +++ b/dm/client_test.go @@ -1,10 +1,9 @@ package dm import ( - "io/ioutil" + "fmt" "net/http" "net/http/httptest" - "os" "strings" "testing" @@ -133,39 +132,28 @@ func TestGetDeployment(t *testing.T) { } } -func TestDeployChart(t *testing.T) { - testfile := "../testdata/charts/frobnitz-0.0.1.tgz" - testname := "sparkles" - - fi, err := os.Stat(testfile) - if err != nil { - t.Fatalf("could not stat file %s: %s", testfile, err) +func TestPostDeployment(t *testing.T) { + cfg := &common.Configuration{ + []*common.Resource{ + { + Name: "foo", + Type: "helm:example.com/foo/bar", + Properties: map[string]interface{}{ + "port": ":8080", + }, + }, + }, } - expectedSize := int(fi.Size()) fc := &fakeClient{ handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - t.Errorf("Failed to read data off of request: %s", err) - } - if len(data) != expectedSize { - t.Errorf("Expected content length %d, got %d", expectedSize, len(data)) - } - - if cn := r.Header.Get("x-chart-name"); cn != "frobnitz-0.0.1.tgz" { - t.Errorf("Expected frobnitz-0.0.1.tgz, got %q", cn) - } - if dn := r.Header.Get("x-deployment-name"); dn != "sparkles" { - t.Errorf("Expected sparkles, got %q", dn) - } - - w.WriteHeader(201) + w.WriteHeader(http.StatusCreated) + fmt.Fprintln(w, "{}") }), } defer fc.teardown() - if err := fc.setup().DeployChart(testfile, testname); err != nil { - t.Fatal(err) + if err := fc.setup().PostDeployment(cfg); err != nil { + t.Fatalf("failed to post deployment: %s", err) } } From 7492ad7fe9e41511c22c75887cce6b7777e3e078 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Tue, 23 Feb 2016 09:55:06 -0800 Subject: [PATCH 46/73] fix(create): do not use full path for chart name --- cmd/helm/create.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/helm/create.go b/cmd/helm/create.go index 3cbaa11fc..61bbd1d43 100644 --- a/cmd/helm/create.go +++ b/cmd/helm/create.go @@ -2,6 +2,7 @@ package main import ( "errors" + "path/filepath" "github.com/codegangsta/cli" "github.com/kubernetes/deployment-manager/chart" @@ -25,12 +26,14 @@ func create(c *cli.Context) error { return errors.New("'helm create' requires a chart name as an argument") } + dir, name := filepath.Split(args[0]) + cf := &chart.Chartfile{ - Name: args[0], + Name: name, Description: "Created by Helm", Version: "0.1.0", } - _, err := chart.Create(cf, ".") + _, err := chart.Create(cf, dir) return err } From 84146a29cde6c66acf2bdde9a64c04940dc9f1df Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Wed, 24 Feb 2016 17:24:54 -0700 Subject: [PATCH 47/73] feat(deploy): upload chart if its local --- cmd/helm/deploy.go | 19 ++++++++++++++++++- dm/client.go | 20 ++++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index bbb2576b9..196a226f0 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -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) diff --git a/dm/client.go b/dm/client.go index e48efb4a0..59ffa7d87 100644 --- a/dm/client.go +++ b/dm/client.go @@ -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. From 9be64e52ede2932f1953c7a44a18730fa2474edb Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Thu, 25 Feb 2016 12:54:35 -0700 Subject: [PATCH 48/73] fix(style): fix style issues from govet --- dm/client.go | 1 + dm/client_test.go | 2 +- format/messages.go | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dm/client.go b/dm/client.go index 59ffa7d87..5cfb85eda 100644 --- a/dm/client.go +++ b/dm/client.go @@ -264,6 +264,7 @@ func (c *Client) DeleteDeployment(name string) (*common.Deployment, error) { return deployment, nil } +// PostDeployment posts a deployment objec to the manager service. func (c *Client) PostDeployment(cfg *common.Configuration) error { return c.CallService("/deployments", "POST", "post deployment", cfg, nil) } diff --git a/dm/client_test.go b/dm/client_test.go index 6c1473a28..bebe5e108 100644 --- a/dm/client_test.go +++ b/dm/client_test.go @@ -134,7 +134,7 @@ func TestGetDeployment(t *testing.T) { func TestPostDeployment(t *testing.T) { cfg := &common.Configuration{ - []*common.Resource{ + Resources: []*common.Resource{ { Name: "foo", Type: "helm:example.com/foo/bar", diff --git a/format/messages.go b/format/messages.go index 1d2a8b0e1..9576e0aad 100644 --- a/format/messages.go +++ b/format/messages.go @@ -38,6 +38,7 @@ func Warning(msg string, v ...interface{}) { fmt.Fprintf(os.Stdout, msg, v...) } +// YAML prints an object in YAML format. func YAML(v interface{}) error { y, err := yaml.Marshal(v) if err != nil { From 7f87745dc7804343d46c65d8f164f70f7a238166 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Thu, 25 Feb 2016 13:13:09 -0700 Subject: [PATCH 49/73] feat(chart_upload): add chart_upload.go Also removed the now unused deploy subpackage and fixed the makefile accordingly. --- Makefile | 16 ++++--- cmd/helm/chart_upload.go | 99 ++++++++++++++++++++++++++++++++++++++++ deploy/deploy.go | 26 ----------- 3 files changed, 108 insertions(+), 33 deletions(-) create mode 100644 cmd/helm/chart_upload.go delete mode 100644 deploy/deploy.go diff --git a/Makefile b/Makefile index da844291f..d1529767b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,9 @@ endif BIN_DIR := bin DIST_DIR := _dist -GO_PACKAGES := cmd/helm dm deploy format kubectl +#GO_PACKAGES := cmd/helm dm format kubectl +GO_DIRS ?= $(shell glide nv -x ) +GO_PKGS ?= $(shell glide nv) MAIN_GO := github.com/deis/helm-dm/cmd/helm HELM_BIN := helm-dm PATH_WITH_HELM = PATH="$(shell pwd)/$(BIN_DIR)/helm:$(PATH)" @@ -44,19 +46,19 @@ install: build install -m 755 bin/${HELM_BIN} ${DESTDIR}/usr/local/bin/${HELM_BIN} quicktest: - $(PATH_WITH_HELM) go test -short $(addprefix ./,$(GO_PACKAGES)) + $(PATH_WITH_HELM) go test -short ${GO_PKGS} test: test-style - $(PATH_WITH_HELM) go test -v -cover $(addprefix ./,$(GO_PACKAGES)) + $(PATH_WITH_HELM) go test -v -cover ${GO_PKGS} test-style: - @if [ $(shell gofmt -e -l -s $(GO_PACKAGES)) ]; then \ - echo "gofmt check failed:"; gofmt -e -d -s $(GO_PACKAGES); exit 1; \ + @if [ $(shell gofmt -e -l -s $(GO_DIRS)) ]; then \ + echo "gofmt check failed:"; gofmt -e -d -s $(GO_DIRS); exit 1; \ fi - @for i in . $(GO_PACKAGES); do \ + @for i in . $(GO_DIRS); do \ golint $$i; \ done - @for i in . $(GO_PACKAGES); do \ + @for i in . $(GO_DIRS); do \ go vet github.com/deis/helm-dm/$$i; \ done diff --git a/cmd/helm/chart_upload.go b/cmd/helm/chart_upload.go new file mode 100644 index 000000000..5e5933af4 --- /dev/null +++ b/cmd/helm/chart_upload.go @@ -0,0 +1,99 @@ +package main + +import ( + "errors" + "fmt" + "os" + "regexp" + "strings" + + "github.com/aokoli/goutils" + "github.com/codegangsta/cli" + "github.com/deis/helm-dm/format" + "github.com/kubernetes/deployment-manager/chart" +) + +func uploadChart(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + format.Err("First argument, filename, is required. Try 'helm deploy --help'") + os.Exit(1) + } + + cname := c.String("name") + fname := args[0] + + if fname == "" { + return errors.New("A filename must be specified. For a tar archive, this is the name of the root template in the archive.") + } + + _, err := doUpload(fname, cname, c) + return err +} +func doUpload(filename, cname string, cxt *cli.Context) (string, error) { + + fi, err := os.Stat(filename) + if err != nil { + return "", err + } + + if fi.IsDir() { + format.Info("Chart is directory") + c, err := chart.LoadDir(filename) + if err != nil { + return "", err + } + if cname == "" { + cname = genName(c.Chartfile().Name) + } + + // TODO: Is it better to generate the file in temp dir like this, or + // just put it in the CWD? + //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 + } + filename = tfile + } else if cname == "" { + n, _, e := parseTarName(filename) + if e != nil { + return "", e + } + cname = n + } + + // TODO: Add a version build metadata on the chart. + + if cxt.Bool("dry-run") { + format.Info("Prepared deploy %q using file %q", cname, filename) + return "", nil + } + + c := client(cxt) + return c.PostChart(filename, cname) +} + +func genName(pname string) string { + s, _ := goutils.RandomAlphaNumeric(8) + return fmt.Sprintf("%s-%s", pname, s) +} + +func parseTarName(name string) (string, string, error) { + tnregexp := regexp.MustCompile(chart.TarNameRegex) + if strings.HasSuffix(name, ".tgz") { + name = strings.TrimSuffix(name, ".tgz") + } + v := tnregexp.FindStringSubmatch(name) + if v == nil { + return name, "", fmt.Errorf("invalid name %s", name) + } + return v[1], v[2], nil +} diff --git a/deploy/deploy.go b/deploy/deploy.go deleted file mode 100644 index a29b2b275..000000000 --- a/deploy/deploy.go +++ /dev/null @@ -1,26 +0,0 @@ -package deploy - -import ( - "os" - - "github.com/kubernetes/deployment-manager/common" -) - -// Deployment describes a deployment of a package. -type Deployment struct { - // Name is the Deployment name. Autogenerated if empty. - Name string - // Filename is the filename for the base deployment. - Filename string - // Imports is a list of imported files. - Imports []string - // Properties to pass into the template. - Properties map[string]interface{} - // Input is a file containing templates. It may be os.Stdin. - Input *os.File - // Repository is the location of the templates. - Repository string - - // The template, typically generated by the Deployment. - Template *common.Template -} From ada5cc1b0062d038e1b361665ee8ddd6f0dd806d Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Thu, 25 Feb 2016 13:24:22 -0700 Subject: [PATCH 50/73] chore(travis): update Travis to use Glide 0.9.1 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 20224a711..b2fbe4c0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go env: - - GO15VENDOREXPERIMENT=1 + - GO15VENDOREXPERIMENT=1 GLIDE_VERSION="0.9.1" branches: only: @@ -16,9 +16,9 @@ go: - 1.5 install: - - wget "https://github.com/Masterminds/glide/releases/download/0.8.3/glide-0.8.3-linux-amd64.tar.gz" + - wget "https://github.com/Masterminds/glide/releases/download/$GLIDE_VERSION/glide-$GLIDE_VERSION-linux-amd64.tar.gz" - mkdir -p $HOME/bin - - tar -vxz -C $HOME/bin --strip=1 -f glide-0.8.3-linux-amd64.tar.gz + - tar -vxz -C $HOME/bin --strip=1 -f glide-$GLIDE_VERSION-linux-amd64.tar.gz - export PATH="$HOME/bin:$PATH" GLIDE_HOME="$HOME/.glide" script: make bootstrap build test From e1f4488ed22aa53306a5755b3f58b00b189d76c7 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 26 Feb 2016 14:38:29 -0700 Subject: [PATCH 51/73] feat(*): stub out commands for helm --- cmd/helm/chart.go | 43 +++++++++++++++++++++++++++++++++++++++ cmd/helm/create.go | 7 ++++--- cmd/helm/credential.go | 41 +++++++++++++++++++++++++++++++++++++ cmd/helm/delete.go | 7 ++++--- cmd/helm/deploy.go | 13 +++++------- cmd/helm/deployment.go | 40 ++++++++++++++++++++++++++++++++++++ cmd/helm/dm.go | 7 +++++-- cmd/helm/get.go | 7 ++++--- cmd/helm/lint.go | 17 ++++++++++++++++ cmd/helm/pack.go | 9 +++++---- cmd/helm/redeploy.go | 23 +++++++++++++++++++++ cmd/helm/release.go | 23 +++++++++++++++++++++ cmd/helm/repository.go | 46 ++++++++++++++++++++++++++++++++++++++++++ cmd/helm/status.go | 17 ++++++++++++++++ 14 files changed, 277 insertions(+), 23 deletions(-) create mode 100644 cmd/helm/chart.go create mode 100644 cmd/helm/credential.go create mode 100644 cmd/helm/deployment.go create mode 100644 cmd/helm/lint.go create mode 100644 cmd/helm/redeploy.go create mode 100644 cmd/helm/release.go create mode 100644 cmd/helm/repository.go create mode 100644 cmd/helm/status.go diff --git a/cmd/helm/chart.go b/cmd/helm/chart.go new file mode 100644 index 000000000..7d4a67dfa --- /dev/null +++ b/cmd/helm/chart.go @@ -0,0 +1,43 @@ +package main + +import ( + "github.com/codegangsta/cli" +) + +func init() { + addCommands(chartCommands()) +} + +func chartCommands() cli.Command { + return cli.Command{ + // Names following form prescribed here: http://is.gd/QUSEOF + Name: "chart", + Usage: "Perform chart-centered operations.", + Subcommands: []cli.Command{ + { + Name: "config", + Usage: "Create a configuration parameters file for this chart.", + ArgsUsage: "CHART", + }, + { + Name: "show", + Aliases: []string{"info"}, + Usage: "Provide details about this package.", + ArgsUsage: "CHART", + }, + { + Name: "scaffold", + }, + { + Name: "list", + Usage: "list all deployed charts, optionally constraining by pattern.", + ArgsUsage: "[PATTERN]", + }, + { + Name: "deployments", + Usage: "given a chart, show all the deployments that reference it.", + ArgsUsage: "CHART", + }, + }, + } +} diff --git a/cmd/helm/create.go b/cmd/helm/create.go index 61bbd1d43..8bbeee5f0 100644 --- a/cmd/helm/create.go +++ b/cmd/helm/create.go @@ -14,9 +14,10 @@ func init() { func createCmd() cli.Command { return cli.Command{ - Name: "create", - Usage: "Create a new local chart for editing.", - Action: func(c *cli.Context) { run(c, create) }, + Name: "create", + Usage: "Create a new local chart for editing.", + Action: func(c *cli.Context) { run(c, create) }, + ArgsUsage: "NAME", } } diff --git a/cmd/helm/credential.go b/cmd/helm/credential.go new file mode 100644 index 000000000..f2afa369b --- /dev/null +++ b/cmd/helm/credential.go @@ -0,0 +1,41 @@ +package main + +import ( + "github.com/codegangsta/cli" +) + +func init() { + addCommands(credCommands()) +} + +func credCommands() cli.Command { + return cli.Command{ + Name: "credential", + Aliases: []string{"cred"}, + Usage: "Perform repository credential operations.", + Subcommands: []cli.Command{ + { + Name: "add", + Usage: "Add a credential to the remote manager.", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "file,f", + Usage: "A JSON file with credential information.", + }, + }, + ArgsUsage: "CREDENTIAL", + }, + { + Name: "list", + Usage: "List the credentials on the remote manager.", + ArgsUsage: "", + }, + { + Name: "remove", + Aliases: []string{"rm"}, + Usage: "Remove a credential from the remote manager.", + ArgsUsage: "CREDENTIAL", + }, + }, + } +} diff --git a/cmd/helm/delete.go b/cmd/helm/delete.go index b954dfe03..985d0ba5f 100644 --- a/cmd/helm/delete.go +++ b/cmd/helm/delete.go @@ -13,9 +13,10 @@ func init() { func deleteCmd() cli.Command { return cli.Command{ - Name: "delete", - Usage: "Deletes the supplied deployment", - Action: func(c *cli.Context) { run(c, deleteDeployment) }, + Name: "delete", + Usage: "Deletes the supplied deployment", + ArgsUsage: "DEPLOYMENT", + Action: func(c *cli.Context) { run(c, deleteDeployment) }, } } diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index bbb2576b9..d6e5c818a 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -14,15 +14,12 @@ func init() { func deployCmd() cli.Command { return cli.Command{ - Name: "deploy", - Aliases: []string{"install"}, - Usage: "Deploy a chart into the cluster.", - Action: func(c *cli.Context) { run(c, deploy) }, + Name: "deploy", + Aliases: []string{"install"}, + Usage: "Deploy a chart into the cluster.", + ArgsUsage: "[CHART]", + Action: func(c *cli.Context) { run(c, deploy) }, Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "dry-run", - Usage: "Only display the underlying kubectl commands.", - }, cli.StringFlag{ Name: "config,c", Usage: "The configuration YAML file for this deployment.", diff --git a/cmd/helm/deployment.go b/cmd/helm/deployment.go new file mode 100644 index 000000000..bf06d2d24 --- /dev/null +++ b/cmd/helm/deployment.go @@ -0,0 +1,40 @@ +package main + +import ( + "github.com/codegangsta/cli" +) + +func init() { + addCommands(deploymentCommands()) +} + +func deploymentCommands() cli.Command { + return cli.Command{ + // Names following form prescribed here: http://is.gd/QUSEOF + Name: "deployment", + Usage: "Perform deployment-centered operations.", + Subcommands: []cli.Command{ + { + Name: "config", + Usage: "Dump the configuration file for this deployment.", + ArgsUsage: "DEPLOYMENT", + }, + { + Name: "manifest", + Usage: "Dump the Kubernetes manifest file for this deployment.", + ArgsUsage: "DEPLOYMENT", + }, + { + Name: "show", + Aliases: []string{"info"}, + Usage: "Provide details about this deployment.", + ArgsUsage: "", + }, + { + Name: "list", + Usage: "list all deployments, or filter by an optional pattern", + ArgsUsage: "PATTERN", + }, + }, + } +} diff --git a/cmd/helm/dm.go b/cmd/helm/dm.go index 97592b48d..9419b3fe1 100644 --- a/cmd/helm/dm.go +++ b/cmd/helm/dm.go @@ -25,6 +25,7 @@ func dmCmd() cli.Command { { Name: "install", Usage: "Install DM on Kubernetes.", + ArgsUsage: "", Description: ``, Flags: []cli.Flag{ cli.BoolFlag{ @@ -42,6 +43,7 @@ func dmCmd() cli.Command { { Name: "uninstall", Usage: "Uninstall the DM from Kubernetes.", + ArgsUsage: "", Description: ``, Flags: []cli.Flag{ cli.BoolFlag{ @@ -57,8 +59,9 @@ func dmCmd() cli.Command { }, }, { - Name: "status", - Usage: "Show status of DM.", + Name: "status", + Usage: "Show status of DM.", + ArgsUsage: "", Action: func(c *cli.Context) { format.Err("Not yet implemented") os.Exit(1) diff --git a/cmd/helm/get.go b/cmd/helm/get.go index ddff95eac..7a9ffa9d5 100644 --- a/cmd/helm/get.go +++ b/cmd/helm/get.go @@ -13,9 +13,10 @@ func init() { func getCmd() cli.Command { return cli.Command{ - Name: "get", - Usage: "Retrieves the supplied deployment", - Action: func(c *cli.Context) { run(c, get) }, + Name: "get", + ArgsUsage: "DEPLOYMENT", + Usage: "Retrieves the supplied deployment", + Action: func(c *cli.Context) { run(c, get) }, } } diff --git a/cmd/helm/lint.go b/cmd/helm/lint.go new file mode 100644 index 000000000..54c899151 --- /dev/null +++ b/cmd/helm/lint.go @@ -0,0 +1,17 @@ +package main + +import ( + "github.com/codegangsta/cli" +) + +func init() { + addCommands(lintCmd()) +} + +func lintCmd() cli.Command { + return cli.Command{ + Name: "lint", + Usage: "Evaluate a chart's conformance to the specification.", + ArgsUsage: "PATH [PATH...]", + } +} diff --git a/cmd/helm/pack.go b/cmd/helm/pack.go index dda22a291..eeb612b84 100644 --- a/cmd/helm/pack.go +++ b/cmd/helm/pack.go @@ -16,10 +16,11 @@ func init() { func packageCmd() cli.Command { return cli.Command{ - Name: "package", - Aliases: []string{"pack"}, - Usage: "Given a chart directory, package it into a release.", - Action: func(c *cli.Context) { run(c, pack) }, + Name: "package", + Aliases: []string{"pack"}, + Usage: "Given a chart directory, package it into a release.", + ArgsUsage: "PATH", + Action: func(c *cli.Context) { run(c, pack) }, } } diff --git a/cmd/helm/redeploy.go b/cmd/helm/redeploy.go new file mode 100644 index 000000000..18bbb5168 --- /dev/null +++ b/cmd/helm/redeploy.go @@ -0,0 +1,23 @@ +package main + +import ( + "github.com/codegangsta/cli" +) + +func init() { + addCommands(redeployCommand()) +} + +func redeployCommand() cli.Command { + return cli.Command{ + Name: "redeploy", + Usage: "update an existing deployment with a new configuration.", + ArgsUsage: "DEPLOYMENT", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "config,f", + Usage: "Configuration values file.", + }, + }, + } +} diff --git a/cmd/helm/release.go b/cmd/helm/release.go new file mode 100644 index 000000000..a9e1a7c71 --- /dev/null +++ b/cmd/helm/release.go @@ -0,0 +1,23 @@ +package main + +import ( + "github.com/codegangsta/cli" +) + +func init() { + addCommands(releaseCmd()) +} + +func releaseCmd() cli.Command { + return cli.Command{ + Name: "release", + Usage: "Release a chart to a remote chart repository.", + ArgsUsage: "PATH", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "destination,u", + Usage: "Destination URL to which this will be POSTed.", + }, + }, + } +} diff --git a/cmd/helm/repository.go b/cmd/helm/repository.go new file mode 100644 index 000000000..463035d31 --- /dev/null +++ b/cmd/helm/repository.go @@ -0,0 +1,46 @@ +package main + +import ( + "github.com/codegangsta/cli" +) + +func init() { + addCommands(repoCommands()) +} + +func repoCommands() cli.Command { + return cli.Command{ + Name: "repository", + Aliases: []string{"repo"}, + Usage: "Perform repository operations.", + Subcommands: []cli.Command{ + { + Name: "add", + Usage: "Add a repository to the remote manager.", + ArgsUsage: "REPOSITORY", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "cred", + Usage: "The name of the credential.", + }, + }, + }, + { + Name: "show", + Usage: "Show the repository details for a given repository.", + ArgsUsage: "REPOSITORY", + }, + { + Name: "list", + Usage: "List the repositories on the remote manager.", + ArgsUsage: "", + }, + { + Name: "remove", + Aliases: []string{"rm"}, + Usage: "Remove a repository from the remote manager.", + ArgsUsage: "REPOSITORY", + }, + }, + } +} diff --git a/cmd/helm/status.go b/cmd/helm/status.go new file mode 100644 index 000000000..d43466ee2 --- /dev/null +++ b/cmd/helm/status.go @@ -0,0 +1,17 @@ +package main + +import ( + "github.com/codegangsta/cli" +) + +func init() { + addCommands(statusCommand()) +} + +func statusCommand() cli.Command { + return cli.Command{ + Name: "status", + Usage: "Provide status on a named deployment.", + ArgsUsage: "DEPLOYMENT", + } +} From 27e01c4d352e9ce79ba5d8f05604480bdf4aabcb Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Fri, 26 Feb 2016 17:38:28 -0700 Subject: [PATCH 52/73] fix(deploy): removed "install" alias --- cmd/helm/deploy.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/helm/deploy.go b/cmd/helm/deploy.go index d6e5c818a..e1d0c138b 100644 --- a/cmd/helm/deploy.go +++ b/cmd/helm/deploy.go @@ -15,7 +15,6 @@ func init() { func deployCmd() cli.Command { return cli.Command{ Name: "deploy", - Aliases: []string{"install"}, Usage: "Deploy a chart into the cluster.", ArgsUsage: "[CHART]", Action: func(c *cli.Context) { run(c, deploy) }, From 4dc58448a001f33d89f47bb443c31a4c57c27266 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Fri, 26 Feb 2016 16:56:09 -0800 Subject: [PATCH 53/73] ref(*) move lib code into pkg --- Makefile | 6 +++--- cmd/helm/chart_upload.go | 2 +- cmd/helm/delete.go | 2 +- cmd/helm/dm.go | 6 +++--- cmd/helm/doctor.go | 6 +++--- cmd/helm/get.go | 2 +- cmd/helm/helm.go | 4 ++-- cmd/helm/list.go | 2 +- cmd/helm/pack.go | 2 +- cmd/helm/target.go | 4 ++-- {dm => pkg/dm}/client.go | 0 {dm => pkg/dm}/client_test.go | 0 {dm => pkg/dm}/install.go | 4 ++-- {dm => pkg/dm}/transport.go | 0 {dm => pkg/dm}/transport_test.go | 0 {dm => pkg/dm}/uninstall.go | 2 +- {format => pkg/format}/messages.go | 0 {kubectl => pkg/kubectl}/cluster_info.go | 0 {kubectl => pkg/kubectl}/command.go | 0 {kubectl => pkg/kubectl}/create.go | 0 {kubectl => pkg/kubectl}/create_test.go | 0 {kubectl => pkg/kubectl}/delete.go | 0 {kubectl => pkg/kubectl}/get.go | 0 {kubectl => pkg/kubectl}/get_test.go | 0 {kubectl => pkg/kubectl}/kubectl.go | 0 {kubectl => pkg/kubectl}/kubectl_test.go | 0 26 files changed, 21 insertions(+), 21 deletions(-) rename {dm => pkg/dm}/client.go (100%) rename {dm => pkg/dm}/client_test.go (100%) rename {dm => pkg/dm}/install.go (98%) rename {dm => pkg/dm}/transport.go (100%) rename {dm => pkg/dm}/transport_test.go (100%) rename {dm => pkg/dm}/uninstall.go (88%) rename {format => pkg/format}/messages.go (100%) rename {kubectl => pkg/kubectl}/cluster_info.go (100%) rename {kubectl => pkg/kubectl}/command.go (100%) rename {kubectl => pkg/kubectl}/create.go (100%) rename {kubectl => pkg/kubectl}/create_test.go (100%) rename {kubectl => pkg/kubectl}/delete.go (100%) rename {kubectl => pkg/kubectl}/get.go (100%) rename {kubectl => pkg/kubectl}/get_test.go (100%) rename {kubectl => pkg/kubectl}/kubectl.go (100%) rename {kubectl => pkg/kubectl}/kubectl_test.go (100%) diff --git a/Makefile b/Makefile index d1529767b..2ba3fa3c2 100644 --- a/Makefile +++ b/Makefile @@ -55,11 +55,11 @@ test-style: @if [ $(shell gofmt -e -l -s $(GO_DIRS)) ]; then \ echo "gofmt check failed:"; gofmt -e -d -s $(GO_DIRS); exit 1; \ fi - @for i in . $(GO_DIRS); do \ + @for i in $(GO_PKGS); do \ golint $$i; \ done - @for i in . $(GO_DIRS); do \ - go vet github.com/deis/helm-dm/$$i; \ + @for i in $(GO_DIRS); do \ + go tool vet $$i; \ done .PHONY: bootstrap \ diff --git a/cmd/helm/chart_upload.go b/cmd/helm/chart_upload.go index 5e5933af4..3c872f002 100644 --- a/cmd/helm/chart_upload.go +++ b/cmd/helm/chart_upload.go @@ -9,7 +9,7 @@ import ( "github.com/aokoli/goutils" "github.com/codegangsta/cli" - "github.com/deis/helm-dm/format" + "github.com/deis/helm-dm/pkg/format" "github.com/kubernetes/deployment-manager/chart" ) diff --git a/cmd/helm/delete.go b/cmd/helm/delete.go index 985d0ba5f..9cb21bf1e 100644 --- a/cmd/helm/delete.go +++ b/cmd/helm/delete.go @@ -4,7 +4,7 @@ import ( "errors" "github.com/codegangsta/cli" - "github.com/deis/helm-dm/format" + "github.com/deis/helm-dm/pkg/format" ) func init() { diff --git a/cmd/helm/dm.go b/cmd/helm/dm.go index 9419b3fe1..746459513 100644 --- a/cmd/helm/dm.go +++ b/cmd/helm/dm.go @@ -5,9 +5,9 @@ import ( "os" "github.com/codegangsta/cli" - "github.com/deis/helm-dm/dm" - "github.com/deis/helm-dm/format" - "github.com/deis/helm-dm/kubectl" + "github.com/deis/helm-dm/pkg/dm" + "github.com/deis/helm-dm/pkg/format" + "github.com/deis/helm-dm/pkg/kubectl" ) // ErrAlreadyInstalled indicates that DM is already installed. diff --git a/cmd/helm/doctor.go b/cmd/helm/doctor.go index 8568b6972..97812ccbc 100644 --- a/cmd/helm/doctor.go +++ b/cmd/helm/doctor.go @@ -2,9 +2,9 @@ package main import ( "github.com/codegangsta/cli" - "github.com/deis/helm-dm/dm" - "github.com/deis/helm-dm/format" - "github.com/deis/helm-dm/kubectl" + "github.com/deis/helm-dm/pkg/dm" + "github.com/deis/helm-dm/pkg/format" + "github.com/deis/helm-dm/pkg/kubectl" ) func init() { diff --git a/cmd/helm/get.go b/cmd/helm/get.go index 7a9ffa9d5..b600e7515 100644 --- a/cmd/helm/get.go +++ b/cmd/helm/get.go @@ -4,7 +4,7 @@ import ( "errors" "github.com/codegangsta/cli" - "github.com/deis/helm-dm/format" + "github.com/deis/helm-dm/pkg/format" ) func init() { diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 84ce287e0..a2f0cb753 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -4,8 +4,8 @@ import ( "os" "github.com/codegangsta/cli" - "github.com/deis/helm-dm/dm" - "github.com/deis/helm-dm/format" + "github.com/deis/helm-dm/pkg/dm" + "github.com/deis/helm-dm/pkg/format" ) var version = "0.0.1" diff --git a/cmd/helm/list.go b/cmd/helm/list.go index a3ea2f0df..2c1bc072c 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -2,7 +2,7 @@ package main import ( "github.com/codegangsta/cli" - "github.com/deis/helm-dm/format" + "github.com/deis/helm-dm/pkg/format" ) func init() { diff --git a/cmd/helm/pack.go b/cmd/helm/pack.go index eeb612b84..44247b605 100644 --- a/cmd/helm/pack.go +++ b/cmd/helm/pack.go @@ -6,7 +6,7 @@ import ( "os" "github.com/codegangsta/cli" - "github.com/deis/helm-dm/format" + "github.com/deis/helm-dm/pkg/format" "github.com/kubernetes/deployment-manager/chart" ) diff --git a/cmd/helm/target.go b/cmd/helm/target.go index cb06c8e77..b9906f87e 100644 --- a/cmd/helm/target.go +++ b/cmd/helm/target.go @@ -3,8 +3,8 @@ package main import ( "fmt" - "github.com/deis/helm-dm/format" - "github.com/deis/helm-dm/kubectl" + "github.com/deis/helm-dm/pkg/format" + "github.com/deis/helm-dm/pkg/kubectl" ) func target(dryRun bool) error { diff --git a/dm/client.go b/pkg/dm/client.go similarity index 100% rename from dm/client.go rename to pkg/dm/client.go diff --git a/dm/client_test.go b/pkg/dm/client_test.go similarity index 100% rename from dm/client_test.go rename to pkg/dm/client_test.go diff --git a/dm/install.go b/pkg/dm/install.go similarity index 98% rename from dm/install.go rename to pkg/dm/install.go index e1290b29d..0894f79c9 100644 --- a/dm/install.go +++ b/pkg/dm/install.go @@ -1,8 +1,8 @@ package dm import ( - "github.com/deis/helm-dm/format" - "github.com/deis/helm-dm/kubectl" + "github.com/deis/helm-dm/pkg/format" + "github.com/deis/helm-dm/pkg/kubectl" ) // Install uses kubectl to install the base DM. diff --git a/dm/transport.go b/pkg/dm/transport.go similarity index 100% rename from dm/transport.go rename to pkg/dm/transport.go diff --git a/dm/transport_test.go b/pkg/dm/transport_test.go similarity index 100% rename from dm/transport_test.go rename to pkg/dm/transport_test.go diff --git a/dm/uninstall.go b/pkg/dm/uninstall.go similarity index 88% rename from dm/uninstall.go rename to pkg/dm/uninstall.go index 4bd6b8c71..3aea10fbe 100644 --- a/dm/uninstall.go +++ b/pkg/dm/uninstall.go @@ -1,7 +1,7 @@ package dm import ( - "github.com/deis/helm-dm/kubectl" + "github.com/deis/helm-dm/pkg/kubectl" ) // Uninstall uses kubectl to uninstall the base DM. diff --git a/format/messages.go b/pkg/format/messages.go similarity index 100% rename from format/messages.go rename to pkg/format/messages.go diff --git a/kubectl/cluster_info.go b/pkg/kubectl/cluster_info.go similarity index 100% rename from kubectl/cluster_info.go rename to pkg/kubectl/cluster_info.go diff --git a/kubectl/command.go b/pkg/kubectl/command.go similarity index 100% rename from kubectl/command.go rename to pkg/kubectl/command.go diff --git a/kubectl/create.go b/pkg/kubectl/create.go similarity index 100% rename from kubectl/create.go rename to pkg/kubectl/create.go diff --git a/kubectl/create_test.go b/pkg/kubectl/create_test.go similarity index 100% rename from kubectl/create_test.go rename to pkg/kubectl/create_test.go diff --git a/kubectl/delete.go b/pkg/kubectl/delete.go similarity index 100% rename from kubectl/delete.go rename to pkg/kubectl/delete.go diff --git a/kubectl/get.go b/pkg/kubectl/get.go similarity index 100% rename from kubectl/get.go rename to pkg/kubectl/get.go diff --git a/kubectl/get_test.go b/pkg/kubectl/get_test.go similarity index 100% rename from kubectl/get_test.go rename to pkg/kubectl/get_test.go diff --git a/kubectl/kubectl.go b/pkg/kubectl/kubectl.go similarity index 100% rename from kubectl/kubectl.go rename to pkg/kubectl/kubectl.go diff --git a/kubectl/kubectl_test.go b/pkg/kubectl/kubectl_test.go similarity index 100% rename from kubectl/kubectl_test.go rename to pkg/kubectl/kubectl_test.go From e43286b6f90824e96cb20b791149f96b8b76cc86 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Fri, 26 Feb 2016 22:35:22 -0800 Subject: [PATCH 54/73] ref(*): isolate go code to /cmd and /pkg --- {dm => cmd/dm}/Dockerfile | 0 {dm => cmd/dm}/Makefile | 0 {dm => cmd/dm}/dm.go | 4 ++-- {expandybird => cmd/expandybird}/Dockerfile | 0 {expandybird => cmd/expandybird}/Makefile | 0 .../expandybird}/expander/expander.go | 2 +- .../expandybird}/expander/expander_test.go | 4 ++-- .../expandybird}/expansion/expansion.py | 0 .../expandybird}/expansion/expansion_test.py | 0 .../expandybird}/expansion/file_expander.py | 0 .../expandybird}/expansion/sandbox_loader.py | 0 .../expandybird}/expansion/schema_validation.py | 0 .../expansion/schema_validation_test.py | 0 .../expansion/schema_validation_utils.py | 0 {expandybird => cmd/expandybird}/main.go | 6 +++--- {expandybird => cmd/expandybird}/requirements.txt | 0 .../expandybird}/service/service.go | 6 +++--- .../expandybird}/service/service_test.go | 6 +++--- .../expandybird}/test/ExpectedOutput.yaml | 0 .../expandybird}/test/InvalidFileName.yaml | 0 .../expandybird}/test/InvalidProperty.yaml | 0 .../expandybird}/test/InvalidTypeName.yaml | 0 .../expandybird}/test/MalformedContent.yaml | 0 .../expandybird}/test/MissingImports.yaml | 0 .../expandybird}/test/MissingResourceName.yaml | 0 .../expandybird}/test/MissingTypeName.yaml | 0 .../expandybird}/test/TestArchive.tar | Bin .../expandybird}/test/ValidContent.yaml | 0 .../expandybird}/test/replicatedservice.py | 0 .../expandybird}/test/schemas/bad.jinja.schema | 0 .../test/schemas/default_ref.jinja.schema | 0 .../test/schemas/defaults.jinja.schema | 0 .../expandybird}/test/schemas/defaults.py.schema | 0 .../test/schemas/invalid_default.jinja.schema | 0 .../test/schemas/invalid_reference.py.schema | 0 .../schemas/invalid_reference_schema.py.schema | 0 .../expandybird}/test/schemas/metadata.py.schema | 0 .../test/schemas/missing_quote.py.schema | 0 .../test/schemas/nested_defaults.py.schema | 0 .../expandybird}/test/schemas/numbers.py.schema | 0 .../test/schemas/ref_nested_defaults.py.schema | 0 .../test/schemas/reference.jinja.schema | 0 .../test/schemas/req_default_ref.py.schema | 0 .../test/schemas/required.jinja.schema | 0 .../test/schemas/required_default.jinja.schema | 0 .../test/templates/description_text.txt | 0 .../test/templates/duplicate_names.yaml | 0 .../test/templates/duplicate_names_B.jinja | 0 .../test/templates/duplicate_names_C.jinja | 0 .../duplicate_names_in_subtemplates.jinja | 0 .../duplicate_names_in_subtemplates.yaml | 0 .../templates/duplicate_names_mixed_level.yaml | 0 .../duplicate_names_mixed_level_result.yaml | 0 .../templates/duplicate_names_parent_child.yaml | 0 .../duplicate_names_parent_child_result.yaml | 0 .../expandybird}/test/templates/helper.jinja | 0 .../test/templates/helper.jinja.schema | 0 .../test/templates/helpers/common.jinja | 0 .../expandybird}/test/templates/helpers/common.py | 0 .../test/templates/helpers/extra/__init__.py | 0 .../test/templates/helpers/extra/common2.py | 0 .../test/templates/invalid_config.yaml | 0 .../test/templates/jinja_defaults.jinja | 0 .../test/templates/jinja_defaults.jinja.schema | 0 .../test/templates/jinja_defaults.yaml | 0 .../test/templates/jinja_defaults_result.yaml | 0 .../test/templates/jinja_missing_required.jinja | 0 .../templates/jinja_missing_required.jinja.schema | 0 .../test/templates/jinja_missing_required.yaml | 0 .../test/templates/jinja_multiple_errors.jinja | 0 .../templates/jinja_multiple_errors.jinja.schema | 0 .../test/templates/jinja_multiple_errors.yaml | 0 .../test/templates/jinja_noparams.jinja | 0 .../test/templates/jinja_noparams.yaml | 0 .../test/templates/jinja_noparams_result.yaml | 0 .../test/templates/jinja_template.jinja | 0 .../test/templates/jinja_template.yaml | 0 .../test/templates/jinja_template_result.yaml | 0 .../test/templates/jinja_template_with_env.jinja | 0 .../test/templates/jinja_template_with_env.yaml | 0 .../templates/jinja_template_with_env_result.yaml | 0 .../templates/jinja_template_with_import.jinja | 0 .../templates/jinja_template_with_import.yaml | 0 .../jinja_template_with_import_result.yaml | 0 .../jinja_template_with_inlinedfile.jinja | 0 .../jinja_template_with_inlinedfile.yaml | 0 .../jinja_template_with_inlinedfile_result.yaml | 0 .../test/templates/jinja_unresolved.jinja | 0 .../test/templates/jinja_unresolved.yaml | 0 .../expandybird}/test/templates/no_properties.py | 0 .../test/templates/no_properties.yaml | 0 .../test/templates/no_properties_result.yaml | 0 .../expandybird}/test/templates/no_resources.py | 0 .../expandybird}/test/templates/no_resources.yaml | 0 .../templates/python_and_jinja_template.jinja | 0 .../test/templates/python_and_jinja_template.py | 0 .../test/templates/python_and_jinja_template.yaml | 0 .../python_and_jinja_template_result.yaml | 0 .../test/templates/python_bad_schema.py | 0 .../test/templates/python_bad_schema.py.schema | 0 .../test/templates/python_bad_schema.yaml | 0 .../test/templates/python_noparams.py | 0 .../test/templates/python_noparams.yaml | 0 .../test/templates/python_noparams_result.yaml | 0 .../expandybird}/test/templates/python_schema.py | 0 .../test/templates/python_schema.py.schema | 0 .../test/templates/python_schema.yaml | 0 .../test/templates/python_schema_result.yaml | 0 .../test/templates/python_template.py | 0 .../test/templates/python_template.yaml | 0 .../test/templates/python_template_result.yaml | 0 .../test/templates/python_template_with_env.py | 0 .../test/templates/python_template_with_env.yaml | 0 .../python_template_with_env_result.yaml | 0 .../test/templates/python_template_with_import.py | 0 .../templates/python_template_with_import.yaml | 0 .../python_template_with_import_result.yaml | 0 .../templates/python_template_with_inlinedfile.py | 0 .../python_template_with_inlinedfile.yaml | 0 .../python_template_with_inlinedfile_result.yaml | 0 .../test/templates/python_with_exception.py | 0 .../test/templates/python_with_exception.yaml | 0 .../expandybird}/test/templates/simple.yaml | 0 .../test/templates/simple_result.yaml | 0 .../expandybird}/test/templates/use_helper.jinja | 0 .../test/templates/use_helper.jinja.schema | 0 .../expandybird}/test/templates/use_helper.yaml | 0 .../test/templates/use_helper_result.yaml | 0 {manager => cmd/manager}/Dockerfile | 0 {manager => cmd/manager}/Makefile | 0 {manager => cmd/manager}/deployments.go | 14 +++++++------- {manager => cmd/manager}/main.go | 4 ++-- {manager => cmd/manager}/manager/deployer.go | 2 +- {manager => cmd/manager}/manager/deployer_test.go | 4 ++-- {manager => cmd/manager}/manager/expander.go | 2 +- {manager => cmd/manager}/manager/expander_test.go | 4 ++-- {manager => cmd/manager}/manager/manager.go | 8 ++++---- {manager => cmd/manager}/manager/manager_test.go | 4 ++-- {manager => cmd/manager}/manager/typeresolver.go | 6 +++--- .../manager}/manager/typeresolver_test.go | 4 ++-- .../manager}/repository/persistent/persistent.go | 4 ++-- .../repository/persistent/persistent_test.go | 2 +- {manager => cmd/manager}/repository/repository.go | 2 +- .../manager}/repository/test_common.go | 2 +- .../manager}/repository/transient/transient.go | 4 ++-- .../repository/transient/transient_test.go | 2 +- {resourcifier => cmd/resourcifier}/Dockerfile | 0 {resourcifier => cmd/resourcifier}/Makefile | 0 .../resourcifier}/configurations.go | 6 +++--- .../resourcifier}/configurator/configurator.go | 4 ++-- {resourcifier => cmd/resourcifier}/main.go | 4 ++-- {chart => pkg/chart}/chart.go | 2 +- {chart => pkg/chart}/chart_test.go | 2 +- {chart => pkg/chart}/chartfile.go | 0 {chart => pkg/chart}/chartfile_test.go | 0 {chart => pkg/chart}/doc.go | 0 {chart => pkg/chart}/locator.go | 0 {chart => pkg/chart}/locator_test.go | 0 {chart => pkg/chart}/save.go | 2 +- {chart => pkg/chart}/save_test.go | 0 {chart => pkg/chart}/testdata/README.md | 0 {chart => pkg/chart}/testdata/frobnitz-0.0.1.tgz | Bin {chart => pkg/chart}/testdata/frobnitz/Chart.yaml | 0 {chart => pkg/chart}/testdata/frobnitz/LICENSE | 0 {chart => pkg/chart}/testdata/frobnitz/README.md | 0 .../chart}/testdata/frobnitz/docs/README.md | 0 .../chart}/testdata/frobnitz/hooks/pre-install.py | 0 {chart => pkg/chart}/testdata/frobnitz/icon.svg | 0 .../frobnitz/templates/wordpress-resources.yaml | 0 .../testdata/frobnitz/templates/wordpress.jinja | 0 .../frobnitz/templates/wordpress.jinja.schema | 0 .../testdata/frobnitz/templates/wordpress.yaml | 0 {chart => pkg/chart}/testdata/ill-1.2.3.tgz | Bin {chart => pkg/chart}/testdata/ill/Chart.yaml | 0 {chart => pkg/chart}/testdata/ill/LICENSE | 0 {chart => pkg/chart}/testdata/ill/README.md | 0 {chart => pkg/chart}/testdata/ill/docs/README.md | 0 .../chart}/testdata/ill/hooks/pre-install.py | 0 .../ill/templates/wordpress-resources.yaml | 0 .../chart}/testdata/ill/templates/wordpress.jinja | 0 .../testdata/ill/templates/wordpress.jinja.schema | 0 .../chart}/testdata/ill/templates/wordpress.yaml | 0 {chart => pkg/chart}/testdata/nochart.tgz | Bin {chart => pkg/chart}/testdata/sprocket/Chart.yaml | 0 {chart => pkg/chart}/testdata/sprocket/LICENSE | 0 {chart => pkg/chart}/testdata/sprocket/README.md | 0 .../chart}/testdata/sprocket/docs/README.md | 0 .../chart}/testdata/sprocket/hooks/pre-install.py | 0 {chart => pkg/chart}/testdata/sprocket/icon.svg | 0 .../testdata/sprocket/templates/placeholder.txt | 0 {common => pkg/common}/types.go | 0 {log => pkg/log}/log.go | 0 {log => pkg/log}/log_test.go | 0 .../registry}/filebased_credential_provider.go | 2 +- .../filebased_credential_provider_test.go | 2 +- {registry => pkg/registry}/gcs_registry.go | 4 ++-- .../registry}/github_package_registry.go | 2 +- {registry => pkg/registry}/github_registry.go | 4 ++-- .../registry}/github_template_registry.go | 2 +- .../registry}/inmem_credential_provider.go | 2 +- .../registry}/inmem_credential_provider_test.go | 2 +- .../registry}/inmem_registry_service.go | 4 ++-- {registry => pkg/registry}/registry.go | 4 ++-- {registry => pkg/registry}/registry_test.go | 0 {registry => pkg/registry}/registryprovider.go | 4 ++-- .../registry}/registryprovider_test.go | 0 .../registry}/secrets_credential_provider.go | 4 ++-- {registry => pkg/registry}/semver.go | 0 {registry => pkg/registry}/semver_test.go | 0 .../registry}/test/test_credentials_file.yaml | 0 {registry => pkg/registry}/testhelper.go | 4 ++-- {util => pkg/util}/httpclient.go | 0 {util => pkg/util}/httpclient_test.go | 0 {util => pkg/util}/httputil.go | 0 {util => pkg/util}/kubernetes.go | 0 {util => pkg/util}/kubernetes_kubectl.go | 0 {util => pkg/util}/kubernetesutil.go | 2 +- {util => pkg/util}/kubernetesutil_test.go | 2 +- {util => pkg/util}/templateutil.go | 2 +- {util => pkg/util}/templateutil_test.go | 0 {version => pkg/version}/version.go | 0 221 files changed, 81 insertions(+), 81 deletions(-) rename {dm => cmd/dm}/Dockerfile (100%) rename {dm => cmd/dm}/Makefile (100%) rename {dm => cmd/dm}/dm.go (99%) rename {expandybird => cmd/expandybird}/Dockerfile (100%) rename {expandybird => cmd/expandybird}/Makefile (100%) rename {expandybird => cmd/expandybird}/expander/expander.go (98%) rename {expandybird => cmd/expandybird}/expander/expander_test.go (97%) rename {expandybird => cmd/expandybird}/expansion/expansion.py (100%) rename {expandybird => cmd/expandybird}/expansion/expansion_test.py (100%) rename {expandybird => cmd/expandybird}/expansion/file_expander.py (100%) rename {expandybird => cmd/expandybird}/expansion/sandbox_loader.py (100%) rename {expandybird => cmd/expandybird}/expansion/schema_validation.py (100%) rename {expandybird => cmd/expandybird}/expansion/schema_validation_test.py (100%) rename {expandybird => cmd/expandybird}/expansion/schema_validation_utils.py (100%) rename {expandybird => cmd/expandybird}/main.go (88%) rename {expandybird => cmd/expandybird}/requirements.txt (100%) rename {expandybird => cmd/expandybird}/service/service.go (94%) rename {expandybird => cmd/expandybird}/service/service_test.go (97%) rename {expandybird => cmd/expandybird}/test/ExpectedOutput.yaml (100%) rename {expandybird => cmd/expandybird}/test/InvalidFileName.yaml (100%) rename {expandybird => cmd/expandybird}/test/InvalidProperty.yaml (100%) rename {expandybird => cmd/expandybird}/test/InvalidTypeName.yaml (100%) rename {expandybird => cmd/expandybird}/test/MalformedContent.yaml (100%) rename {expandybird => cmd/expandybird}/test/MissingImports.yaml (100%) rename {expandybird => cmd/expandybird}/test/MissingResourceName.yaml (100%) rename {expandybird => cmd/expandybird}/test/MissingTypeName.yaml (100%) rename {expandybird => cmd/expandybird}/test/TestArchive.tar (100%) rename {expandybird => cmd/expandybird}/test/ValidContent.yaml (100%) rename {expandybird => cmd/expandybird}/test/replicatedservice.py (100%) rename {expandybird => cmd/expandybird}/test/schemas/bad.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/default_ref.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/defaults.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/defaults.py.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/invalid_default.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/invalid_reference.py.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/invalid_reference_schema.py.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/metadata.py.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/missing_quote.py.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/nested_defaults.py.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/numbers.py.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/ref_nested_defaults.py.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/reference.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/req_default_ref.py.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/required.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/schemas/required_default.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/templates/description_text.txt (100%) rename {expandybird => cmd/expandybird}/test/templates/duplicate_names.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/duplicate_names_B.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/duplicate_names_C.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/duplicate_names_in_subtemplates.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/duplicate_names_in_subtemplates.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/duplicate_names_mixed_level.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/duplicate_names_mixed_level_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/duplicate_names_parent_child.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/duplicate_names_parent_child_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/helper.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/helper.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/templates/helpers/common.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/helpers/common.py (100%) rename {expandybird => cmd/expandybird}/test/templates/helpers/extra/__init__.py (100%) rename {expandybird => cmd/expandybird}/test/templates/helpers/extra/common2.py (100%) rename {expandybird => cmd/expandybird}/test/templates/invalid_config.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_defaults.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_defaults.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_defaults.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_defaults_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_missing_required.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_missing_required.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_missing_required.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_multiple_errors.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_multiple_errors.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_multiple_errors.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_noparams.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_noparams.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_noparams_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template_with_env.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template_with_env.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template_with_env_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template_with_import.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template_with_import.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template_with_import_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template_with_inlinedfile.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template_with_inlinedfile.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_template_with_inlinedfile_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_unresolved.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/jinja_unresolved.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/no_properties.py (100%) rename {expandybird => cmd/expandybird}/test/templates/no_properties.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/no_properties_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/no_resources.py (100%) rename {expandybird => cmd/expandybird}/test/templates/no_resources.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_and_jinja_template.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/python_and_jinja_template.py (100%) rename {expandybird => cmd/expandybird}/test/templates/python_and_jinja_template.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_and_jinja_template_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_bad_schema.py (100%) rename {expandybird => cmd/expandybird}/test/templates/python_bad_schema.py.schema (100%) rename {expandybird => cmd/expandybird}/test/templates/python_bad_schema.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_noparams.py (100%) rename {expandybird => cmd/expandybird}/test/templates/python_noparams.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_noparams_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_schema.py (100%) rename {expandybird => cmd/expandybird}/test/templates/python_schema.py.schema (100%) rename {expandybird => cmd/expandybird}/test/templates/python_schema.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_schema_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template.py (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template_with_env.py (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template_with_env.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template_with_env_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template_with_import.py (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template_with_import.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template_with_import_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template_with_inlinedfile.py (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template_with_inlinedfile.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_template_with_inlinedfile_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/python_with_exception.py (100%) rename {expandybird => cmd/expandybird}/test/templates/python_with_exception.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/simple.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/simple_result.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/use_helper.jinja (100%) rename {expandybird => cmd/expandybird}/test/templates/use_helper.jinja.schema (100%) rename {expandybird => cmd/expandybird}/test/templates/use_helper.yaml (100%) rename {expandybird => cmd/expandybird}/test/templates/use_helper_result.yaml (100%) rename {manager => cmd/manager}/Dockerfile (100%) rename {manager => cmd/manager}/Makefile (100%) rename {manager => cmd/manager}/deployments.go (97%) rename {manager => cmd/manager}/main.go (95%) rename {manager => cmd/manager}/manager/deployer.go (99%) rename {manager => cmd/manager}/manager/deployer_test.go (98%) rename {manager => cmd/manager}/manager/expander.go (99%) rename {manager => cmd/manager}/manager/expander_test.go (98%) rename {manager => cmd/manager}/manager/manager.go (98%) rename {manager => cmd/manager}/manager/manager_test.go (99%) rename {manager => cmd/manager}/manager/typeresolver.go (97%) rename {manager => cmd/manager}/manager/typeresolver_test.go (99%) rename {manager => cmd/manager}/repository/persistent/persistent.go (99%) rename {manager => cmd/manager}/repository/persistent/persistent_test.go (97%) rename {manager => cmd/manager}/repository/repository.go (97%) rename {manager => cmd/manager}/repository/test_common.go (99%) rename {manager => cmd/manager}/repository/transient/transient.go (98%) rename {manager => cmd/manager}/repository/transient/transient_test.go (96%) rename {resourcifier => cmd/resourcifier}/Dockerfile (100%) rename {resourcifier => cmd/resourcifier}/Makefile (100%) rename {resourcifier => cmd/resourcifier}/configurations.go (97%) rename {resourcifier => cmd/resourcifier}/configurator/configurator.go (98%) rename {resourcifier => cmd/resourcifier}/main.go (94%) rename {chart => pkg/chart}/chart.go (99%) rename {chart => pkg/chart}/chart_test.go (98%) rename {chart => pkg/chart}/chartfile.go (100%) rename {chart => pkg/chart}/chartfile_test.go (100%) rename {chart => pkg/chart}/doc.go (100%) rename {chart => pkg/chart}/locator.go (100%) rename {chart => pkg/chart}/locator_test.go (100%) rename {chart => pkg/chart}/save.go (98%) rename {chart => pkg/chart}/save_test.go (100%) rename {chart => pkg/chart}/testdata/README.md (100%) rename {chart => pkg/chart}/testdata/frobnitz-0.0.1.tgz (100%) rename {chart => pkg/chart}/testdata/frobnitz/Chart.yaml (100%) rename {chart => pkg/chart}/testdata/frobnitz/LICENSE (100%) rename {chart => pkg/chart}/testdata/frobnitz/README.md (100%) rename {chart => pkg/chart}/testdata/frobnitz/docs/README.md (100%) rename {chart => pkg/chart}/testdata/frobnitz/hooks/pre-install.py (100%) rename {chart => pkg/chart}/testdata/frobnitz/icon.svg (100%) rename {chart => pkg/chart}/testdata/frobnitz/templates/wordpress-resources.yaml (100%) rename {chart => pkg/chart}/testdata/frobnitz/templates/wordpress.jinja (100%) rename {chart => pkg/chart}/testdata/frobnitz/templates/wordpress.jinja.schema (100%) rename {chart => pkg/chart}/testdata/frobnitz/templates/wordpress.yaml (100%) rename {chart => pkg/chart}/testdata/ill-1.2.3.tgz (100%) rename {chart => pkg/chart}/testdata/ill/Chart.yaml (100%) rename {chart => pkg/chart}/testdata/ill/LICENSE (100%) rename {chart => pkg/chart}/testdata/ill/README.md (100%) rename {chart => pkg/chart}/testdata/ill/docs/README.md (100%) rename {chart => pkg/chart}/testdata/ill/hooks/pre-install.py (100%) rename {chart => pkg/chart}/testdata/ill/templates/wordpress-resources.yaml (100%) rename {chart => pkg/chart}/testdata/ill/templates/wordpress.jinja (100%) rename {chart => pkg/chart}/testdata/ill/templates/wordpress.jinja.schema (100%) rename {chart => pkg/chart}/testdata/ill/templates/wordpress.yaml (100%) rename {chart => pkg/chart}/testdata/nochart.tgz (100%) rename {chart => pkg/chart}/testdata/sprocket/Chart.yaml (100%) rename {chart => pkg/chart}/testdata/sprocket/LICENSE (100%) rename {chart => pkg/chart}/testdata/sprocket/README.md (100%) rename {chart => pkg/chart}/testdata/sprocket/docs/README.md (100%) rename {chart => pkg/chart}/testdata/sprocket/hooks/pre-install.py (100%) rename {chart => pkg/chart}/testdata/sprocket/icon.svg (100%) rename {chart => pkg/chart}/testdata/sprocket/templates/placeholder.txt (100%) rename {common => pkg/common}/types.go (100%) rename {log => pkg/log}/log.go (100%) rename {log => pkg/log}/log_test.go (100%) rename {registry => pkg/registry}/filebased_credential_provider.go (97%) rename {registry => pkg/registry}/filebased_credential_provider_test.go (97%) rename {registry => pkg/registry}/gcs_registry.go (97%) rename {registry => pkg/registry}/github_package_registry.go (98%) rename {registry => pkg/registry}/github_registry.go (97%) rename {registry => pkg/registry}/github_template_registry.go (99%) rename {registry => pkg/registry}/inmem_credential_provider.go (96%) rename {registry => pkg/registry}/inmem_credential_provider_test.go (97%) rename {registry => pkg/registry}/inmem_registry_service.go (97%) rename {registry => pkg/registry}/registry.go (97%) rename {registry => pkg/registry}/registry_test.go (100%) rename {registry => pkg/registry}/registryprovider.go (99%) rename {registry => pkg/registry}/registryprovider_test.go (100%) rename {registry => pkg/registry}/secrets_credential_provider.go (97%) rename {registry => pkg/registry}/semver.go (100%) rename {registry => pkg/registry}/semver_test.go (100%) rename {registry => pkg/registry}/test/test_credentials_file.yaml (100%) rename {registry => pkg/registry}/testhelper.go (97%) rename {util => pkg/util}/httpclient.go (100%) rename {util => pkg/util}/httpclient_test.go (100%) rename {util => pkg/util}/httputil.go (100%) rename {util => pkg/util}/kubernetes.go (100%) rename {util => pkg/util}/kubernetes_kubectl.go (100%) rename {util => pkg/util}/kubernetesutil.go (96%) rename {util => pkg/util}/kubernetesutil_test.go (98%) rename {util => pkg/util}/templateutil.go (98%) rename {util => pkg/util}/templateutil_test.go (100%) rename {version => pkg/version}/version.go (100%) diff --git a/dm/Dockerfile b/cmd/dm/Dockerfile similarity index 100% rename from dm/Dockerfile rename to cmd/dm/Dockerfile diff --git a/dm/Makefile b/cmd/dm/Makefile similarity index 100% rename from dm/Makefile rename to cmd/dm/Makefile diff --git a/dm/dm.go b/cmd/dm/dm.go similarity index 99% rename from dm/dm.go rename to cmd/dm/dm.go index 03ee06dbb..93c91e707 100644 --- a/dm/dm.go +++ b/cmd/dm/dm.go @@ -19,8 +19,8 @@ package main import ( "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" "archive/tar" "bytes" diff --git a/expandybird/Dockerfile b/cmd/expandybird/Dockerfile similarity index 100% rename from expandybird/Dockerfile rename to cmd/expandybird/Dockerfile diff --git a/expandybird/Makefile b/cmd/expandybird/Makefile similarity index 100% rename from expandybird/Makefile rename to cmd/expandybird/Makefile diff --git a/expandybird/expander/expander.go b/cmd/expandybird/expander/expander.go similarity index 98% rename from expandybird/expander/expander.go rename to cmd/expandybird/expander/expander.go index 01176301f..f8d5472ca 100644 --- a/expandybird/expander/expander.go +++ b/cmd/expandybird/expander/expander.go @@ -24,7 +24,7 @@ import ( "os/exec" "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" ) // Expander abstracts interactions with the expander and deployer services. diff --git a/expandybird/expander/expander_test.go b/cmd/expandybird/expander/expander_test.go similarity index 97% rename from expandybird/expander/expander_test.go rename to cmd/expandybird/expander/expander_test.go index bb12577c1..dcd27f557 100644 --- a/expandybird/expander/expander_test.go +++ b/cmd/expandybird/expander/expander_test.go @@ -26,8 +26,8 @@ import ( "strings" "testing" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" ) var importFileNames = []string{ diff --git a/expandybird/expansion/expansion.py b/cmd/expandybird/expansion/expansion.py similarity index 100% rename from expandybird/expansion/expansion.py rename to cmd/expandybird/expansion/expansion.py diff --git a/expandybird/expansion/expansion_test.py b/cmd/expandybird/expansion/expansion_test.py similarity index 100% rename from expandybird/expansion/expansion_test.py rename to cmd/expandybird/expansion/expansion_test.py diff --git a/expandybird/expansion/file_expander.py b/cmd/expandybird/expansion/file_expander.py similarity index 100% rename from expandybird/expansion/file_expander.py rename to cmd/expandybird/expansion/file_expander.py diff --git a/expandybird/expansion/sandbox_loader.py b/cmd/expandybird/expansion/sandbox_loader.py similarity index 100% rename from expandybird/expansion/sandbox_loader.py rename to cmd/expandybird/expansion/sandbox_loader.py diff --git a/expandybird/expansion/schema_validation.py b/cmd/expandybird/expansion/schema_validation.py similarity index 100% rename from expandybird/expansion/schema_validation.py rename to cmd/expandybird/expansion/schema_validation.py diff --git a/expandybird/expansion/schema_validation_test.py b/cmd/expandybird/expansion/schema_validation_test.py similarity index 100% rename from expandybird/expansion/schema_validation_test.py rename to cmd/expandybird/expansion/schema_validation_test.py diff --git a/expandybird/expansion/schema_validation_utils.py b/cmd/expandybird/expansion/schema_validation_utils.py similarity index 100% rename from expandybird/expansion/schema_validation_utils.py rename to cmd/expandybird/expansion/schema_validation_utils.py diff --git a/expandybird/main.go b/cmd/expandybird/main.go similarity index 88% rename from expandybird/main.go rename to cmd/expandybird/main.go index df2d3714e..ecbdaf0c7 100644 --- a/expandybird/main.go +++ b/cmd/expandybird/main.go @@ -17,9 +17,9 @@ limitations under the License. package main import ( - "github.com/kubernetes/deployment-manager/expandybird/expander" - "github.com/kubernetes/deployment-manager/expandybird/service" - "github.com/kubernetes/deployment-manager/version" + "github.com/kubernetes/deployment-manager/cmd/expandybird/expander" + "github.com/kubernetes/deployment-manager/cmd/expandybird/service" + "github.com/kubernetes/deployment-manager/pkg/version" "flag" "fmt" diff --git a/expandybird/requirements.txt b/cmd/expandybird/requirements.txt similarity index 100% rename from expandybird/requirements.txt rename to cmd/expandybird/requirements.txt diff --git a/expandybird/service/service.go b/cmd/expandybird/service/service.go similarity index 94% rename from expandybird/service/service.go rename to cmd/expandybird/service/service.go index ac75d47e6..384083ecb 100644 --- a/expandybird/service/service.go +++ b/cmd/expandybird/service/service.go @@ -17,9 +17,9 @@ limitations under the License. package service import ( - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/expandybird/expander" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/cmd/expandybird/expander" + "github.com/kubernetes/deployment-manager/pkg/util" "errors" "fmt" diff --git a/expandybird/service/service_test.go b/cmd/expandybird/service/service_test.go similarity index 97% rename from expandybird/service/service_test.go rename to cmd/expandybird/service/service_test.go index ee5f029ae..9acdf1d74 100644 --- a/expandybird/service/service_test.go +++ b/cmd/expandybird/service/service_test.go @@ -26,9 +26,9 @@ import ( "reflect" "testing" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/expandybird/expander" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/cmd/expandybird/expander" + "github.com/kubernetes/deployment-manager/pkg/util" restful "github.com/emicklei/go-restful" ) diff --git a/expandybird/test/ExpectedOutput.yaml b/cmd/expandybird/test/ExpectedOutput.yaml similarity index 100% rename from expandybird/test/ExpectedOutput.yaml rename to cmd/expandybird/test/ExpectedOutput.yaml diff --git a/expandybird/test/InvalidFileName.yaml b/cmd/expandybird/test/InvalidFileName.yaml similarity index 100% rename from expandybird/test/InvalidFileName.yaml rename to cmd/expandybird/test/InvalidFileName.yaml diff --git a/expandybird/test/InvalidProperty.yaml b/cmd/expandybird/test/InvalidProperty.yaml similarity index 100% rename from expandybird/test/InvalidProperty.yaml rename to cmd/expandybird/test/InvalidProperty.yaml diff --git a/expandybird/test/InvalidTypeName.yaml b/cmd/expandybird/test/InvalidTypeName.yaml similarity index 100% rename from expandybird/test/InvalidTypeName.yaml rename to cmd/expandybird/test/InvalidTypeName.yaml diff --git a/expandybird/test/MalformedContent.yaml b/cmd/expandybird/test/MalformedContent.yaml similarity index 100% rename from expandybird/test/MalformedContent.yaml rename to cmd/expandybird/test/MalformedContent.yaml diff --git a/expandybird/test/MissingImports.yaml b/cmd/expandybird/test/MissingImports.yaml similarity index 100% rename from expandybird/test/MissingImports.yaml rename to cmd/expandybird/test/MissingImports.yaml diff --git a/expandybird/test/MissingResourceName.yaml b/cmd/expandybird/test/MissingResourceName.yaml similarity index 100% rename from expandybird/test/MissingResourceName.yaml rename to cmd/expandybird/test/MissingResourceName.yaml diff --git a/expandybird/test/MissingTypeName.yaml b/cmd/expandybird/test/MissingTypeName.yaml similarity index 100% rename from expandybird/test/MissingTypeName.yaml rename to cmd/expandybird/test/MissingTypeName.yaml diff --git a/expandybird/test/TestArchive.tar b/cmd/expandybird/test/TestArchive.tar similarity index 100% rename from expandybird/test/TestArchive.tar rename to cmd/expandybird/test/TestArchive.tar diff --git a/expandybird/test/ValidContent.yaml b/cmd/expandybird/test/ValidContent.yaml similarity index 100% rename from expandybird/test/ValidContent.yaml rename to cmd/expandybird/test/ValidContent.yaml diff --git a/expandybird/test/replicatedservice.py b/cmd/expandybird/test/replicatedservice.py similarity index 100% rename from expandybird/test/replicatedservice.py rename to cmd/expandybird/test/replicatedservice.py diff --git a/expandybird/test/schemas/bad.jinja.schema b/cmd/expandybird/test/schemas/bad.jinja.schema similarity index 100% rename from expandybird/test/schemas/bad.jinja.schema rename to cmd/expandybird/test/schemas/bad.jinja.schema diff --git a/expandybird/test/schemas/default_ref.jinja.schema b/cmd/expandybird/test/schemas/default_ref.jinja.schema similarity index 100% rename from expandybird/test/schemas/default_ref.jinja.schema rename to cmd/expandybird/test/schemas/default_ref.jinja.schema diff --git a/expandybird/test/schemas/defaults.jinja.schema b/cmd/expandybird/test/schemas/defaults.jinja.schema similarity index 100% rename from expandybird/test/schemas/defaults.jinja.schema rename to cmd/expandybird/test/schemas/defaults.jinja.schema diff --git a/expandybird/test/schemas/defaults.py.schema b/cmd/expandybird/test/schemas/defaults.py.schema similarity index 100% rename from expandybird/test/schemas/defaults.py.schema rename to cmd/expandybird/test/schemas/defaults.py.schema diff --git a/expandybird/test/schemas/invalid_default.jinja.schema b/cmd/expandybird/test/schemas/invalid_default.jinja.schema similarity index 100% rename from expandybird/test/schemas/invalid_default.jinja.schema rename to cmd/expandybird/test/schemas/invalid_default.jinja.schema diff --git a/expandybird/test/schemas/invalid_reference.py.schema b/cmd/expandybird/test/schemas/invalid_reference.py.schema similarity index 100% rename from expandybird/test/schemas/invalid_reference.py.schema rename to cmd/expandybird/test/schemas/invalid_reference.py.schema diff --git a/expandybird/test/schemas/invalid_reference_schema.py.schema b/cmd/expandybird/test/schemas/invalid_reference_schema.py.schema similarity index 100% rename from expandybird/test/schemas/invalid_reference_schema.py.schema rename to cmd/expandybird/test/schemas/invalid_reference_schema.py.schema diff --git a/expandybird/test/schemas/metadata.py.schema b/cmd/expandybird/test/schemas/metadata.py.schema similarity index 100% rename from expandybird/test/schemas/metadata.py.schema rename to cmd/expandybird/test/schemas/metadata.py.schema diff --git a/expandybird/test/schemas/missing_quote.py.schema b/cmd/expandybird/test/schemas/missing_quote.py.schema similarity index 100% rename from expandybird/test/schemas/missing_quote.py.schema rename to cmd/expandybird/test/schemas/missing_quote.py.schema diff --git a/expandybird/test/schemas/nested_defaults.py.schema b/cmd/expandybird/test/schemas/nested_defaults.py.schema similarity index 100% rename from expandybird/test/schemas/nested_defaults.py.schema rename to cmd/expandybird/test/schemas/nested_defaults.py.schema diff --git a/expandybird/test/schemas/numbers.py.schema b/cmd/expandybird/test/schemas/numbers.py.schema similarity index 100% rename from expandybird/test/schemas/numbers.py.schema rename to cmd/expandybird/test/schemas/numbers.py.schema diff --git a/expandybird/test/schemas/ref_nested_defaults.py.schema b/cmd/expandybird/test/schemas/ref_nested_defaults.py.schema similarity index 100% rename from expandybird/test/schemas/ref_nested_defaults.py.schema rename to cmd/expandybird/test/schemas/ref_nested_defaults.py.schema diff --git a/expandybird/test/schemas/reference.jinja.schema b/cmd/expandybird/test/schemas/reference.jinja.schema similarity index 100% rename from expandybird/test/schemas/reference.jinja.schema rename to cmd/expandybird/test/schemas/reference.jinja.schema diff --git a/expandybird/test/schemas/req_default_ref.py.schema b/cmd/expandybird/test/schemas/req_default_ref.py.schema similarity index 100% rename from expandybird/test/schemas/req_default_ref.py.schema rename to cmd/expandybird/test/schemas/req_default_ref.py.schema diff --git a/expandybird/test/schemas/required.jinja.schema b/cmd/expandybird/test/schemas/required.jinja.schema similarity index 100% rename from expandybird/test/schemas/required.jinja.schema rename to cmd/expandybird/test/schemas/required.jinja.schema diff --git a/expandybird/test/schemas/required_default.jinja.schema b/cmd/expandybird/test/schemas/required_default.jinja.schema similarity index 100% rename from expandybird/test/schemas/required_default.jinja.schema rename to cmd/expandybird/test/schemas/required_default.jinja.schema diff --git a/expandybird/test/templates/description_text.txt b/cmd/expandybird/test/templates/description_text.txt similarity index 100% rename from expandybird/test/templates/description_text.txt rename to cmd/expandybird/test/templates/description_text.txt diff --git a/expandybird/test/templates/duplicate_names.yaml b/cmd/expandybird/test/templates/duplicate_names.yaml similarity index 100% rename from expandybird/test/templates/duplicate_names.yaml rename to cmd/expandybird/test/templates/duplicate_names.yaml diff --git a/expandybird/test/templates/duplicate_names_B.jinja b/cmd/expandybird/test/templates/duplicate_names_B.jinja similarity index 100% rename from expandybird/test/templates/duplicate_names_B.jinja rename to cmd/expandybird/test/templates/duplicate_names_B.jinja diff --git a/expandybird/test/templates/duplicate_names_C.jinja b/cmd/expandybird/test/templates/duplicate_names_C.jinja similarity index 100% rename from expandybird/test/templates/duplicate_names_C.jinja rename to cmd/expandybird/test/templates/duplicate_names_C.jinja diff --git a/expandybird/test/templates/duplicate_names_in_subtemplates.jinja b/cmd/expandybird/test/templates/duplicate_names_in_subtemplates.jinja similarity index 100% rename from expandybird/test/templates/duplicate_names_in_subtemplates.jinja rename to cmd/expandybird/test/templates/duplicate_names_in_subtemplates.jinja diff --git a/expandybird/test/templates/duplicate_names_in_subtemplates.yaml b/cmd/expandybird/test/templates/duplicate_names_in_subtemplates.yaml similarity index 100% rename from expandybird/test/templates/duplicate_names_in_subtemplates.yaml rename to cmd/expandybird/test/templates/duplicate_names_in_subtemplates.yaml diff --git a/expandybird/test/templates/duplicate_names_mixed_level.yaml b/cmd/expandybird/test/templates/duplicate_names_mixed_level.yaml similarity index 100% rename from expandybird/test/templates/duplicate_names_mixed_level.yaml rename to cmd/expandybird/test/templates/duplicate_names_mixed_level.yaml diff --git a/expandybird/test/templates/duplicate_names_mixed_level_result.yaml b/cmd/expandybird/test/templates/duplicate_names_mixed_level_result.yaml similarity index 100% rename from expandybird/test/templates/duplicate_names_mixed_level_result.yaml rename to cmd/expandybird/test/templates/duplicate_names_mixed_level_result.yaml diff --git a/expandybird/test/templates/duplicate_names_parent_child.yaml b/cmd/expandybird/test/templates/duplicate_names_parent_child.yaml similarity index 100% rename from expandybird/test/templates/duplicate_names_parent_child.yaml rename to cmd/expandybird/test/templates/duplicate_names_parent_child.yaml diff --git a/expandybird/test/templates/duplicate_names_parent_child_result.yaml b/cmd/expandybird/test/templates/duplicate_names_parent_child_result.yaml similarity index 100% rename from expandybird/test/templates/duplicate_names_parent_child_result.yaml rename to cmd/expandybird/test/templates/duplicate_names_parent_child_result.yaml diff --git a/expandybird/test/templates/helper.jinja b/cmd/expandybird/test/templates/helper.jinja similarity index 100% rename from expandybird/test/templates/helper.jinja rename to cmd/expandybird/test/templates/helper.jinja diff --git a/expandybird/test/templates/helper.jinja.schema b/cmd/expandybird/test/templates/helper.jinja.schema similarity index 100% rename from expandybird/test/templates/helper.jinja.schema rename to cmd/expandybird/test/templates/helper.jinja.schema diff --git a/expandybird/test/templates/helpers/common.jinja b/cmd/expandybird/test/templates/helpers/common.jinja similarity index 100% rename from expandybird/test/templates/helpers/common.jinja rename to cmd/expandybird/test/templates/helpers/common.jinja diff --git a/expandybird/test/templates/helpers/common.py b/cmd/expandybird/test/templates/helpers/common.py similarity index 100% rename from expandybird/test/templates/helpers/common.py rename to cmd/expandybird/test/templates/helpers/common.py diff --git a/expandybird/test/templates/helpers/extra/__init__.py b/cmd/expandybird/test/templates/helpers/extra/__init__.py similarity index 100% rename from expandybird/test/templates/helpers/extra/__init__.py rename to cmd/expandybird/test/templates/helpers/extra/__init__.py diff --git a/expandybird/test/templates/helpers/extra/common2.py b/cmd/expandybird/test/templates/helpers/extra/common2.py similarity index 100% rename from expandybird/test/templates/helpers/extra/common2.py rename to cmd/expandybird/test/templates/helpers/extra/common2.py diff --git a/expandybird/test/templates/invalid_config.yaml b/cmd/expandybird/test/templates/invalid_config.yaml similarity index 100% rename from expandybird/test/templates/invalid_config.yaml rename to cmd/expandybird/test/templates/invalid_config.yaml diff --git a/expandybird/test/templates/jinja_defaults.jinja b/cmd/expandybird/test/templates/jinja_defaults.jinja similarity index 100% rename from expandybird/test/templates/jinja_defaults.jinja rename to cmd/expandybird/test/templates/jinja_defaults.jinja diff --git a/expandybird/test/templates/jinja_defaults.jinja.schema b/cmd/expandybird/test/templates/jinja_defaults.jinja.schema similarity index 100% rename from expandybird/test/templates/jinja_defaults.jinja.schema rename to cmd/expandybird/test/templates/jinja_defaults.jinja.schema diff --git a/expandybird/test/templates/jinja_defaults.yaml b/cmd/expandybird/test/templates/jinja_defaults.yaml similarity index 100% rename from expandybird/test/templates/jinja_defaults.yaml rename to cmd/expandybird/test/templates/jinja_defaults.yaml diff --git a/expandybird/test/templates/jinja_defaults_result.yaml b/cmd/expandybird/test/templates/jinja_defaults_result.yaml similarity index 100% rename from expandybird/test/templates/jinja_defaults_result.yaml rename to cmd/expandybird/test/templates/jinja_defaults_result.yaml diff --git a/expandybird/test/templates/jinja_missing_required.jinja b/cmd/expandybird/test/templates/jinja_missing_required.jinja similarity index 100% rename from expandybird/test/templates/jinja_missing_required.jinja rename to cmd/expandybird/test/templates/jinja_missing_required.jinja diff --git a/expandybird/test/templates/jinja_missing_required.jinja.schema b/cmd/expandybird/test/templates/jinja_missing_required.jinja.schema similarity index 100% rename from expandybird/test/templates/jinja_missing_required.jinja.schema rename to cmd/expandybird/test/templates/jinja_missing_required.jinja.schema diff --git a/expandybird/test/templates/jinja_missing_required.yaml b/cmd/expandybird/test/templates/jinja_missing_required.yaml similarity index 100% rename from expandybird/test/templates/jinja_missing_required.yaml rename to cmd/expandybird/test/templates/jinja_missing_required.yaml diff --git a/expandybird/test/templates/jinja_multiple_errors.jinja b/cmd/expandybird/test/templates/jinja_multiple_errors.jinja similarity index 100% rename from expandybird/test/templates/jinja_multiple_errors.jinja rename to cmd/expandybird/test/templates/jinja_multiple_errors.jinja diff --git a/expandybird/test/templates/jinja_multiple_errors.jinja.schema b/cmd/expandybird/test/templates/jinja_multiple_errors.jinja.schema similarity index 100% rename from expandybird/test/templates/jinja_multiple_errors.jinja.schema rename to cmd/expandybird/test/templates/jinja_multiple_errors.jinja.schema diff --git a/expandybird/test/templates/jinja_multiple_errors.yaml b/cmd/expandybird/test/templates/jinja_multiple_errors.yaml similarity index 100% rename from expandybird/test/templates/jinja_multiple_errors.yaml rename to cmd/expandybird/test/templates/jinja_multiple_errors.yaml diff --git a/expandybird/test/templates/jinja_noparams.jinja b/cmd/expandybird/test/templates/jinja_noparams.jinja similarity index 100% rename from expandybird/test/templates/jinja_noparams.jinja rename to cmd/expandybird/test/templates/jinja_noparams.jinja diff --git a/expandybird/test/templates/jinja_noparams.yaml b/cmd/expandybird/test/templates/jinja_noparams.yaml similarity index 100% rename from expandybird/test/templates/jinja_noparams.yaml rename to cmd/expandybird/test/templates/jinja_noparams.yaml diff --git a/expandybird/test/templates/jinja_noparams_result.yaml b/cmd/expandybird/test/templates/jinja_noparams_result.yaml similarity index 100% rename from expandybird/test/templates/jinja_noparams_result.yaml rename to cmd/expandybird/test/templates/jinja_noparams_result.yaml diff --git a/expandybird/test/templates/jinja_template.jinja b/cmd/expandybird/test/templates/jinja_template.jinja similarity index 100% rename from expandybird/test/templates/jinja_template.jinja rename to cmd/expandybird/test/templates/jinja_template.jinja diff --git a/expandybird/test/templates/jinja_template.yaml b/cmd/expandybird/test/templates/jinja_template.yaml similarity index 100% rename from expandybird/test/templates/jinja_template.yaml rename to cmd/expandybird/test/templates/jinja_template.yaml diff --git a/expandybird/test/templates/jinja_template_result.yaml b/cmd/expandybird/test/templates/jinja_template_result.yaml similarity index 100% rename from expandybird/test/templates/jinja_template_result.yaml rename to cmd/expandybird/test/templates/jinja_template_result.yaml diff --git a/expandybird/test/templates/jinja_template_with_env.jinja b/cmd/expandybird/test/templates/jinja_template_with_env.jinja similarity index 100% rename from expandybird/test/templates/jinja_template_with_env.jinja rename to cmd/expandybird/test/templates/jinja_template_with_env.jinja diff --git a/expandybird/test/templates/jinja_template_with_env.yaml b/cmd/expandybird/test/templates/jinja_template_with_env.yaml similarity index 100% rename from expandybird/test/templates/jinja_template_with_env.yaml rename to cmd/expandybird/test/templates/jinja_template_with_env.yaml diff --git a/expandybird/test/templates/jinja_template_with_env_result.yaml b/cmd/expandybird/test/templates/jinja_template_with_env_result.yaml similarity index 100% rename from expandybird/test/templates/jinja_template_with_env_result.yaml rename to cmd/expandybird/test/templates/jinja_template_with_env_result.yaml diff --git a/expandybird/test/templates/jinja_template_with_import.jinja b/cmd/expandybird/test/templates/jinja_template_with_import.jinja similarity index 100% rename from expandybird/test/templates/jinja_template_with_import.jinja rename to cmd/expandybird/test/templates/jinja_template_with_import.jinja diff --git a/expandybird/test/templates/jinja_template_with_import.yaml b/cmd/expandybird/test/templates/jinja_template_with_import.yaml similarity index 100% rename from expandybird/test/templates/jinja_template_with_import.yaml rename to cmd/expandybird/test/templates/jinja_template_with_import.yaml diff --git a/expandybird/test/templates/jinja_template_with_import_result.yaml b/cmd/expandybird/test/templates/jinja_template_with_import_result.yaml similarity index 100% rename from expandybird/test/templates/jinja_template_with_import_result.yaml rename to cmd/expandybird/test/templates/jinja_template_with_import_result.yaml diff --git a/expandybird/test/templates/jinja_template_with_inlinedfile.jinja b/cmd/expandybird/test/templates/jinja_template_with_inlinedfile.jinja similarity index 100% rename from expandybird/test/templates/jinja_template_with_inlinedfile.jinja rename to cmd/expandybird/test/templates/jinja_template_with_inlinedfile.jinja diff --git a/expandybird/test/templates/jinja_template_with_inlinedfile.yaml b/cmd/expandybird/test/templates/jinja_template_with_inlinedfile.yaml similarity index 100% rename from expandybird/test/templates/jinja_template_with_inlinedfile.yaml rename to cmd/expandybird/test/templates/jinja_template_with_inlinedfile.yaml diff --git a/expandybird/test/templates/jinja_template_with_inlinedfile_result.yaml b/cmd/expandybird/test/templates/jinja_template_with_inlinedfile_result.yaml similarity index 100% rename from expandybird/test/templates/jinja_template_with_inlinedfile_result.yaml rename to cmd/expandybird/test/templates/jinja_template_with_inlinedfile_result.yaml diff --git a/expandybird/test/templates/jinja_unresolved.jinja b/cmd/expandybird/test/templates/jinja_unresolved.jinja similarity index 100% rename from expandybird/test/templates/jinja_unresolved.jinja rename to cmd/expandybird/test/templates/jinja_unresolved.jinja diff --git a/expandybird/test/templates/jinja_unresolved.yaml b/cmd/expandybird/test/templates/jinja_unresolved.yaml similarity index 100% rename from expandybird/test/templates/jinja_unresolved.yaml rename to cmd/expandybird/test/templates/jinja_unresolved.yaml diff --git a/expandybird/test/templates/no_properties.py b/cmd/expandybird/test/templates/no_properties.py similarity index 100% rename from expandybird/test/templates/no_properties.py rename to cmd/expandybird/test/templates/no_properties.py diff --git a/expandybird/test/templates/no_properties.yaml b/cmd/expandybird/test/templates/no_properties.yaml similarity index 100% rename from expandybird/test/templates/no_properties.yaml rename to cmd/expandybird/test/templates/no_properties.yaml diff --git a/expandybird/test/templates/no_properties_result.yaml b/cmd/expandybird/test/templates/no_properties_result.yaml similarity index 100% rename from expandybird/test/templates/no_properties_result.yaml rename to cmd/expandybird/test/templates/no_properties_result.yaml diff --git a/expandybird/test/templates/no_resources.py b/cmd/expandybird/test/templates/no_resources.py similarity index 100% rename from expandybird/test/templates/no_resources.py rename to cmd/expandybird/test/templates/no_resources.py diff --git a/expandybird/test/templates/no_resources.yaml b/cmd/expandybird/test/templates/no_resources.yaml similarity index 100% rename from expandybird/test/templates/no_resources.yaml rename to cmd/expandybird/test/templates/no_resources.yaml diff --git a/expandybird/test/templates/python_and_jinja_template.jinja b/cmd/expandybird/test/templates/python_and_jinja_template.jinja similarity index 100% rename from expandybird/test/templates/python_and_jinja_template.jinja rename to cmd/expandybird/test/templates/python_and_jinja_template.jinja diff --git a/expandybird/test/templates/python_and_jinja_template.py b/cmd/expandybird/test/templates/python_and_jinja_template.py similarity index 100% rename from expandybird/test/templates/python_and_jinja_template.py rename to cmd/expandybird/test/templates/python_and_jinja_template.py diff --git a/expandybird/test/templates/python_and_jinja_template.yaml b/cmd/expandybird/test/templates/python_and_jinja_template.yaml similarity index 100% rename from expandybird/test/templates/python_and_jinja_template.yaml rename to cmd/expandybird/test/templates/python_and_jinja_template.yaml diff --git a/expandybird/test/templates/python_and_jinja_template_result.yaml b/cmd/expandybird/test/templates/python_and_jinja_template_result.yaml similarity index 100% rename from expandybird/test/templates/python_and_jinja_template_result.yaml rename to cmd/expandybird/test/templates/python_and_jinja_template_result.yaml diff --git a/expandybird/test/templates/python_bad_schema.py b/cmd/expandybird/test/templates/python_bad_schema.py similarity index 100% rename from expandybird/test/templates/python_bad_schema.py rename to cmd/expandybird/test/templates/python_bad_schema.py diff --git a/expandybird/test/templates/python_bad_schema.py.schema b/cmd/expandybird/test/templates/python_bad_schema.py.schema similarity index 100% rename from expandybird/test/templates/python_bad_schema.py.schema rename to cmd/expandybird/test/templates/python_bad_schema.py.schema diff --git a/expandybird/test/templates/python_bad_schema.yaml b/cmd/expandybird/test/templates/python_bad_schema.yaml similarity index 100% rename from expandybird/test/templates/python_bad_schema.yaml rename to cmd/expandybird/test/templates/python_bad_schema.yaml diff --git a/expandybird/test/templates/python_noparams.py b/cmd/expandybird/test/templates/python_noparams.py similarity index 100% rename from expandybird/test/templates/python_noparams.py rename to cmd/expandybird/test/templates/python_noparams.py diff --git a/expandybird/test/templates/python_noparams.yaml b/cmd/expandybird/test/templates/python_noparams.yaml similarity index 100% rename from expandybird/test/templates/python_noparams.yaml rename to cmd/expandybird/test/templates/python_noparams.yaml diff --git a/expandybird/test/templates/python_noparams_result.yaml b/cmd/expandybird/test/templates/python_noparams_result.yaml similarity index 100% rename from expandybird/test/templates/python_noparams_result.yaml rename to cmd/expandybird/test/templates/python_noparams_result.yaml diff --git a/expandybird/test/templates/python_schema.py b/cmd/expandybird/test/templates/python_schema.py similarity index 100% rename from expandybird/test/templates/python_schema.py rename to cmd/expandybird/test/templates/python_schema.py diff --git a/expandybird/test/templates/python_schema.py.schema b/cmd/expandybird/test/templates/python_schema.py.schema similarity index 100% rename from expandybird/test/templates/python_schema.py.schema rename to cmd/expandybird/test/templates/python_schema.py.schema diff --git a/expandybird/test/templates/python_schema.yaml b/cmd/expandybird/test/templates/python_schema.yaml similarity index 100% rename from expandybird/test/templates/python_schema.yaml rename to cmd/expandybird/test/templates/python_schema.yaml diff --git a/expandybird/test/templates/python_schema_result.yaml b/cmd/expandybird/test/templates/python_schema_result.yaml similarity index 100% rename from expandybird/test/templates/python_schema_result.yaml rename to cmd/expandybird/test/templates/python_schema_result.yaml diff --git a/expandybird/test/templates/python_template.py b/cmd/expandybird/test/templates/python_template.py similarity index 100% rename from expandybird/test/templates/python_template.py rename to cmd/expandybird/test/templates/python_template.py diff --git a/expandybird/test/templates/python_template.yaml b/cmd/expandybird/test/templates/python_template.yaml similarity index 100% rename from expandybird/test/templates/python_template.yaml rename to cmd/expandybird/test/templates/python_template.yaml diff --git a/expandybird/test/templates/python_template_result.yaml b/cmd/expandybird/test/templates/python_template_result.yaml similarity index 100% rename from expandybird/test/templates/python_template_result.yaml rename to cmd/expandybird/test/templates/python_template_result.yaml diff --git a/expandybird/test/templates/python_template_with_env.py b/cmd/expandybird/test/templates/python_template_with_env.py similarity index 100% rename from expandybird/test/templates/python_template_with_env.py rename to cmd/expandybird/test/templates/python_template_with_env.py diff --git a/expandybird/test/templates/python_template_with_env.yaml b/cmd/expandybird/test/templates/python_template_with_env.yaml similarity index 100% rename from expandybird/test/templates/python_template_with_env.yaml rename to cmd/expandybird/test/templates/python_template_with_env.yaml diff --git a/expandybird/test/templates/python_template_with_env_result.yaml b/cmd/expandybird/test/templates/python_template_with_env_result.yaml similarity index 100% rename from expandybird/test/templates/python_template_with_env_result.yaml rename to cmd/expandybird/test/templates/python_template_with_env_result.yaml diff --git a/expandybird/test/templates/python_template_with_import.py b/cmd/expandybird/test/templates/python_template_with_import.py similarity index 100% rename from expandybird/test/templates/python_template_with_import.py rename to cmd/expandybird/test/templates/python_template_with_import.py diff --git a/expandybird/test/templates/python_template_with_import.yaml b/cmd/expandybird/test/templates/python_template_with_import.yaml similarity index 100% rename from expandybird/test/templates/python_template_with_import.yaml rename to cmd/expandybird/test/templates/python_template_with_import.yaml diff --git a/expandybird/test/templates/python_template_with_import_result.yaml b/cmd/expandybird/test/templates/python_template_with_import_result.yaml similarity index 100% rename from expandybird/test/templates/python_template_with_import_result.yaml rename to cmd/expandybird/test/templates/python_template_with_import_result.yaml diff --git a/expandybird/test/templates/python_template_with_inlinedfile.py b/cmd/expandybird/test/templates/python_template_with_inlinedfile.py similarity index 100% rename from expandybird/test/templates/python_template_with_inlinedfile.py rename to cmd/expandybird/test/templates/python_template_with_inlinedfile.py diff --git a/expandybird/test/templates/python_template_with_inlinedfile.yaml b/cmd/expandybird/test/templates/python_template_with_inlinedfile.yaml similarity index 100% rename from expandybird/test/templates/python_template_with_inlinedfile.yaml rename to cmd/expandybird/test/templates/python_template_with_inlinedfile.yaml diff --git a/expandybird/test/templates/python_template_with_inlinedfile_result.yaml b/cmd/expandybird/test/templates/python_template_with_inlinedfile_result.yaml similarity index 100% rename from expandybird/test/templates/python_template_with_inlinedfile_result.yaml rename to cmd/expandybird/test/templates/python_template_with_inlinedfile_result.yaml diff --git a/expandybird/test/templates/python_with_exception.py b/cmd/expandybird/test/templates/python_with_exception.py similarity index 100% rename from expandybird/test/templates/python_with_exception.py rename to cmd/expandybird/test/templates/python_with_exception.py diff --git a/expandybird/test/templates/python_with_exception.yaml b/cmd/expandybird/test/templates/python_with_exception.yaml similarity index 100% rename from expandybird/test/templates/python_with_exception.yaml rename to cmd/expandybird/test/templates/python_with_exception.yaml diff --git a/expandybird/test/templates/simple.yaml b/cmd/expandybird/test/templates/simple.yaml similarity index 100% rename from expandybird/test/templates/simple.yaml rename to cmd/expandybird/test/templates/simple.yaml diff --git a/expandybird/test/templates/simple_result.yaml b/cmd/expandybird/test/templates/simple_result.yaml similarity index 100% rename from expandybird/test/templates/simple_result.yaml rename to cmd/expandybird/test/templates/simple_result.yaml diff --git a/expandybird/test/templates/use_helper.jinja b/cmd/expandybird/test/templates/use_helper.jinja similarity index 100% rename from expandybird/test/templates/use_helper.jinja rename to cmd/expandybird/test/templates/use_helper.jinja diff --git a/expandybird/test/templates/use_helper.jinja.schema b/cmd/expandybird/test/templates/use_helper.jinja.schema similarity index 100% rename from expandybird/test/templates/use_helper.jinja.schema rename to cmd/expandybird/test/templates/use_helper.jinja.schema diff --git a/expandybird/test/templates/use_helper.yaml b/cmd/expandybird/test/templates/use_helper.yaml similarity index 100% rename from expandybird/test/templates/use_helper.yaml rename to cmd/expandybird/test/templates/use_helper.yaml diff --git a/expandybird/test/templates/use_helper_result.yaml b/cmd/expandybird/test/templates/use_helper_result.yaml similarity index 100% rename from expandybird/test/templates/use_helper_result.yaml rename to cmd/expandybird/test/templates/use_helper_result.yaml diff --git a/manager/Dockerfile b/cmd/manager/Dockerfile similarity index 100% rename from manager/Dockerfile rename to cmd/manager/Dockerfile diff --git a/manager/Makefile b/cmd/manager/Makefile similarity index 100% rename from manager/Makefile rename to cmd/manager/Makefile diff --git a/manager/deployments.go b/cmd/manager/deployments.go similarity index 97% rename from manager/deployments.go rename to cmd/manager/deployments.go index 37de85909..ae174763b 100644 --- a/manager/deployments.go +++ b/cmd/manager/deployments.go @@ -33,13 +33,13 @@ import ( "github.com/ghodss/yaml" "github.com/gorilla/mux" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/manager/manager" - "github.com/kubernetes/deployment-manager/manager/repository" - "github.com/kubernetes/deployment-manager/manager/repository/persistent" - "github.com/kubernetes/deployment-manager/manager/repository/transient" - "github.com/kubernetes/deployment-manager/registry" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/cmd/manager/manager" + "github.com/kubernetes/deployment-manager/cmd/manager/repository" + "github.com/kubernetes/deployment-manager/cmd/manager/repository/persistent" + "github.com/kubernetes/deployment-manager/cmd/manager/repository/transient" + "github.com/kubernetes/deployment-manager/pkg/registry" + "github.com/kubernetes/deployment-manager/pkg/util" ) var deployments = []Route{ diff --git a/manager/main.go b/cmd/manager/main.go similarity index 95% rename from manager/main.go rename to cmd/manager/main.go index 0009a41d4..a17369a7d 100644 --- a/manager/main.go +++ b/cmd/manager/main.go @@ -17,8 +17,8 @@ limitations under the License. package main import ( - "github.com/kubernetes/deployment-manager/util" - "github.com/kubernetes/deployment-manager/version" + "github.com/kubernetes/deployment-manager/pkg/util" + "github.com/kubernetes/deployment-manager/pkg/version" "flag" "fmt" diff --git a/manager/manager/deployer.go b/cmd/manager/manager/deployer.go similarity index 99% rename from manager/manager/deployer.go rename to cmd/manager/manager/deployer.go index 953f5a806..e47b2c5f5 100644 --- a/manager/manager/deployer.go +++ b/cmd/manager/manager/deployer.go @@ -28,7 +28,7 @@ import ( "time" "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" ) // Deployer abstracts interactions with the expander and deployer services. diff --git a/manager/manager/deployer_test.go b/cmd/manager/manager/deployer_test.go similarity index 98% rename from manager/manager/deployer_test.go rename to cmd/manager/manager/deployer_test.go index 535536364..e1ee1b340 100644 --- a/manager/manager/deployer_test.go +++ b/cmd/manager/manager/deployer_test.go @@ -26,8 +26,8 @@ import ( "strings" "testing" - "github.com/kubernetes/deployment-manager/util" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/util" + "github.com/kubernetes/deployment-manager/pkg/common" "github.com/ghodss/yaml" ) diff --git a/manager/manager/expander.go b/cmd/manager/manager/expander.go similarity index 99% rename from manager/manager/expander.go rename to cmd/manager/manager/expander.go index f41406cfe..bc3fc2bb5 100644 --- a/manager/manager/expander.go +++ b/cmd/manager/manager/expander.go @@ -24,7 +24,7 @@ import ( "net/http" "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" ) const ( diff --git a/manager/manager/expander_test.go b/cmd/manager/manager/expander_test.go similarity index 98% rename from manager/manager/expander_test.go rename to cmd/manager/manager/expander_test.go index 59d302cbf..423686698 100644 --- a/manager/manager/expander_test.go +++ b/cmd/manager/manager/expander_test.go @@ -26,8 +26,8 @@ import ( "strings" "testing" - "github.com/kubernetes/deployment-manager/util" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/util" + "github.com/kubernetes/deployment-manager/pkg/common" "github.com/ghodss/yaml" ) diff --git a/manager/manager/manager.go b/cmd/manager/manager/manager.go similarity index 98% rename from manager/manager/manager.go rename to cmd/manager/manager/manager.go index 801b09fab..827142e5b 100644 --- a/manager/manager/manager.go +++ b/cmd/manager/manager/manager.go @@ -24,10 +24,10 @@ import ( "strings" "time" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/manager/repository" - "github.com/kubernetes/deployment-manager/registry" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/cmd/manager/repository" + "github.com/kubernetes/deployment-manager/pkg/registry" + "github.com/kubernetes/deployment-manager/pkg/util" ) // Manager manages a persistent set of Deployments. diff --git a/manager/manager/manager_test.go b/cmd/manager/manager/manager_test.go similarity index 99% rename from manager/manager/manager_test.go rename to cmd/manager/manager/manager_test.go index 40ebe7f4f..0a04d167b 100644 --- a/manager/manager/manager_test.go +++ b/cmd/manager/manager/manager_test.go @@ -22,8 +22,8 @@ import ( "strings" "testing" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/registry" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/registry" ) var template = common.Template{Name: "test", Content: "test"} diff --git a/manager/manager/typeresolver.go b/cmd/manager/manager/typeresolver.go similarity index 97% rename from manager/manager/typeresolver.go rename to cmd/manager/manager/typeresolver.go index 52221b3c5..67a9f63f4 100644 --- a/manager/manager/typeresolver.go +++ b/cmd/manager/manager/typeresolver.go @@ -20,9 +20,9 @@ import ( "fmt" "net/http" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/registry" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/registry" + "github.com/kubernetes/deployment-manager/pkg/util" "github.com/ghodss/yaml" ) diff --git a/manager/manager/typeresolver_test.go b/cmd/manager/manager/typeresolver_test.go similarity index 99% rename from manager/manager/typeresolver_test.go rename to cmd/manager/manager/typeresolver_test.go index 0e175a8f7..1fcd4f499 100644 --- a/manager/manager/typeresolver_test.go +++ b/cmd/manager/manager/typeresolver_test.go @@ -24,8 +24,8 @@ import ( "testing" "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/registry" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/registry" ) type responseAndError struct { diff --git a/manager/repository/persistent/persistent.go b/cmd/manager/repository/persistent/persistent.go similarity index 99% rename from manager/repository/persistent/persistent.go rename to cmd/manager/repository/persistent/persistent.go index fadf1285a..0ab0ec825 100644 --- a/manager/repository/persistent/persistent.go +++ b/cmd/manager/repository/persistent/persistent.go @@ -25,8 +25,8 @@ import ( "os" "time" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/manager/repository" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/cmd/manager/repository" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" diff --git a/manager/repository/persistent/persistent_test.go b/cmd/manager/repository/persistent/persistent_test.go similarity index 97% rename from manager/repository/persistent/persistent_test.go rename to cmd/manager/repository/persistent/persistent_test.go index 47038c76e..00ac70d05 100644 --- a/manager/repository/persistent/persistent_test.go +++ b/cmd/manager/repository/persistent/persistent_test.go @@ -14,7 +14,7 @@ limitations under the License. package persistent import ( - "github.com/kubernetes/deployment-manager/manager/repository" + "github.com/kubernetes/deployment-manager/cmd/manager/repository" "sync" "testing" diff --git a/manager/repository/repository.go b/cmd/manager/repository/repository.go similarity index 97% rename from manager/repository/repository.go rename to cmd/manager/repository/repository.go index d4e70d05b..e9424b1ab 100644 --- a/manager/repository/repository.go +++ b/cmd/manager/repository/repository.go @@ -18,7 +18,7 @@ limitations under the License. package repository import ( - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" ) // Repository manages storage for all Deployment Manager entities, as well as diff --git a/manager/repository/test_common.go b/cmd/manager/repository/test_common.go similarity index 99% rename from manager/repository/test_common.go rename to cmd/manager/repository/test_common.go index 3d5586172..a2b5fb8c2 100644 --- a/manager/repository/test_common.go +++ b/cmd/manager/repository/test_common.go @@ -17,7 +17,7 @@ limitations under the License. package repository import ( - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" "fmt" "testing" diff --git a/manager/repository/transient/transient.go b/cmd/manager/repository/transient/transient.go similarity index 98% rename from manager/repository/transient/transient.go rename to cmd/manager/repository/transient/transient.go index 36b7176f7..0125f762b 100644 --- a/manager/repository/transient/transient.go +++ b/cmd/manager/repository/transient/transient.go @@ -23,8 +23,8 @@ import ( "sync" "time" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/manager/repository" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/cmd/manager/repository" ) // deploymentTypeInstanceMap stores type instances mapped by deployment name. diff --git a/manager/repository/transient/transient_test.go b/cmd/manager/repository/transient/transient_test.go similarity index 96% rename from manager/repository/transient/transient_test.go rename to cmd/manager/repository/transient/transient_test.go index 368898eb2..06ca917f3 100644 --- a/manager/repository/transient/transient_test.go +++ b/cmd/manager/repository/transient/transient_test.go @@ -14,7 +14,7 @@ limitations under the License. package transient import ( - "github.com/kubernetes/deployment-manager/manager/repository" + "github.com/kubernetes/deployment-manager/cmd/manager/repository" "testing" ) diff --git a/resourcifier/Dockerfile b/cmd/resourcifier/Dockerfile similarity index 100% rename from resourcifier/Dockerfile rename to cmd/resourcifier/Dockerfile diff --git a/resourcifier/Makefile b/cmd/resourcifier/Makefile similarity index 100% rename from resourcifier/Makefile rename to cmd/resourcifier/Makefile diff --git a/resourcifier/configurations.go b/cmd/resourcifier/configurations.go similarity index 97% rename from resourcifier/configurations.go rename to cmd/resourcifier/configurations.go index 140f5159f..272008bef 100644 --- a/resourcifier/configurations.go +++ b/cmd/resourcifier/configurations.go @@ -17,9 +17,9 @@ limitations under the License. package main import ( - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/resourcifier/configurator" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/cmd/resourcifier/configurator" + "github.com/kubernetes/deployment-manager/pkg/util" "encoding/json" "errors" diff --git a/resourcifier/configurator/configurator.go b/cmd/resourcifier/configurator/configurator.go similarity index 98% rename from resourcifier/configurator/configurator.go rename to cmd/resourcifier/configurator/configurator.go index 627c42e5f..25499922e 100644 --- a/resourcifier/configurator/configurator.go +++ b/cmd/resourcifier/configurator/configurator.go @@ -23,8 +23,8 @@ import ( "strings" "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" ) // Configurator configures a Kubernetes cluster using kubectl. diff --git a/resourcifier/main.go b/cmd/resourcifier/main.go similarity index 94% rename from resourcifier/main.go rename to cmd/resourcifier/main.go index c43b92b04..62b94d928 100644 --- a/resourcifier/main.go +++ b/cmd/resourcifier/main.go @@ -17,8 +17,8 @@ limitations under the License. package main import ( - "github.com/kubernetes/deployment-manager/util" - "github.com/kubernetes/deployment-manager/version" + "github.com/kubernetes/deployment-manager/pkg/util" + "github.com/kubernetes/deployment-manager/pkg/version" "flag" "fmt" diff --git a/chart/chart.go b/pkg/chart/chart.go similarity index 99% rename from chart/chart.go rename to pkg/chart/chart.go index a7b3b4cee..98ccd2c0a 100644 --- a/chart/chart.go +++ b/pkg/chart/chart.go @@ -28,7 +28,7 @@ import ( "path/filepath" "strings" - "github.com/kubernetes/deployment-manager/log" + "github.com/kubernetes/deployment-manager/pkg/log" ) // ChartfileName is the default Chart file name. diff --git a/chart/chart_test.go b/pkg/chart/chart_test.go similarity index 98% rename from chart/chart_test.go rename to pkg/chart/chart_test.go index 88a1815a5..8ef4bf682 100644 --- a/chart/chart_test.go +++ b/pkg/chart/chart_test.go @@ -21,7 +21,7 @@ import ( "path/filepath" "testing" - "github.com/kubernetes/deployment-manager/log" + "github.com/kubernetes/deployment-manager/pkg/log" ) const ( diff --git a/chart/chartfile.go b/pkg/chart/chartfile.go similarity index 100% rename from chart/chartfile.go rename to pkg/chart/chartfile.go diff --git a/chart/chartfile_test.go b/pkg/chart/chartfile_test.go similarity index 100% rename from chart/chartfile_test.go rename to pkg/chart/chartfile_test.go diff --git a/chart/doc.go b/pkg/chart/doc.go similarity index 100% rename from chart/doc.go rename to pkg/chart/doc.go diff --git a/chart/locator.go b/pkg/chart/locator.go similarity index 100% rename from chart/locator.go rename to pkg/chart/locator.go diff --git a/chart/locator_test.go b/pkg/chart/locator_test.go similarity index 100% rename from chart/locator_test.go rename to pkg/chart/locator_test.go diff --git a/chart/save.go b/pkg/chart/save.go similarity index 98% rename from chart/save.go rename to pkg/chart/save.go index 9d4302e14..8bc815fd6 100644 --- a/chart/save.go +++ b/pkg/chart/save.go @@ -24,7 +24,7 @@ import ( "os" "path/filepath" - "github.com/kubernetes/deployment-manager/log" + "github.com/kubernetes/deployment-manager/pkg/log" ) // Save creates an archived chart to the given directory. diff --git a/chart/save_test.go b/pkg/chart/save_test.go similarity index 100% rename from chart/save_test.go rename to pkg/chart/save_test.go diff --git a/chart/testdata/README.md b/pkg/chart/testdata/README.md similarity index 100% rename from chart/testdata/README.md rename to pkg/chart/testdata/README.md diff --git a/chart/testdata/frobnitz-0.0.1.tgz b/pkg/chart/testdata/frobnitz-0.0.1.tgz similarity index 100% rename from chart/testdata/frobnitz-0.0.1.tgz rename to pkg/chart/testdata/frobnitz-0.0.1.tgz diff --git a/chart/testdata/frobnitz/Chart.yaml b/pkg/chart/testdata/frobnitz/Chart.yaml similarity index 100% rename from chart/testdata/frobnitz/Chart.yaml rename to pkg/chart/testdata/frobnitz/Chart.yaml diff --git a/chart/testdata/frobnitz/LICENSE b/pkg/chart/testdata/frobnitz/LICENSE similarity index 100% rename from chart/testdata/frobnitz/LICENSE rename to pkg/chart/testdata/frobnitz/LICENSE diff --git a/chart/testdata/frobnitz/README.md b/pkg/chart/testdata/frobnitz/README.md similarity index 100% rename from chart/testdata/frobnitz/README.md rename to pkg/chart/testdata/frobnitz/README.md diff --git a/chart/testdata/frobnitz/docs/README.md b/pkg/chart/testdata/frobnitz/docs/README.md similarity index 100% rename from chart/testdata/frobnitz/docs/README.md rename to pkg/chart/testdata/frobnitz/docs/README.md diff --git a/chart/testdata/frobnitz/hooks/pre-install.py b/pkg/chart/testdata/frobnitz/hooks/pre-install.py similarity index 100% rename from chart/testdata/frobnitz/hooks/pre-install.py rename to pkg/chart/testdata/frobnitz/hooks/pre-install.py diff --git a/chart/testdata/frobnitz/icon.svg b/pkg/chart/testdata/frobnitz/icon.svg similarity index 100% rename from chart/testdata/frobnitz/icon.svg rename to pkg/chart/testdata/frobnitz/icon.svg diff --git a/chart/testdata/frobnitz/templates/wordpress-resources.yaml b/pkg/chart/testdata/frobnitz/templates/wordpress-resources.yaml similarity index 100% rename from chart/testdata/frobnitz/templates/wordpress-resources.yaml rename to pkg/chart/testdata/frobnitz/templates/wordpress-resources.yaml diff --git a/chart/testdata/frobnitz/templates/wordpress.jinja b/pkg/chart/testdata/frobnitz/templates/wordpress.jinja similarity index 100% rename from chart/testdata/frobnitz/templates/wordpress.jinja rename to pkg/chart/testdata/frobnitz/templates/wordpress.jinja diff --git a/chart/testdata/frobnitz/templates/wordpress.jinja.schema b/pkg/chart/testdata/frobnitz/templates/wordpress.jinja.schema similarity index 100% rename from chart/testdata/frobnitz/templates/wordpress.jinja.schema rename to pkg/chart/testdata/frobnitz/templates/wordpress.jinja.schema diff --git a/chart/testdata/frobnitz/templates/wordpress.yaml b/pkg/chart/testdata/frobnitz/templates/wordpress.yaml similarity index 100% rename from chart/testdata/frobnitz/templates/wordpress.yaml rename to pkg/chart/testdata/frobnitz/templates/wordpress.yaml diff --git a/chart/testdata/ill-1.2.3.tgz b/pkg/chart/testdata/ill-1.2.3.tgz similarity index 100% rename from chart/testdata/ill-1.2.3.tgz rename to pkg/chart/testdata/ill-1.2.3.tgz diff --git a/chart/testdata/ill/Chart.yaml b/pkg/chart/testdata/ill/Chart.yaml similarity index 100% rename from chart/testdata/ill/Chart.yaml rename to pkg/chart/testdata/ill/Chart.yaml diff --git a/chart/testdata/ill/LICENSE b/pkg/chart/testdata/ill/LICENSE similarity index 100% rename from chart/testdata/ill/LICENSE rename to pkg/chart/testdata/ill/LICENSE diff --git a/chart/testdata/ill/README.md b/pkg/chart/testdata/ill/README.md similarity index 100% rename from chart/testdata/ill/README.md rename to pkg/chart/testdata/ill/README.md diff --git a/chart/testdata/ill/docs/README.md b/pkg/chart/testdata/ill/docs/README.md similarity index 100% rename from chart/testdata/ill/docs/README.md rename to pkg/chart/testdata/ill/docs/README.md diff --git a/chart/testdata/ill/hooks/pre-install.py b/pkg/chart/testdata/ill/hooks/pre-install.py similarity index 100% rename from chart/testdata/ill/hooks/pre-install.py rename to pkg/chart/testdata/ill/hooks/pre-install.py diff --git a/chart/testdata/ill/templates/wordpress-resources.yaml b/pkg/chart/testdata/ill/templates/wordpress-resources.yaml similarity index 100% rename from chart/testdata/ill/templates/wordpress-resources.yaml rename to pkg/chart/testdata/ill/templates/wordpress-resources.yaml diff --git a/chart/testdata/ill/templates/wordpress.jinja b/pkg/chart/testdata/ill/templates/wordpress.jinja similarity index 100% rename from chart/testdata/ill/templates/wordpress.jinja rename to pkg/chart/testdata/ill/templates/wordpress.jinja diff --git a/chart/testdata/ill/templates/wordpress.jinja.schema b/pkg/chart/testdata/ill/templates/wordpress.jinja.schema similarity index 100% rename from chart/testdata/ill/templates/wordpress.jinja.schema rename to pkg/chart/testdata/ill/templates/wordpress.jinja.schema diff --git a/chart/testdata/ill/templates/wordpress.yaml b/pkg/chart/testdata/ill/templates/wordpress.yaml similarity index 100% rename from chart/testdata/ill/templates/wordpress.yaml rename to pkg/chart/testdata/ill/templates/wordpress.yaml diff --git a/chart/testdata/nochart.tgz b/pkg/chart/testdata/nochart.tgz similarity index 100% rename from chart/testdata/nochart.tgz rename to pkg/chart/testdata/nochart.tgz diff --git a/chart/testdata/sprocket/Chart.yaml b/pkg/chart/testdata/sprocket/Chart.yaml similarity index 100% rename from chart/testdata/sprocket/Chart.yaml rename to pkg/chart/testdata/sprocket/Chart.yaml diff --git a/chart/testdata/sprocket/LICENSE b/pkg/chart/testdata/sprocket/LICENSE similarity index 100% rename from chart/testdata/sprocket/LICENSE rename to pkg/chart/testdata/sprocket/LICENSE diff --git a/chart/testdata/sprocket/README.md b/pkg/chart/testdata/sprocket/README.md similarity index 100% rename from chart/testdata/sprocket/README.md rename to pkg/chart/testdata/sprocket/README.md diff --git a/chart/testdata/sprocket/docs/README.md b/pkg/chart/testdata/sprocket/docs/README.md similarity index 100% rename from chart/testdata/sprocket/docs/README.md rename to pkg/chart/testdata/sprocket/docs/README.md diff --git a/chart/testdata/sprocket/hooks/pre-install.py b/pkg/chart/testdata/sprocket/hooks/pre-install.py similarity index 100% rename from chart/testdata/sprocket/hooks/pre-install.py rename to pkg/chart/testdata/sprocket/hooks/pre-install.py diff --git a/chart/testdata/sprocket/icon.svg b/pkg/chart/testdata/sprocket/icon.svg similarity index 100% rename from chart/testdata/sprocket/icon.svg rename to pkg/chart/testdata/sprocket/icon.svg diff --git a/chart/testdata/sprocket/templates/placeholder.txt b/pkg/chart/testdata/sprocket/templates/placeholder.txt similarity index 100% rename from chart/testdata/sprocket/templates/placeholder.txt rename to pkg/chart/testdata/sprocket/templates/placeholder.txt diff --git a/common/types.go b/pkg/common/types.go similarity index 100% rename from common/types.go rename to pkg/common/types.go diff --git a/log/log.go b/pkg/log/log.go similarity index 100% rename from log/log.go rename to pkg/log/log.go diff --git a/log/log_test.go b/pkg/log/log_test.go similarity index 100% rename from log/log_test.go rename to pkg/log/log_test.go diff --git a/registry/filebased_credential_provider.go b/pkg/registry/filebased_credential_provider.go similarity index 97% rename from registry/filebased_credential_provider.go rename to pkg/registry/filebased_credential_provider.go index f508717f0..62e436594 100644 --- a/registry/filebased_credential_provider.go +++ b/pkg/registry/filebased_credential_provider.go @@ -22,7 +22,7 @@ import ( "log" "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" ) // FilebasedCredentialProvider provides credentials for registries. diff --git a/registry/filebased_credential_provider_test.go b/pkg/registry/filebased_credential_provider_test.go similarity index 97% rename from registry/filebased_credential_provider_test.go rename to pkg/registry/filebased_credential_provider_test.go index bec6ea542..595463e58 100644 --- a/registry/filebased_credential_provider_test.go +++ b/pkg/registry/filebased_credential_provider_test.go @@ -19,7 +19,7 @@ package registry import ( "testing" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" ) var filename = "./test/test_credentials_file.yaml" diff --git a/registry/gcs_registry.go b/pkg/registry/gcs_registry.go similarity index 97% rename from registry/gcs_registry.go rename to pkg/registry/gcs_registry.go index de2ac9d13..471e016ed 100644 --- a/registry/gcs_registry.go +++ b/pkg/registry/gcs_registry.go @@ -17,8 +17,8 @@ limitations under the License. package registry import ( - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" // "golang.org/x/net/context" // "golang.org/x/oauth2/google" diff --git a/registry/github_package_registry.go b/pkg/registry/github_package_registry.go similarity index 98% rename from registry/github_package_registry.go rename to pkg/registry/github_package_registry.go index 08eae1d91..f79e489c6 100644 --- a/registry/github_package_registry.go +++ b/pkg/registry/github_package_registry.go @@ -18,7 +18,7 @@ package registry import ( "github.com/google/go-github/github" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" "fmt" "log" diff --git a/registry/github_registry.go b/pkg/registry/github_registry.go similarity index 97% rename from registry/github_registry.go rename to pkg/registry/github_registry.go index bb40df620..2e56cd87a 100644 --- a/registry/github_registry.go +++ b/pkg/registry/github_registry.go @@ -18,8 +18,8 @@ package registry import ( "github.com/google/go-github/github" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" "fmt" "net/http" diff --git a/registry/github_template_registry.go b/pkg/registry/github_template_registry.go similarity index 99% rename from registry/github_template_registry.go rename to pkg/registry/github_template_registry.go index dfb20bb9f..1e89efced 100644 --- a/registry/github_template_registry.go +++ b/pkg/registry/github_template_registry.go @@ -18,7 +18,7 @@ package registry import ( "github.com/google/go-github/github" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" "fmt" "log" diff --git a/registry/inmem_credential_provider.go b/pkg/registry/inmem_credential_provider.go similarity index 96% rename from registry/inmem_credential_provider.go rename to pkg/registry/inmem_credential_provider.go index d09d5c7fc..843d31231 100644 --- a/registry/inmem_credential_provider.go +++ b/pkg/registry/inmem_credential_provider.go @@ -17,7 +17,7 @@ limitations under the License. package registry import ( - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" "fmt" ) diff --git a/registry/inmem_credential_provider_test.go b/pkg/registry/inmem_credential_provider_test.go similarity index 97% rename from registry/inmem_credential_provider_test.go rename to pkg/registry/inmem_credential_provider_test.go index 6b650eb05..422021128 100644 --- a/registry/inmem_credential_provider_test.go +++ b/pkg/registry/inmem_credential_provider_test.go @@ -21,7 +21,7 @@ import ( "reflect" "testing" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" ) type testCase struct { diff --git a/registry/inmem_registry_service.go b/pkg/registry/inmem_registry_service.go similarity index 97% rename from registry/inmem_registry_service.go rename to pkg/registry/inmem_registry_service.go index c22b802e7..6b9a37ff1 100644 --- a/registry/inmem_registry_service.go +++ b/pkg/registry/inmem_registry_service.go @@ -17,8 +17,8 @@ limitations under the License. package registry import ( - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" "fmt" "strings" diff --git a/registry/registry.go b/pkg/registry/registry.go similarity index 97% rename from registry/registry.go rename to pkg/registry/registry.go index f1946269f..2c7358abb 100644 --- a/registry/registry.go +++ b/pkg/registry/registry.go @@ -17,8 +17,8 @@ limitations under the License. package registry import ( - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" "fmt" "net/url" diff --git a/registry/registry_test.go b/pkg/registry/registry_test.go similarity index 100% rename from registry/registry_test.go rename to pkg/registry/registry_test.go diff --git a/registry/registryprovider.go b/pkg/registry/registryprovider.go similarity index 99% rename from registry/registryprovider.go rename to pkg/registry/registryprovider.go index d722f4b4c..87e9d7261 100644 --- a/registry/registryprovider.go +++ b/pkg/registry/registryprovider.go @@ -18,8 +18,8 @@ package registry import ( "github.com/google/go-github/github" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" "golang.org/x/oauth2" "golang.org/x/oauth2/google" storage "google.golang.org/api/storage/v1" diff --git a/registry/registryprovider_test.go b/pkg/registry/registryprovider_test.go similarity index 100% rename from registry/registryprovider_test.go rename to pkg/registry/registryprovider_test.go diff --git a/registry/secrets_credential_provider.go b/pkg/registry/secrets_credential_provider.go similarity index 97% rename from registry/secrets_credential_provider.go rename to pkg/registry/secrets_credential_provider.go index 5ee2f4fd9..54668c529 100644 --- a/registry/secrets_credential_provider.go +++ b/pkg/registry/secrets_credential_provider.go @@ -24,8 +24,8 @@ import ( "log" "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" ) var ( diff --git a/registry/semver.go b/pkg/registry/semver.go similarity index 100% rename from registry/semver.go rename to pkg/registry/semver.go diff --git a/registry/semver_test.go b/pkg/registry/semver_test.go similarity index 100% rename from registry/semver_test.go rename to pkg/registry/semver_test.go diff --git a/registry/test/test_credentials_file.yaml b/pkg/registry/test/test_credentials_file.yaml similarity index 100% rename from registry/test/test_credentials_file.yaml rename to pkg/registry/test/test_credentials_file.yaml diff --git a/registry/testhelper.go b/pkg/registry/testhelper.go similarity index 97% rename from registry/testhelper.go rename to pkg/registry/testhelper.go index 1df44ce06..76a6e6393 100644 --- a/registry/testhelper.go +++ b/pkg/registry/testhelper.go @@ -22,8 +22,8 @@ import ( "bytes" "io/ioutil" - "github.com/kubernetes/deployment-manager/common" - "github.com/kubernetes/deployment-manager/util" + "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" "fmt" "net/http" diff --git a/util/httpclient.go b/pkg/util/httpclient.go similarity index 100% rename from util/httpclient.go rename to pkg/util/httpclient.go diff --git a/util/httpclient_test.go b/pkg/util/httpclient_test.go similarity index 100% rename from util/httpclient_test.go rename to pkg/util/httpclient_test.go diff --git a/util/httputil.go b/pkg/util/httputil.go similarity index 100% rename from util/httputil.go rename to pkg/util/httputil.go diff --git a/util/kubernetes.go b/pkg/util/kubernetes.go similarity index 100% rename from util/kubernetes.go rename to pkg/util/kubernetes.go diff --git a/util/kubernetes_kubectl.go b/pkg/util/kubernetes_kubectl.go similarity index 100% rename from util/kubernetes_kubectl.go rename to pkg/util/kubernetes_kubectl.go diff --git a/util/kubernetesutil.go b/pkg/util/kubernetesutil.go similarity index 96% rename from util/kubernetesutil.go rename to pkg/util/kubernetesutil.go index 959c6ecae..cbf653217 100644 --- a/util/kubernetesutil.go +++ b/pkg/util/kubernetesutil.go @@ -21,7 +21,7 @@ import ( "time" "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" ) // ParseKubernetesObject parses a Kubernetes API object in YAML format. diff --git a/util/kubernetesutil_test.go b/pkg/util/kubernetesutil_test.go similarity index 98% rename from util/kubernetesutil_test.go rename to pkg/util/kubernetesutil_test.go index d34991a1f..04304a43d 100644 --- a/util/kubernetesutil_test.go +++ b/pkg/util/kubernetesutil_test.go @@ -23,7 +23,7 @@ import ( "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" ) var serviceInput = ` diff --git a/util/templateutil.go b/pkg/util/templateutil.go similarity index 98% rename from util/templateutil.go rename to pkg/util/templateutil.go index 35f507afd..69d4f04d3 100644 --- a/util/templateutil.go +++ b/pkg/util/templateutil.go @@ -26,7 +26,7 @@ import ( "path/filepath" "github.com/ghodss/yaml" - "github.com/kubernetes/deployment-manager/common" + "github.com/kubernetes/deployment-manager/pkg/common" ) // NewTemplateFromType creates and returns a new template whose content diff --git a/util/templateutil_test.go b/pkg/util/templateutil_test.go similarity index 100% rename from util/templateutil_test.go rename to pkg/util/templateutil_test.go diff --git a/version/version.go b/pkg/version/version.go similarity index 100% rename from version/version.go rename to pkg/version/version.go From 25f339731a00724fb138779d7deb06bc9e9469eb Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Sun, 28 Feb 2016 23:56:56 -0800 Subject: [PATCH 55/73] doc(cmd/pkg): add package godocs --- cmd/doc.go | 2 ++ pkg/doc.go | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 cmd/doc.go create mode 100644 pkg/doc.go diff --git a/cmd/doc.go b/cmd/doc.go new file mode 100644 index 000000000..91b7ead51 --- /dev/null +++ b/cmd/doc.go @@ -0,0 +1,2 @@ +// Package cmd contains the executables for Deployment Manager. +package cmd diff --git a/pkg/doc.go b/pkg/doc.go new file mode 100644 index 000000000..9d78a47aa --- /dev/null +++ b/pkg/doc.go @@ -0,0 +1,2 @@ +// Package pkg contains all libraries for Deployment Manager +package pkg From 21985dafa79bcc630ef509d4288f90fd6023f673 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Sun, 28 Feb 2016 23:59:02 -0800 Subject: [PATCH 56/73] fix(gitignore): ignore bin directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1a3ab219d..33a165d14 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ resourcifier/bin/* manager/pkg/* .project vendor/* +/bin From 01ad0ffa00023f9b28563c21e37cf2112cfcf713 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 09:55:51 -0800 Subject: [PATCH 57/73] doc(rootfs): add rootfs README --- rootfs/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 rootfs/README.md diff --git a/rootfs/README.md b/rootfs/README.md new file mode 100644 index 000000000..161bc9e9f --- /dev/null +++ b/rootfs/README.md @@ -0,0 +1,26 @@ +# RootFS + +This directory stores all files that should be copied to the rootfs of a +Docker container. The files should be stored according to the correct +directory structure of the destination container. For example: + +``` +rootfs/bin -> /bin +rootfs/usr/local/share -> /usr/local/share +``` + +## Dockerfile + +A Dockerfile in the rootfs is used to build the image. Where possible, +compilation should not be done in this Dockerfile, since we are +interested in deploying the smallest possible images. + +Example: + +```Dockerfile +FROM alpine:3.2 + +COPY . / + +ENTRYPOINT ["/usr/local/bin/boot"] +``` From 09796298eac2e31b9b2648243f62f218887804f6 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 10:01:55 -0800 Subject: [PATCH 58/73] ref(expansion): move python code out of cmd --- cmd/expandybird/expander/expander_test.go | 2 +- cmd/expandybird/main.go | 2 +- cmd/expandybird/service/service_test.go | 4 ++-- {cmd/expandybird/expansion => expansion}/expansion.py | 0 {cmd/expandybird/expansion => expansion}/expansion_test.py | 0 {cmd/expandybird/expansion => expansion}/file_expander.py | 0 {cmd/expandybird/expansion => expansion}/sandbox_loader.py | 0 {cmd/expandybird/expansion => expansion}/schema_validation.py | 0 .../expansion => expansion}/schema_validation_test.py | 0 .../expansion => expansion}/schema_validation_utils.py | 0 10 files changed, 4 insertions(+), 4 deletions(-) rename {cmd/expandybird/expansion => expansion}/expansion.py (100%) rename {cmd/expandybird/expansion => expansion}/expansion_test.py (100%) rename {cmd/expandybird/expansion => expansion}/file_expander.py (100%) rename {cmd/expandybird/expansion => expansion}/sandbox_loader.py (100%) rename {cmd/expandybird/expansion => expansion}/schema_validation.py (100%) rename {cmd/expandybird/expansion => expansion}/schema_validation_test.py (100%) rename {cmd/expandybird/expansion => expansion}/schema_validation_utils.py (100%) diff --git a/cmd/expandybird/expander/expander_test.go b/cmd/expandybird/expander/expander_test.go index dcd27f557..efde69559 100644 --- a/cmd/expandybird/expander/expander_test.go +++ b/cmd/expandybird/expander/expander_test.go @@ -37,7 +37,7 @@ var importFileNames = []string{ var validFileName = "../test/ValidContent.yaml" var outputFileName = "../test/ExpectedOutput.yaml" var archiveFileName = "../test/TestArchive.tar" -var expanderName = "../expansion/expansion.py" +var expanderName = "../../../expansion/expansion.py" type ExpanderTestCase struct { Description string diff --git a/cmd/expandybird/main.go b/cmd/expandybird/main.go index ecbdaf0c7..d067bbe5b 100644 --- a/cmd/expandybird/main.go +++ b/cmd/expandybird/main.go @@ -33,7 +33,7 @@ import ( var port = flag.Int("port", 8080, "Port to listen on") // path to expansion binary -var expansionBinary = flag.String("expansion_binary", "../expansion/expansion.py", +var expansionBinary = flag.String("expansion_binary", "../../../expansion/expansion.py", "The path to the expansion binary that will be used to expand the template.") func main() { diff --git a/cmd/expandybird/service/service_test.go b/cmd/expandybird/service/service_test.go index 9acdf1d74..1af7a4d35 100644 --- a/cmd/expandybird/service/service_test.go +++ b/cmd/expandybird/service/service_test.go @@ -26,8 +26,8 @@ import ( "reflect" "testing" - "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/cmd/expandybird/expander" + "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/pkg/util" restful "github.com/emicklei/go-restful" @@ -112,7 +112,7 @@ var ServiceWrapperTestCases = []ServiceWrapperTestCase{ } func TestServiceWrapper(t *testing.T) { - backend := expander.NewExpander("../expansion/expansion.py") + backend := expander.NewExpander("../../../expansion/expansion.py") wrapper := NewService(NewExpansionHandler(backend)) container := restful.NewContainer() container.ServeMux = http.NewServeMux() diff --git a/cmd/expandybird/expansion/expansion.py b/expansion/expansion.py similarity index 100% rename from cmd/expandybird/expansion/expansion.py rename to expansion/expansion.py diff --git a/cmd/expandybird/expansion/expansion_test.py b/expansion/expansion_test.py similarity index 100% rename from cmd/expandybird/expansion/expansion_test.py rename to expansion/expansion_test.py diff --git a/cmd/expandybird/expansion/file_expander.py b/expansion/file_expander.py similarity index 100% rename from cmd/expandybird/expansion/file_expander.py rename to expansion/file_expander.py diff --git a/cmd/expandybird/expansion/sandbox_loader.py b/expansion/sandbox_loader.py similarity index 100% rename from cmd/expandybird/expansion/sandbox_loader.py rename to expansion/sandbox_loader.py diff --git a/cmd/expandybird/expansion/schema_validation.py b/expansion/schema_validation.py similarity index 100% rename from cmd/expandybird/expansion/schema_validation.py rename to expansion/schema_validation.py diff --git a/cmd/expandybird/expansion/schema_validation_test.py b/expansion/schema_validation_test.py similarity index 100% rename from cmd/expandybird/expansion/schema_validation_test.py rename to expansion/schema_validation_test.py diff --git a/cmd/expandybird/expansion/schema_validation_utils.py b/expansion/schema_validation_utils.py similarity index 100% rename from cmd/expandybird/expansion/schema_validation_utils.py rename to expansion/schema_validation_utils.py From daf446fce222aa437b9e3885dfd8cc91130931c8 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 10:06:37 -0800 Subject: [PATCH 59/73] fix(gitignore): ignore pyc files --- .gitignore | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 33a165d14..e6e102372 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,4 @@ -expandybird/pkg/* -expandybird/expansion/*.pyc -resourcifier/pkg/* -resourcifier/bin/* -manager/pkg/* +*.pyc .project vendor/* /bin From b916b2b102f981e46cf2dc78750ad17ba8577f4e Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 10:24:15 -0800 Subject: [PATCH 60/73] fix(version.go): make version updatable by build scripts --- pkg/version/version.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/version/version.go b/pkg/version/version.go index 35b47d089..fa1332c96 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,4 +22,4 @@ package version // Increment major number for new feature additions and behavioral changes. // Increment minor number for bug fixes and performance enhancements. // Increment patch number for critical fixes to existing releases. -const DeploymentManagerVersion = "0.0.1" +var DeploymentManagerVersion = "0.0.1" From de5f77d8e51c7ef5115657d1fbf872b06d19bb23 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 10:25:49 -0800 Subject: [PATCH 61/73] fix(build): add build script --- scripts/build-go.sh | 22 ++++++++++++++++++++ scripts/common.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100755 scripts/build-go.sh create mode 100644 scripts/common.sh diff --git a/scripts/build-go.sh b/scripts/build-go.sh new file mode 100755 index 000000000..a824cdcbd --- /dev/null +++ b/scripts/build-go.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -o errexit +set -o pipefail + +[[ "$TRACE" ]] && set -x + +readonly REPO=github.com/kubernetes/deployment-manager +readonly DIR="${GOPATH}/src/${REPO}" + +source "${DIR}/scripts/common.sh" + +if [[ -z "${VERSION:-}" ]]; then + VERSION=$(version_from_git) +fi + +LDFLAGS="-s -X ${REPO}/pkg/version.DeploymentManagerVersion=${VERSION}" + +echo "Build version: ${VERSION}" + +build_binaries "$@" + +exit 0 diff --git a/scripts/common.sh b/scripts/common.sh new file mode 100644 index 000000000..b55741392 --- /dev/null +++ b/scripts/common.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +set -o errexit +set -o pipefail + +readonly ALL_TARGETS=(cmd/dm cmd/expandybird cmd/manager cmd/resourcifier) + +error_exit() { + # Display error message and exit + echo "error: ${1:-"unknown error"}" 1>&2 + exit 1 +} + +version_from_git() { + local git_tag=$(git describe --tags --abbrev=0 2>/dev/null) + local git_commit=$(git rev-parse --short HEAD) + echo "${git_tag}+${git_commit}" +} + +build_binary_cross() { + local target="$1" + + echo "Building ${target}" + gox -verbose \ + -ldflags="${LDFLAGS}" \ + -os="linux darwin" \ + -arch="amd64 386" \ + -output="bin/{{.OS}}-{{.Arch}}/{{.Dir}}" "${REPO}/${target}" +} + +build_binaries() { + local -a targets=($@) + + if [[ ${#targets[@]} -eq 0 ]]; then + targets=("${ALL_TARGETS[@]}") + fi + + for t in "${targets[@]}"; do + build_binary "$t" + done +} + +build_binary() { + local target="$1" + local binary="${target##*/}" + local outfile="bin/${binary}" + + echo "Building ${target}" + go build -o "$outfile" -ldflags "$LDFLAGS" "${REPO}/${target}" +} From 4017128389913c9a64d3d0bc3e02d29adbf1b63b Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 10:27:08 -0800 Subject: [PATCH 62/73] fix(Makefile): update targets in Makefile --- Makefile | 59 ++++++++++++++++++++++++++++++++++++------------------ include.mk | 24 ---------------------- 2 files changed, 40 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 507ad93a2..2e9a040b2 100644 --- a/Makefile +++ b/Makefile @@ -14,39 +14,60 @@ include include.mk -SUBDIRS := expandybird/. resourcifier/. manager/. -TARGETS := all build test push container clean - -SUBDIRS_TARGETS := \ - $(foreach t,$(TARGETS),$(addsuffix $t,$(SUBDIRS))) - -GO_DEPS := github.com/kubernetes/deployment-manager/util/... github.com/kubernetes/deployment-manager/version/... github.com/kubernetes/deployment-manager/expandybird/... github.com/kubernetes/deployment-manager/resourcifier/... github.com/kubernetes/deployment-manager/manager/... github.com/kubernetes/deployment-manager/dm/... - -.PHONY : all build test clean $(TARGETS) $(SUBDIRS_TARGETS) .project .docker +GO_PKGS := $(shell glide nv) +.PHONY: build build: - go get -v $(GO_DEPS) - go install -v $(GO_DEPS) + @scripts/build-go.sh +.PHONY: all all: build +.PHONY: clean clean: - go clean -v $(GO_DEPS) + go clean -v $(GO_PKGS) -test: build - go test -v $(GO_DEPS) +.PHONY: clean +test: build lint vet test-unit +.PHONY: push push: container +.PHONY: container container: .project .docker +.PHONY: test-unit +test-unit: + @echo Running tests... + go test -v $(shell glide nv) + +.PHONY: lint +lint: + @echo Running golint... + @for i in $(shell glide nv); do \ + golint $$i; \ + done + @echo ----------------- + +.PHONY: vet +vet: + @echo Running go vet... + @for i in $(shell glide nv -x); do \ + go tool vet $$i; \ + done + @echo ----------------- + +.PHONY: setup-gotools +setup-gotools: + @echo Installing golint + go get -u github.com/golang/lint/golint + @echo Installing vet + go get -u -v golang.org/x/tools/cmd/vet + +.PHONY: .project .project: @if [[ -z "${PROJECT}" ]]; then echo "PROJECT variable must be set"; exit 1; fi +.PHONY: .docker .docker: @if [[ -z `which docker` ]] || ! docker version &> /dev/null; then echo "docker is not installed correctly"; exit 1; fi - -$(TARGETS) : % : $(addsuffix %,$(SUBDIRS)) - -$(SUBDIRS_TARGETS) : - $(MAKE) -C $(@D) $(@F:.%=%) diff --git a/include.mk b/include.mk index fba7d5f4e..4ae3c4c89 100644 --- a/include.mk +++ b/include.mk @@ -4,27 +4,3 @@ info: @echo "Registry: ${DOCKER_REGISTRY}" @echo "Project: ${PROJECT}" @echo "Image: ${IMAGE}" - -.PHONY: test-unit -test-unit: - @echo Running tests... - go test -v ./... - -.PHONY: lint -lint: - @echo Running golint... - golint ./... - @echo ----------------- - -.PHONY: vet -vet: - @echo Running go vet... - go vet ./... - @echo ----------------- - -.PHONY: setup-gotools -setup-gotools: - @echo Installing golint - go get -u github.com/golang/lint/golint - @echo Installing vet - go get -u -v golang.org/x/tools/cmd/vet From 4134afee10f5a6db579b97f720e8d0218c0a1d8b Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 12:07:54 -0800 Subject: [PATCH 63/73] style(*): gofmt --- cmd/dm/dm.go | 2 +- cmd/expandybird/main.go | 2 +- cmd/expandybird/service/service.go | 4 +- cmd/manager/deployments.go | 2 +- cmd/manager/manager/deployer.go | 2 +- cmd/manager/manager/deployer_test.go | 4 +- cmd/manager/manager/expander_test.go | 10 +- cmd/manager/manager/manager.go | 2 +- cmd/manager/manager/manager_test.go | 10 +- cmd/manager/manager/typeresolver.go | 2 +- cmd/manager/manager/typeresolver_test.go | 92 +++++++++---------- .../repository/persistent/persistent.go | 2 +- cmd/manager/repository/test_common.go | 12 +-- cmd/manager/repository/transient/transient.go | 2 +- cmd/resourcifier/configurations.go | 2 +- cmd/resourcifier/main.go | 2 +- pkg/chart/locator_test.go | 6 +- pkg/registry/registryprovider.go | 4 +- pkg/registry/registryprovider_test.go | 16 ++-- pkg/util/httpclient_test.go | 2 +- pkg/util/kubernetesutil_test.go | 2 +- 21 files changed, 91 insertions(+), 91 deletions(-) diff --git a/cmd/dm/dm.go b/cmd/dm/dm.go index 93c91e707..9e33bf5a9 100644 --- a/cmd/dm/dm.go +++ b/cmd/dm/dm.go @@ -275,7 +275,7 @@ func callService(path, method, action string, reader io.ReadCloser) { panic(fmt.Errorf("cannot parse url (%s): %s\n", path, err)) } - URL.Path = strings.TrimRight(URL.Path, "/") + "/" + strings.TrimLeft(path, "/") + URL.Path = strings.TrimRight(URL.Path, "/") + "/" + strings.TrimLeft(path, "/") resp := callHTTP(URL.String(), method, action, reader) var j interface{} if err := json.Unmarshal([]byte(resp), &j); err != nil { diff --git a/cmd/expandybird/main.go b/cmd/expandybird/main.go index d067bbe5b..332ffa33d 100644 --- a/cmd/expandybird/main.go +++ b/cmd/expandybird/main.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cmd/expandybird/service/service.go b/cmd/expandybird/service/service.go index 384083ecb..e12fdda8a 100644 --- a/cmd/expandybird/service/service.go +++ b/cmd/expandybird/service/service.go @@ -17,8 +17,8 @@ limitations under the License. package service import ( - "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/cmd/expandybird/expander" + "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/pkg/util" "errors" @@ -86,7 +86,7 @@ func NewExpansionHandler(backend expander.Expander) restful.RouteFunction { } util.LogHandlerExit("expandybird", http.StatusOK, "OK", resp.ResponseWriter) - message := fmt.Sprintf("\nConfig:\n%s\nLayout:\n%s\n", response.Config, response.Layout) + message := fmt.Sprintf("\nConfig:\n%s\nLayout:\n%s\n", response.Config, response.Layout) util.LogHandlerText("expandybird", message) resp.WriteEntity(response) } diff --git a/cmd/manager/deployments.go b/cmd/manager/deployments.go index ae174763b..993dc1678 100644 --- a/cmd/manager/deployments.go +++ b/cmd/manager/deployments.go @@ -33,11 +33,11 @@ import ( "github.com/ghodss/yaml" "github.com/gorilla/mux" - "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/cmd/manager/manager" "github.com/kubernetes/deployment-manager/cmd/manager/repository" "github.com/kubernetes/deployment-manager/cmd/manager/repository/persistent" "github.com/kubernetes/deployment-manager/cmd/manager/repository/transient" + "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/pkg/registry" "github.com/kubernetes/deployment-manager/pkg/util" ) diff --git a/cmd/manager/manager/deployer.go b/cmd/manager/manager/deployer.go index e47b2c5f5..9c9c70190 100644 --- a/cmd/manager/manager/deployer.go +++ b/cmd/manager/manager/deployer.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cmd/manager/manager/deployer_test.go b/cmd/manager/manager/deployer_test.go index e1ee1b340..6947119ae 100644 --- a/cmd/manager/manager/deployer_test.go +++ b/cmd/manager/manager/deployer_test.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,8 +26,8 @@ import ( "strings" "testing" - "github.com/kubernetes/deployment-manager/pkg/util" "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" "github.com/ghodss/yaml" ) diff --git a/cmd/manager/manager/expander_test.go b/cmd/manager/manager/expander_test.go index 423686698..6e803e6ea 100644 --- a/cmd/manager/manager/expander_test.go +++ b/cmd/manager/manager/expander_test.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,8 +26,8 @@ import ( "strings" "testing" - "github.com/kubernetes/deployment-manager/pkg/util" "github.com/kubernetes/deployment-manager/pkg/common" + "github.com/kubernetes/deployment-manager/pkg/util" "github.com/ghodss/yaml" ) @@ -64,15 +64,15 @@ resources: `) var validImportFilesTestCaseData = []*common.ImportFile{ - &common.ImportFile{ + { Name: "test-type.py", Content: "test-type.py validTemplateTestCaseData content", }, - &common.ImportFile{ + { Name: "test.py", Content: "test.py validTemplateTestCaseData content", }, - &common.ImportFile{ + { Name: "test2.py", Content: "test2.py validTemplateTestCaseData content", }, diff --git a/cmd/manager/manager/manager.go b/cmd/manager/manager/manager.go index 827142e5b..e62488256 100644 --- a/cmd/manager/manager/manager.go +++ b/cmd/manager/manager/manager.go @@ -24,8 +24,8 @@ import ( "strings" "time" - "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/cmd/manager/repository" + "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/pkg/registry" "github.com/kubernetes/deployment-manager/pkg/util" ) diff --git a/cmd/manager/manager/manager_test.go b/cmd/manager/manager/manager_test.go index 0a04d167b..3065f281a 100644 --- a/cmd/manager/manager/manager_test.go +++ b/cmd/manager/manager/manager_test.go @@ -29,16 +29,16 @@ import ( var template = common.Template{Name: "test", Content: "test"} var layout = common.Layout{ - Resources: []*common.LayoutResource{&common.LayoutResource{Resource: common.Resource{Name: "test", Type: "test"}}}, + Resources: []*common.LayoutResource{{Resource: common.Resource{Name: "test", Type: "test"}}}, } var configuration = common.Configuration{ - Resources: []*common.Resource{&common.Resource{Name: "test", Type: "test"}}, + Resources: []*common.Resource{{Name: "test", Type: "test"}}, } var resourcesWithSuccessState = common.Configuration{ - Resources: []*common.Resource{&common.Resource{Name: "test", Type: "test", State: &common.ResourceState{Status: common.Created}}}, + Resources: []*common.Resource{{Name: "test", Type: "test", State: &common.ResourceState{Status: common.Created}}}, } var resourcesWithFailureState = common.Configuration{ - Resources: []*common.Resource{&common.Resource{ + Resources: []*common.Resource{{ Name: "test", Type: "test", State: &common.ResourceState{ @@ -64,7 +64,7 @@ var deployment = common.Deployment{ var deploymentList = []common.Deployment{deployment, {Name: "test2"}} -var typeInstMap = map[string][]string{"test": []string{"test"}} +var typeInstMap = map[string][]string{"test": {"test"}} var errTest = errors.New("test error") diff --git a/cmd/manager/manager/typeresolver.go b/cmd/manager/manager/typeresolver.go index 67a9f63f4..449003fee 100644 --- a/cmd/manager/manager/typeresolver.go +++ b/cmd/manager/manager/typeresolver.go @@ -180,7 +180,7 @@ func (tr *typeResolver) ResolveTypes(config *common.Configuration, imports []*co for _, u := range urls { if len(fetched[u]) == 0 { // If this import URL is new to us, add it to the URLs to fetch. - toFetch = append(toFetch, &fetchUnit{[]fetchableURL{fetchableURL{urlRegistry, u}}}) + toFetch = append(toFetch, &fetchUnit{[]fetchableURL{{urlRegistry, u}}}) } else { // If this is not a new import URL and we've already fetched its contents, // reuse them. Also, check if we also found a schema for that import URL and diff --git a/cmd/manager/manager/typeresolver_test.go b/cmd/manager/manager/typeresolver_test.go index 1fcd4f499..0c1b1719c 100644 --- a/cmd/manager/manager/typeresolver_test.go +++ b/cmd/manager/manager/typeresolver_test.go @@ -118,7 +118,7 @@ resources: ` func TestIncludedImport(t *testing.T) { - imports := []*common.ImportFile{&common.ImportFile{Name: "foo.py"}} + imports := []*common.ImportFile{{Name: "foo.py"}} test := resolverTestCase{ config: includeImport, imports: imports, @@ -133,11 +133,11 @@ resources: ` func TestSingleUrl(t *testing.T) { - finalImports := []*common.ImportFile{&common.ImportFile{Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"}} + finalImports := []*common.ImportFile{{Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"}} responses := map[string]responseAndError{ - "http://my-fake-url": responseAndError{nil, http.StatusOK, "my-content"}, - "http://my-fake-url.schema": responseAndError{nil, http.StatusNotFound, ""}, + "http://my-fake-url": {nil, http.StatusOK, "my-content"}, + "http://my-fake-url.schema": {nil, http.StatusNotFound, ""}, } test := resolverTestCase{ @@ -151,7 +151,7 @@ func TestSingleUrl(t *testing.T) { func TestSingleUrlWith500(t *testing.T) { responses := map[string]responseAndError{ - "http://my-fake-url": responseAndError{nil, http.StatusInternalServerError, "my-content"}, + "http://my-fake-url": {nil, http.StatusInternalServerError, "my-content"}, } test := resolverTestCase{ @@ -171,16 +171,16 @@ imports: func TestSingleUrlWithSchema(t *testing.T) { finalImports := []*common.ImportFile{ - &common.ImportFile{Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"}, - &common.ImportFile{Name: "schema-import", Content: "schema-import"}, - &common.ImportFile{Name: "http://my-fake-url.schema", Content: schema1}, + {Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"}, + {Name: "schema-import", Content: "schema-import"}, + {Name: "http://my-fake-url.schema", Content: schema1}, } responses := map[string]responseAndError{ - "http://my-fake-url": responseAndError{nil, http.StatusOK, "my-content"}, - "http://my-fake-url.schema": responseAndError{nil, http.StatusOK, schema1}, - "my-next-url": responseAndError{nil, http.StatusOK, "schema-import"}, - "my-next-url.schema": responseAndError{nil, http.StatusNotFound, ""}, + "http://my-fake-url": {nil, http.StatusOK, "my-content"}, + "http://my-fake-url.schema": {nil, http.StatusOK, schema1}, + "my-next-url": {nil, http.StatusOK, "schema-import"}, + "my-next-url.schema": {nil, http.StatusNotFound, ""}, } test := resolverTestCase{ @@ -210,18 +210,18 @@ resources: func TestTooManyImports(t *testing.T) { responses := map[string]responseAndError{ - "http://my-fake-url": responseAndError{nil, http.StatusOK, "my-content"}, - "http://my-fake-url.schema": responseAndError{nil, http.StatusNotFound, ""}, - "http://my-fake-url1": responseAndError{nil, http.StatusOK, "my-content"}, - "http://my-fake-url1.schema": responseAndError{nil, http.StatusNotFound, ""}, - "http://my-fake-url2": responseAndError{nil, http.StatusOK, "my-content"}, - "http://my-fake-url2.schema": responseAndError{nil, http.StatusNotFound, ""}, - "http://my-fake-url3": responseAndError{nil, http.StatusOK, "my-content"}, - "http://my-fake-url3.schema": responseAndError{nil, http.StatusNotFound, ""}, - "http://my-fake-url4": responseAndError{nil, http.StatusOK, "my-content"}, - "http://my-fake-url4.schema": responseAndError{nil, http.StatusNotFound, ""}, - "http://my-fake-url5": responseAndError{nil, http.StatusOK, "my-content"}, - "http://my-fake-url5.schema": responseAndError{nil, http.StatusNotFound, ""}, + "http://my-fake-url": {nil, http.StatusOK, "my-content"}, + "http://my-fake-url.schema": {nil, http.StatusNotFound, ""}, + "http://my-fake-url1": {nil, http.StatusOK, "my-content"}, + "http://my-fake-url1.schema": {nil, http.StatusNotFound, ""}, + "http://my-fake-url2": {nil, http.StatusOK, "my-content"}, + "http://my-fake-url2.schema": {nil, http.StatusNotFound, ""}, + "http://my-fake-url3": {nil, http.StatusOK, "my-content"}, + "http://my-fake-url3.schema": {nil, http.StatusNotFound, ""}, + "http://my-fake-url4": {nil, http.StatusOK, "my-content"}, + "http://my-fake-url4.schema": {nil, http.StatusNotFound, ""}, + "http://my-fake-url5": {nil, http.StatusOK, "my-content"}, + "http://my-fake-url5.schema": {nil, http.StatusNotFound, ""}, } test := resolverTestCase{ @@ -250,21 +250,21 @@ imports: func TestSharedImport(t *testing.T) { finalImports := []*common.ImportFile{ - &common.ImportFile{Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"}, - &common.ImportFile{Name: "http://my-fake-url1", Path: "http://my-fake-url1", Content: "my-content-1"}, - &common.ImportFile{Name: "schema-import", Content: "schema-import"}, - &common.ImportFile{Name: "schema-import-1", Content: "schema-import"}, - &common.ImportFile{Name: "http://my-fake-url.schema", Content: schema1}, - &common.ImportFile{Name: "http://my-fake-url1.schema", Content: schema2}, + {Name: "http://my-fake-url", Path: "http://my-fake-url", Content: "my-content"}, + {Name: "http://my-fake-url1", Path: "http://my-fake-url1", Content: "my-content-1"}, + {Name: "schema-import", Content: "schema-import"}, + {Name: "schema-import-1", Content: "schema-import"}, + {Name: "http://my-fake-url.schema", Content: schema1}, + {Name: "http://my-fake-url1.schema", Content: schema2}, } responses := map[string]responseAndError{ - "http://my-fake-url": responseAndError{nil, http.StatusOK, "my-content"}, - "http://my-fake-url.schema": responseAndError{nil, http.StatusOK, schema1}, - "http://my-fake-url1": responseAndError{nil, http.StatusOK, "my-content-1"}, - "http://my-fake-url1.schema": responseAndError{nil, http.StatusOK, schema2}, - "my-next-url": responseAndError{nil, http.StatusOK, "schema-import"}, - "my-next-url.schema": responseAndError{nil, http.StatusNotFound, ""}, + "http://my-fake-url": {nil, http.StatusOK, "my-content"}, + "http://my-fake-url.schema": {nil, http.StatusOK, schema1}, + "http://my-fake-url1": {nil, http.StatusOK, "my-content-1"}, + "http://my-fake-url1.schema": {nil, http.StatusOK, schema2}, + "my-next-url": {nil, http.StatusOK, "schema-import"}, + "my-next-url.schema": {nil, http.StatusNotFound, ""}, } test := resolverTestCase{ @@ -287,31 +287,31 @@ resources: func TestShortGithubUrl(t *testing.T) { finalImports := []*common.ImportFile{ - &common.ImportFile{ + { Name: "github.com/kubernetes/application-dm-templates/common/replicatedservice:v1", Path: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Content: "my-content"}, - &common.ImportFile{ + { Name: "github.com/kubernetes/application-dm-templates/common/replicatedservice:v2", Path: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Content: "my-content-2"}, } downloadResponses := map[string]registry.DownloadResponse{ - "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py": registry.DownloadResponse{Err: nil, Code: http.StatusOK, Body: "my-content"}, - "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py.schema": registry.DownloadResponse{Err: nil, Code: http.StatusNotFound, Body: ""}, - "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py": registry.DownloadResponse{Err: nil, Code: http.StatusOK, Body: "my-content-2"}, - "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py.schema": registry.DownloadResponse{Err: nil, Code: http.StatusNotFound, Body: ""}, + "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py": {Err: nil, Code: http.StatusOK, Body: "my-content"}, + "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py.schema": {Err: nil, Code: http.StatusNotFound, Body: ""}, + "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py": {Err: nil, Code: http.StatusOK, Body: "my-content-2"}, + "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py.schema": {Err: nil, Code: http.StatusNotFound, Body: ""}, } githubURLMaps := map[registry.Type]registry.TestURLAndError{ - registry.NewTypeOrDie("common", "replicatedservice", "v1"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Err: nil}, - registry.NewTypeOrDie("common", "replicatedservice", "v2"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Err: nil}, + registry.NewTypeOrDie("common", "replicatedservice", "v1"): {URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Err: nil}, + registry.NewTypeOrDie("common", "replicatedservice", "v2"): {URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Err: nil}, } gcsURLMaps := map[registry.Type]registry.TestURLAndError{ - registry.NewTypeOrDie("common", "replicatedservice", "v1"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Err: nil}, - registry.NewTypeOrDie("common", "replicatedservice", "v2"): registry.TestURLAndError{URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Err: nil}, + registry.NewTypeOrDie("common", "replicatedservice", "v1"): {URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", Err: nil}, + registry.NewTypeOrDie("common", "replicatedservice", "v2"): {URL: "https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v2/replicatedservice.py", Err: nil}, } grp := registry.NewTestGithubRegistryProviderWithDownloads("github.com/kubernetes/application-dm-templates", githubURLMaps, downloadResponses) diff --git a/cmd/manager/repository/persistent/persistent.go b/cmd/manager/repository/persistent/persistent.go index 0ab0ec825..f5a9e0ca9 100644 --- a/cmd/manager/repository/persistent/persistent.go +++ b/cmd/manager/repository/persistent/persistent.go @@ -25,8 +25,8 @@ import ( "os" "time" - "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/cmd/manager/repository" + "github.com/kubernetes/deployment-manager/pkg/common" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" diff --git a/cmd/manager/repository/test_common.go b/cmd/manager/repository/test_common.go index a2b5fb8c2..7f20b7d0c 100644 --- a/cmd/manager/repository/test_common.go +++ b/cmd/manager/repository/test_common.go @@ -213,8 +213,8 @@ func TestRepositoryDeleteDeploymentWorksForget(t *testing.T, r Repository) { // TestRepositoryTypeInstances checks that type instances can be listed and retrieved successfully. func TestRepositoryTypeInstances(t *testing.T, r Repository) { d1Map := map[string][]*common.TypeInstance{ - "t1": []*common.TypeInstance{ - &common.TypeInstance{ + "t1": { + { Name: "i1", Type: "t1", Deployment: "d1", @@ -225,8 +225,8 @@ func TestRepositoryTypeInstances(t *testing.T, r Repository) { } d2Map := map[string][]*common.TypeInstance{ - "t2": []*common.TypeInstance{ - &common.TypeInstance{ + "t2": { + { Name: "i2", Type: "t2", Deployment: "d2", @@ -237,8 +237,8 @@ func TestRepositoryTypeInstances(t *testing.T, r Repository) { } d3Map := map[string][]*common.TypeInstance{ - "t2": []*common.TypeInstance{ - &common.TypeInstance{ + "t2": { + { Name: "i3", Type: "t2", Deployment: "d3", diff --git a/cmd/manager/repository/transient/transient.go b/cmd/manager/repository/transient/transient.go index 0125f762b..4655709c7 100644 --- a/cmd/manager/repository/transient/transient.go +++ b/cmd/manager/repository/transient/transient.go @@ -23,8 +23,8 @@ import ( "sync" "time" - "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/cmd/manager/repository" + "github.com/kubernetes/deployment-manager/pkg/common" ) // deploymentTypeInstanceMap stores type instances mapped by deployment name. diff --git a/cmd/resourcifier/configurations.go b/cmd/resourcifier/configurations.go index 272008bef..f2d9f93dc 100644 --- a/cmd/resourcifier/configurations.go +++ b/cmd/resourcifier/configurations.go @@ -17,8 +17,8 @@ limitations under the License. package main import ( - "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/cmd/resourcifier/configurator" + "github.com/kubernetes/deployment-manager/pkg/common" "github.com/kubernetes/deployment-manager/pkg/util" "encoding/json" diff --git a/cmd/resourcifier/main.go b/cmd/resourcifier/main.go index 62b94d928..7d82e983a 100644 --- a/cmd/resourcifier/main.go +++ b/cmd/resourcifier/main.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pkg/chart/locator_test.go b/pkg/chart/locator_test.go index cf87d6eb4..67bfcf751 100644 --- a/pkg/chart/locator_test.go +++ b/pkg/chart/locator_test.go @@ -22,9 +22,9 @@ import ( func TestParse(t *testing.T) { tests := map[string]Locator{ - "helm:host/bucket/name#1.2.3": Locator{Scheme: "helm", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"}, - "https://host/bucket/name-1.2.3.tgz": Locator{Scheme: "https", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"}, - "http://host/bucket/name-1.2.3.tgz": Locator{Scheme: "http", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"}, + "helm:host/bucket/name#1.2.3": {Scheme: "helm", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"}, + "https://host/bucket/name-1.2.3.tgz": {Scheme: "https", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"}, + "http://host/bucket/name-1.2.3.tgz": {Scheme: "http", Host: "host", Bucket: "bucket", Name: "name", Version: "1.2.3"}, } for start, expect := range tests { diff --git a/pkg/registry/registryprovider.go b/pkg/registry/registryprovider.go index 87e9d7261..c1f356c8a 100644 --- a/pkg/registry/registryprovider.go +++ b/pkg/registry/registryprovider.go @@ -168,7 +168,7 @@ type githubRegistryProvider struct { // NewGithubRegistryProvider creates a GithubRegistryProvider. func NewGithubRegistryProvider(cp common.CredentialProvider) GithubRegistryProvider { if cp == nil { - // TODO: replace this panic with an error return. + // TODO: replace this panic with an error return. panic(fmt.Errorf("no credential provider")) } return &githubRegistryProvider{cp: cp} @@ -240,7 +240,7 @@ type gcsRegistryProvider struct { // NewGCSRegistryProvider creates a GCSRegistryProvider. func NewGCSRegistryProvider(cp common.CredentialProvider) GCSRegistryProvider { if cp == nil { - // TODO: replace this panic with an error return. + // TODO: replace this panic with an error return. panic(fmt.Errorf("no credential provider")) } return &gcsRegistryProvider{cp: cp} diff --git a/pkg/registry/registryprovider_test.go b/pkg/registry/registryprovider_test.go index bd41b354d..968d51a8a 100644 --- a/pkg/registry/registryprovider_test.go +++ b/pkg/registry/registryprovider_test.go @@ -36,13 +36,13 @@ func testURLConversionDriver(rp RegistryProvider, tests map[string]TestURLAndErr func TestShortGithubURLTemplateMapping(t *testing.T) { githubURLMaps := map[Type]TestURLAndError{ - NewTypeOrDie("common", "replicatedservice", "v1"): TestURLAndError{"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", nil}, - NewTypeOrDie("storage", "redis", "v1"): TestURLAndError{"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/storage/redis/v1/redis.jinja", nil}, + NewTypeOrDie("common", "replicatedservice", "v1"): {"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", nil}, + NewTypeOrDie("storage", "redis", "v1"): {"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/storage/redis/v1/redis.jinja", nil}, } tests := map[string]TestURLAndError{ - "github.com/kubernetes/application-dm-templates/common/replicatedservice:v1": TestURLAndError{"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", nil}, - "github.com/kubernetes/application-dm-templates/storage/redis:v1": TestURLAndError{"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/storage/redis/v1/redis.jinja", nil}, + "github.com/kubernetes/application-dm-templates/common/replicatedservice:v1": {"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/common/replicatedservice/v1/replicatedservice.py", nil}, + "github.com/kubernetes/application-dm-templates/storage/redis:v1": {"https://raw.githubusercontent.com/kubernetes/application-dm-templates/master/storage/redis/v1/redis.jinja", nil}, } grp := NewTestGithubRegistryProvider("github.com/kubernetes/application-dm-templates", githubURLMaps) @@ -52,13 +52,13 @@ func TestShortGithubURLTemplateMapping(t *testing.T) { func TestShortGithubURLPackageMapping(t *testing.T) { githubURLMaps := map[Type]TestURLAndError{ - NewTypeOrDie("", "mongodb", ""): TestURLAndError{"https://raw.githubusercontent.com/helm/charts/master/mongodb/manifests/mongodb.yaml", nil}, - NewTypeOrDie("", "redis", ""): TestURLAndError{"https://raw.githubusercontent.com/helm/charts/master/redis/manifests/redis.yaml", nil}, + NewTypeOrDie("", "mongodb", ""): {"https://raw.githubusercontent.com/helm/charts/master/mongodb/manifests/mongodb.yaml", nil}, + NewTypeOrDie("", "redis", ""): {"https://raw.githubusercontent.com/helm/charts/master/redis/manifests/redis.yaml", nil}, } tests := map[string]TestURLAndError{ - "github.com/helm/charts/mongodb": TestURLAndError{"https://raw.githubusercontent.com/helm/charts/master/mongodb/manifests/mongodb.yaml", nil}, - "github.com/helm/charts/redis": TestURLAndError{"https://raw.githubusercontent.com/helm/charts/master/redis/manifests/redis.yaml", nil}, + "github.com/helm/charts/mongodb": {"https://raw.githubusercontent.com/helm/charts/master/mongodb/manifests/mongodb.yaml", nil}, + "github.com/helm/charts/redis": {"https://raw.githubusercontent.com/helm/charts/master/redis/manifests/redis.yaml", nil}, } grp := NewTestGithubRegistryProvider("github.com/helm/charts", githubURLMaps) diff --git a/pkg/util/httpclient_test.go b/pkg/util/httpclient_test.go index c7b7eef46..001ebccc4 100644 --- a/pkg/util/httpclient_test.go +++ b/pkg/util/httpclient_test.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/pkg/util/kubernetesutil_test.go b/pkg/util/kubernetesutil_test.go index 04304a43d..0f1513135 100644 --- a/pkg/util/kubernetesutil_test.go +++ b/pkg/util/kubernetesutil_test.go @@ -6,7 +6,7 @@ you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. From bddebc9428c54b912883fcb5a330e5dee36f57b0 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 12:08:37 -0800 Subject: [PATCH 64/73] fix(Makefile): fix gofmt too many args error --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ce2acfef1..a3e377221 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ test-unit: .PHONY: .test-style test-style: lint vet - @if [ $(shell gofmt -e -l -s $(GO_DIRS)) ]; then \ + @if [ $(shell gofmt -e -l -s $(GO_DIRS) | wc -l) ]; then \ echo "gofmt check failed:"; gofmt -e -d -s $(GO_DIRS); exit 1; \ fi From 9550aefd739a20ce88b3cfeb67f060db0a64f4c4 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 15:50:55 -0800 Subject: [PATCH 65/73] chore(testdata): remove unused testdata --- testdata/charts/README.md | 9 -- testdata/charts/frobnitz-0.0.1.tgz | Bin 6246 -> 0 bytes testdata/charts/frobnitz/Chart.yaml | 27 ---- testdata/charts/frobnitz/LICENSE | 1 - testdata/charts/frobnitz/README.md | 11 -- testdata/charts/frobnitz/docs/README.md | 1 - testdata/charts/frobnitz/hooks/pre-install.py | 1 - testdata/charts/frobnitz/icon.svg | 8 -- .../templates/wordpress-resources.yaml | 12 -- .../charts/frobnitz/templates/wordpress.jinja | 72 ---------- .../frobnitz/templates/wordpress.jinja.schema | 69 ---------- .../charts/frobnitz/templates/wordpress.yaml | 6 - testdata/guestbook/README.md | 127 ------------------ testdata/guestbook/guestbook.yaml | 12 -- 14 files changed, 356 deletions(-) delete mode 100644 testdata/charts/README.md delete mode 100644 testdata/charts/frobnitz-0.0.1.tgz delete mode 100644 testdata/charts/frobnitz/Chart.yaml delete mode 100644 testdata/charts/frobnitz/LICENSE delete mode 100644 testdata/charts/frobnitz/README.md delete mode 100644 testdata/charts/frobnitz/docs/README.md delete mode 100644 testdata/charts/frobnitz/hooks/pre-install.py delete mode 100644 testdata/charts/frobnitz/icon.svg delete mode 100644 testdata/charts/frobnitz/templates/wordpress-resources.yaml delete mode 100644 testdata/charts/frobnitz/templates/wordpress.jinja delete mode 100644 testdata/charts/frobnitz/templates/wordpress.jinja.schema delete mode 100644 testdata/charts/frobnitz/templates/wordpress.yaml delete mode 100644 testdata/guestbook/README.md delete mode 100644 testdata/guestbook/guestbook.yaml diff --git a/testdata/charts/README.md b/testdata/charts/README.md deleted file mode 100644 index 6ddc704f5..000000000 --- a/testdata/charts/README.md +++ /dev/null @@ -1,9 +0,0 @@ -The testdata directory here holds charts that match the specification. - -The `fromnitz/` directory contains a chart that matches the chart -specification. - -The `frobnitz-0.0.1.tgz` file is an archive of the `frobnitz` directory. - -The `ill` chart and directory is a chart that is not 100% compatible, -but which should still be parseable. diff --git a/testdata/charts/frobnitz-0.0.1.tgz b/testdata/charts/frobnitz-0.0.1.tgz deleted file mode 100644 index 78fb3bc176af80192b52fb4fec619249905dda80..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6246 zcmV-s7@6lEiwFQ3{I6C31MNL)bK6Fe`K(_tN7t66I*JlSNsg5`yNX5I+}M(il;cgg za;_mUBqs(i3uG z&fZsS_mfky;`%q2|AVQBlcR}9MaFZ%#!79ZJP}9CDaJ-5^eB_FT&nblT}-8B@DI1o zKeRS3MW*RlquttTb+&mtoAOrsKihkq{e#BFd$E|SEYe3CjBS@t@rRyeYV=;@^dnLc zk2Vr6(;WT~DJDiJCbtQ%_) zPD#~JMT^QLt%__U48m!i&-BsGPVjsOxUw_k*~U~MU>s2$06dzBG!p4ZiVEHNRHhS= z4b_k+h}DQ2KCZ$tLJQP8<(%yfFtpvuCm(3GXY_w}HbigTlWa70Q+}pWq4@J(~H$2*jxJckPNsTc+lg~3%%mQ$oEINmUEH=Kh zYOk+5T;BgjYNS6?5^(qU@BBaf@n{|Y@8k0FpDOkKGbzA7A^!u6|7-bw{>#f>j#S#x zmy^$c4>#MPTp%(ggV1lZH)s z=JR=L-f5|9va<(^+<|8eGwjA8lo}XlSFudruNvHb{P^(>J#B=ki=l|kWt2~!H1-Y- z8<6tJ$uze=Wb~u~*-qa04rYCesp@xKlTtBM=x=xE7Cy_wD5v3LnZbB=1rQo+LI1Vj z_jgO^hw%5YjN>PblwU3yJ5?B30Pu)_v=0c%{w+{45h0Loks;sxiBcnP|1Wz_yQhQh z=fH8Z{qG&NJBM}uzrVM?w*ULMY}$Uqbv)z16!ub%pcD`{jsMZuEZb}CHrd~KTJUVa zzzghOJ1Ou3oY0Ujhz%;evw;&Yy8TxJc6@rmo}Qha^e%d5rvvuvtj}H#x=q&ap7+mA zUO&a#O&WF58(j2z-@nE?1fbnwCt@r?%dwDYZCGj=c0~=Qr#y~XB6tb~n_#)f5~y&~ zh@p|2Sx^{ftk9y#G67XGkNE_fowKSQs z$4rf}I)rg*RA3obr%Po^gpJf}k)dN@Y7P}L1Cn5(%omIo`BY`{1L3o9R?Wz#Jje2V zl5v=rPH2$jLqLF-@R)T8^b!$8iVGy_1>+-v;-~;Nz*q}L!2nAjRK*50Ff`9p++;ix z?ng{SH*qz1w}3i2gJ%g;nHG{A2o5%%8aM`Fi#<~r(J?EsnF5U|x#|V(WYn-w8nhJ6 zHszL?s^%hVg80a}13a0Uzc*Q~*ocGBah!!>9uWsJmhhBM1PTxF>S8ptgf-cGDros2 zeZtELcF38zL~Q~nn-VA?@#v|XA*8V!12<|>nN|-7B?9g{+ao|0j2X~$_CJ=BBBSRR$VK2j&W68$ zDlC)E(}lSQ;wWOW4+ydeJRD7V3RF7-0j)?ij^s|E=uT{Zju~f$Jp`^+G@;9)TmdN*x7&JmzwBJQ2|HXsuK5p!Fe}e0}S@=&2S0^OJXZTc8o2= zAxEtRu?Y(hE@9N5athSkOvI7LGwkchD=?;5&9_P}oQO}uuY983t zTS$fnj_@JZD7=(RF+v=u{h&R@S0O4A7uv#nDo4}68Gx{Ihyh@knYffBO4MRtjkOad zfWs~iA({@vdowLvGY^oiupHLoqd*jsLfV( z1l~rC3_G{pKE;e@q$$W3T1Fx=5ib}P55%}3Xbb8I_C&Xw&?PvcY|KX#B$`2t^h{kM z3b`ZHxRm-+bmcb2uatP*2E54z_&fux!MRxK=|Er=nUD@gHWP7>l;I7{g6G!}-wcc* zN3X8{b?n@>E{5Pctn+Yr2Wb~kPUKlrAVlQHm(mI+WeRsUMvE{}L9a~cQQwCGm^lVk zT%Ww$E!wk&UsJ=vGV$KKWtb#lFu+WKGj5_3hCC)cnrApKrR1YXE%zB(LCADbG79;W z>(W?=|GIf&DDu85!~y@5G%?(#z{xSBlmIOVSw0og3!RHZhb|mqZXqy)j3`Fh5k~wN z`AoLrbFGl+&A^RRv>@O%@(ps_QK2cy6UK!6rA;H>kjE=SleltBsIJxNBP>PFQu6(viYOyu>`F~UXVo|besdPuYOAqq!nOR`FWXt*ttn5) zK=hAE4Jn%fF+&0R1Sz8+PYy(fcuFJG;@1N7Cq}d*1^hPQ8WY~Y{EQ>oYq95;Rw3G_ ze)%r5VuQj2SF5Wli z8mUURN%9(2j6b(=TWf-alUndNUu=&v0ly?9c9&{|j(jPa+xia?x@rq%fQ`*ikC!}M z>CR`x5at3GK~ZNh2SxXHfMyeFHQlj^MOe3mX}oBI6cY^L+LqcSoKY#9gg$O>?Bq(_+1z@N%T0?e7f z11wFKHwPs=RR=&(eQ^O|kFZpTCR$h-9h+9Wo9GrJfq7FiNG3={^U~bx+Dr>#1wD0_ zidUJr8Sm*}5OI;BgchOV!<_*Q(>3hPARPw5+gu*1QxxPRajhmdTN|w4(zs?Rlt4fQXoLj-vuGO^x$v?{ zu|Ed|GbR>-LlJs0HB}h;uVpp|@}}g$l+wP*2Q@@lykdq@CCAzpd8|dHH}As+k0Shg zhV@RUkpUD(y5-PaETL(*uR##uny8+__C^$mG%6C8wpKL8ITlm@IdRr~8Zp>4F@Oy# zjfuKdP&1i4AS>$nXBczczQsxwl~o0$t<_GOS7h*I zYj4GtkpUCz6{+zGYMQ0ljHy^$TvLjK-8pYc1P@UM-Mo^3rQNDZ6!uv+_L3=;Mm?&u zWqhSls{|?nIiO<4?gW@xwafx_i@i=EifR&?xB^5YiRCXr3^qu7e`8V4B7^}dV(#)n=L}s8c282mnBe(l#=AWt@C;8nQiZ4TDiZVI@O647f z5h6_&5Dv76gxLr}GYCXt5t;15G)RGqz9gDJO-G8quoglUnYa?8z{Qi}^$f|xglA@7 zsa|{7y?{e-g)RZnEpsr~<WxctWPfb|9q_WkjoH*m~-)4O;PY3cT|@vk>ppRpiNp@5cNs9^HU2ba*0(` z5M|3Q7MOX_yLj1c0@qKsd#BI(z0>F2SKZT#CVSQGKYamI9)I6^*}M3OROngn;36%E zl~%6r{M@SVnV=m(&Gtr30<037S8w!FePJ-Yr04i_D4}(}}P#n}lOwj9%I19r!(|L3$X_Itp zk8gklSSGl`4HmqyfX6L%Ji?fOTyUNjF&~$KIxvbiQ%v2f=33t@ym7nDWuc>~Ql<+^ zozBW;JM~=g9U4LY1Y8|a$kUN9i>%gt2ClW8Q9Ia@b^DH4xLJ?B806gl#9$yHL?%^{cW$yQq;JUcugr+@4QSBzUv|54HWKf3Z zuB*{3EBUb$aikdp2rzcz^oO`hDL^wDZ+~uh$48wB8|@ZOnaHc!sxPRdTWs@0r4Rji zfxt!`@c-CiRIO8)sv*4qO@I{N(_yQFAZ!PFvuG=N0sj2TZ-i1&ZwLTC0TW}58&qbr z?UOn$PGgPUfR3c58Jg$|EbZL+U8eII#i5QR5nYa06pSb?4I_enB!p z@uc66x14kPuD(4}HaU1Un&OVNQHF9e@$CYxpV?cY8|bXkJa_7T+mTay z40;<#rYU#H(67rq?3ptJ6SUNpPdMSGK{(*L4EztK-!Abcwhe@+kl>V@(i+eiSXw$M zK;a-IfUuC(PxjevNtv(f<#o0GMCaVs*Xqlk|L=E?PhNFfN%ZM)-1h#@UZ-6@|9^P6 ze*gPkt_SRydnJ3rzuaA(iKKUuAv`>Iz+P+c2CD`^C7Dxxo?;OKgUt97NGD@8!$`WZ z@r+=OUr}?K8Xs`upGiJlx+sSik>y zAJ+=`$8n4OAM8SK zsM>#f|KQQu{_o?eeg7v)-g$ff?Jtm`_36`bX) zcfE6%SpI(dP|hsU_HJvp1)9~`+kdng<-7B<{zYv%c3=&Fz1{uCtEZjx20zrMp;NMW zopZbfCr*C%Y;f_@dA9~*tkKt5DB>#LuRwU-JN-wUM-!P|tzr+3b&LCYcj-yLd;YTb z^cV$8H{L$PCY&5`ZC4)5cyrc2Iq!D|gLmgI&TII~jA1sNt)QbaH^f?baA)jpMYY+b z#2%vsmXlxoH2ANVHIgZ`tRR)fIt2711l;ND9xe|)9t@C_U;@_~d16Iq!kE9g1i-41 zog8RT8UI#KD%Ho%U9CCSL~b8bCo-QFL;42Qd;bBc9oy!@-p)4IZ5bal6ljnc>;Q

l58sp29L!H2sNJmdXt#`EbB+qvW!_DFZ8dE&P5=t!d7 zNBWT_KgC^Y}SxDX*e=Qu3R+a(gq;f`abxh5lV?xk{q#uFYPjf^Zj#?X@NMuonx_O!yU z1h!Oh@%Jmr)dZ{%^@<>Iy~wX0T#9}#6ul?lXgo`<6MqTy+6$Wx7U9y4K-2nN6Nrk>c7rmyVn2P+k4b*uj{}2xUdzE7N5&JM!(}^ zzrk4L!>|8CUV*-&L$7G~fov{@T0-eKT-f)p@q-t*dtbVF=c>V_@)R>WcZ0qtK$%H! zr|Rm%p%FZMwZLTF-n6F}aF@RVg~r)wkdGsKy~%z#6Y; zq8{$l+M^G!VqU}$QL2@#eHQTV+<@_)fJL;i;)Y6T4`O91!OdA$@=EhfT8CDZ-;Jn; zO3Jyt-(I4!LTOkI2Tv;>`4tQ@c6Xk&6qh@_OhL4UPNw-XE-am|$AMsOz!FumnVT0C zG$OA-=FT$Ep)nu#2uYm)R1JSp+ZG&mqyuZN>uDejqxbU73xtS!dHo)}N!jnJ0X}WH zlVEOORFMqLIb{dY9}cM47*bfV)ISrYD_zL%R$uHR+@ikMB4b&BFASuJ)Km?3WzU_- z!*0YK$g6nFkSs!GyApR*@Ml^dGPxOBSxNZNhz4xfz|L^Rr^S^t!%oi7^F=#5qTK2!Pc{mTUL}MiNSzmft z>+6nJ?fc&#!)-j+%;UH - - Example icon - - - diff --git a/testdata/charts/frobnitz/templates/wordpress-resources.yaml b/testdata/charts/frobnitz/templates/wordpress-resources.yaml deleted file mode 100644 index 00f709de0..000000000 --- a/testdata/charts/frobnitz/templates/wordpress-resources.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# Google Cloud Deployment Manager template -resources: -- name: nfs-disk - type: compute.v1.disk - properties: - zone: us-central1-b - sizeGb: 200 -- name: mysql-disk - type: compute.v1.disk - properties: - zone: us-central1-b - sizeGb: 200 diff --git a/testdata/charts/frobnitz/templates/wordpress.jinja b/testdata/charts/frobnitz/templates/wordpress.jinja deleted file mode 100644 index f34e4fec9..000000000 --- a/testdata/charts/frobnitz/templates/wordpress.jinja +++ /dev/null @@ -1,72 +0,0 @@ -#helm:generate dm_template -{% set PROPERTIES = properties or {} %} -{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-testing' %} -{% set NFS_SERVER = PROPERTIES['nfs-server'] or {} %} -{% set NFS_SERVER_IP = NFS_SERVER['ip'] or '10.0.253.247' %} -{% set NFS_SERVER_PORT = NFS_SERVER['port'] or 2049 %} -{% set NFS_SERVER_DISK = NFS_SERVER['disk'] or 'nfs-disk' %} -{% set NFS_SERVER_DISK_FSTYPE = NFS_SERVER['fstype'] or 'ext4' %} -{% set NGINX = PROPERTIES['nginx'] or {} %} -{% set NGINX_PORT = 80 %} -{% set NGINX_REPLICAS = NGINX['replicas'] or 2 %} -{% set WORDPRESS_PHP = PROPERTIES['wordpress-php'] or {} %} -{% set WORDPRESS_PHP_REPLICAS = WORDPRESS_PHP['replicas'] or 2 %} -{% set WORDPRESS_PHP_PORT = WORDPRESS_PHP['port'] or 9000 %} -{% set MYSQL = PROPERTIES['mysql'] or {} %} -{% set MYSQL_PORT = MYSQL['port'] or 3306 %} -{% set MYSQL_PASSWORD = MYSQL['password'] or 'mysql-password' %} -{% set MYSQL_DISK = MYSQL['disk'] or 'mysql-disk' %} -{% set MYSQL_DISK_FSTYPE = MYSQL['fstype'] or 'ext4' %} - -resources: -- name: nfs - type: github.com/kubernetes/application-dm-templates/storage/nfs:v1 - properties: - ip: {{ NFS_SERVER_IP }} - port: {{ NFS_SERVER_PORT }} - disk: {{ NFS_SERVER_DISK }} - fstype: {{NFS_SERVER_DISK_FSTYPE }} -- name: nginx - type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v2 - properties: - service_port: {{ NGINX_PORT }} - container_port: {{ NGINX_PORT }} - replicas: {{ NGINX_REPLICAS }} - external_service: true - image: gcr.io/{{ PROJECT }}/nginx:latest - volumes: - - mount_path: /var/www/html - persistentVolumeClaim: - claimName: nfs -- name: mysql - type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v2 - properties: - service_port: {{ MYSQL_PORT }} - container_port: {{ MYSQL_PORT }} - replicas: 1 - image: mysql:5.6 - env: - - name: MYSQL_ROOT_PASSWORD - value: {{ MYSQL_PASSWORD }} - volumes: - - mount_path: /var/lib/mysql - gcePersistentDisk: - pdName: {{ MYSQL_DISK }} - fsType: {{ MYSQL_DISK_FSTYPE }} -- name: wordpress-php - type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v2 - properties: - service_name: wordpress-php - service_port: {{ WORDPRESS_PHP_PORT }} - container_port: {{ WORDPRESS_PHP_PORT }} - replicas: 2 - image: wordpress:fpm - env: - - name: WORDPRESS_DB_PASSWORD - value: {{ MYSQL_PASSWORD }} - - name: WORDPRESS_DB_HOST - value: mysql-service - volumes: - - mount_path: /var/www/html - persistentVolumeClaim: - claimName: nfs diff --git a/testdata/charts/frobnitz/templates/wordpress.jinja.schema b/testdata/charts/frobnitz/templates/wordpress.jinja.schema deleted file mode 100644 index 215b47e1e..000000000 --- a/testdata/charts/frobnitz/templates/wordpress.jinja.schema +++ /dev/null @@ -1,69 +0,0 @@ -info: - title: Wordpress - description: | - Defines a Wordpress website by defining four replicated services: an NFS service, an nginx service, a wordpress-php service, and a MySQL service. - - The nginx service and the Wordpress-php service both use NFS to share files. - -properties: - project: - type: string - default: dm-k8s-testing - description: Project location to load the images from. - nfs-service: - type: object - properties: - ip: - type: string - default: 10.0.253.247 - description: The IP of the NFS service. - port: - type: int - default: 2049 - description: The port of the NFS service. - disk: - type: string - default: nfs-disk - description: The name of the persistent disk the NFS service uses. - fstype: - type: string - default: ext4 - description: The filesystem the disk of the NFS service uses. - nginx: - type: object - properties: - replicas: - type: int - default: 2 - description: The number of replicas for the nginx service. - wordpress-php: - type: object - properties: - replicas: - type: int - default: 2 - description: The number of replicas for the wordpress-php service. - port: - type: int - default: 9000 - description: The port the wordpress-php service runs on. - mysql: - type: object - properties: - port: - type: int - default: 3306 - description: The port the MySQL service runs on. - password: - type: string - default: mysql-password - description: The root password of the MySQL service. - disk: - type: string - default: mysql-disk - description: The name of the persistent disk the MySQL service uses. - fstype: - type: string - default: ext4 - description: The filesystem the disk of the MySQL service uses. - diff --git a/testdata/charts/frobnitz/templates/wordpress.yaml b/testdata/charts/frobnitz/templates/wordpress.yaml deleted file mode 100644 index b401897ab..000000000 --- a/testdata/charts/frobnitz/templates/wordpress.yaml +++ /dev/null @@ -1,6 +0,0 @@ -imports: -- path: wordpress.jinja - -resources: -- name: wordpress - type: wordpress.jinja diff --git a/testdata/guestbook/README.md b/testdata/guestbook/README.md deleted file mode 100644 index b48dd5933..000000000 --- a/testdata/guestbook/README.md +++ /dev/null @@ -1,127 +0,0 @@ -T**Testing fork of the guestbook example.** - -# Guestbook Example - -Welcome to the Guestbook example. It shows you how to build and reuse -parameterized templates. - -## Prerequisites - -First, make sure DM is installed in your Kubernetes cluster and that the -Guestbook example is deployed by following the instructions in the top level -[README.md](../../README.md). - -## Understanding the Guestbook example - -Let's take a closer look at the configuration used by the Guestbook example. - -### Replicated services - -The typical design pattern for microservices in Kubernetes is to create a -replication controller and a service with the same selector, so that the service -exposes ports from the pods managed by the replication controller. - -We have created a parameterized template for this kind of replicated service -called [Replicated Service](../../templates/replicatedservice/v1), and we use it -three times in the Guestbook example. - -The template is defined by a -[Python script](../../templates/replicatedservice/v1/replicatedservice.py). It -also has a [schema](../../templates/replicatedservice/v1/replicatedservice.py.schema). -Schemas are optional. If provided, they are used to validate template invocations -that appear in configurations. - -For more information about templates and schemas, see the -[design document](../../docs/design/design.md#templates). - -### The Guestbook application -The Guestbook application consists of 2 microservices: a front end and a Redis -cluster. - -#### The front end - -The front end is a replicated service with 3 replicas: - -``` -- name: frontend - type: https://raw.githubusercontent.com/kubernetes/deployment-manager/master/templates/replicatedservice/v1/replicatedservice.py - properties: - service_port: 80 - container_port: 80 - external_service: true - replicas: 3 - image: gcr.io/google_containers/example-guestbook-php-redis:v3 -``` - -(Note that we use the URL for a specific version of the template replicatedservice.py, -not just the template name.) - -#### The Redis cluster - -The Redis cluster consists of two replicated services: a master with a single replica -and the slaves with 2 replicas. It's defined by [this template](../../templates/redis/v1/redis.jinja), -which is a [Jinja](http://jinja.pocoo.org/) file with a [schema](../../templates/redis/v1/redis.jinja.schema). - -``` -{% set REDIS_PORT = 6379 %} -{% set WORKERS = properties['workers'] or 2 %} - -resources: -- name: redis-master - type: https://raw.githubusercontent.com/kubernetes/deployment-manager/master/templates/replicatedservice/v1/replicatedservice.py - properties: - # This has to be overwritten since service names are hard coded in the code - service_name: redis-master - service_port: {{ REDIS_PORT }} - target_port: {{ REDIS_PORT }} - container_port: {{ REDIS_PORT }} - replicas: 1 - container_name: master - image: redis - -- name: redis-slave - type: https://raw.githubusercontent.com/kubernetes/deployment-manager/master/templates/replicatedservice/v1/replicatedservice.py - properties: - # This has to be overwritten since service names are hard coded in the code - service_name: redis-slave - service_port: {{ REDIS_PORT }} - container_port: {{ REDIS_PORT }} - replicas: {{ WORKERS }} - container_name: worker - image: kubernetes/redis-slave:v2 - # An example of how to specify env variables. - env: - - name: GET_HOSTS_FROM - value: env - - name: REDIS_MASTER_SERVICE_HOST - value: redis-master -``` - -### Displaying types - -You can see both the both primitive types and the templates you've deployed to the -cluster using the `deployed-types` command: - -``` -dm deployed-types - -["Service","ReplicationController","redis.jinja","https://raw.githubusercontent.com/kubernetes/deployment-manager/master/templates/replicatedservice/v1/replicatedservice.py"] -``` - -This output shows 2 primitive types (Service and ReplicationController), and 2 -templates (redis.jinja and one imported from github named replicatedservice.py). - -You can also see where a specific type is being used with the `deployed-instances` command: - -``` -dm deployed-instances Service -[{"name":"frontend-service","type":"Service","deployment":"guestbook4","manifest":"manifest-1446682551242763329","path":"$.resources[0].resources[0]"},{"name":"redis-master","type":"Service","deployment":"guestbook4","manifest":"manifest-1446682551242763329","path":"$.resources[1].resources[0].resources[0]"},{"name":"redis-slave","type":"Service","deployment":"guestbook4","manifest":"manifest-1446682551242763329","path":"$.resources[1].resources[1].resources[0]"}] -``` - -This output describes the deployment and manifest, as well as the JSON paths to -the instances of the type within the layout. - -For more information about deployments, manifests and layouts, see the -[design document](../../docs/design/design.md#api-model). - - diff --git a/testdata/guestbook/guestbook.yaml b/testdata/guestbook/guestbook.yaml deleted file mode 100644 index 9a31d2489..000000000 --- a/testdata/guestbook/guestbook.yaml +++ /dev/null @@ -1,12 +0,0 @@ -resources: -- name: frontend - type: github.com/kubernetes/application-dm-templates/common/replicatedservice:v1 - properties: - service_port: 80 - container_port: 80 - external_service: true - replicas: 3 - image: gcr.io/google_containers/example-guestbook-php-redis:v3 -- name: redis - type: github.com/kubernetes/application-dm-templates/storage/redis:v1 - properties: null From 3611d6c100b875cbb117c24830dc859ef889fff1 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 17:18:36 -0800 Subject: [PATCH 66/73] feat(images): create new image directories --- .gitignore | 6 ++++++ rootfs/expandybird/.dockerignore | 3 +++ rootfs/expandybird/bin/.keep | 0 rootfs/expandybird/opt/.keep | 0 rootfs/manager/.dockerignore | 3 +++ rootfs/manager/bin/.keep | 0 rootfs/resourcifer/.dockerignore | 3 +++ rootfs/resourcifer/bin/.keep | 0 8 files changed, 15 insertions(+) create mode 100644 rootfs/expandybird/.dockerignore create mode 100644 rootfs/expandybird/bin/.keep create mode 100644 rootfs/expandybird/opt/.keep create mode 100644 rootfs/manager/.dockerignore create mode 100644 rootfs/manager/bin/.keep create mode 100644 rootfs/resourcifer/.dockerignore create mode 100644 rootfs/resourcifer/bin/.keep diff --git a/.gitignore b/.gitignore index f19b2533d..875c22e57 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,9 @@ .project /bin /vendor/* +/rootfs/manager/bin/manager +/rootfs/manager/bin/kubectl +/rootfs/resourcifier/bin/resourcifier +/rootfs/resourcifier/bin/kubectl +/rootfs/expandybird/bin/expandybird +/rootfs/expandybird/opt/expansion diff --git a/rootfs/expandybird/.dockerignore b/rootfs/expandybird/.dockerignore new file mode 100644 index 000000000..f6fb65317 --- /dev/null +++ b/rootfs/expandybird/.dockerignore @@ -0,0 +1,3 @@ +.dockerignore +Dockerfile +Makefile diff --git a/rootfs/expandybird/bin/.keep b/rootfs/expandybird/bin/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/rootfs/expandybird/opt/.keep b/rootfs/expandybird/opt/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/rootfs/manager/.dockerignore b/rootfs/manager/.dockerignore new file mode 100644 index 000000000..f6fb65317 --- /dev/null +++ b/rootfs/manager/.dockerignore @@ -0,0 +1,3 @@ +.dockerignore +Dockerfile +Makefile diff --git a/rootfs/manager/bin/.keep b/rootfs/manager/bin/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/rootfs/resourcifer/.dockerignore b/rootfs/resourcifer/.dockerignore new file mode 100644 index 000000000..f6fb65317 --- /dev/null +++ b/rootfs/resourcifer/.dockerignore @@ -0,0 +1,3 @@ +.dockerignore +Dockerfile +Makefile diff --git a/rootfs/resourcifer/bin/.keep b/rootfs/resourcifer/bin/.keep new file mode 100644 index 000000000..e69de29bb From f3525d96682cba5c3bb080645ae2af4d1f432af2 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 17:21:12 -0800 Subject: [PATCH 67/73] fix(build): create cross compile target in Makefile --- Makefile | 4 ++++ scripts/build-go.sh | 8 -------- scripts/common.sh | 20 +++++++++++++++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index a3e377221..4d52f72ed 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,10 @@ GO_PKGS ?= $(shell glide nv) build: @scripts/build-go.sh +.PHONY: build-cross +build-cross: + @BUILD_CROSS=1 scripts/build-go.sh + .PHONY: all all: build diff --git a/scripts/build-go.sh b/scripts/build-go.sh index a824cdcbd..b15b1bcd7 100755 --- a/scripts/build-go.sh +++ b/scripts/build-go.sh @@ -9,14 +9,6 @@ readonly DIR="${GOPATH}/src/${REPO}" source "${DIR}/scripts/common.sh" -if [[ -z "${VERSION:-}" ]]; then - VERSION=$(version_from_git) -fi - -LDFLAGS="-s -X ${REPO}/pkg/version.DeploymentManagerVersion=${VERSION}" - -echo "Build version: ${VERSION}" - build_binaries "$@" exit 0 diff --git a/scripts/common.sh b/scripts/common.sh index 861e88400..f1c819213 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -10,6 +10,18 @@ error_exit() { exit 1 } +assign_version() { + if [[ -z "${VERSION:-}" ]]; then + VERSION=$(version_from_git) + fi +} + +assign_ldflags() { + if [[ -z "${LDFLAGS:-}" ]]; then + LDFLAGS="-s -X ${REPO}/pkg/version.DeploymentManagerVersion=${VERSION}" + fi +} + version_from_git() { local git_tag=$(git describe --tags --abbrev=0 2>/dev/null) local git_commit=$(git rev-parse --short HEAD) @@ -29,13 +41,19 @@ build_binary_cross() { build_binaries() { local -a targets=($@) + #TODO: accept specific os/arch + local build_cross="${BUILD_CROSS:-}" if [[ ${#targets[@]} -eq 0 ]]; then targets=("${ALL_TARGETS[@]}") fi for t in "${targets[@]}"; do - build_binary "$t" + if [[ -n "$build_cross" ]]; then + build_binary_cross "$t" + else + build_binary "$t" + fi done } From 3cdf4cb3f436f2e66af64175ed12edd8bb6b061e Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 18:01:56 -0800 Subject: [PATCH 68/73] feat(images): initial pass at new Dockerfiles --- .../requirements.txt | 0 rootfs/expandybird/Dockerfile | 24 +++++++++++++++++ rootfs/expandybird/Makefile | 24 +++++++++++++++++ rootfs/manager/Dockerfile | 4 +++ rootfs/manager/Makefile | 27 +++++++++++++++++++ rootfs/resourcifer/Dockerfile | 4 +++ rootfs/resourcifer/Makefile | 27 +++++++++++++++++++ 7 files changed, 110 insertions(+) rename {cmd/expandybird => expansion}/requirements.txt (100%) create mode 100644 rootfs/expandybird/Dockerfile create mode 100644 rootfs/expandybird/Makefile create mode 100644 rootfs/manager/Dockerfile create mode 100644 rootfs/manager/Makefile create mode 100644 rootfs/resourcifer/Dockerfile create mode 100644 rootfs/resourcifer/Makefile diff --git a/cmd/expandybird/requirements.txt b/expansion/requirements.txt similarity index 100% rename from cmd/expandybird/requirements.txt rename to expansion/requirements.txt diff --git a/rootfs/expandybird/Dockerfile b/rootfs/expandybird/Dockerfile new file mode 100644 index 000000000..cea99a7cd --- /dev/null +++ b/rootfs/expandybird/Dockerfile @@ -0,0 +1,24 @@ +FROM alpine:3.3 + +COPY . / + +# install common packages +RUN apk add --update-cache curl python + +WORKDIR /opt + +# install pip +RUN curl -sSL https://raw.githubusercontent.com/pypa/pip/7.1.2/contrib/get-pip.py | python - + +# install dependencies +RUN pip install --disable-pip-version-check --no-cache-dir -r /opt/expansion/requirements.txt + +# cleanup. +RUN apk del --purge \ + curl \ + python \ + && rm -rf /var/cache/apk/* + +# define execution environment +CMD ["/bin/expandybird", "-expansion_binary", "/opt/expansion/expansion.py"] +EXPOSE 8000 diff --git a/rootfs/expandybird/Makefile b/rootfs/expandybird/Makefile new file mode 100644 index 000000000..e293f49af --- /dev/null +++ b/rootfs/expandybird/Makefile @@ -0,0 +1,24 @@ +DOCKER_REGISTRY := gcr.io +PREFIX := $(DOCKER_REGISTRY)/$(PROJECT) +IMAGE ?= expandybird +TAG ?= git-$(shell git rev-parse --short HEAD) +FULL_IMAGE := $(PREFIX)/$(IMAGE) + +.PHONY: container +container: binary expansion + docker build -t $(FULL_IMAGE):latest -f Dockerfile . + docker tag $(FULL_IMAGE):latest $(FULL_IMAGE):$(TAG) + +.PHONY: push +push: container +ifeq ($(DOCKER_REGISTRY),gcr.io) + gcloud docker push $(PREFIX)/$(IMAGE):$(TAG) +else + docker push $(PREFIX)/$(IMAGE):$(TAG) +endif + +expansion: + cp -R ../../expansion ./opt + +binary: + cp ../../bin/linux-amd64/expandybird ./bin diff --git a/rootfs/manager/Dockerfile b/rootfs/manager/Dockerfile new file mode 100644 index 000000000..55bbe6b67 --- /dev/null +++ b/rootfs/manager/Dockerfile @@ -0,0 +1,4 @@ +FROM alpine:3.3 +COPY . / +EXPOSE 8080 +CMD ["/bin/manager", "--kubectl=/bin/kubectl"] diff --git a/rootfs/manager/Makefile b/rootfs/manager/Makefile new file mode 100644 index 000000000..886ca837a --- /dev/null +++ b/rootfs/manager/Makefile @@ -0,0 +1,27 @@ +DOCKER_REGISTRY := gcr.io +PREFIX := $(DOCKER_REGISTRY)/$(PROJECT) +IMAGE ?= manager +TAG ?= git-$(shell git rev-parse --short HEAD) +FULL_IMAGE := $(PREFIX)/$(IMAGE) + +KUBE_VERSION ?= v1.1.7 + +.PHONY: container +container: binary kubectl + docker build -t $(FULL_IMAGE):latest -f Dockerfile . + docker tag $(FULL_IMAGE):latest $(FULL_IMAGE):$(TAG) + +.PHONY: push +push: container +ifeq ($(DOCKER_REGISTRY),gcr.io) + gcloud docker push $(PREFIX)/$(IMAGE):$(TAG) +else + docker push $(PREFIX)/$(IMAGE):$(TAG) +endif + +binary: + cp ../../bin/linux-amd64/manager ./bin + +kubectl: + curl -fsSL -o bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl + chmod +x bin/kubectl diff --git a/rootfs/resourcifer/Dockerfile b/rootfs/resourcifer/Dockerfile new file mode 100644 index 000000000..fca4437c3 --- /dev/null +++ b/rootfs/resourcifer/Dockerfile @@ -0,0 +1,4 @@ +FROM alpine:3.3 +COPY . / +EXPOSE 8080 +CMD ["/bin/resourcifier", "--kubectl=/bin/kubectl"] diff --git a/rootfs/resourcifer/Makefile b/rootfs/resourcifer/Makefile new file mode 100644 index 000000000..56a21da77 --- /dev/null +++ b/rootfs/resourcifer/Makefile @@ -0,0 +1,27 @@ +DOCKER_REGISTRY := gcr.io +PREFIX := $(DOCKER_REGISTRY)/$(PROJECT) +IMAGE ?= resourcifier +TAG ?= git-$(shell git rev-parse --short HEAD) +FULL_IMAGE := $(PREFIX)/$(IMAGE) + +KUBE_VERSION ?= v1.1.7 + +.PHONY: container +container: binary kubectl + docker build -t $(FULL_IMAGE):latest -f Dockerfile . + docker tag $(FULL_IMAGE):latest $(FULL_IMAGE):$(TAG) + +.PHONY: push +push: container +ifeq ($(DOCKER_REGISTRY),gcr.io) + gcloud docker push $(PREFIX)/$(IMAGE):$(TAG) +else + docker push $(PREFIX)/$(IMAGE):$(TAG) +endif + +binary: + cp ../../bin/linux-amd64/resourcifier ./bin + +kubectl: + curl -fsSL -o bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/amd64/kubectl + chmod +x bin/kubectl From d3e4c4e052e22d8363bcb510c64f2782c63bf42d Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 29 Feb 2016 18:20:18 -0800 Subject: [PATCH 69/73] fix(gofmt): fix test-style target in Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4d52f72ed..bb052f0df 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ test-unit: .PHONY: .test-style test-style: lint vet - @if [ $(shell gofmt -e -l -s $(GO_DIRS) | wc -l) ]; then \ + @if [[ -z $(shell gofmt -e -l -s $(GO_DIRS) | wc -l) ]]; then \ echo "gofmt check failed:"; gofmt -e -d -s $(GO_DIRS); exit 1; \ fi From 8e3034cde06a78550abbf1f7725a8c099eebd475 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Tue, 1 Mar 2016 10:25:11 -0800 Subject: [PATCH 70/73] Revert "Merge pull request #290 from jackgr/release-prep" This reverts commit c3ee20302f0500014232aa35de3f360cf728d108, reversing changes made to 69f3b1d9b27477b3fce4afc9317017fe7d7f03b5. --- .../frobnitz/templates/wordpress.jinja | 2 +- .../frobnitz/templates/wordpress.jinja.schema | 2 +- chart/testdata/ill/templates/wordpress.jinja | 2 +- .../ill/templates/wordpress.jinja.schema | 2 +- dm/Makefile | 12 +++++------- dm/dm.go | 4 ++-- docs/pushing.md | 4 ++-- examples/bootstrap/bootstrap.yaml | 6 +++--- examples/wordpress/README.md | 2 +- examples/wordpress/wordpress.jinja | 2 +- examples/wordpress/wordpress.jinja.schema | 2 +- expandybird/test/ExpectedOutput.yaml | 4 ++-- expandybird/test/InvalidFileName.yaml | 2 +- expandybird/test/InvalidProperty.yaml | 2 +- expandybird/test/InvalidTypeName.yaml | 2 +- expandybird/test/MissingImports.yaml | 2 +- expandybird/test/MissingResourceName.yaml | 2 +- expandybird/test/MissingTypeName.yaml | 2 +- expandybird/test/TestArchive.tar | Bin 9728 -> 9728 bytes expandybird/test/ValidContent.yaml | 2 +- get-install.sh | 8 +++----- hack/dm-push.sh | 12 +++++------- include.mk | 2 +- install.yaml | 6 +++--- util/templateutil_test.go | 2 +- 25 files changed, 41 insertions(+), 47 deletions(-) diff --git a/chart/testdata/frobnitz/templates/wordpress.jinja b/chart/testdata/frobnitz/templates/wordpress.jinja index 62269a899..f34e4fec9 100644 --- a/chart/testdata/frobnitz/templates/wordpress.jinja +++ b/chart/testdata/frobnitz/templates/wordpress.jinja @@ -1,6 +1,6 @@ #helm:generate dm_template {% set PROPERTIES = properties or {} %} -{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-prod' %} +{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-testing' %} {% set NFS_SERVER = PROPERTIES['nfs-server'] or {} %} {% set NFS_SERVER_IP = NFS_SERVER['ip'] or '10.0.253.247' %} {% set NFS_SERVER_PORT = NFS_SERVER['port'] or 2049 %} diff --git a/chart/testdata/frobnitz/templates/wordpress.jinja.schema b/chart/testdata/frobnitz/templates/wordpress.jinja.schema index 5b4a8bc21..215b47e1e 100644 --- a/chart/testdata/frobnitz/templates/wordpress.jinja.schema +++ b/chart/testdata/frobnitz/templates/wordpress.jinja.schema @@ -8,7 +8,7 @@ info: properties: project: type: string - default: dm-k8s-prod + default: dm-k8s-testing description: Project location to load the images from. nfs-service: type: object diff --git a/chart/testdata/ill/templates/wordpress.jinja b/chart/testdata/ill/templates/wordpress.jinja index 62269a899..f34e4fec9 100644 --- a/chart/testdata/ill/templates/wordpress.jinja +++ b/chart/testdata/ill/templates/wordpress.jinja @@ -1,6 +1,6 @@ #helm:generate dm_template {% set PROPERTIES = properties or {} %} -{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-prod' %} +{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-testing' %} {% set NFS_SERVER = PROPERTIES['nfs-server'] or {} %} {% set NFS_SERVER_IP = NFS_SERVER['ip'] or '10.0.253.247' %} {% set NFS_SERVER_PORT = NFS_SERVER['port'] or 2049 %} diff --git a/chart/testdata/ill/templates/wordpress.jinja.schema b/chart/testdata/ill/templates/wordpress.jinja.schema index 5b4a8bc21..215b47e1e 100644 --- a/chart/testdata/ill/templates/wordpress.jinja.schema +++ b/chart/testdata/ill/templates/wordpress.jinja.schema @@ -8,7 +8,7 @@ info: properties: project: type: string - default: dm-k8s-prod + default: dm-k8s-testing description: Project location to load the images from. nfs-service: type: object diff --git a/dm/Makefile b/dm/Makefile index aa771203b..7ae51e886 100644 --- a/dm/Makefile +++ b/dm/Makefile @@ -14,7 +14,7 @@ SHELL := /bin/bash -GOLANG_CROSSPLATFORMS := darwin/386 darwin/amd64 freebsd/386 freebsd/amd64 freebsd/arm linux/386 linux/amd64 linux/arm windows/386 windows/amd64 +GOLANG_CROSSPLATFORMS="darwin/386 darwin/amd64 freebsd/386 freebsd/amd64 freebsd/arm linux/386 linux/amd64 linux/arm windows/386 windows/amd64" all: build binary @@ -22,15 +22,13 @@ build: docker build -t dm . binary: - - docker stop dm - - docker rm dm docker run --name dm dm - for platform in ${GOLANG_CROSSPLATFORMS}; do \ + for platform in $$GOLANG_CROSSPLATFORMS; do \ echo $$platform; \ docker cp dm:/go/src/dm/dm-$${platform%/*}-$${platform##*/} .; \ done clean: - - docker rm dm - - docker rmi dm - rm -f dm-* + docker rm dm + docker rmi dm + rm dm-* diff --git a/dm/dm.go b/dm/dm.go index b348605fd..03ee06dbb 100644 --- a/dm/dm.go +++ b/dm/dm.go @@ -272,10 +272,10 @@ func callService(path, method, action string, reader io.ReadCloser) { var URL *url.URL URL, err := url.Parse(*service) if err != nil { - panic(fmt.Errorf("cannot parse url (%s): %s\n", *service, err)) + panic(fmt.Errorf("cannot parse url (%s): %s\n", path, err)) } - URL.Path = strings.TrimRight(URL.Path, "/") + "/" + strings.TrimLeft(path, "/") + URL.Path = strings.TrimRight(URL.Path, "/") + "/" + strings.TrimLeft(path, "/") resp := callHTTP(URL.String(), method, action, reader) var j interface{} if err := json.Unmarshal([]byte(resp), &j); err != nil { diff --git a/docs/pushing.md b/docs/pushing.md index 381e7a28b..06c4faf37 100644 --- a/docs/pushing.md +++ b/docs/pushing.md @@ -6,7 +6,7 @@ This details the requirements and steps for doing a DM push. In order to build and push DM, you must: -* be an editor or owner on the GCP project `dm-k8s-prod` +* be an editor or owner on the GCP project `dm-k8s-testing` * have `docker` installed and runnable in your current environment * have `gcloud` installed * have `gsutil` installed @@ -17,7 +17,7 @@ To build and push the service containers: ``` $ cd ${GOPATH}/src/github.com/kubernetes/deployment-manager -$ export PROJECT=dm-k8s-prod +$ export PROJECT=dm-k8s-testing $ make push ``` diff --git a/examples/bootstrap/bootstrap.yaml b/examples/bootstrap/bootstrap.yaml index 4deabeb45..c36d38103 100644 --- a/examples/bootstrap/bootstrap.yaml +++ b/examples/bootstrap/bootstrap.yaml @@ -8,7 +8,7 @@ resources: container_port: 8080 external_service: false replicas: 2 - image: gcr.io/dm-k8s-prod/expandybird:latest + image: gcr.io/dm-k8s-testing/expandybird:latest labels: app: dm - name: resourcifier @@ -20,7 +20,7 @@ resources: container_port: 8080 external_service: false replicas: 2 - image: gcr.io/dm-k8s-prod/resourcifier:latest + image: gcr.io/dm-k8s-testing/resourcifier:latest labels: app: dm - name: manager @@ -32,6 +32,6 @@ resources: container_port: 8080 external_service: false replicas: 1 - image: gcr.io/dm-k8s-prod/manager:latest + image: gcr.io/dm-k8s-testing/manager:latest labels: app: dm diff --git a/examples/wordpress/README.md b/examples/wordpress/README.md index 177ff47c7..12573ba0e 100644 --- a/examples/wordpress/README.md +++ b/examples/wordpress/README.md @@ -42,7 +42,7 @@ The template contains the following variables: ``` {% set PROPERTIES = properties or {} %} -{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-prod' %} +{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-testing' %} {% set NFS_SERVER = PROPERTIES['nfs-server'] or {} %} {% set NFS_SERVER_IP = NFS_SERVER['ip'] or '10.0.253.247' %} {% set NFS_SERVER_PORT = NFS_SERVER['port'] or 2049 %} diff --git a/examples/wordpress/wordpress.jinja b/examples/wordpress/wordpress.jinja index 5855b2e8c..c3789b555 100644 --- a/examples/wordpress/wordpress.jinja +++ b/examples/wordpress/wordpress.jinja @@ -1,5 +1,5 @@ {% set PROPERTIES = properties or {} %} -{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-prod' %} +{% set PROJECT = PROPERTIES['project'] or 'dm-k8s-testing' %} {% set NFS_SERVER = PROPERTIES['nfs-server'] or {} %} {% set NFS_SERVER_IP = NFS_SERVER['ip'] or '10.0.253.247' %} {% set NFS_SERVER_PORT = NFS_SERVER['port'] or 2049 %} diff --git a/examples/wordpress/wordpress.jinja.schema b/examples/wordpress/wordpress.jinja.schema index 5b4a8bc21..215b47e1e 100644 --- a/examples/wordpress/wordpress.jinja.schema +++ b/examples/wordpress/wordpress.jinja.schema @@ -8,7 +8,7 @@ info: properties: project: type: string - default: dm-k8s-prod + default: dm-k8s-testing description: Project location to load the images from. nfs-service: type: object diff --git a/expandybird/test/ExpectedOutput.yaml b/expandybird/test/ExpectedOutput.yaml index 13e510d3c..24bd519a3 100644 --- a/expandybird/test/ExpectedOutput.yaml +++ b/expandybird/test/ExpectedOutput.yaml @@ -51,7 +51,7 @@ config: spec: containers: - env: [] - image: gcr.io/dm-k8s-prod/expandybird + image: gcr.io/dm-k8s-testing/expandybird name: expandybird ports: - containerPort: 8080 @@ -63,7 +63,7 @@ layout: properties: container_port: 8080 external_service: true - image: gcr.io/dm-k8s-prod/expandybird + image: gcr.io/dm-k8s-testing/expandybird labels: app: expandybird replicas: 3 diff --git a/expandybird/test/InvalidFileName.yaml b/expandybird/test/InvalidFileName.yaml index fd3800466..712426be2 100644 --- a/expandybird/test/InvalidFileName.yaml +++ b/expandybird/test/InvalidFileName.yaml @@ -19,4 +19,4 @@ resources: properties: service_port: 8080 target_port: 8080 - image: gcr.io/dm-k8s-prod/expandybird + image: gcr.io/dm-k8s-testing/expandybird diff --git a/expandybird/test/InvalidProperty.yaml b/expandybird/test/InvalidProperty.yaml index fd3d5edeb..7eeb78538 100644 --- a/expandybird/test/InvalidProperty.yaml +++ b/expandybird/test/InvalidProperty.yaml @@ -19,4 +19,4 @@ resources: properties: service_port: 8080 target_port: 8080 - invalidproperty: gcr.io/dm-k8s-prod/expandybird + invalidproperty: gcr.io/dm-k8s-testing/expandybird diff --git a/expandybird/test/InvalidTypeName.yaml b/expandybird/test/InvalidTypeName.yaml index e411c1b11..387e4a172 100644 --- a/expandybird/test/InvalidTypeName.yaml +++ b/expandybird/test/InvalidTypeName.yaml @@ -19,4 +19,4 @@ resources: properties: service_port: 8080 target_port: 8080 - image: gcr.io/dm-k8s-prod/expandybird + image: gcr.io/dm-k8s-testing/expandybird diff --git a/expandybird/test/MissingImports.yaml b/expandybird/test/MissingImports.yaml index 6a6741f8a..e6a24e6f6 100644 --- a/expandybird/test/MissingImports.yaml +++ b/expandybird/test/MissingImports.yaml @@ -18,4 +18,4 @@ resources: properties: service_port: 8080 target_port: 8080 - image: gcr.io/dm-k8s-prod/expandybird + image: gcr.io/dm-k8s-testing/expandybird diff --git a/expandybird/test/MissingResourceName.yaml b/expandybird/test/MissingResourceName.yaml index 32215e765..8ae93dace 100644 --- a/expandybird/test/MissingResourceName.yaml +++ b/expandybird/test/MissingResourceName.yaml @@ -18,4 +18,4 @@ resources: properties: service_port: 8080 target_port: 8080 - image: gcr.io/dm-k8s-prod/expandybird + image: gcr.io/dm-k8s-testing/expandybird diff --git a/expandybird/test/MissingTypeName.yaml b/expandybird/test/MissingTypeName.yaml index f246d99f8..65bd433a4 100644 --- a/expandybird/test/MissingTypeName.yaml +++ b/expandybird/test/MissingTypeName.yaml @@ -18,4 +18,4 @@ resources: properties: service_port: 8080 target_port: 8080 - image: gcr.io/dm-k8s-prod/expandybird + image: gcr.io/dm-k8s-testing/expandybird diff --git a/expandybird/test/TestArchive.tar b/expandybird/test/TestArchive.tar index 3b4e30e84dd0518737822fcf195bcb61183775db..2c364b00004513f120872ea7dfa10c6f4dd8daf0 100644 GIT binary patch delta 84 zcmZqhY4DlQDq(D(U}$7!Y-nh1W?*QjU|?u$Ze+}$U@$q6F=aC&<3kqqlGNgo%)Io? d&sfEoCUJBN0o9tB0TEEGiK(#(TrKB+834E97Hj|j delta 82 zcmZqhY4DlQDq&=*U}$7!W@>0;WMFKhU|?u$ZfwAyU@$q6F=aC&<3kpff};GC%`aKS enI`{b?-MdJGB-3gFg63KG%+ Date: Tue, 1 Mar 2016 10:31:38 -0800 Subject: [PATCH 71/73] Revert "Merge pull request #280 from jackgr/image-tags" This reverts commit 69f3b1d9b27477b3fce4afc9317017fe7d7f03b5, reversing changes made to e1c35b2e9d2755c94ec19dbb1b23e2759cd85789. --- expandybird/Makefile | 1 + include.mk | 2 -- manager/Makefile | 1 + resourcifier/Makefile | 1 + 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/expandybird/Makefile b/expandybird/Makefile index 16f0c7882..df97481fd 100644 --- a/expandybird/Makefile +++ b/expandybird/Makefile @@ -19,6 +19,7 @@ include ../include.mk DOCKER_REGISTRY := gcr.io PREFIX := $(DOCKER_REGISTRY)/$(PROJECT) IMAGE := expandybird +TAG := latest ROOT_DIR := $(abspath ./..) DIR = $(ROOT_DIR) diff --git a/include.mk b/include.mk index 28b957e61..fba7d5f4e 100644 --- a/include.mk +++ b/include.mk @@ -5,8 +5,6 @@ info: @echo "Project: ${PROJECT}" @echo "Image: ${IMAGE}" -TAG := $(shell echo `date +"%s"`_`date +"%N"`) - .PHONY: test-unit test-unit: @echo Running tests... diff --git a/manager/Makefile b/manager/Makefile index 209c874f2..2e3a2ad55 100644 --- a/manager/Makefile +++ b/manager/Makefile @@ -19,6 +19,7 @@ include ../include.mk DOCKER_REGISTRY := gcr.io PREFIX := $(DOCKER_REGISTRY)/$(PROJECT) IMAGE := manager +TAG := latest ROOT_DIR := $(abspath ./..) DIR = $(ROOT_DIR) diff --git a/resourcifier/Makefile b/resourcifier/Makefile index 9d6eebe1a..1b80a7dca 100644 --- a/resourcifier/Makefile +++ b/resourcifier/Makefile @@ -21,6 +21,7 @@ include ../include.mk DOCKER_REGISTRY := gcr.io PREFIX := $(DOCKER_REGISTRY)/$(PROJECT) IMAGE := resourcifier +TAG := latest ROOT_DIR := $(abspath ./..) DIR = $(ROOT_DIR) From a2c4950a613848c5757a6647c8ca3e96a23d357d Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Tue, 1 Mar 2016 12:20:48 -0800 Subject: [PATCH 72/73] fix(travis): remove duplicate `install:` --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 40e8462b0..6f0af72dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,6 @@ language: go go: - 1.6 -install: - - sudo pip install -r expandybird/requirements.txt - script: - make bootstrap test @@ -24,3 +21,4 @@ install: - mkdir -p $HOME/bin - tar -vxz -C $HOME/bin --strip=1 -f glide-$GLIDE_VERSION-linux-amd64.tar.gz - export PATH="$HOME/bin:$PATH" GLIDE_HOME="$HOME/.glide" + - sudo pip install -r expandybird/requirements.txt From 5f39a8f64f5b5b94139df6297392c9930090e8d8 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Tue, 1 Mar 2016 14:25:43 -0800 Subject: [PATCH 73/73] fix(travis): fix pip requirements.txt path --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6f0af72dc..c63fac3fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,4 +21,4 @@ install: - mkdir -p $HOME/bin - tar -vxz -C $HOME/bin --strip=1 -f glide-$GLIDE_VERSION-linux-amd64.tar.gz - export PATH="$HOME/bin:$PATH" GLIDE_HOME="$HOME/.glide" - - sudo pip install -r expandybird/requirements.txt + - sudo pip install -r expansion/requirements.txt