ref(*): use go conventions for naming types

pull/3945/head
Adam Reese 8 years ago
parent 36536d77ba
commit c5a76deba3
No known key found for this signature in database
GPG Key ID: 06F35E60A7A18DD6

@ -91,7 +91,7 @@ func (c *createCmd) run() error {
Description: "A Helm chart for Kubernetes", Description: "A Helm chart for Kubernetes",
Version: "0.1.0", Version: "0.1.0",
AppVersion: "1.0", AppVersion: "1.0",
ApiVersion: chartutil.ApiVersionV1, APIVersion: chartutil.APIVersionv1,
} }
if c.starter != "" { if c.starter != "" {

@ -67,8 +67,8 @@ func TestCreateCmd(t *testing.T) {
if c.Metadata.Name != cname { if c.Metadata.Name != cname {
t.Errorf("Expected %q name, got %q", cname, c.Metadata.Name) t.Errorf("Expected %q name, got %q", cname, c.Metadata.Name)
} }
if c.Metadata.ApiVersion != chartutil.ApiVersionV1 { if c.Metadata.APIVersion != chartutil.APIVersionv1 {
t.Errorf("Wrong API version: %q", c.Metadata.ApiVersion) t.Errorf("Wrong API version: %q", c.Metadata.APIVersion)
} }
} }
@ -139,8 +139,8 @@ func TestCreateStarterCmd(t *testing.T) {
if c.Metadata.Name != cname { if c.Metadata.Name != cname {
t.Errorf("Expected %q name, got %q", cname, c.Metadata.Name) t.Errorf("Expected %q name, got %q", cname, c.Metadata.Name)
} }
if c.Metadata.ApiVersion != chartutil.ApiVersionV1 { if c.Metadata.APIVersion != chartutil.APIVersionv1 {
t.Errorf("Wrong API version: %q", c.Metadata.ApiVersion) t.Errorf("Wrong API version: %q", c.Metadata.APIVersion)
} }
if l := len(c.Templates); l != 6 { if l := len(c.Templates); l != 6 {

@ -44,7 +44,7 @@ type getCmd struct {
release string release string
out io.Writer out io.Writer
client helm.Interface client helm.Interface
version int32 version int
} }
func newGetCmd(client helm.Interface, out io.Writer) *cobra.Command { func newGetCmd(client helm.Interface, out io.Writer) *cobra.Command {
@ -69,7 +69,7 @@ func newGetCmd(client helm.Interface, out io.Writer) *cobra.Command {
}, },
} }
cmd.Flags().Int32Var(&get.version, "revision", 0, "get the named release with revision") cmd.Flags().IntVar(&get.version, "revision", 0, "get the named release with revision")
cmd.AddCommand(newGetValuesCmd(nil, out)) cmd.AddCommand(newGetValuesCmd(nil, out))
cmd.AddCommand(newGetManifestCmd(nil, out)) cmd.AddCommand(newGetManifestCmd(nil, out))

@ -35,7 +35,7 @@ type getHooksCmd struct {
release string release string
out io.Writer out io.Writer
client helm.Interface client helm.Interface
version int32 version int
} }
func newGetHooksCmd(client helm.Interface, out io.Writer) *cobra.Command { func newGetHooksCmd(client helm.Interface, out io.Writer) *cobra.Command {
@ -56,7 +56,7 @@ func newGetHooksCmd(client helm.Interface, out io.Writer) *cobra.Command {
return ghc.run() return ghc.run()
}, },
} }
cmd.Flags().Int32Var(&ghc.version, "revision", 0, "get the named release with revision") cmd.Flags().IntVar(&ghc.version, "revision", 0, "get the named release with revision")
return cmd return cmd
} }

@ -37,7 +37,7 @@ type getManifestCmd struct {
release string release string
out io.Writer out io.Writer
client helm.Interface client helm.Interface
version int32 version int
} }
func newGetManifestCmd(client helm.Interface, out io.Writer) *cobra.Command { func newGetManifestCmd(client helm.Interface, out io.Writer) *cobra.Command {
@ -59,7 +59,7 @@ func newGetManifestCmd(client helm.Interface, out io.Writer) *cobra.Command {
}, },
} }
cmd.Flags().Int32Var(&get.version, "revision", 0, "get the named release with revision") cmd.Flags().IntVar(&get.version, "revision", 0, "get the named release with revision")
return cmd return cmd
} }

@ -35,7 +35,7 @@ type getValuesCmd struct {
allValues bool allValues bool
out io.Writer out io.Writer
client helm.Interface client helm.Interface
version int32 version int
} }
func newGetValuesCmd(client helm.Interface, out io.Writer) *cobra.Command { func newGetValuesCmd(client helm.Interface, out io.Writer) *cobra.Command {
@ -57,7 +57,7 @@ func newGetValuesCmd(client helm.Interface, out io.Writer) *cobra.Command {
}, },
} }
cmd.Flags().Int32Var(&get.version, "revision", 0, "get the named release with revision") cmd.Flags().IntVar(&get.version, "revision", 0, "get the named release with revision")
cmd.Flags().BoolVarP(&get.allValues, "all", "a", false, "dump all (computed) values") cmd.Flags().BoolVarP(&get.allValues, "all", "a", false, "dump all (computed) values")
return cmd return cmd
} }

@ -73,7 +73,7 @@ type releaseCase struct {
resp *release.Release resp *release.Release
// Rels are the available releases at the start of the test. // Rels are the available releases at the start of the test.
rels []*release.Release rels []*release.Release
responses map[string]release.TestRun_Status responses map[string]release.TestRunStatus
} }
// tempHelmHome sets up a Helm Home in a temp dir. // tempHelmHome sets up a Helm Home in a temp dir.

