From fedeac77a09f673c0409a26c62e5a72f1d3d0523 Mon Sep 17 00:00:00 2001 From: jackgr Date: Tue, 29 Mar 2016 13:55:19 -0700 Subject: [PATCH 1/7] Set default repo format and type --- cmd/manager/chartrepos.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/manager/chartrepos.go b/cmd/manager/chartrepos.go index 64ae8ddd8..2f13b3947 100644 --- a/cmd/manager/chartrepos.go +++ b/cmd/manager/chartrepos.go @@ -58,6 +58,14 @@ func addChartRepoHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.C return nil } + if string(cr.Format) == "" { + cr.Type = repo.GCSRepoType + } + + if string(cr.Type) == "" { + cr.Type = repo.GCSRepoType + } + if err := c.Manager.AddRepo(cr); err != nil { httputil.BadRequest(w, r, err) return nil From 94fbdda7e4a536e06864e901c804fc71f743082f Mon Sep 17 00:00:00 2001 From: jackgr Date: Tue, 29 Mar 2016 13:55:44 -0700 Subject: [PATCH 2/7] Correct invalid assumption about test repository --- pkg/repo/gcs_repo_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/repo/gcs_repo_test.go b/pkg/repo/gcs_repo_test.go index b2aa952f6..e71719947 100644 --- a/pkg/repo/gcs_repo_test.go +++ b/pkg/repo/gcs_repo_test.go @@ -65,15 +65,17 @@ func TestListCharts(t *testing.T) { t.Fatal(err) } - if len(charts) != 1 { - t.Fatalf("expected one chart in list, got %d", len(charts)) + if len(charts) < 1 { + t.Fatalf("expected at least one chart in test repository %s", TestRepoURL) } - haveName := charts[0] - wantName := TestArchiveName - if haveName != wantName { - t.Fatalf("expected chart named %s, got %s", wantName, haveName) + for _, ch := range charts { + if ch == TestArchiveName { + return + } } + + t.Fatalf("expected chart named %s in test repository %s", TestArchiveName, TestRepoURL) } func TestListChartsWithShouldFindRegex(t *testing.T) { From fb0e722ed953cca51d5695f8fc34f48e8a86fcc4 Mon Sep 17 00:00:00 2001 From: jackgr Date: Tue, 29 Mar 2016 13:56:24 -0700 Subject: [PATCH 3/7] Fix incorrect expansion validation --- pkg/expansion/validate.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/expansion/validate.go b/pkg/expansion/validate.go index 02f97c0d9..a012df194 100644 --- a/pkg/expansion/validate.go +++ b/pkg/expansion/validate.go @@ -17,6 +17,8 @@ limitations under the License. package expansion import ( + "github.com/kubernetes/helm/pkg/chart" + "fmt" ) @@ -32,8 +34,13 @@ func ValidateRequest(request *ServiceRequest) error { chartInv := request.ChartInvocation chartFile := request.Chart.Chartfile - if chartInv.Type != chartFile.Name { - return fmt.Errorf("Request chart invocation does not match provided chart") + l, err := chart.Parse(chartInv.Type) + if err != nil { + return fmt.Errorf("cannot parse chart reference %s: %s", chartInv.Type, err) + } + + if l.Name != chartFile.Name { + return fmt.Errorf("Chart invocation type (%s) does not match provided chart (%s)", chartInv.Type, chartFile.Name) } if chartFile.Expander == nil { From e46a1eb752dcde3ce4dd045772a0176b0ece601f Mon Sep 17 00:00:00 2001 From: jackgr Date: Tue, 29 Mar 2016 13:56:44 -0700 Subject: [PATCH 4/7] Port replicatedservice template to chart format --- examples/charts/replicatedservice-v3.tgz | Bin 0 -> 2847 bytes examples/charts/replicatedservice/Chart.yaml | 7 + .../templates/replicatedservice.py | 195 ++++++++++++++++++ .../templates/replicatedservice.py.schema | 91 ++++++++ 4 files changed, 293 insertions(+) create mode 100644 examples/charts/replicatedservice-v3.tgz create mode 100644 examples/charts/replicatedservice/Chart.yaml create mode 100644 examples/charts/replicatedservice/templates/replicatedservice.py create mode 100644 examples/charts/replicatedservice/templates/replicatedservice.py.schema diff --git a/examples/charts/replicatedservice-v3.tgz b/examples/charts/replicatedservice-v3.tgz new file mode 100644 index 0000000000000000000000000000000000000000..eefd10ae0d3bda3832c4403dba4890c00e9af08a GIT binary patch literal 2847 zcmV+)3*hu0iwFP>>-tsz1MM1XZ`;T*pZO~m2~gRnEX$500|J5~b)3Rz;slP7;$RrY zid%m#_)hlG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t=e5${BJk12)tzJiuHGSjn*&rM8z zg)yYgtsDnopO2S4-D&ugG|T9+PPn!wa(qZbTUBOQ<3fpPf7W5F-e>uGPK1aVP3oGS ztD7!VEzb(ph4rDXju(jqjmX4YW2s14xry5BkMqy#r>gR-=l5t@aw#J)u;*y<5x)AW zF_E!4kJH{!L$Nh=ElQfaM>P3No#*+Ta)Tr535AEMRs*BF!+oWGWHHP0RE`f1!&nqi z?@kEVEqbAtAG&29KobF<`X{z{0(YRhslUzQH%xDDsgRPR*^GU9JSl5dQN1U54C z)E$iQcu5CtPV#qL-m6{g;{6xQM<}ik929yuFd0zI=)#cFNS*e~n8XK6_MHCk?bFn^ zNKHa@ut=keN+xVHW8IXFb4NnM4(fYnry8d63Yk4oz6mkq~4;!Dfs-Um5jH+E%0`q5urYcDB=N+(Pv+uZ5 zfXAT~+aMFq20uY~G|TmqeVw(1+Rd#9Ef!N{Vs2$Xg>M`bLrDiJ62TL5F7cKbCh9-B x18$*(7FuYbg%(<9p@kM&XrYA`T4 Date: Tue, 29 Mar 2016 14:14:15 -0700 Subject: [PATCH 5/7] Remove invalid assertion in expandybird service wrapper --- cmd/expandybird/expander/expander.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cmd/expandybird/expander/expander.go b/cmd/expandybird/expander/expander.go index 6a4a7fb6a..1acceea68 100644 --- a/cmd/expandybird/expander/expander.go +++ b/cmd/expandybird/expander/expander.go @@ -58,11 +58,6 @@ func (e *expander) ExpandChart(request *expansion.ServiceRequest) (*expansion.Se chartFile := request.Chart.Chartfile chartMembers := request.Chart.Members - if chartFile.Expander.Name != "ExpandyBird" { - message := fmt.Sprintf("ExpandyBird cannot do this kind of expansion: ", chartFile.Expander.Name) - return nil, fmt.Errorf("%s: %s", chartInv.Name, message) - } - if e.ExpansionBinary == "" { message := fmt.Sprintf("expansion binary cannot be empty") return nil, fmt.Errorf("%s: %s", chartInv.Name, message) From ffb7978333bc12ce7ef92487539af202021d5f6b Mon Sep 17 00:00:00 2001 From: jackgr Date: Tue, 29 Mar 2016 14:40:32 -0700 Subject: [PATCH 6/7] Fix chart names in expandybird tests --- cmd/expandybird/expander/expander_test.go | 105 ++++++++++++++-------- 1 file changed, 68 insertions(+), 37 deletions(-) diff --git a/cmd/expandybird/expander/expander_test.go b/cmd/expandybird/expander/expander_test.go index 8e1b172c2..28a79a9a6 100644 --- a/cmd/expandybird/expander/expander_test.go +++ b/cmd/expandybird/expander/expander_test.go @@ -18,6 +18,7 @@ package expander import ( "fmt" + "path/filepath" "reflect" "runtime" "strings" @@ -42,10 +43,40 @@ func content(lines []string) []byte { return []byte(strings.Join(lines, "\n") + "\n") } -// funcName returns the name of the calling function. -func funcName() string { +func getChartNameFromPC(pc uintptr) string { + rf := runtime.FuncForPC(pc) + fn := rf.Name() + bn := filepath.Base(fn) + split := strings.Split(bn, ".") + if len(split) > 1 { + split = split[1:] + } + + cn := fmt.Sprintf("%s-1.2.3.tgz", split[0]) + return cn +} + +func getChartURLFromPC(pc uintptr) string { + cn := getChartNameFromPC(pc) + cu := fmt.Sprintf("gs://kubernetes-charts-testing/%s", cn) + return cu +} + +func getTestChartName(t *testing.T) string { + pc, _, _, _ := runtime.Caller(1) + cu := getChartURLFromPC(pc) + cl, err := chart.Parse(cu) + if err != nil { + t.Fatalf("cannot parse chart reference %s: %s", cu, err) + } + + return cl.Name +} + +func getTestChartURL() string { pc, _, _, _ := runtime.Caller(1) - return runtime.FuncForPC(pc).Name() + cu := getChartURLFromPC(pc) + return cu } func testExpansion(t *testing.T, req *expansion.ServiceRequest, @@ -85,11 +116,11 @@ func TestEmptyJinja(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, }, Members: []*chart.Member{ @@ -113,11 +144,11 @@ func TestEmptyPython(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: pyExpander, }, Members: []*chart.Member{ @@ -144,11 +175,11 @@ func TestSimpleJinja(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, }, Members: []*chart.Member{ @@ -181,11 +212,11 @@ func TestSimplePython(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: pyExpander, }, Members: []*chart.Member{ @@ -220,7 +251,7 @@ func TestPropertiesJinja(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), Properties: map[string]interface{}{ "prop1": 3.0, "prop2": "foo", @@ -228,7 +259,7 @@ func TestPropertiesJinja(t *testing.T) { }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, }, Members: []*chart.Member{ @@ -266,7 +297,7 @@ func TestPropertiesPython(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), Properties: map[string]interface{}{ "prop1": 3.0, "prop2": "foo", @@ -274,7 +305,7 @@ func TestPropertiesPython(t *testing.T) { }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: pyExpander, }, Members: []*chart.Member{ @@ -314,11 +345,11 @@ func TestMultiFileJinja(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, }, Members: []*chart.Member{ @@ -372,7 +403,7 @@ func TestSchema(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), Properties: map[string]interface{}{ "prop1": 3.0, "prop2": "foo", @@ -380,7 +411,7 @@ func TestSchema(t *testing.T) { }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, Schema: "Schema.yaml", }, @@ -423,7 +454,7 @@ func TestSchemaFail(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), Properties: map[string]interface{}{ "prop1": 3.0, "prop3": "foo", @@ -431,7 +462,7 @@ func TestSchemaFail(t *testing.T) { }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, Schema: "Schema.yaml", }, @@ -464,11 +495,11 @@ func TestMultiFileJinjaMissing(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, }, Members: []*chart.Member{ @@ -490,11 +521,11 @@ func TestMultiFilePython(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: pyExpander, }, Members: []*chart.Member{ @@ -550,11 +581,11 @@ func TestMultiFilePythonMissing(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: pyExpander, }, Members: []*chart.Member{ @@ -578,7 +609,7 @@ func TestWrongChartName(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ @@ -594,7 +625,7 @@ func TestWrongChartName(t *testing.T) { }, }, nil, // Response - "Request chart invocation does not match provided chart", + "does not match provided chart", ) } @@ -604,11 +635,11 @@ func TestEntrypointNotFound(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, }, Members: []*chart.Member{}, @@ -625,11 +656,11 @@ func TestMalformedResource(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, }, Members: []*chart.Member{ @@ -654,11 +685,11 @@ func TestResourceNoName(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, }, Members: []*chart.Member{ @@ -683,11 +714,11 @@ func TestResourceNoType(t *testing.T) { &expansion.ServiceRequest{ ChartInvocation: &common.Resource{ Name: "test_invocation", - Type: funcName(), + Type: getTestChartURL(), }, Chart: &chart.Content{ Chartfile: &chart.Chartfile{ - Name: funcName(), + Name: getTestChartName(t), Expander: jinjaExpander, }, Members: []*chart.Member{ From 2710a538677aa68a15b2e826ce1ebe03fa781cba Mon Sep 17 00:00:00 2001 From: jackgr Date: Tue, 29 Mar 2016 14:42:26 -0700 Subject: [PATCH 7/7] Fix repo format default error --- cmd/manager/chartrepos.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/manager/chartrepos.go b/cmd/manager/chartrepos.go index 2f13b3947..8a1ab1304 100644 --- a/cmd/manager/chartrepos.go +++ b/cmd/manager/chartrepos.go @@ -59,7 +59,7 @@ func addChartRepoHandlerFunc(w http.ResponseWriter, r *http.Request, c *router.C } if string(cr.Format) == "" { - cr.Type = repo.GCSRepoType + cr.Format = repo.GCSRepoFormat } if string(cr.Type) == "" {