Commit 10eb74ab authored by Matt Butcher's avatar Matt Butcher Committed by GitHub

Merge pull request #1269 from technosophos/feat/1264-chart-apiversion

fix(chart): Chart.yaml now has an apiVersion field.
parents 62dfe05a e0227c75
...@@ -61,4 +61,7 @@ message Metadata { ...@@ -61,4 +61,7 @@ message Metadata {
// The URL to an icon file. // The URL to an icon file.
string icon = 9; string icon = 9;
// The API Version of this chart.
string apiVersion = 10;
} }
...@@ -85,6 +85,7 @@ func (c *createCmd) run() error { ...@@ -85,6 +85,7 @@ func (c *createCmd) run() error {
Name: chartname, Name: chartname,
Description: "A Helm chart for Kubernetes", Description: "A Helm chart for Kubernetes",
Version: "0.1.0", Version: "0.1.0",
ApiVersion: chartutil.ApiVersionV1,
} }
_, err := chartutil.Create(cfile, filepath.Dir(c.name)) _, err := chartutil.Create(cfile, filepath.Dir(c.name))
......
/*
Copyright 2016 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.
*/
package main
import (
"io/ioutil"
"os"
"testing"
"k8s.io/helm/pkg/chartutil"
)
func TestCreateCmd(t *testing.T) {
cname := "testchart"
// Make a temp dir
tdir, err := ioutil.TempDir("", "helm-create-")
if err != nil {
t.Fatal(err)
}
defer os.Remove(tdir)
// CD into it
pwd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
if err := os.Chdir(tdir); err != nil {
t.Fatal(err)
}
defer os.Chdir(pwd)
// Run a create
cmd := newCreateCmd(os.Stdout)
if err := cmd.RunE(cmd, []string{cname}); err != nil {
t.Errorf("Failed to run create: %s", err)
return
}
// Test that the chart is there
if fi, err := os.Stat(cname); err != nil {
t.Fatalf("no chart directory: %s", err)
} else if !fi.IsDir() {
t.Fatalf("chart is not directory")
}
c, err := chartutil.LoadDir(cname)
if err != nil {
t.Fatal(err)
}
if c.Metadata.Name != cname {
t.Errorf("Expected %q name, got %q", cname, c.Metadata.Name)
}
if c.Metadata.ApiVersion != chartutil.ApiVersionV1 {
t.Errorf("Wrong API version: %q", c.Metadata.ApiVersion)
}
}
...@@ -24,6 +24,9 @@ import ( ...@@ -24,6 +24,9 @@ import (
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
) )
// APIVersionV1 is the API version number for version 1.
const ApiVersionV1 = "v1"
// UnmarshalChartfile takes raw Chart.yaml data and unmarshals it. // UnmarshalChartfile takes raw Chart.yaml data and unmarshals it.
func UnmarshalChartfile(data []byte) (*chart.Metadata, error) { func UnmarshalChartfile(data []byte) (*chart.Metadata, error) {
y := &chart.Metadata{} y := &chart.Metadata{}
......
...@@ -39,6 +39,11 @@ func verifyChartfile(t *testing.T, f *chart.Metadata) { ...@@ -39,6 +39,11 @@ func verifyChartfile(t *testing.T, f *chart.Metadata) {
t.Fatal("Failed verifyChartfile because f is nil") t.Fatal("Failed verifyChartfile because f is nil")
} }
// Api instead of API because it was generated via protobuf.
if f.ApiVersion != ApiVersionV1 {
t.Errorf("Expected API Version %q, got %q", ApiVersionV1, f.ApiVersion)
}
if f.Name != "frobnitz" { if f.Name != "frobnitz" {
t.Errorf("Expected frobnitz, got %s", f.Name) t.Errorf("Expected frobnitz, got %s", f.Name)
} }
......
apiVersion: v1
name: frobnitz name: frobnitz
description: This is a frobnitz. description: This is a frobnitz.
version: "1.2.3" version: "1.2.3"
......
apiVersion: v1
name: frobnitz name: frobnitz
description: This is a frobnitz. description: This is a frobnitz.
version: "1.2.3" version: "1.2.3"
......
...@@ -69,6 +69,8 @@ type Metadata struct { ...@@ -69,6 +69,8 @@ type Metadata struct {
Engine string `protobuf:"bytes,8,opt,name=engine" json:"engine,omitempty"` Engine string `protobuf:"bytes,8,opt,name=engine" json:"engine,omitempty"`
// The URL to an icon file. // The URL to an icon file.
Icon string `protobuf:"bytes,9,opt,name=icon" json:"icon,omitempty"` Icon string `protobuf:"bytes,9,opt,name=icon" json:"icon,omitempty"`
// The API Version of this chart.
ApiVersion string `protobuf:"bytes,10,opt,name=apiVersion" json:"apiVersion,omitempty"`
} }
func (m *Metadata) Reset() { *m = Metadata{} } func (m *Metadata) Reset() { *m = Metadata{} }
...@@ -92,23 +94,23 @@ func init() { ...@@ -92,23 +94,23 @@ func init() {
func init() { proto.RegisterFile("hapi/chart/metadata.proto", fileDescriptor2) } func init() { proto.RegisterFile("hapi/chart/metadata.proto", fileDescriptor2) }
var fileDescriptor2 = []byte{ var fileDescriptor2 = []byte{
// 275 bytes of a gzipped FileDescriptorProto // 287 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x91, 0x4b, 0x4b, 0xc4, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x51, 0x4b, 0x4b, 0xc4, 0x30,
0x14, 0x85, 0x9d, 0x47, 0x5f, 0xb7, 0x9b, 0xe1, 0x22, 0x43, 0x74, 0x55, 0xba, 0x72, 0xd5, 0x01, 0x10, 0x76, 0x1f, 0x6d, 0xb7, 0xd3, 0xcb, 0x32, 0xc8, 0x12, 0x3d, 0x48, 0xe9, 0xc9, 0x53, 0x17,
0x05, 0x71, 0x2d, 0x88, 0x0b, 0x9d, 0x8e, 0x0c, 0x8a, 0xe0, 0x2e, 0xb6, 0xc1, 0x06, 0x6d, 0x53, 0x14, 0xc4, 0xb3, 0x20, 0x1e, 0x74, 0xbb, 0xb2, 0xf8, 0x00, 0x6f, 0xb1, 0x0d, 0x36, 0x68, 0x9b,
0x92, 0xa8, 0xf8, 0x9f, 0xfc, 0x91, 0x26, 0xb7, 0xf3, 0x5a, 0xb8, 0x28, 0x9c, 0x73, 0xbe, 0xde, 0x92, 0x44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0x13, 0x08, 0x6e, 0x57, 0x8f, 0x0f, 0xf7, 0xb3, 0xd1, 0x75, 0xf4, 0x12, 0xd0, 0x83, 0x7f, 0xdd, 0xa5, 0x23, 0x08, 0x1e, 0xb3, 0xdb, 0x6c, 0xfd, 0x9c, 0xcd, 0x0f, 0x30, 0x04,
0xba, 0xd7, 0x90, 0xae, 0xe0, 0xe2, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x72, 0xdf, 0x74, 0xb5, 0x9f, 0xef, 0x66, 0xfd, 0x70, 0x7f, 0x37, 0x1f, 0x5d, 0x05, 0x2f, 0x1e, 0xad, 0xf3, 0xea, 0xd3, 0x13,
0x01, 0x00, 0x00, 0x9d, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x65, 0x86, 0x8b, 0xda, 0xbf, 0x01, 0x00, 0x00,
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment