From b2d07ccea68d2c5c6fa5509817c4f3aa6effbd39 Mon Sep 17 00:00:00 2001 From: Dave Cunningham Date: Wed, 16 Mar 2016 16:31:52 -0400 Subject: [PATCH] Change common.Template to hold a chart. Comment out (most) broken code --- cmd/dm/dm.go | 12 ++++++++--- cmd/expandybird/expander/expander_test.go | 2 ++ pkg/common/types.go | 26 +++++++++++++++++++---- pkg/util/templateutil.go | 3 +++ 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/cmd/dm/dm.go b/cmd/dm/dm.go index 0d586e876..9b7480f5f 100644 --- a/cmd/dm/dm.go +++ b/cmd/dm/dm.go @@ -20,9 +20,9 @@ import ( "github.com/ghodss/yaml" "github.com/kubernetes/helm/pkg/common" - "github.com/kubernetes/helm/pkg/util" + //"github.com/kubernetes/helm/pkg/util" - "archive/tar" + //"archive/tar" "bytes" "encoding/json" "flag" @@ -33,7 +33,7 @@ import ( "net/http" "net/url" "os" - "strconv" +// "strconv" "strings" "time" ) @@ -179,6 +179,7 @@ func execute() { path := fmt.Sprintf("types/%s/metadata", url.QueryEscape(args[1])) callService(path, "GET", "get metadata for type", nil) +/* case "expand": template := loadTemplate(args) callService("expand", "POST", "expand configuration", marshalTemplate(template)) @@ -186,6 +187,7 @@ func execute() { template := loadTemplate(args) action := fmt.Sprintf("deploy configuration named %s", template.Name) callService("deployments", "POST", action, marshalTemplate(template)) +*/ case "list": callService("deployments", "GET", "list deployments", nil) case "getcredential": @@ -242,11 +244,13 @@ func execute() { path := fmt.Sprintf("deployments/%s", url.QueryEscape(args[1])) action := fmt.Sprintf("delete deployment named %s", args[1]) callService(path, "DELETE", action, nil) +/* case "update": template := loadTemplate(args) path := fmt.Sprintf("deployments/%s", url.QueryEscape(template.Name)) action := fmt.Sprintf("delete deployment named %s", template.Name) callService(path, "PUT", action, marshalTemplate(template)) +*/ case "deployed-types": callService("types", "GET", "list deployed types", nil) case "deployed-instances": @@ -318,6 +322,7 @@ func callHTTP(path, method, action string, reader io.ReadCloser) string { return string(body) } +/* func loadTemplate(args []string) *common.Template { var template *common.Template var err error @@ -404,6 +409,7 @@ func buildTemplateFromType(t string) *common.Template { return template } +*/ func marshalTemplate(template *common.Template) io.ReadCloser { j, err := json.Marshal(template) diff --git a/cmd/expandybird/expander/expander_test.go b/cmd/expandybird/expander/expander_test.go index 2a86b28f6..5fb5929fa 100644 --- a/cmd/expandybird/expander/expander_test.go +++ b/cmd/expandybird/expander/expander_test.go @@ -109,10 +109,12 @@ func TestExpandTemplateFromReader(t *testing.T) { testExpandTemplateFromFile(t, validFileName, baseName, importFileNames, util.NewTemplateFromReader) } +/* func TestExpandTemplateFromArchive(t *testing.T) { baseName := path.Base(validFileName) testExpandTemplateFromFile(t, archiveFileName, baseName, nil, util.NewTemplateFromArchive) } +*/ var ExpanderTestCases = []ExpanderTestCase{ { diff --git a/pkg/common/types.go b/pkg/common/types.go index 67ef834a6..717ddaf05 100644 --- a/pkg/common/types.go +++ b/pkg/common/types.go @@ -97,21 +97,39 @@ type Manifest struct { Layout *Layout `json:"layout,omitempty"` } +type Expander struct { + Name string `json:"name"` + Entrypoint string `json:"entry_point"` +} + +type ChartFile struct { + Path string `json:"path"` // Path from the root of the chart. + Content string `json:"content"` // Base64 encoded file content. +} + +type Chart struct { + Name string `json:"name"` + Expander *Expander `json:"expander"` + Schema interface{} `json:"schema"` + Files []*ChartFile `json:"files"` +} + // Template describes a set of resources to be deployed. // Manager expands a Template into a Configuration, which // describes the set in a form that can be instantiated. type Template struct { Name string `json:"name"` - Content string `json:"content"` - Imports []*ImportFile `json:"imports"` + ChartInvocation *Resource `json:"content"` + Chart Chart `json:"chart"` } +/* // ImportFile describes a base64 encoded file imported by a Template. type ImportFile struct { Name string `json:"name,omitempty"` - Path string `json:"path,omitempty"` // Actual URL for the file - Content string `json:"content"` + Chart Chart `json:"chart"` } +*/ // Configuration describes a set of resources in a form // that can be instantiated. diff --git a/pkg/util/templateutil.go b/pkg/util/templateutil.go index ea111448c..5eab0586e 100644 --- a/pkg/util/templateutil.go +++ b/pkg/util/templateutil.go @@ -14,8 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ + package util +/* import ( "archive/tar" "fmt" @@ -194,3 +196,4 @@ func collectImportFiles(importFileNames []string) ([]*common.ImportFile, error) return imports, nil } +*/