@ -31,7 +31,7 @@ import (
) )
type releaseInfo struct { type releaseInfo struct {
Revision int32 `json:"revision"` Revision int `json:"revision"`
Updated string `json:"updated"` Updated string `json:"updated"`
Status string `json:"status"` Status string `json:"status"`
Chart string `json:"chart"` Chart string `json:"chart"`
@ -57,7 +57,7 @@ The historical release set is printed as a formatted table, e.g:
` `
type historyCmd struct { type historyCmd struct {
max int32 max int
rls string rls string
out io.Writer out io.Writer
helmc helm.Interface helmc helm.Interface
@ -86,7 +86,7 @@ func newHistoryCmd(c helm.Interface, w io.Writer) *cobra.Command {
} }
f := cmd.Flags() f := cmd.Flags()
f.Int32Var(&his.max, "max", 256, "maximum number of revision to include in history") f.IntVar(&his.max, "max", 256, "maximum number of revision to include in history")
f.UintVar(&his.colWidth, "col-width", 60, "specifies the max column width of output") f.UintVar(&his.colWidth, "col-width", 60, "specifies the max column width of output")
f.StringVarP(&his.outputFormat, "output", "o", "table", "prints the output in the specified format (json|table|yaml)") f.StringVarP(&his.outputFormat, "output", "o", "table", "prints the output in the specified format (json|table|yaml)")

@ -27,7 +27,7 @@ import (
) )
func TestHistoryCmd(t *testing.T) { func TestHistoryCmd(t *testing.T) {
mk := func(name string, vers int32, code rpb.Status_Code) *rpb.Release { mk := func(name string, vers int, code rpb.StatusCode) *rpb.Release {
return helm.ReleaseMock(&helm.MockReleaseOptions{ return helm.ReleaseMock(&helm.MockReleaseOptions{
Name: name, Name: name,
Version: vers, Version: vers,

@ -136,8 +136,8 @@ func (l *listCmd) run() error {
helm.ReleaseListLimit(l.limit), helm.ReleaseListLimit(l.limit),
helm.ReleaseListOffset(l.offset), helm.ReleaseListOffset(l.offset),
helm.ReleaseListFilter(l.filter), helm.ReleaseListFilter(l.filter),
helm.ReleaseListSort(int32(sortBy)), helm.ReleaseListSort(int(sortBy)),
helm.ReleaseListOrder(int32(sortOrder)), helm.ReleaseListOrder(int(sortOrder)),
helm.ReleaseListStatuses(stats), helm.ReleaseListStatuses(stats),
helm.ReleaseListNamespace(l.namespace), helm.ReleaseListNamespace(l.namespace),
) )
@ -164,7 +164,7 @@ func (l *listCmd) run() error {
// filterList returns a list scrubbed of old releases. // filterList returns a list scrubbed of old releases.
func filterList(rels []*release.Release) []*release.Release { func filterList(rels []*release.Release) []*release.Release {
idx := map[string]int32{} idx := map[string]int{}
for _, r := range rels { for _, r := range rels {
name, version := r.Name, r.Version name, version := r.Name, r.Version
@ -187,9 +187,9 @@ func filterList(rels []*release.Release) []*release.Release {
} }
// statusCodes gets the list of status codes that are to be included in the results. // statusCodes gets the list of status codes that are to be included in the results.
func (l *listCmd) statusCodes() []release.Status_Code { func (l *listCmd) statusCodes() []release.StatusCode {
if l.all { if l.all {
return []release.Status_Code{ return []release.StatusCode{
release.Status_UNKNOWN, release.Status_UNKNOWN,
release.Status_DEPLOYED, release.Status_DEPLOYED,
release.Status_DELETED, release.Status_DELETED,
@ -200,7 +200,7 @@ func (l *listCmd) statusCodes() []release.Status_Code {
release.Status_PENDING_ROLLBACK, release.Status_PENDING_ROLLBACK,
} }
} }
status := []release.Status_Code{} status := []release.StatusCode{}
if l.deployed { if l.deployed {
status = append(status, release.Status_DEPLOYED) status = append(status, release.Status_DEPLOYED)
} }

@ -32,42 +32,42 @@ func TestReleaseTesting(t *testing.T) {
name: "basic test", name: "basic test",
args: []string{"example-release"}, args: []string{"example-release"},
flags: []string{}, flags: []string{},
responses: map[string]release.TestRun_Status{"PASSED: green lights everywhere": release.TestRun_SUCCESS}, responses: map[string]release.TestRunStatus{"PASSED: green lights everywhere": release.TestRun_SUCCESS},
err: false, err: false,
}, },
{ {
name: "test failure", name: "test failure",
args: []string{"example-fail"}, args: []string{"example-fail"},
flags: []string{}, flags: []string{},
responses: map[string]release.TestRun_Status{"FAILURE: red lights everywhere": release.TestRun_FAILURE}, responses: map[string]release.TestRunStatus{"FAILURE: red lights everywhere": release.TestRun_FAILURE},
err: true, err: true,
}, },
{ {
name: "test unknown", name: "test unknown",
args: []string{"example-unknown"}, args: []string{"example-unknown"},
flags: []string{}, flags: []string{},
responses: map[string]release.TestRun_Status{"UNKNOWN: yellow lights everywhere": release.TestRun_UNKNOWN}, responses: map[string]release.TestRunStatus{"UNKNOWN: yellow lights everywhere": release.TestRun_UNKNOWN},
err: false, err: false,
}, },
{ {
name: "test error", name: "test error",
args: []string{"example-error"}, args: []string{"example-error"},
flags: []string{}, flags: []string{},
responses: map[string]release.TestRun_Status{"ERROR: yellow lights everywhere": release.TestRun_FAILURE}, responses: map[string]release.TestRunStatus{"ERROR: yellow lights everywhere": release.TestRun_FAILURE},
err: true, err: true,
}, },
{ {
name: "test running", name: "test running",
args: []string{"example-running"}, args: []string{"example-running"},
flags: []string{}, flags: []string{},
responses: map[string]release.TestRun_Status{"RUNNING: things are happpeningggg": release.TestRun_RUNNING}, responses: map[string]release.TestRunStatus{"RUNNING: things are happpeningggg": release.TestRun_RUNNING},
err: false, err: false,
}, },
{ {
name: "multiple tests example", name: "multiple tests example",
args: []string{"example-suite"}, args: []string{"example-suite"},
flags: []string{}, flags: []string{},
responses: map[string]release.TestRun_Status{ responses: map[string]release.TestRunStatus{
"RUNNING: things are happpeningggg": release.TestRun_RUNNING, "RUNNING: things are happpeningggg": release.TestRun_RUNNING,
"PASSED: party time": release.TestRun_SUCCESS, "PASSED: party time": release.TestRun_SUCCESS,
"RUNNING: things are happening again": release.TestRun_RUNNING, "RUNNING: things are happening again": release.TestRun_RUNNING,

@ -36,7 +36,7 @@ second is a revision (version) number. To see revision numbers, run
type rollbackCmd struct { type rollbackCmd struct {
name string name string
revision int32 revision int
dryRun bool dryRun bool
recreate bool recreate bool
force bool force bool
@ -69,7 +69,7 @@ func newRollbackCmd(c helm.Interface, out io.Writer) *cobra.Command {
return fmt.Errorf("invalid revision number '%q': %s", args[1], err) return fmt.Errorf("invalid revision number '%q': %s", args[1], err)
} }
rollback.revision = int32(v64) rollback.revision = int(v64)
rollback.client = ensureHelmClient(rollback.client) rollback.client = ensureHelmClient(rollback.client)
return rollback.run() return rollback.run()
}, },

@ -48,7 +48,7 @@ type statusCmd struct {
release string release string
out io.Writer out io.Writer
client helm.Interface client helm.Interface
version int32 version int
outfmt string outfmt string
} }
@ -74,7 +74,7 @@ func newStatusCmd(client helm.Interface, out io.Writer) *cobra.Command {
}, },
} }
cmd.PersistentFlags().Int32Var(&status.version, "revision", 0, "if set, display the status of the named release with revision") cmd.PersistentFlags().IntVar(&status.version, "revision", 0, "if set, display the status of the named release with revision")
cmd.PersistentFlags().StringVarP(&status.outfmt, "output", "o", "", "output the status in the specified format (json or yaml)") cmd.PersistentFlags().StringVarP(&status.outfmt, "output", "o", "", "output the status in the specified format (json or yaml)")
return cmd return cmd
@ -116,7 +116,7 @@ func PrintStatus(out io.Writer, res *hapi.GetReleaseStatusResponse) {
fmt.Fprintf(out, "LAST DEPLOYED: %s\n", res.Info.LastDeployed) fmt.Fprintf(out, "LAST DEPLOYED: %s\n", res.Info.LastDeployed)
} }
fmt.Fprintf(out, "NAMESPACE: %s\n", res.Namespace) fmt.Fprintf(out, "NAMESPACE: %s\n", res.Namespace)
fmt.Fprintf(out, "STATUS: %s\n", res.Info.Status.Code) fmt.Fprintf(out, "STATUS: %s\n", res.Info.Status.Code.String())
fmt.Fprintf(out, "\n") fmt.Fprintf(out, "\n")
if len(res.Info.Status.Resources) > 0 { if len(res.Info.Status.Resources) > 0 {
re := regexp.MustCompile(" +") re := regexp.MustCompile(" +")

@ -28,10 +28,8 @@ import (
"k8s.io/helm/pkg/hapi/chart" "k8s.io/helm/pkg/hapi/chart"
) )
// ApiVersionV1 is the API version number for version 1. // APIVersionv1 is the API version number for version 1.
// const APIVersionv1 = "v1" // nolint
// This is ApiVersionV1 instead of APIVersionV1 to match the protobuf-generated name.
const ApiVersionV1 = "v1" // nolint
// 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) {

@ -40,8 +40,8 @@ func verifyChartfile(t *testing.T, f *chart.Metadata, name string) {
} }
// Api instead of API because it was generated via protobuf. // Api instead of API because it was generated via protobuf.
if f.ApiVersion != ApiVersionV1 { if f.APIVersion != APIVersionv1 {
t.Errorf("Expected API Version %q, got %q", ApiVersionV1, f.ApiVersion) t.Errorf("Expected API Version %q, got %q", APIVersionv1, f.APIVersion)
} }
if f.Name != name { if f.Name != name {

@ -1,25 +1,5 @@
package chart package chart
type Metadata_Engine int32
const (
Metadata_UNKNOWN Metadata_Engine = 0
Metadata_GOTPL Metadata_Engine = 1
)
var Metadata_Engine_name = map[int32]string{
0: "UNKNOWN",
1: "GOTPL",
}
var Metadata_Engine_value = map[string]int32{
"UNKNOWN": 0,
"GOTPL": 1,
}
func (x Metadata_Engine) String() string {
return Metadata_Engine_name[int32(x)]
}
// Maintainer describes a Chart maintainer. // Maintainer describes a Chart maintainer.
type Maintainer struct { type Maintainer struct {
// Name is a user name or organization name // Name is a user name or organization name
@ -53,7 +33,7 @@ type Metadata struct {
// The URL to an icon file. // The URL to an icon file.
Icon string `json:"icon,omitempty"` Icon string `json:"icon,omitempty"`
// The API Version of this chart. // The API Version of this chart.
ApiVersion string `json:"apiVersion,omitempty"` APIVersion string `json:"apiVersion,omitempty"`
// The condition to check to enable chart // The condition to check to enable chart
Condition string `json:"condition,omitempty"` Condition string `json:"condition,omitempty"`
// The tags to check to enable chart // The tags to check to enable chart

@ -2,72 +2,54 @@ package release
import "time" import "time"
type Hook_Event int32 type HookEvent int
const ( const (
Hook_UNKNOWN Hook_Event = 0 Hook_UNKNOWN HookEvent = iota
Hook_PRE_INSTALL Hook_Event = 1 Hook_PRE_INSTALL
Hook_POST_INSTALL Hook_Event = 2 Hook_POST_INSTALL
Hook_PRE_DELETE Hook_Event = 3 Hook_PRE_DELETE
Hook_POST_DELETE Hook_Event = 4 Hook_POST_DELETE
Hook_PRE_UPGRADE Hook_Event = 5 Hook_PRE_UPGRADE
Hook_POST_UPGRADE Hook_Event = 6 Hook_POST_UPGRADE
Hook_PRE_ROLLBACK Hook_Event = 7 Hook_PRE_ROLLBACK
Hook_POST_ROLLBACK Hook_Event = 8 Hook_POST_ROLLBACK
Hook_RELEASE_TEST_SUCCESS Hook_Event = 9 Hook_RELEASE_TEST_SUCCESS
Hook_RELEASE_TEST_FAILURE Hook_Event = 10 Hook_RELEASE_TEST_FAILURE
) )
var Hook_Event_name = map[int32]string{ var eventNames = [...]string{
0: "UNKNOWN", "UNKNOWN",
1: "PRE_INSTALL", "PRE_INSTALL",
2: "POST_INSTALL", "POST_INSTALL",
3: "PRE_DELETE", "PRE_DELETE",
4: "POST_DELETE", "POST_DELETE",
5: "PRE_UPGRADE", "PRE_UPGRADE",
6: "POST_UPGRADE", "POST_UPGRADE",
7: "PRE_ROLLBACK", "PRE_ROLLBACK",
8: "POST_ROLLBACK", "POST_ROLLBACK",
9: "RELEASE_TEST_SUCCESS", "RELEASE_TEST_SUCCESS",
10: "RELEASE_TEST_FAILURE", "RELEASE_TEST_FAILURE",
}
var Hook_Event_value = map[string]int32{
"UNKNOWN": 0,
"PRE_INSTALL": 1,
"POST_INSTALL": 2,
"PRE_DELETE": 3,
"POST_DELETE": 4,
"PRE_UPGRADE": 5,
"POST_UPGRADE": 6,
"PRE_ROLLBACK": 7,
"POST_ROLLBACK": 8,
"RELEASE_TEST_SUCCESS": 9,
"RELEASE_TEST_FAILURE": 10,
} }
func (x Hook_Event) String() string { func (x HookEvent) String() string { return eventNames[x] }
return Hook_Event_name[int32(x)]
}
type Hook_DeletePolicy int32 type HookDeletePolicy int
const ( const (
Hook_SUCCEEDED Hook_DeletePolicy = 0 Hook_SUCCEEDED HookDeletePolicy = iota
Hook_FAILED Hook_DeletePolicy = 1 Hook_FAILED
Hook_BEFORE_HOOK_CREATION Hook_DeletePolicy = 2 Hook_BEFORE_HOOK_CREATION
) )
var Hook_DeletePolicy_name = map[int32]string{ var deletePolicyNames = [...]string{
0: "SUCCEEDED", "SUCCEEDED",
1: "FAILED", "FAILED",
2: "BEFORE_HOOK_CREATION", "BEFORE_HOOK_CREATION",
}
var Hook_DeletePolicy_value = map[string]int32{
"SUCCEEDED": 0,
"FAILED": 1,
"BEFORE_HOOK_CREATION": 2,
} }
func (x HookDeletePolicy) String() string { return deletePolicyNames[x] }
// Hook defines a hook object. // Hook defines a hook object.
type Hook struct { type Hook struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
@ -78,11 +60,11 @@ type Hook struct {
// Manifest is the manifest contents. // Manifest is the manifest contents.
Manifest string `json:"manifest,omitempty"` Manifest string `json:"manifest,omitempty"`
// Events are the events that this hook fires on. // Events are the events that this hook fires on.
Events []Hook_Event `json:"events,omitempty"` Events []HookEvent `json:"events,omitempty"`
// LastRun indicates the date/time this was last run. // LastRun indicates the date/time this was last run.
LastRun time.Time `json:"last_run,omitempty"` LastRun time.Time `json:"last_run,omitempty"`
// Weight indicates the sort order for execution among similar Hook type // Weight indicates the sort order for execution among similar Hook type
Weight int32 `json:"weight,omitempty"` Weight int `json:"weight,omitempty"`
// DeletePolicies are the policies that indicate when to delete the hook // DeletePolicies are the policies that indicate when to delete the hook
DeletePolicies []Hook_DeletePolicy `json:"delete_policies,omitempty"` DeletePolicies []HookDeletePolicy `json:"delete_policies,omitempty"`
} }

@ -18,8 +18,8 @@ type Release struct {
Manifest string `json:"manifest,omitempty"` Manifest string `json:"manifest,omitempty"`
// Hooks are all of the hooks declared for this release. // Hooks are all of the hooks declared for this release.
Hooks []*Hook `json:"hooks,omitempty"` Hooks []*Hook `json:"hooks,omitempty"`
// Version is an int32 which represents the version of the release. // Version is an int which represents the version of the release.
Version int32 `json:"version,omitempty"` Version int `json:"version,omitempty"`
// Namespace is the kubernetes namespace of the release. // Namespace is the kubernetes namespace of the release.
Namespace string `json:"namespace,omitempty"` Namespace string `json:"namespace,omitempty"`
} }

@ -1,58 +1,45 @@
package release package release
type Status_Code int32 type StatusCode int
const ( const (
// Status_UNKNOWN indicates that a release is in an uncertain state. // Status_UNKNOWN indicates that a release is in an uncertain state.
Status_UNKNOWN Status_Code = 0 Status_UNKNOWN StatusCode = iota
// Status_DEPLOYED indicates that the release has been pushed to Kubernetes. // Status_DEPLOYED indicates that the release has been pushed to Kubernetes.
Status_DEPLOYED Status_Code = 1 Status_DEPLOYED
// Status_DELETED indicates that a release has been deleted from Kubermetes. // Status_DELETED indicates that a release has been deleted from Kubermetes.
Status_DELETED Status_Code = 2 Status_DELETED
// Status_SUPERSEDED indicates that this release object is outdated and a newer one exists. // Status_SUPERSEDED indicates that this release object is outdated and a newer one exists.
Status_SUPERSEDED Status_Code = 3 Status_SUPERSEDED
// Status_FAILED indicates that the release was not successfully deployed. // Status_FAILED indicates that the release was not successfully deployed.
Status_FAILED Status_Code = 4 Status_FAILED
// Status_DELETING indicates that a delete operation is underway. // Status_DELETING indicates that a delete operation is underway.
Status_DELETING Status_Code = 5 Status_DELETING
// Status_PENDING_INSTALL indicates that an install operation is underway. // Status_PENDING_INSTALL indicates that an install operation is underway.
Status_PENDING_INSTALL Status_Code = 6 Status_PENDING_INSTALL
// Status_PENDING_UPGRADE indicates that an upgrade operation is underway. // Status_PENDING_UPGRADE indicates that an upgrade operation is underway.
Status_PENDING_UPGRADE Status_Code = 7 Status_PENDING_UPGRADE
// Status_PENDING_ROLLBACK indicates that an rollback operation is underway. // Status_PENDING_ROLLBACK indicates that an rollback operation is underway.
Status_PENDING_ROLLBACK Status_Code = 8 Status_PENDING_ROLLBACK
) )
var Status_Code_name = map[int32]string{ var statusCodeNames = [...]string{
0: "UNKNOWN", "UNKNOWN",
1: "DEPLOYED", "DEPLOYED",
2: "DELETED", "DELETED",
3: "SUPERSEDED", "SUPERSEDED",
4: "FAILED", "FAILED",
5: "DELETING", "DELETING",
6: "PENDING_INSTALL", "PENDING_INSTALL",
7: "PENDING_UPGRADE", "PENDING_UPGRADE",
8: "PENDING_ROLLBACK", "PENDING_ROLLBACK",
}
var Status_Code_value = map[string]int32{
"UNKNOWN": 0,
"DEPLOYED": 1,
"DELETED": 2,
"SUPERSEDED": 3,
"FAILED": 4,
"DELETING": 5,
"PENDING_INSTALL": 6,
"PENDING_UPGRADE": 7,
"PENDING_ROLLBACK": 8,
} }
func (x Status_Code) String() string { func (x StatusCode) String() string { return statusCodeNames[x] }
return Status_Code_name[int32(x)]
}
// Status defines the status of a release. // Status defines the status of a release.
type Status struct { type Status struct {
Code Status_Code `json:"code,omitempty"` Code StatusCode `json:"code,omitempty"`
// Cluster resources as kubectl would print them. // Cluster resources as kubectl would print them.
Resources string `json:"resources,omitempty"` Resources string `json:"resources,omitempty"`
// Contains the rendered templates/NOTES.txt if available // Contains the rendered templates/NOTES.txt if available

@ -2,35 +2,27 @@ package release
import "time" import "time"
type TestRun_Status int32 type TestRunStatus int
const ( const (
TestRun_UNKNOWN TestRun_Status = 0 TestRun_UNKNOWN TestRunStatus = iota
TestRun_SUCCESS TestRun_Status = 1 TestRun_SUCCESS
TestRun_FAILURE TestRun_Status = 2 TestRun_FAILURE
TestRun_RUNNING TestRun_Status = 3 TestRun_RUNNING
) )
var TestRun_Status_name = map[int32]string{ var testRunStatusNames = [...]string{
0: "UNKNOWN", "UNKNOWN",
1: "SUCCESS", "SUCCESS",
2: "FAILURE", "FAILURE",
3: "RUNNING", "RUNNING",
}
var TestRun_Status_value = map[string]int32{
"UNKNOWN": 0,
"SUCCESS": 1,
"FAILURE": 2,
"RUNNING": 3,
} }
func (x TestRun_Status) String() string { func (x TestRunStatus) String() string { return testRunStatusNames[x] }
return TestRun_Status_name[int32(x)]
}
type TestRun struct { type TestRun struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Status TestRun_Status `json:"status,omitempty"` Status TestRunStatus `json:"status,omitempty"`
Info string `json:"info,omitempty"` Info string `json:"info,omitempty"`
StartedAt time.Time `json:"started_at,omitempty"` StartedAt time.Time `json:"started_at,omitempty"`
CompletedAt time.Time `json:"completed_at,omitempty"` CompletedAt time.Time `json:"completed_at,omitempty"`

@ -6,49 +6,36 @@ import (
) )
// SortBy defines sort operations. // SortBy defines sort operations.
type ListSort_SortBy int32 type ListSortBy int
const ( const (
ListSort_UNKNOWN ListSort_SortBy = 0 ListSort_UNKNOWN ListSortBy = iota
ListSort_NAME ListSort_SortBy = 1 ListSort_NAME
ListSort_LAST_RELEASED ListSort_SortBy = 2 ListSort_LAST_RELEASED
) )
var ListSort_SortBy_name = map[int32]string{ var sortByNames = [...]string{
0: "UNKNOWN", "UNKNOWN",
1: "NAME", "NAME",
2: "LAST_RELEASED", "LAST_RELEASED",
}
var ListSort_SortBy_value = map[string]int32{
"UNKNOWN": 0,
"NAME": 1,
"LAST_RELEASED": 2,
} }
func (x ListSort_SortBy) String() string { func (x ListSortBy) String() string { return sortByNames[x] }
return ListSort_SortBy_name[int32(x)]
}
// SortOrder defines sort orders to augment sorting operations. // SortOrder defines sort orders to augment sorting operations.
type ListSort_SortOrder int32 type ListSortOrder int
const ( const (
ListSort_ASC ListSort_SortOrder = 0 ListSort_ASC ListSortOrder = iota
ListSort_DESC ListSort_SortOrder = 1 ListSort_DESC
) )
var ListSort_SortOrder_name = map[int32]string{ var sortOrderNames = [...]string{
0: "ASC", "ASC",
1: "DESC", "DESC",
}
var ListSort_SortOrder_value = map[string]int32{
"ASC": 0,
"DESC": 1,
} }
func (x ListSort_SortOrder) String() string { func (x ListSortOrder) String() string { return sortOrderNames[x] }
return ListSort_SortOrder_name[int32(x)]
}
// ListReleasesRequest requests a list of releases. // ListReleasesRequest requests a list of releases.
// //
@ -65,14 +52,14 @@ type ListReleasesRequest struct {
// cause the next batch to return a set of results starting with 'dennis'. // cause the next batch to return a set of results starting with 'dennis'.
Offset string `json:"offset,omityempty"` Offset string `json:"offset,omityempty"`
// SortBy is the sort field that the ListReleases server should sort data before returning. // SortBy is the sort field that the ListReleases server should sort data before returning.
SortBy ListSort_SortBy `json:"sort_by,omityempty"` SortBy ListSortBy `json:"sort_by,omityempty"`
// Filter is a regular expression used to filter which releases should be listed. // Filter is a regular expression used to filter which releases should be listed.
// //
// Anything that matches the regexp will be included in the results. // Anything that matches the regexp will be included in the results.
Filter string `json:"filter,omityempty"` Filter string `json:"filter,omityempty"`
// SortOrder is the ordering directive used for sorting. // SortOrder is the ordering directive used for sorting.
SortOrder ListSort_SortOrder `json:"sort_order,omityempty"` SortOrder ListSortOrder `json:"sort_order,omityempty"`
StatusCodes []release.Status_Code `json:"status_codes,omityempty"` StatusCodes []release.StatusCode `json:"status_codes,omityempty"`
// Namespace is the filter to select releases only from a specific namespace. // Namespace is the filter to select releases only from a specific namespace.
Namespace string `json:"namespace,omityempty"` Namespace string `json:"namespace,omityempty"`
} }
@ -95,7 +82,7 @@ type GetReleaseStatusRequest struct {
// Name is the name of the release // Name is the name of the release
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
// Version is the version of the release // Version is the version of the release
Version int32 `json:"version,omitempty"` Version int `json:"version,omitempty"`
} }
// GetReleaseStatusResponse is the response indicating the status of the named release. // GetReleaseStatusResponse is the response indicating the status of the named release.
@ -113,7 +100,7 @@ type GetReleaseContentRequest struct {
// The name of the release // The name of the release
Name string `json:"name,omityempty"` Name string `json:"name,omityempty"`
// Version is the version of the release // Version is the version of the release
Version int32 `json:"version,omityempty"` Version int `json:"version,omityempty"`
} }
// UpdateReleaseRequest updates a release. // UpdateReleaseRequest updates a release.
@ -152,7 +139,7 @@ type RollbackReleaseRequest struct {
// DisableHooks causes the server to skip running any hooks for the rollback // DisableHooks causes the server to skip running any hooks for the rollback
DisableHooks bool `json:"disable_hooks,omityempty"` DisableHooks bool `json:"disable_hooks,omityempty"`
// Version is the version of the release to deploy. // Version is the version of the release to deploy.
Version int32 `json:"version,omityempty"` Version int `json:"version,omityempty"`
// Performs pods restart for resources if applicable // Performs pods restart for resources if applicable
Recreate bool `json:"recreate,omityempty"` Recreate bool `json:"recreate,omityempty"`
// timeout specifies the max amount of time any kubernetes client command can run. // timeout specifies the max amount of time any kubernetes client command can run.
@ -216,7 +203,7 @@ type GetHistoryRequest struct {
// The name of the release. // The name of the release.
Name string `json:"name,omityempty"` Name string `json:"name,omityempty"`
// The maximum number of releases to include. // The maximum number of releases to include.
Max int32 `json:"max,omityempty"` Max int `json:"max,omityempty"`
} }
// TestReleaseRequest is a request to get the status of a release. // TestReleaseRequest is a request to get the status of a release.
@ -232,5 +219,5 @@ type TestReleaseRequest struct {
// TestReleaseResponse represents a message from executing a test // TestReleaseResponse represents a message from executing a test
type TestReleaseResponse struct { type TestReleaseResponse struct {
Msg string `json:"msg,omityempty"` Msg string `json:"msg,omityempty"`
Status release.TestRun_Status `json:"status,omityempty"` Status release.TestRunStatus `json:"status,omityempty"`
} }

@ -198,7 +198,7 @@ func (c *Client) RollbackRelease(rlsName string, opts ...RollbackOption) (*relea
} }
// ReleaseStatus returns the given release's status. // ReleaseStatus returns the given release's status.
func (c *Client) ReleaseStatus(rlsName string, version int32) (*hapi.GetReleaseStatusResponse, error) { func (c *Client) ReleaseStatus(rlsName string, version int) (*hapi.GetReleaseStatusResponse, error) {
reqOpts := c.opts reqOpts := c.opts
req := &reqOpts.statusReq req := &reqOpts.statusReq
req.Name = rlsName req.Name = rlsName
@ -211,7 +211,7 @@ func (c *Client) ReleaseStatus(rlsName string, version int32) (*hapi.GetReleaseS
} }
// ReleaseContent returns the configuration for a given release. // ReleaseContent returns the configuration for a given release.
func (c *Client) ReleaseContent(name string, version int32) (*release.Release, error) { func (c *Client) ReleaseContent(name string, version int) (*release.Release, error) {
reqOpts := c.opts reqOpts := c.opts
req := &reqOpts.contentReq req := &reqOpts.contentReq
req.Name = name req.Name = name
@ -224,7 +224,7 @@ func (c *Client) ReleaseContent(name string, version int32) (*release.Release, e
} }
// ReleaseHistory returns a release's revision history. // ReleaseHistory returns a release's revision history.
func (c *Client) ReleaseHistory(rlsName string, max int32) ([]*release.Release, error) { func (c *Client) ReleaseHistory(rlsName string, max int) ([]*release.Release, error) {
reqOpts := c.opts reqOpts := c.opts
req := &reqOpts.histReq req := &reqOpts.histReq
req.Name = rlsName req.Name = rlsName

@ -31,7 +31,7 @@ import (
// FakeClient implements Interface // FakeClient implements Interface
type FakeClient struct { type FakeClient struct {
Rels []*release.Release Rels []*release.Release
Responses map[string]release.TestRun_Status Responses map[string]release.TestRunStatus
Opts options Opts options
} }
@ -108,7 +108,7 @@ func (c *FakeClient) RollbackRelease(rlsName string, opts ...RollbackOption) (*r
} }
// ReleaseStatus returns a release status response with info from the matching release name. // ReleaseStatus returns a release status response with info from the matching release name.
func (c *FakeClient) ReleaseStatus(rlsName string, version int32) (*hapi.GetReleaseStatusResponse, error) { func (c *FakeClient) ReleaseStatus(rlsName string, version int) (*hapi.GetReleaseStatusResponse, error) {
for _, rel := range c.Rels { for _, rel := range c.Rels {
if rel.Name == rlsName { if rel.Name == rlsName {
return &hapi.GetReleaseStatusResponse{ return &hapi.GetReleaseStatusResponse{
@ -122,7 +122,7 @@ func (c *FakeClient) ReleaseStatus(rlsName string, version int32) (*hapi.GetRele
} }
// ReleaseContent returns the configuration for the matching release name in the fake release client. // ReleaseContent returns the configuration for the matching release name in the fake release client.
func (c *FakeClient) ReleaseContent(rlsName string, version int32) (*release.Release, error) { func (c *FakeClient) ReleaseContent(rlsName string, version int) (*release.Release, error) {
for _, rel := range c.Rels { for _, rel := range c.Rels {
if rel.Name == rlsName { if rel.Name == rlsName {
return rel, nil return rel, nil
@ -132,7 +132,7 @@ func (c *FakeClient) ReleaseContent(rlsName string, version int32) (*release.Rel
} }
// ReleaseHistory returns a release's revision history. // ReleaseHistory returns a release's revision history.
func (c *FakeClient) ReleaseHistory(rlsName string, max int32) ([]*release.Release, error) { func (c *FakeClient) ReleaseHistory(rlsName string, max int) ([]*release.Release, error) {
return c.Rels, nil return c.Rels, nil
} }
@ -147,7 +147,7 @@ func (c *FakeClient) RunReleaseTest(rlsName string, opts ...ReleaseTestOption) (
for m, s := range c.Responses { for m, s := range c.Responses {
wg.Add(1) wg.Add(1)
go func(msg string, status release.TestRun_Status) { go func(msg string, status release.TestRunStatus) {
defer wg.Done() defer wg.Done()
results <- &hapi.TestReleaseResponse{Msg: msg, Status: status} results <- &hapi.TestReleaseResponse{Msg: msg, Status: status}
}(m, s) }(m, s)
@ -179,9 +179,9 @@ metadata:
// MockReleaseOptions allows for user-configurable options on mock release objects. // MockReleaseOptions allows for user-configurable options on mock release objects.
type MockReleaseOptions struct { type MockReleaseOptions struct {
Name string Name string
Version int32 Version int
Chart *chart.Chart Chart *chart.Chart
StatusCode release.Status_Code StatusCode release.StatusCode
Namespace string Namespace string
} }
@ -194,7 +194,7 @@ func ReleaseMock(opts *MockReleaseOptions) *release.Release {
name = "testrelease-" + string(rand.Intn(100)) name = "testrelease-" + string(rand.Intn(100))
} }
var version int32 = 1 var version int = 1
if opts.Version != 0 { if opts.Version != 0 {
version = opts.Version version = opts.Version
} }
@ -241,7 +241,7 @@ func ReleaseMock(opts *MockReleaseOptions) *release.Release {
Path: "pre-install-hook.yaml", Path: "pre-install-hook.yaml",
Manifest: MockHookTemplate, Manifest: MockHookTemplate,
LastRun: date, LastRun: date,
Events: []release.Hook_Event{release.Hook_PRE_INSTALL}, Events: []release.HookEvent{release.Hook_PRE_INSTALL},
}, },
}, },
Manifest: MockManifest, Manifest: MockManifest,

@ -40,9 +40,9 @@ func TestListReleases_VerifyOptions(t *testing.T) {
var limit = 2 var limit = 2
var offset = "offset" var offset = "offset"
var filter = "filter" var filter = "filter"
var sortBy = int32(2) var sortBy = 2
var sortOrd = int32(1) var sortOrd = 1
var codes = []rls.Status_Code{ var codes = []rls.StatusCode{
rls.Status_FAILED, rls.Status_FAILED,
rls.Status_DELETED, rls.Status_DELETED,
rls.Status_DEPLOYED, rls.Status_DEPLOYED,
@ -55,8 +55,8 @@ func TestListReleases_VerifyOptions(t *testing.T) {
Limit: int64(limit), Limit: int64(limit),
Offset: offset, Offset: offset,
Filter: filter, Filter: filter,
SortBy: hapi.ListSort_SortBy(sortBy), SortBy: hapi.ListSortBy(sortBy),
SortOrder: hapi.ListSort_SortOrder(sortOrd), SortOrder: hapi.ListSortOrder(sortOrd),
StatusCodes: codes, StatusCodes: codes,
Namespace: namespace, Namespace: namespace,
} }
@ -240,7 +240,7 @@ func TestRollbackRelease_VerifyOptions(t *testing.T) {
// Options testdata // Options testdata
var disableHooks = true var disableHooks = true
var releaseName = "test" var releaseName = "test"
var revision = int32(2) var revision = 2
var dryRun = true var dryRun = true
// Expected RollbackReleaseRequest message // Expected RollbackReleaseRequest message
@ -283,7 +283,7 @@ func TestRollbackRelease_VerifyOptions(t *testing.T) {
func TestReleaseStatus_VerifyOptions(t *testing.T) { func TestReleaseStatus_VerifyOptions(t *testing.T) {
// Options testdata // Options testdata
var releaseName = "test" var releaseName = "test"
var revision = int32(2) var revision = 2
// Expected GetReleaseStatusRequest message // Expected GetReleaseStatusRequest message
exp := &hapi.GetReleaseStatusRequest{ exp := &hapi.GetReleaseStatusRequest{
@ -317,7 +317,7 @@ func TestReleaseContent_VerifyOptions(t *testing.T) {
t.Skip("refactoring out") t.Skip("refactoring out")
// Options testdata // Options testdata
var releaseName = "test" var releaseName = "test"
var revision = int32(2) var revision = 2
// Expected GetReleaseContentRequest message // Expected GetReleaseContentRequest message
exp := &hapi.GetReleaseContentRequest{ exp := &hapi.GetReleaseContentRequest{

@ -28,11 +28,11 @@ type Interface interface {
InstallRelease(chStr, namespace string, opts ...InstallOption) (*release.Release, error) InstallRelease(chStr, namespace string, opts ...InstallOption) (*release.Release, error)
InstallReleaseFromChart(chart *chart.Chart, namespace string, opts ...InstallOption) (*release.Release, error) InstallReleaseFromChart(chart *chart.Chart, namespace string, opts ...InstallOption) (*release.Release, error)
DeleteRelease(rlsName string, opts ...DeleteOption) (*hapi.UninstallReleaseResponse, error) DeleteRelease(rlsName string, opts ...DeleteOption) (*hapi.UninstallReleaseResponse, error)
ReleaseStatus(rlsName string, version int32) (*hapi.GetReleaseStatusResponse, error) ReleaseStatus(rlsName string, version int) (*hapi.GetReleaseStatusResponse, error)
UpdateRelease(rlsName, chStr string, opts ...UpdateOption) (*release.Release, error) UpdateRelease(rlsName, chStr string, opts ...UpdateOption) (*release.Release, error)
UpdateReleaseFromChart(rlsName string, chart *chart.Chart, opts ...UpdateOption) (*release.Release, error) UpdateReleaseFromChart(rlsName string, chart *chart.Chart, opts ...UpdateOption) (*release.Release, error)
RollbackRelease(rlsName string, opts ...RollbackOption) (*release.Release, error) RollbackRelease(rlsName string, opts ...RollbackOption) (*release.Release, error)
ReleaseContent(rlsName string, version int32) (*release.Release, error) ReleaseContent(rlsName string, version int) (*release.Release, error)
ReleaseHistory(rlsName string, max int32) ([]*release.Release, error) ReleaseHistory(rlsName string, max int) ([]*release.Release, error)
RunReleaseTest(rlsName string, opts ...ReleaseTestOption) (<-chan *hapi.TestReleaseResponse, <-chan error) RunReleaseTest(rlsName string, opts ...ReleaseTestOption) (<-chan *hapi.TestReleaseResponse, <-chan error)
} }

@ -116,24 +116,24 @@ func ReleaseListLimit(limit int) ReleaseListOption {
} }
// ReleaseListOrder specifies how to order a list of releases. // ReleaseListOrder specifies how to order a list of releases.
func ReleaseListOrder(order int32) ReleaseListOption { func ReleaseListOrder(order int) ReleaseListOption {
return func(opts *options) { return func(opts *options) {
opts.listReq.SortOrder = hapi.ListSort_SortOrder(order) opts.listReq.SortOrder = hapi.ListSortOrder(order)
} }
} }
// ReleaseListSort specifies how to sort a release list. // ReleaseListSort specifies how to sort a release list.
func ReleaseListSort(sort int32) ReleaseListOption { func ReleaseListSort(sort int) ReleaseListOption {
return func(opts *options) { return func(opts *options) {
opts.listReq.SortBy = hapi.ListSort_SortBy(sort) opts.listReq.SortBy = hapi.ListSortBy(sort)
} }
} }
// ReleaseListStatuses specifies which status codes should be returned. // ReleaseListStatuses specifies which status codes should be returned.
func ReleaseListStatuses(statuses []release.Status_Code) ReleaseListOption { func ReleaseListStatuses(statuses []release.StatusCode) ReleaseListOption {
return func(opts *options) { return func(opts *options) {
if len(statuses) == 0 { if len(statuses) == 0 {
statuses = []release.Status_Code{release.Status_DEPLOYED} statuses = []release.StatusCode{release.Status_DEPLOYED}
} }
opts.listReq.StatusCodes = statuses opts.listReq.StatusCodes = statuses
} }
@ -306,7 +306,7 @@ func RollbackForce(force bool) RollbackOption {
} }
// RollbackVersion sets the version of the release to deploy. // RollbackVersion sets the version of the release to deploy.
func RollbackVersion(ver int32) RollbackOption { func RollbackVersion(ver int) RollbackOption {
return func(opts *options) { return func(opts *options) {
opts.rollbackReq.Version = ver opts.rollbackReq.Version = ver
} }

@ -21,7 +21,6 @@ import (
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"github.com/Masterminds/semver" "github.com/Masterminds/semver"
@ -52,7 +51,6 @@ func Chartfile(linter *support.Linter) {
// Chart metadata // Chart metadata
linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartVersion(chartFile)) linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartVersion(chartFile))
linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartEngine(chartFile))
linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartMaintainer(chartFile)) linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartMaintainer(chartFile))
linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartSources(chartFile)) linter.RunLinterRule(support.ErrorSev, chartFileName, validateChartSources(chartFile))
linter.RunLinterRule(support.InfoSev, chartFileName, validateChartIconPresence(chartFile)) linter.RunLinterRule(support.InfoSev, chartFileName, validateChartIconPresence(chartFile))
@ -113,29 +111,6 @@ func validateChartVersion(cf *chart.Metadata) error {
return nil return nil
} }
func validateChartEngine(cf *chart.Metadata) error {
if cf.Engine == "" {
return nil
}
keys := make([]string, 0, len(chart.Metadata_Engine_value))
for engine := range chart.Metadata_Engine_value {
str := strings.ToLower(engine)
if str == "unknown" {
continue
}
if str == cf.Engine {
return nil
}
keys = append(keys, str)
}
return fmt.Errorf("engine '%v' not valid. Valid options are %v", cf.Engine, keys)
}
func validateChartMaintainer(cf *chart.Metadata) error { func validateChartMaintainer(cf *chart.Metadata) error {
for _, maintainer := range cf.Maintainers { for _, maintainer := range cf.Maintainers {
if maintainer.Name == "" { if maintainer.Name == "" {

@ -120,24 +120,6 @@ func TestValidateChartVersion(t *testing.T) {
} }
} }
func TestValidateChartEngine(t *testing.T) {
var successTest = []string{"", "gotpl"}
for _, engine := range successTest {
badChart.Engine = engine
err := validateChartEngine(badChart)
if err != nil {
t.Errorf("validateChartEngine(%s) to return no error, got a linter error %s", engine, err.Error())
}
}
badChart.Engine = "foobar"
err := validateChartEngine(badChart)
if err == nil || !strings.Contains(err.Error(), "not valid. Valid options are [gotpl") {
t.Errorf("validateChartEngine(%s) to return an error, got no error", badChart.Engine)
}
}
func TestValidateChartMaintainer(t *testing.T) { func TestValidateChartMaintainer(t *testing.T) {
var failTest = []struct { var failTest = []struct {
Name string Name string

@ -105,7 +105,7 @@ func (env *Environment) streamUnknown(name, info string) error {
return env.streamMessage(msg, release.TestRun_UNKNOWN) return env.streamMessage(msg, release.TestRun_UNKNOWN)
} }
func (env *Environment) streamMessage(msg string, status release.TestRun_Status) error { func (env *Environment) streamMessage(msg string, status release.TestRunStatus) error {
resp := &hapi.TestReleaseResponse{Msg: msg, Status: status} resp := &hapi.TestReleaseResponse{Msg: msg, Status: status}
env.Mesages <- resp env.Mesages <- resp
return nil return nil

@ -243,7 +243,7 @@ func releaseStub() *release.Release {
Kind: "Pod", Kind: "Pod",
Path: "finding-nemo", Path: "finding-nemo",
Manifest: manifestWithTestSuccessHook, Manifest: manifestWithTestSuccessHook,
Events: []release.Hook_Event{ Events: []release.HookEvent{
release.Hook_RELEASE_TEST_SUCCESS, release.Hook_RELEASE_TEST_SUCCESS,
}, },
}, },
@ -252,7 +252,7 @@ func releaseStub() *release.Release {
Kind: "ConfigMap", Kind: "ConfigMap",
Path: "test-cm", Path: "test-cm",
Manifest: manifestWithInstallHooks, Manifest: manifestWithInstallHooks,
Events: []release.Hook_Event{ Events: []release.HookEvent{
release.Hook_POST_INSTALL, release.Hook_POST_INSTALL,
release.Hook_PRE_DELETE, release.Hook_PRE_DELETE,
}, },

@ -68,7 +68,7 @@ func All(filters ...FilterFunc) FilterFunc {
} }
// StatusFilter filters a set of releases by status code. // StatusFilter filters a set of releases by status code.
func StatusFilter(status rspb.Status_Code) FilterFunc { func StatusFilter(status rspb.StatusCode) FilterFunc {
return FilterFunc(func(rls *rspb.Release) bool { return FilterFunc(func(rls *rspb.Release) bool {
if rls == nil { if rls == nil {
return true return true

@ -31,9 +31,9 @@ func TestFilterAny(t *testing.T) {
r0, r1 := ls[0], ls[1] r0, r1 := ls[0], ls[1]
switch { switch {
case r0.Info.Status.Code != rspb.Status_DELETED: case r0.Info.Status.Code != rspb.Status_DELETED:
t.Fatalf("expected DELETED result, got '%s'", r1.Info.Status.Code) t.Fatalf("expected DELETED result, got '%s'", r1.Info.Status.Code.String())
case r1.Info.Status.Code != rspb.Status_DELETED: case r1.Info.Status.Code != rspb.Status_DELETED:
t.Fatalf("expected DELETED result, got '%s'", r1.Info.Status.Code) t.Fatalf("expected DELETED result, got '%s'", r1.Info.Status.Code.String())
} }
} }

@ -32,7 +32,7 @@ var releases = []*rspb.Release{
tsRelease("vocal-dogs", 3, 6000, rspb.Status_DELETED), tsRelease("vocal-dogs", 3, 6000, rspb.Status_DELETED),
} }
func tsRelease(name string, vers int32, dur time.Duration, code rspb.Status_Code) *rspb.Release { func tsRelease(name string, vers int, dur time.Duration, code rspb.StatusCode) *rspb.Release {
tmsp := time.Now().Add(time.Duration(dur)) tmsp := time.Now().Add(time.Duration(dur))
info := &rspb.Info{Status: &rspb.Status{Code: code}, LastDeployed: tmsp} info := &rspb.Info{Status: &rspb.Status{Code: code}, LastDeployed: tmsp}
return &rspb.Release{ return &rspb.Release{

@ -244,8 +244,8 @@ func newConfigMapsObject(key string, rls *rspb.Release, lbs labels) (*v1.ConfigM
// apply labels // apply labels
lbs.set("NAME", rls.Name) lbs.set("NAME", rls.Name)
lbs.set("OWNER", owner) lbs.set("OWNER", owner)
lbs.set("STATUS", rspb.Status_Code_name[int32(rls.Info.Status.Code)]) lbs.set("STATUS", rls.Info.Status.Code.String())
lbs.set("VERSION", strconv.Itoa(int(rls.Version))) lbs.set("VERSION", strconv.Itoa(rls.Version))
// create and return configmap object // create and return configmap object
return &v1.ConfigMap{ return &v1.ConfigMap{

@ -32,7 +32,7 @@ func TestConfigMapName(t *testing.T) {
} }
func TestConfigMapGet(t *testing.T) { func TestConfigMapGet(t *testing.T) {
vers := int32(1) vers := 1
name := "smug-pigeon" name := "smug-pigeon"
namespace := "default" namespace := "default"
key := testKey(name, vers) key := testKey(name, vers)
@ -52,7 +52,7 @@ func TestConfigMapGet(t *testing.T) {
} }
func TestUNcompressedConfigMapGet(t *testing.T) { func TestUNcompressedConfigMapGet(t *testing.T) {
vers := int32(1) vers := 1
name := "smug-pigeon" name := "smug-pigeon"
namespace := "default" namespace := "default"
key := testKey(name, vers) key := testKey(name, vers)
@ -133,7 +133,7 @@ func TestConfigMapList(t *testing.T) {
func TestConfigMapCreate(t *testing.T) { func TestConfigMapCreate(t *testing.T) {
cfgmaps := newTestFixtureCfgMaps(t) cfgmaps := newTestFixtureCfgMaps(t)
vers := int32(1) vers := 1
name := "smug-pigeon" name := "smug-pigeon"
namespace := "default" namespace := "default"
key := testKey(name, vers) key := testKey(name, vers)
@ -157,7 +157,7 @@ func TestConfigMapCreate(t *testing.T) {
} }
func TestConfigMapUpdate(t *testing.T) { func TestConfigMapUpdate(t *testing.T) {
vers := int32(1) vers := 1
name := "smug-pigeon" name := "smug-pigeon"
namespace := "default" namespace := "default"
key := testKey(name, vers) key := testKey(name, vers)
@ -181,6 +181,6 @@ func TestConfigMapUpdate(t *testing.T) {
// check release has actually been updated by comparing modified fields // check release has actually been updated by comparing modified fields
if rel.Info.Status.Code != got.Info.Status.Code { if rel.Info.Status.Code != got.Info.Status.Code {
t.Errorf("Expected status %s, got status %s", rel.Info.Status.Code, got.Info.Status.Code) t.Errorf("Expected status %s, got status %s", rel.Info.Status.Code.String(), got.Info.Status.Code.String())
} }
} }

@ -28,7 +28,7 @@ import (
rspb "k8s.io/helm/pkg/hapi/release" rspb "k8s.io/helm/pkg/hapi/release"
) )
func releaseStub(name string, vers int32, namespace string, code rspb.Status_Code) *rspb.Release { func releaseStub(name string, vers int, namespace string, code rspb.StatusCode) *rspb.Release {
return &rspb.Release{ return &rspb.Release{
Name: name, Name: name,
Version: vers, Version: vers,
@ -37,7 +37,7 @@ func releaseStub(name string, vers int32, namespace string, code rspb.Status_Cod
} }
} }
func testKey(name string, vers int32) string { func testKey(name string, vers int) string {
return fmt.Sprintf("%s.v%d", name, vers) return fmt.Sprintf("%s.v%d", name, vers)
} }

@ -93,7 +93,7 @@ func (rs *records) Replace(key string, rec *record) *record {
return nil return nil
} }
func (rs records) FindByVersion(vers int32) (int, bool) { func (rs records) FindByVersion(vers int) (int, bool) {
i := sort.Search(len(rs), func(i int) bool { i := sort.Search(len(rs), func(i int) bool {
return rs[i].rls.Version == vers return rs[i].rls.Version == vers
}) })
@ -126,8 +126,8 @@ func newRecord(key string, rls *rspb.Release) *record {
lbs.init() lbs.init()
lbs.set("NAME", rls.Name) lbs.set("NAME", rls.Name)
lbs.set("OWNER", "TILLER") lbs.set("OWNER", "TILLER")
lbs.set("STATUS", rspb.Status_Code_name[int32(rls.Info.Status.Code)]) lbs.set("STATUS", rls.Info.Status.Code.String())
lbs.set("VERSION", strconv.Itoa(int(rls.Version))) lbs.set("VERSION", strconv.Itoa(rls.Version))
// return &record{key: key, lbs: lbs, rls: proto.Clone(rls).(*rspb.Release)} // return &record{key: key, lbs: lbs, rls: proto.Clone(rls).(*rspb.Release)}
return &record{key: key, lbs: lbs, rls: rls} return &record{key: key, lbs: lbs, rls: rls}

@ -244,8 +244,8 @@ func newSecretsObject(key string, rls *rspb.Release, lbs labels) (*v1.Secret, er
// apply labels // apply labels
lbs.set("NAME", rls.Name) lbs.set("NAME", rls.Name)
lbs.set("OWNER", owner) lbs.set("OWNER", owner)
lbs.set("STATUS", rspb.Status_Code_name[int32(rls.Info.Status.Code)]) lbs.set("STATUS", rls.Info.Status.Code.String())
lbs.set("VERSION", strconv.Itoa(int(rls.Version))) lbs.set("VERSION", strconv.Itoa(rls.Version))
// create and return secret object // create and return secret object
return &v1.Secret{ return &v1.Secret{

@ -32,7 +32,7 @@ func TestSecretName(t *testing.T) {
} }
func TestSecretGet(t *testing.T) { func TestSecretGet(t *testing.T) {
vers := int32(1) vers := 1
name := "smug-pigeon" name := "smug-pigeon"
namespace := "default" namespace := "default"
key := testKey(name, vers) key := testKey(name, vers)
@ -52,7 +52,7 @@ func TestSecretGet(t *testing.T) {
} }
func TestUNcompressedSecretGet(t *testing.T) { func TestUNcompressedSecretGet(t *testing.T) {
vers := int32(1) vers := 1
name := "smug-pigeon" name := "smug-pigeon"
namespace := "default" namespace := "default"
key := testKey(name, vers) key := testKey(name, vers)
@ -133,7 +133,7 @@ func TestSecretList(t *testing.T) {
func TestSecretCreate(t *testing.T) { func TestSecretCreate(t *testing.T) {
secrets := newTestFixtureSecrets(t) secrets := newTestFixtureSecrets(t)
vers := int32(1) vers := 1
name := "smug-pigeon" name := "smug-pigeon"
namespace := "default" namespace := "default"
key := testKey(name, vers) key := testKey(name, vers)
@ -157,7 +157,7 @@ func TestSecretCreate(t *testing.T) {
} }
func TestSecretUpdate(t *testing.T) { func TestSecretUpdate(t *testing.T) {
vers := int32(1) vers := 1
name := "smug-pigeon" name := "smug-pigeon"
namespace := "default" namespace := "default"
key := testKey(name, vers) key := testKey(name, vers)
@ -181,6 +181,6 @@ func TestSecretUpdate(t *testing.T) {
// check release has actually been updated by comparing modified fields // check release has actually been updated by comparing modified fields
if rel.Info.Status.Code != got.Info.Status.Code { if rel.Info.Status.Code != got.Info.Status.Code {
t.Errorf("Expected status %s, got status %s", rel.Info.Status.Code, got.Info.Status.Code) t.Errorf("Expected status %s, got status %s", rel.Info.Status.Code.String(), got.Info.Status.Code.String())
} }
} }

@ -40,7 +40,7 @@ type Storage struct {
// Get retrieves the release from storage. An error is returned // Get retrieves the release from storage. An error is returned
// if the storage driver failed to fetch the release, or the // if the storage driver failed to fetch the release, or the
// release identified by the key, version pair does not exist. // release identified by the key, version pair does not exist.
func (s *Storage) Get(name string, version int32) (*rspb.Release, error) { func (s *Storage) Get(name string, version int) (*rspb.Release, error) {
s.Log("getting release %q", makeKey(name, version)) s.Log("getting release %q", makeKey(name, version))
return s.Driver.Get(makeKey(name, version)) return s.Driver.Get(makeKey(name, version))
} }
@ -68,7 +68,7 @@ func (s *Storage) Update(rls *rspb.Release) error {
// Delete deletes the release from storage. An error is returned if // Delete deletes the release from storage. An error is returned if
// the storage backend fails to delete the release or if the release // the storage backend fails to delete the release or if the release
// does not exist. // does not exist.
func (s *Storage) Delete(name string, version int32) (*rspb.Release, error) { func (s *Storage) Delete(name string, version int) (*rspb.Release, error) {
s.Log("deleting release %q", makeKey(name, version)) s.Log("deleting release %q", makeKey(name, version))
return s.Driver.Delete(makeKey(name, version)) return s.Driver.Delete(makeKey(name, version))
} }
@ -226,7 +226,7 @@ func (s *Storage) Last(name string) (*rspb.Release, error) {
// makeKey concatenates a release name and version into // makeKey concatenates a release name and version into
// a string with format ```<release_name>#v<version>```. // a string with format ```<release_name>#v<version>```.
// This key is used to uniquely identify storage objects. // This key is used to uniquely identify storage objects.
func makeKey(rlsname string, version int32) string { func makeKey(rlsname string, version int) string {
return fmt.Sprintf("%s.v%d", rlsname, version) return fmt.Sprintf("%s.v%d", rlsname, version)
} }

@ -169,7 +169,7 @@ func TestStorageDeployed(t *testing.T) {
storage := Init(driver.NewMemory()) storage := Init(driver.NewMemory())
const name = "angry-bird" const name = "angry-bird"
const vers = int32(4) const vers = 4
// setup storage with test releases // setup storage with test releases
setup := func() { setup := func() {
@ -201,7 +201,7 @@ func TestStorageDeployed(t *testing.T) {
case rls.Version != vers: case rls.Version != vers:
t.Fatalf("Expected release version %d, actual %d\n", vers, rls.Version) t.Fatalf("Expected release version %d, actual %d\n", vers, rls.Version)
case rls.Info.Status.Code != rspb.Status_DEPLOYED: case rls.Info.Status.Code != rspb.Status_DEPLOYED:
t.Fatalf("Expected release status 'DEPLOYED', actual %s\n", rls.Info.Status.Code) t.Fatalf("Expected release status 'DEPLOYED', actual %s\n", rls.Info.Status.Code.String())
} }
} }
@ -286,7 +286,7 @@ func TestStorageRemoveLeastRecent(t *testing.T) {
// We expect the existing records to be 3, 4, and 5. // We expect the existing records to be 3, 4, and 5.
for i, item := range hist { for i, item := range hist {
v := int(item.Version) v := item.Version
if expect := i + 3; v != expect { if expect := i + 3; v != expect {
t.Errorf("Expected release %d, got %d", expect, v) t.Errorf("Expected release %d, got %d", expect, v)
} }
@ -327,10 +327,10 @@ func TestStorageLast(t *testing.T) {
type ReleaseTestData struct { type ReleaseTestData struct {
Name string Name string
Version int32 Version int
Manifest string Manifest string
Namespace string Namespace string
Status rspb.Status_Code Status rspb.StatusCode
} }
func (test ReleaseTestData) ToRelease() *rspb.Release { func (test ReleaseTestData) ToRelease() *rspb.Release {

@ -31,7 +31,7 @@ import (
util "k8s.io/helm/pkg/releaseutil" util "k8s.io/helm/pkg/releaseutil"
) )
var events = map[string]release.Hook_Event{ var events = map[string]release.HookEvent{
hooks.PreInstall: release.Hook_PRE_INSTALL, hooks.PreInstall: release.Hook_PRE_INSTALL,
hooks.PostInstall: release.Hook_POST_INSTALL, hooks.PostInstall: release.Hook_POST_INSTALL,
hooks.PreDelete: release.Hook_PRE_DELETE, hooks.PreDelete: release.Hook_PRE_DELETE,
@ -45,7 +45,7 @@ var events = map[string]release.Hook_Event{
} }
// deletePolices represents a mapping between the key in the annotation for label deleting policy and its real meaning // deletePolices represents a mapping between the key in the annotation for label deleting policy and its real meaning
var deletePolices = map[string]release.Hook_DeletePolicy{ var deletePolices = map[string]release.HookDeletePolicy{
hooks.HookSucceeded: release.Hook_SUCCEEDED, hooks.HookSucceeded: release.Hook_SUCCEEDED,
hooks.HookFailed: release.Hook_FAILED, hooks.HookFailed: release.Hook_FAILED,
hooks.BeforeHookCreation: release.Hook_BEFORE_HOOK_CREATION, hooks.BeforeHookCreation: release.Hook_BEFORE_HOOK_CREATION,
@ -167,9 +167,9 @@ func (file *manifestFile) sort(result *result) error {
Kind: entry.Kind, Kind: entry.Kind,
Path: file.path, Path: file.path,
Manifest: m, Manifest: m,
Events: []release.Hook_Event{}, Events: []release.HookEvent{},
Weight: hw, Weight: hw,
DeletePolicies: []release.Hook_DeletePolicy{}, DeletePolicies: []release.HookDeletePolicy{},
} }
isUnknownHook := false isUnknownHook := false
@ -213,14 +213,13 @@ func hasAnyAnnotation(entry util.SimpleHead) bool {
return true return true
} }
func calculateHookWeight(entry util.SimpleHead) int32 { func calculateHookWeight(entry util.SimpleHead) int {
hws := entry.Metadata.Annotations[hooks.HookWeightAnno] hws := entry.Metadata.Annotations[hooks.HookWeightAnno]
hw, err := strconv.Atoi(hws) hw, err := strconv.Atoi(hws)
if err != nil { if err != nil {
hw = 0 hw = 0
} }
return hw
return int32(hw)
} }
func operateAnnotationValues(entry util.SimpleHead, annotation string, operate func(p string)) { func operateAnnotationValues(entry util.SimpleHead, annotation string, operate func(p string)) {

@ -33,14 +33,14 @@ func TestSortManifests(t *testing.T) {
name []string name []string
path string path string
kind []string kind []string
hooks map[string][]release.Hook_Event hooks map[string][]release.HookEvent
manifest string manifest string
}{ }{
{ {
name: []string{"first"}, name: []string{"first"},
path: "one", path: "one",
kind: []string{"Job"}, kind: []string{"Job"},
hooks: map[string][]release.Hook_Event{"first": {release.Hook_PRE_INSTALL}}, hooks: map[string][]release.HookEvent{"first": {release.Hook_PRE_INSTALL}},
manifest: `apiVersion: v1 manifest: `apiVersion: v1
kind: Job kind: Job
metadata: metadata:
@ -55,7 +55,7 @@ metadata:
name: []string{"second"}, name: []string{"second"},
path: "two", path: "two",
kind: []string{"ReplicaSet"}, kind: []string{"ReplicaSet"},
hooks: map[string][]release.Hook_Event{"second": {release.Hook_POST_INSTALL}}, hooks: map[string][]release.HookEvent{"second": {release.Hook_POST_INSTALL}},
manifest: `kind: ReplicaSet manifest: `kind: ReplicaSet
apiVersion: v1beta1 apiVersion: v1beta1
metadata: metadata:
@ -67,7 +67,7 @@ metadata:
name: []string{"third"}, name: []string{"third"},
path: "three", path: "three",
kind: []string{"ReplicaSet"}, kind: []string{"ReplicaSet"},
hooks: map[string][]release.Hook_Event{"third": nil}, hooks: map[string][]release.HookEvent{"third": nil},
manifest: `kind: ReplicaSet manifest: `kind: ReplicaSet
apiVersion: v1beta1 apiVersion: v1beta1
metadata: metadata:
@ -79,7 +79,7 @@ metadata:
name: []string{"fourth"}, name: []string{"fourth"},
path: "four", path: "four",
kind: []string{"Pod"}, kind: []string{"Pod"},
hooks: map[string][]release.Hook_Event{"fourth": nil}, hooks: map[string][]release.HookEvent{"fourth": nil},
manifest: `kind: Pod manifest: `kind: Pod
apiVersion: v1 apiVersion: v1
metadata: metadata:
@ -90,7 +90,7 @@ metadata:
name: []string{"fifth"}, name: []string{"fifth"},
path: "five", path: "five",
kind: []string{"ReplicaSet"}, kind: []string{"ReplicaSet"},
hooks: map[string][]release.Hook_Event{"fifth": {release.Hook_POST_DELETE, release.Hook_POST_INSTALL}}, hooks: map[string][]release.HookEvent{"fifth": {release.Hook_POST_DELETE, release.Hook_POST_INSTALL}},
manifest: `kind: ReplicaSet manifest: `kind: ReplicaSet
apiVersion: v1beta1 apiVersion: v1beta1
metadata: metadata:
@ -103,21 +103,21 @@ metadata:
name: []string{"sixth"}, name: []string{"sixth"},
path: "six/_six", path: "six/_six",
kind: []string{"ReplicaSet"}, kind: []string{"ReplicaSet"},
hooks: map[string][]release.Hook_Event{"sixth": nil}, hooks: map[string][]release.HookEvent{"sixth": nil},
manifest: `invalid manifest`, // This will fail if partial is not skipped. manifest: `invalid manifest`, // This will fail if partial is not skipped.
}, { }, {
// Regression test: files with no content should be skipped. // Regression test: files with no content should be skipped.
name: []string{"seventh"}, name: []string{"seventh"},
path: "seven", path: "seven",
kind: []string{"ReplicaSet"}, kind: []string{"ReplicaSet"},
hooks: map[string][]release.Hook_Event{"seventh": nil}, hooks: map[string][]release.HookEvent{"seventh": nil},
manifest: "", manifest: "",
}, },
{ {
name: []string{"eighth", "example-test"}, name: []string{"eighth", "example-test"},
path: "eight", path: "eight",
kind: []string{"ConfigMap", "Pod"}, kind: []string{"ConfigMap", "Pod"},
hooks: map[string][]release.Hook_Event{"eighth": nil, "example-test": {release.Hook_RELEASE_TEST_SUCCESS}}, hooks: map[string][]release.HookEvent{"eighth": nil, "example-test": {release.Hook_RELEASE_TEST_SUCCESS}},
manifest: `kind: ConfigMap manifest: `kind: ConfigMap
apiVersion: v1 apiVersion: v1
metadata: metadata:

@ -38,7 +38,7 @@ func (s *ReleaseServer) GetHistory(req *hapi.GetHistoryRequest) ([]*release.Rele
relutil.Reverse(h, relutil.SortByRevision) relutil.Reverse(h, relutil.SortByRevision)
var rels []*release.Release var rels []*release.Release
for i := 0; i < min(len(h), int(req.Max)); i++ { for i := 0; i < min(len(h), req.Max); i++ {
rels = append(rels, h[i]) rels = append(rels, h[i])
} }

@ -25,7 +25,7 @@ import (
) )
func TestGetHistory_WithRevisions(t *testing.T) { func TestGetHistory_WithRevisions(t *testing.T) {
mk := func(name string, vers int32, code rpb.Status_Code) *rpb.Release { mk := func(name string, vers int, code rpb.StatusCode) *rpb.Release {
return &rpb.Release{ return &rpb.Release{
Name: name, Name: name,
Version: vers, Version: vers,

@ -119,7 +119,7 @@ func (s *ReleaseServer) prepareRelease(req *hapi.InstallReleaseRequest) (*releas
}, },
Manifest: manifestDoc.String(), Manifest: manifestDoc.String(),
Hooks: hooks, Hooks: hooks,
Version: int32(revision), Version: revision,
} }
if len(notesTxt) > 0 { if len(notesTxt) > 0 {
rel.Info.Status.Notes = notesTxt rel.Info.Status.Notes = notesTxt

@ -27,7 +27,7 @@ import (
// ListReleases lists the releases found by the server. // ListReleases lists the releases found by the server.
func (s *ReleaseServer) ListReleases(req *hapi.ListReleasesRequest) ([]*release.Release, error) { func (s *ReleaseServer) ListReleases(req *hapi.ListReleasesRequest) ([]*release.Release, error) {
if len(req.StatusCodes) == 0 { if len(req.StatusCodes) == 0 {
req.StatusCodes = []release.Status_Code{release.Status_DEPLOYED} req.StatusCodes = []release.StatusCode{release.Status_DEPLOYED}
} }
rels, err := s.env.Releases.ListFilterAll(func(r *release.Release) bool { rels, err := s.env.Releases.ListFilterAll(func(r *release.Release) bool {

@ -60,24 +60,24 @@ func TestListReleasesByStatus(t *testing.T) {
} }
tests := []struct { tests := []struct {
statusCodes []release.Status_Code statusCodes []release.StatusCode
names []string names []string
}{ }{
{ {
names: []string{"kamal"}, names: []string{"kamal"},
statusCodes: []release.Status_Code{release.Status_DEPLOYED}, statusCodes: []release.StatusCode{release.Status_DEPLOYED},
}, },
{ {
names: []string{"astrolabe"}, names: []string{"astrolabe"},
statusCodes: []release.Status_Code{release.Status_DELETED}, statusCodes: []release.StatusCode{release.Status_DELETED},
}, },
{ {
names: []string{"kamal", "octant"}, names: []string{"kamal", "octant"},
statusCodes: []release.Status_Code{release.Status_DEPLOYED, release.Status_FAILED}, statusCodes: []release.StatusCode{release.Status_DEPLOYED, release.Status_FAILED},
}, },
{ {
names: []string{"kamal", "astrolabe", "octant", "sextant"}, names: []string{"kamal", "astrolabe", "octant", "sextant"},
statusCodes: []release.Status_Code{ statusCodes: []release.StatusCode{
release.Status_DEPLOYED, release.Status_DEPLOYED,
release.Status_DELETED, release.Status_DELETED,
release.Status_FAILED, release.Status_FAILED,

@ -35,7 +35,7 @@ func TestRollbackRelease(t *testing.T) {
Kind: "ConfigMap", Kind: "ConfigMap",
Path: "test-cm", Path: "test-cm",
Manifest: manifestWithRollbackHooks, Manifest: manifestWithRollbackHooks,
Events: []release.Hook_Event{ Events: []release.HookEvent{
release.Hook_PRE_ROLLBACK, release.Hook_PRE_ROLLBACK,
release.Hook_POST_ROLLBACK, release.Hook_POST_ROLLBACK,
}, },
@ -190,7 +190,7 @@ func TestRollbackReleaseNoHooks(t *testing.T) {
Kind: "ConfigMap", Kind: "ConfigMap",
Path: "test-cm", Path: "test-cm",
Manifest: manifestWithRollbackHooks, Manifest: manifestWithRollbackHooks,
Events: []release.Hook_Event{ Events: []release.HookEvent{
release.Hook_PRE_ROLLBACK, release.Hook_PRE_ROLLBACK,
release.Hook_POST_ROLLBACK, release.Hook_POST_ROLLBACK,
}, },

@ -221,7 +221,7 @@ func releaseStub() *release.Release {
return namedReleaseStub("angry-panda", release.Status_DEPLOYED) return namedReleaseStub("angry-panda", release.Status_DEPLOYED)
} }
func namedReleaseStub(name string, status release.Status_Code) *release.Release { func namedReleaseStub(name string, status release.StatusCode) *release.Release {
date := time.Unix(242085845, 0) date := time.Unix(242085845, 0)
return &release.Release{ return &release.Release{
Name: name, Name: name,
@ -240,7 +240,7 @@ func namedReleaseStub(name string, status release.Status_Code) *release.Release
Kind: "ConfigMap", Kind: "ConfigMap",
Path: "test-cm", Path: "test-cm",
Manifest: manifestWithHook, Manifest: manifestWithHook,
Events: []release.Hook_Event{ Events: []release.HookEvent{
release.Hook_POST_INSTALL, release.Hook_POST_INSTALL,
release.Hook_PRE_DELETE, release.Hook_PRE_DELETE,
}, },
@ -250,7 +250,7 @@ func namedReleaseStub(name string, status release.Status_Code) *release.Release
Kind: "Pod", Kind: "Pod",
Path: "finding-nemo", Path: "finding-nemo",
Manifest: manifestWithTestHook, Manifest: manifestWithTestHook,
Events: []release.Hook_Event{ Events: []release.HookEvent{
release.Hook_RELEASE_TEST_SUCCESS, release.Hook_RELEASE_TEST_SUCCESS,
}, },
}, },
@ -513,7 +513,7 @@ func deletePolicyStub(kubeClient *mockHooksKubeClient) *ReleaseServer {
} }
} }
func deletePolicyHookStub(hookName string, extraAnnotations map[string]string, DeletePolicies []release.Hook_DeletePolicy) *release.Hook { func deletePolicyHookStub(hookName string, extraAnnotations map[string]string, DeletePolicies []release.HookDeletePolicy) *release.Hook {
extraAnnotationsStr := "" extraAnnotationsStr := ""
for k, v := range extraAnnotations { for k, v := range extraAnnotations {
extraAnnotationsStr += fmt.Sprintf(" \"%s\": \"%s\"\n", k, v) extraAnnotationsStr += fmt.Sprintf(" \"%s\": \"%s\"\n", k, v)
@ -530,7 +530,7 @@ metadata:
"helm.sh/hook": pre-install,pre-upgrade "helm.sh/hook": pre-install,pre-upgrade
%sdata: %sdata:
name: value`, hookName, extraAnnotationsStr), name: value`, hookName, extraAnnotationsStr),
Events: []release.Hook_Event{ Events: []release.HookEvent{
release.Hook_PRE_INSTALL, release.Hook_PRE_INSTALL,
release.Hook_PRE_UPGRADE, release.Hook_PRE_UPGRADE,
}, },
@ -617,7 +617,7 @@ func TestSuccessfulHookWithSucceededDeletePolicy(t *testing.T) {
ctx := newDeletePolicyContext() ctx := newDeletePolicyContext()
hook := deletePolicyHookStub(ctx.HookName, hook := deletePolicyHookStub(ctx.HookName,
map[string]string{"helm.sh/hook-delete-policy": "hook-succeeded"}, map[string]string{"helm.sh/hook-delete-policy": "hook-succeeded"},
[]release.Hook_DeletePolicy{release.Hook_SUCCEEDED}, []release.HookDeletePolicy{release.Hook_SUCCEEDED},
) )
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall) err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
@ -633,7 +633,7 @@ func TestSuccessfulHookWithFailedDeletePolicy(t *testing.T) {
ctx := newDeletePolicyContext() ctx := newDeletePolicyContext()
hook := deletePolicyHookStub(ctx.HookName, hook := deletePolicyHookStub(ctx.HookName,
map[string]string{"helm.sh/hook-delete-policy": "hook-failed"}, map[string]string{"helm.sh/hook-delete-policy": "hook-failed"},
[]release.Hook_DeletePolicy{release.Hook_FAILED}, []release.HookDeletePolicy{release.Hook_FAILED},
) )
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall) err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
@ -653,7 +653,7 @@ func TestFailedHookWithSucceededDeletePolicy(t *testing.T) {
"mockHooksKubeClient/Emulate": "hook-failed", "mockHooksKubeClient/Emulate": "hook-failed",
"helm.sh/hook-delete-policy": "hook-succeeded", "helm.sh/hook-delete-policy": "hook-succeeded",
}, },
[]release.Hook_DeletePolicy{release.Hook_SUCCEEDED}, []release.HookDeletePolicy{release.Hook_SUCCEEDED},
) )
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall) err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
@ -673,7 +673,7 @@ func TestFailedHookWithFailedDeletePolicy(t *testing.T) {
"mockHooksKubeClient/Emulate": "hook-failed", "mockHooksKubeClient/Emulate": "hook-failed",
"helm.sh/hook-delete-policy": "hook-failed", "helm.sh/hook-delete-policy": "hook-failed",
}, },
[]release.Hook_DeletePolicy{release.Hook_FAILED}, []release.HookDeletePolicy{release.Hook_FAILED},
) )
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall) err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
@ -692,7 +692,7 @@ func TestSuccessfulHookWithSuccededOrFailedDeletePolicy(t *testing.T) {
map[string]string{ map[string]string{
"helm.sh/hook-delete-policy": "hook-succeeded,hook-failed", "helm.sh/hook-delete-policy": "hook-succeeded,hook-failed",
}, },
[]release.Hook_DeletePolicy{release.Hook_SUCCEEDED, release.Hook_FAILED}, []release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_FAILED},
) )
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall) err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
@ -712,7 +712,7 @@ func TestFailedHookWithSuccededOrFailedDeletePolicy(t *testing.T) {
"mockHooksKubeClient/Emulate": "hook-failed", "mockHooksKubeClient/Emulate": "hook-failed",
"helm.sh/hook-delete-policy": "hook-succeeded,hook-failed", "helm.sh/hook-delete-policy": "hook-succeeded,hook-failed",
}, },
[]release.Hook_DeletePolicy{release.Hook_SUCCEEDED, release.Hook_FAILED}, []release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_FAILED},
) )
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall) err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
@ -753,7 +753,7 @@ func TestHookDeletingWithBeforeHookCreationDeletePolicy(t *testing.T) {
hook := deletePolicyHookStub(ctx.HookName, hook := deletePolicyHookStub(ctx.HookName,
map[string]string{"helm.sh/hook-delete-policy": "before-hook-creation"}, map[string]string{"helm.sh/hook-delete-policy": "before-hook-creation"},
[]release.Hook_DeletePolicy{release.Hook_BEFORE_HOOK_CREATION}, []release.HookDeletePolicy{release.Hook_BEFORE_HOOK_CREATION},
) )
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall) err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
@ -782,7 +782,7 @@ func TestSuccessfulHookWithMixedDeletePolicies(t *testing.T) {
map[string]string{ map[string]string{
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation", "helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation",
}, },
[]release.Hook_DeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION}, []release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
) )
err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall) err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
@ -812,7 +812,7 @@ func TestFailedHookWithMixedDeletePolicies(t *testing.T) {
"mockHooksKubeClient/Emulate": "hook-failed", "mockHooksKubeClient/Emulate": "hook-failed",
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation", "helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation",
}, },
[]release.Hook_DeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION}, []release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
) )
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall) err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
@ -842,7 +842,7 @@ func TestFailedThenSuccessfulHookWithMixedDeletePolicies(t *testing.T) {
"mockHooksKubeClient/Emulate": "hook-failed", "mockHooksKubeClient/Emulate": "hook-failed",
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation", "helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation",
}, },
[]release.Hook_DeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION}, []release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
) )
err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall) err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall)
@ -858,7 +858,7 @@ func TestFailedThenSuccessfulHookWithMixedDeletePolicies(t *testing.T) {
map[string]string{ map[string]string{
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation", "helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation",
}, },
[]release.Hook_DeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION}, []release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
) )
err = execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade) err = execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade)

@ -99,7 +99,7 @@ func (s *ReleaseServer) prepareUpdate(req *hapi.UpdateReleaseRequest) (*release.
Time: ts, Time: ts,
Namespace: currentRelease.Namespace, Namespace: currentRelease.Namespace,
IsUpgrade: true, IsUpgrade: true,
Revision: int(revision), Revision: revision,
} }
caps, err := capabilities(s.discovery) caps, err := capabilities(s.discovery)

Loading…
Cancel
Save