Merge pull request #3978 from adamreese/dev-v3-const

ref(*): convert const types to strings
pull/3989/head
Adam Reese 7 years ago committed by GitHub
commit a06d14ae00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -50,10 +50,10 @@ The historical release set is printed as a formatted table, e.g:
$ helm history angry-bird --max=4
REVISION UPDATED STATUS CHART DESCRIPTION
1 Mon Oct 3 10:15:13 2016 SUPERSEDED alpine-0.1.0 Initial install
2 Mon Oct 3 10:15:13 2016 SUPERSEDED alpine-0.1.0 Upgraded successfully
3 Mon Oct 3 10:15:13 2016 SUPERSEDED alpine-0.1.0 Rolled back to 2
4 Mon Oct 3 10:15:13 2016 DEPLOYED alpine-0.1.0 Upgraded successfully
1 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 Initial install
2 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 Upgraded successfully
3 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 Rolled back to 2
4 Mon Oct 3 10:15:13 2016 deployed alpine-0.1.0 Upgraded successfully
`
type historyCmd struct {
@ -128,7 +128,7 @@ func getReleaseHistory(rls []*release.Release) (history releaseHistory) {
for i := len(rls) - 1; i >= 0; i-- {
r := rls[i]
c := formatChartname(r.Chart)
s := r.Info.Status.Code.String()
s := r.Info.Status.String()
v := r.Version
d := r.Info.Description

@ -24,11 +24,11 @@ import (
)
func TestHistoryCmd(t *testing.T) {
mk := func(name string, vers int, code rpb.StatusCode) *rpb.Release {
mk := func(name string, vers int, status rpb.ReleaseStatus) *rpb.Release {
return helm.ReleaseMock(&helm.MockReleaseOptions{
Name: name,
Version: vers,
StatusCode: code,
Name: name,
Version: vers,
Status: status,
})
}
@ -37,39 +37,39 @@ func TestHistoryCmd(t *testing.T) {
name: "get history for release",
cmd: "history angry-bird",
rels: []*rpb.Release{
mk("angry-bird", 4, rpb.Status_DEPLOYED),
mk("angry-bird", 3, rpb.Status_SUPERSEDED),
mk("angry-bird", 2, rpb.Status_SUPERSEDED),
mk("angry-bird", 1, rpb.Status_SUPERSEDED),
mk("angry-bird", 4, rpb.StatusDeployed),
mk("angry-bird", 3, rpb.StatusSuperseded),
mk("angry-bird", 2, rpb.StatusSuperseded),
mk("angry-bird", 1, rpb.StatusSuperseded),
},
matches: `REVISION\s+UPDATED\s+STATUS\s+CHART\s+DESCRIPTION \n1\s+(.*)\s+SUPERSEDED\s+foo-0.1.0-beta.1\s+Release mock\n2(.*)SUPERSEDED\s+foo-0.1.0-beta.1\s+Release mock\n3(.*)SUPERSEDED\s+foo-0.1.0-beta.1\s+Release mock\n4(.*)DEPLOYED\s+foo-0.1.0-beta.1\s+Release mock\n`,
matches: `REVISION\s+UPDATED\s+STATUS\s+CHART\s+DESCRIPTION \n1\s+(.*)\s+superseded\s+foo-0.1.0-beta.1\s+Release mock\n2(.*)superseded\s+foo-0.1.0-beta.1\s+Release mock\n3(.*)superseded\s+foo-0.1.0-beta.1\s+Release mock\n4(.*)deployed\s+foo-0.1.0-beta.1\s+Release mock\n`,
},
{
name: "get history with max limit set",
cmd: "history angry-bird --max 2",
rels: []*rpb.Release{
mk("angry-bird", 4, rpb.Status_DEPLOYED),
mk("angry-bird", 3, rpb.Status_SUPERSEDED),
mk("angry-bird", 4, rpb.StatusDeployed),
mk("angry-bird", 3, rpb.StatusSuperseded),
},
matches: `REVISION\s+UPDATED\s+STATUS\s+CHART\s+DESCRIPTION \n3\s+(.*)\s+SUPERSEDED\s+foo-0.1.0-beta.1\s+Release mock\n4\s+(.*)\s+DEPLOYED\s+foo-0.1.0-beta.1\s+Release mock\n`,
matches: `REVISION\s+UPDATED\s+STATUS\s+CHART\s+DESCRIPTION \n3\s+(.*)\s+superseded\s+foo-0.1.0-beta.1\s+Release mock\n4\s+(.*)\s+deployed\s+foo-0.1.0-beta.1\s+Release mock\n`,
},
{
name: "get history with yaml output format",
cmd: "history angry-bird --output yaml",
rels: []*rpb.Release{
mk("angry-bird", 4, rpb.Status_DEPLOYED),
mk("angry-bird", 3, rpb.Status_SUPERSEDED),
mk("angry-bird", 4, rpb.StatusDeployed),
mk("angry-bird", 3, rpb.StatusSuperseded),
},
matches: "- chart: foo-0.1.0-beta.1\n description: Release mock\n revision: 3\n status: SUPERSEDED\n updated: (.*)\n- chart: foo-0.1.0-beta.1\n description: Release mock\n revision: 4\n status: DEPLOYED\n updated: (.*)\n\n",
matches: "- chart: foo-0.1.0-beta.1\n description: Release mock\n revision: 3\n status: superseded\n updated: (.*)\n- chart: foo-0.1.0-beta.1\n description: Release mock\n revision: 4\n status: deployed\n updated: (.*)\n\n",
},
{
name: "get history with json output format",
cmd: "history angry-bird --output json",
rels: []*rpb.Release{
mk("angry-bird", 4, rpb.Status_DEPLOYED),
mk("angry-bird", 3, rpb.Status_SUPERSEDED),
mk("angry-bird", 4, rpb.StatusDeployed),
mk("angry-bird", 3, rpb.StatusSuperseded),
},
matches: `[{"revision":3,"updated":".*","status":"SUPERSEDED","chart":"foo\-0.1.0-beta.1","description":"Release mock"},{"revision":4,"updated":".*","status":"DEPLOYED","chart":"foo\-0.1.0-beta.1","description":"Release mock"}]\n`,
matches: `[{"revision":3,"updated":".*","status":"superseded","chart":"foo\-0.1.0-beta.1","description":"Release mock"},{"revision":4,"updated":".*","status":"deployed","chart":"foo\-0.1.0-beta.1","description":"Release mock"}]\n`,
},
}
testReleaseCmd(t, tests)

@ -102,7 +102,7 @@ func newListCmd(client helm.Interface, out io.Writer) *cobra.Command {
f.BoolVarP(&list.sortDesc, "reverse", "r", false, "reverse the sort order")
f.IntVarP(&list.limit, "max", "m", 256, "maximum number of releases to fetch")
f.StringVarP(&list.offset, "offset", "o", "", "next release name in the list, used to offset from start value")
f.BoolVarP(&list.all, "all", "a", false, "show all releases, not just the ones marked DEPLOYED")
f.BoolVarP(&list.all, "all", "a", false, "show all releases, not just the ones marked deployed")
f.BoolVar(&list.deleted, "deleted", false, "show deleted releases")
f.BoolVar(&list.deleting, "deleting", false, "show releases that are currently being deleted")
f.BoolVar(&list.deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled")
@ -115,14 +115,14 @@ func newListCmd(client helm.Interface, out io.Writer) *cobra.Command {
}
func (l *listCmd) run() error {
sortBy := hapi.ListSort_NAME
sortBy := hapi.ListSortName
if l.byDate {
sortBy = hapi.ListSort_LAST_RELEASED
sortBy = hapi.ListSortLastReleased
}
sortOrder := hapi.ListSort_ASC
sortOrder := hapi.ListSortAsc
if l.sortDesc {
sortOrder = hapi.ListSort_DESC
sortOrder = hapi.ListSortDesc
}
stats := l.statusCodes()
@ -131,8 +131,8 @@ func (l *listCmd) run() error {
helm.ReleaseListLimit(l.limit),
helm.ReleaseListOffset(l.offset),
helm.ReleaseListFilter(l.filter),
helm.ReleaseListSort(int(sortBy)),
helm.ReleaseListOrder(int(sortOrder)),
helm.ReleaseListSort(sortBy),
helm.ReleaseListOrder(sortOrder),
helm.ReleaseListStatuses(stats),
)
@ -181,42 +181,42 @@ func filterList(rels []*release.Release) []*release.Release {
}
// statusCodes gets the list of status codes that are to be included in the results.
func (l *listCmd) statusCodes() []release.StatusCode {
func (l *listCmd) statusCodes() []release.ReleaseStatus {
if l.all {
return []release.StatusCode{
release.Status_UNKNOWN,
release.Status_DEPLOYED,
release.Status_DELETED,
release.Status_DELETING,
release.Status_FAILED,
release.Status_PENDING_INSTALL,
release.Status_PENDING_UPGRADE,
release.Status_PENDING_ROLLBACK,
return []release.ReleaseStatus{
release.StatusUnknown,
release.StatusDeployed,
release.StatusDeleted,
release.StatusDeleting,
release.StatusFailed,
release.StatusPendingInstall,
release.StatusPendingUpgrade,
release.StatusPendingRollback,
}
}
status := []release.StatusCode{}
status := []release.ReleaseStatus{}
if l.deployed {
status = append(status, release.Status_DEPLOYED)
status = append(status, release.StatusDeployed)
}
if l.deleted {
status = append(status, release.Status_DELETED)
status = append(status, release.StatusDeleted)
}
if l.deleting {
status = append(status, release.Status_DELETING)
status = append(status, release.StatusDeleting)
}
if l.failed {
status = append(status, release.Status_FAILED)
status = append(status, release.StatusFailed)
}
if l.superseded {
status = append(status, release.Status_SUPERSEDED)
status = append(status, release.StatusSuperseded)
}
if l.pending {
status = append(status, release.Status_PENDING_INSTALL, release.Status_PENDING_UPGRADE, release.Status_PENDING_ROLLBACK)
status = append(status, release.StatusPendingInstall, release.StatusPendingUpgrade, release.StatusPendingRollback)
}
// Default case.
if len(status) == 0 {
status = append(status, release.Status_DEPLOYED, release.Status_FAILED)
status = append(status, release.StatusDeployed, release.StatusFailed)
}
return status
}
@ -233,7 +233,7 @@ func formatList(rels []*release.Release, colWidth uint) string {
if tspb := r.Info.LastDeployed; !tspb.IsZero() {
t = tspb.String()
}
s := r.Info.Status.Code.String()
s := r.Info.Status.String()
v := r.Version
n := r.Namespace
table.AddRow(r.Name, v, t, s, c, n)

@ -39,14 +39,14 @@ func TestListCmd(t *testing.T) {
rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas"}),
},
matches: `NAME\s+REVISION\s+UPDATED\s+STATUS\s+CHART\s+NAMESPACE\natlas\s+1\s+(.*)\s+DEPLOYED\s+foo-0.1.0-beta.1\s+default`,
matches: `NAME\s+REVISION\s+UPDATED\s+STATUS\s+CHART\s+NAMESPACE\natlas\s+1\s+(.*)\s+deployed\s+foo-0.1.0-beta.1\s+default`,
},
{
name: "list, one deployed, one failed",
cmd: "list -q",
rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", StatusCode: release.Status_FAILED}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", StatusCode: release.Status_DEPLOYED}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusFailed}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}),
},
matches: "thomas-guide\natlas-guide",
},
@ -54,8 +54,8 @@ func TestListCmd(t *testing.T) {
name: "with a release, multiple flags",
cmd: "list --deleted --deployed --failed -q",
rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", StatusCode: release.Status_DELETED}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", StatusCode: release.Status_DEPLOYED}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusDeleted}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}),
},
// Note: We're really only testing that the flags parsed correctly. Which results are returned
// depends on the backend. And until pkg/helm is done, we can't mock this.
@ -65,8 +65,8 @@ func TestListCmd(t *testing.T) {
name: "with a release, multiple flags",
cmd: "list --all -q",
rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", StatusCode: release.Status_DELETED}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", StatusCode: release.Status_DEPLOYED}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusDeleted}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}),
},
// See note on previous test.
matches: "thomas-guide\natlas-guide",
@ -75,8 +75,8 @@ func TestListCmd(t *testing.T) {
name: "with a release, multiple flags, deleting",
cmd: "list --all -q",
rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", StatusCode: release.Status_DELETING}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", StatusCode: release.Status_DEPLOYED}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusDeleting}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}),
},
// See note on previous test.
matches: "thomas-guide\natlas-guide",
@ -95,8 +95,8 @@ func TestListCmd(t *testing.T) {
name: "with a pending release, multiple flags",
cmd: "list --all -q",
rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", StatusCode: release.Status_PENDING_INSTALL}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", StatusCode: release.Status_DEPLOYED}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusPendingInstall}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}),
},
matches: "thomas-guide\natlas-guide",
},
@ -104,10 +104,10 @@ func TestListCmd(t *testing.T) {
name: "with a pending release, pending flag",
cmd: "list --pending -q",
rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", StatusCode: release.Status_PENDING_INSTALL}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "wild-idea", StatusCode: release.Status_PENDING_UPGRADE}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "crazy-maps", StatusCode: release.Status_PENDING_ROLLBACK}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", StatusCode: release.Status_DEPLOYED}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusPendingInstall}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "wild-idea", Status: release.StatusPendingUpgrade}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "crazy-maps", Status: release.StatusPendingRollback}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "atlas-guide", Status: release.StatusDeployed}),
},
matches: "thomas-guide\nwild-idea\ncrazy-maps",
},
@ -116,7 +116,7 @@ func TestListCmd(t *testing.T) {
cmd: "list",
rels: []*release.Release{
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide"}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", StatusCode: release.Status_FAILED}),
helm.ReleaseMock(&helm.MockReleaseOptions{Name: "thomas-guide", Status: release.StatusFailed}),
},
matches: "thomas-guide",
},

@ -89,7 +89,7 @@ func (t *releaseTestCmd) run() (err error) {
break
}
if res.Status == release.TestRun_FAILURE {
if res.Status == release.TestRunFailure {
testErr.failed++
}

@ -27,43 +27,43 @@ func TestReleaseTesting(t *testing.T) {
{
name: "basic test",
cmd: "test example-release",
responses: map[string]release.TestRunStatus{"PASSED: green lights everywhere": release.TestRun_SUCCESS},
responses: map[string]release.TestRunStatus{"PASSED: green lights everywhere": release.TestRunSuccess},
wantError: false,
},
{
name: "test failure",
cmd: "test example-fail",
responses: map[string]release.TestRunStatus{"FAILURE: red lights everywhere": release.TestRun_FAILURE},
responses: map[string]release.TestRunStatus{"FAILURE: red lights everywhere": release.TestRunFailure},
wantError: true,
},
{
name: "test unknown",
cmd: "test example-unknown",
responses: map[string]release.TestRunStatus{"UNKNOWN: yellow lights everywhere": release.TestRun_UNKNOWN},
responses: map[string]release.TestRunStatus{"UNKNOWN: yellow lights everywhere": release.TestRunUnknown},
wantError: false,
},
{
name: "test error",
cmd: "test example-error",
responses: map[string]release.TestRunStatus{"ERROR: yellow lights everywhere": release.TestRun_FAILURE},
responses: map[string]release.TestRunStatus{"ERROR: yellow lights everywhere": release.TestRunFailure},
wantError: true,
},
{
name: "test running",
cmd: "test example-running",
responses: map[string]release.TestRunStatus{"RUNNING: things are happpeningggg": release.TestRun_RUNNING},
responses: map[string]release.TestRunStatus{"RUNNING: things are happpeningggg": release.TestRunRunning},
wantError: false,
},
{
name: "multiple tests example",
cmd: "test example-suite",
responses: map[string]release.TestRunStatus{
"RUNNING: things are happpeningggg": release.TestRun_RUNNING,
"PASSED: party time": release.TestRun_SUCCESS,
"RUNNING: things are happening again": release.TestRun_RUNNING,
"FAILURE: good thing u checked :)": release.TestRun_FAILURE,
"RUNNING: things are happpeningggg yet again": release.TestRun_RUNNING,
"PASSED: feel free to party again": release.TestRun_SUCCESS},
"RUNNING: things are happpeningggg": release.TestRunRunning,
"PASSED: party time": release.TestRunSuccess,
"RUNNING: things are happening again": release.TestRunRunning,
"FAILURE: good thing u checked :)": release.TestRunFailure,
"RUNNING: things are happpeningggg yet again": release.TestRunRunning,
"PASSED: feel free to party again": release.TestRunSuccess},
wantError: true,
},
}

@ -38,7 +38,7 @@ This command shows the status of a named release.
The status consists of:
- last deployment time
- k8s namespace in which the release lives
- state of the release (can be: UNKNOWN, DEPLOYED, DELETED, SUPERSEDED, FAILED or DELETING)
- state of the release (can be: unknown, deployed, deleted, superseded, failed or deleting)
- list of resources that this release consists of, sorted by kind
- details on last test suite run, if applicable
- additional notes provided by the chart
@ -114,25 +114,25 @@ func PrintStatus(out io.Writer, res *hapi.GetReleaseStatusResponse) {
fmt.Fprintf(out, "LAST DEPLOYED: %s\n", res.Info.LastDeployed)
}
fmt.Fprintf(out, "NAMESPACE: %s\n", res.Namespace)
fmt.Fprintf(out, "STATUS: %s\n", res.Info.Status.Code.String())
fmt.Fprintf(out, "STATUS: %s\n", res.Info.Status.String())
fmt.Fprintf(out, "\n")
if len(res.Info.Status.Resources) > 0 {
if len(res.Info.Resources) > 0 {
re := regexp.MustCompile(" +")
w := tabwriter.NewWriter(out, 0, 0, 2, ' ', tabwriter.TabIndent)
fmt.Fprintf(w, "RESOURCES:\n%s\n", re.ReplaceAllString(res.Info.Status.Resources, "\t"))
fmt.Fprintf(w, "RESOURCES:\n%s\n", re.ReplaceAllString(res.Info.Resources, "\t"))
w.Flush()
}
if res.Info.Status.LastTestSuiteRun != nil {
lastRun := res.Info.Status.LastTestSuiteRun
if res.Info.LastTestSuiteRun != nil {
lastRun := res.Info.LastTestSuiteRun
fmt.Fprintf(out, "TEST SUITE:\n%s\n%s\n\n%s\n",
fmt.Sprintf("Last Started: %s", lastRun.StartedAt),
fmt.Sprintf("Last Completed: %s", lastRun.CompletedAt),
formatTestResults(lastRun.Results))
}
if len(res.Info.Status.Notes) > 0 {
fmt.Fprintf(out, "NOTES:\n%s\n", res.Info.Status.Notes)
if len(res.Info.Notes) > 0 {
fmt.Fprintf(out, "NOTES:\n%s\n", res.Info.Notes)
}
}

@ -29,42 +29,42 @@ func TestStatusCmd(t *testing.T) {
{
name: "get status of a deployed release",
cmd: "status flummoxed-chickadee",
matches: outputWithStatus("DEPLOYED"),
matches: outputWithStatus("deployed"),
rels: []*release.Release{
releaseMockWithStatus(&release.Status{
Code: release.Status_DEPLOYED,
releaseMockWithStatus(&release.Info{
Status: release.StatusDeployed,
}),
},
},
{
name: "get status of a deployed release with notes",
cmd: "status flummoxed-chickadee",
matches: outputWithStatus("DEPLOYED\n\nNOTES:\nrelease notes\n"),
matches: outputWithStatus("deployed\n\nNOTES:\nrelease notes\n"),
rels: []*release.Release{
releaseMockWithStatus(&release.Status{
Code: release.Status_DEPLOYED,
Notes: "release notes",
releaseMockWithStatus(&release.Info{
Status: release.StatusDeployed,
Notes: "release notes",
}),
},
},
{
name: "get status of a deployed release with notes in json",
cmd: "status flummoxed-chickadee -o json",
matches: `{"name":"flummoxed-chickadee","info":{"status":{"code":1,"notes":"release notes"},"first_deployed":(.*),"last_deployed":(.*)}}`,
matches: `{"name":"flummoxed-chickadee","info":{"first_deployed":(.*),"last_deployed":(.*),"deleted":(.*),"status":"deployed","notes":"release notes"}}`,
rels: []*release.Release{
releaseMockWithStatus(&release.Status{
Code: release.Status_DEPLOYED,
Notes: "release notes",
releaseMockWithStatus(&release.Info{
Status: release.StatusDeployed,
Notes: "release notes",
}),
},
},
{
name: "get status of a deployed release with resources",
cmd: "status flummoxed-chickadee",
matches: outputWithStatus("DEPLOYED\n\nRESOURCES:\nresource A\nresource B\n\n"),
matches: outputWithStatus("deployed\n\nRESOURCES:\nresource A\nresource B\n\n"),
rels: []*release.Release{
releaseMockWithStatus(&release.Status{
Code: release.Status_DEPLOYED,
releaseMockWithStatus(&release.Info{
Status: release.StatusDeployed,
Resources: "resource A\nresource B\n",
}),
},
@ -72,10 +72,10 @@ func TestStatusCmd(t *testing.T) {
{
name: "get status of a deployed release with resources in YAML",
cmd: "status flummoxed-chickadee -o yaml",
matches: "info:\n (.*)first_deployed:\n (.*)seconds: 242085845\n (.*)last_deployed:\n (.*)seconds: 242085845\n (.*)status:\n code: 1\n (.*)resources: |\n (.*)resource A\n (.*)resource B\nname: flummoxed-chickadee\n",
matches: `info:\n deleted: .*\n first_deployed: .*\n last_deployed: .*\n resources: |\n resource A\n resource B\n status: deployed\nname: flummoxed-chickadee\n`,
rels: []*release.Release{
releaseMockWithStatus(&release.Status{
Code: release.Status_DEPLOYED,
releaseMockWithStatus(&release.Info{
Status: release.StatusDeployed,
Resources: "resource A\nresource B\n",
}),
},
@ -84,27 +84,27 @@ func TestStatusCmd(t *testing.T) {
name: "get status of a deployed release with test suite",
cmd: "status flummoxed-chickadee",
matches: outputWithStatus(
"DEPLOYED\n\nTEST SUITE:\nLast Started: (.*)\nLast Completed: (.*)\n\n" +
"deployed\n\nTEST SUITE:\nLast Started: (.*)\nLast Completed: (.*)\n\n" +
"TEST \tSTATUS (.*)\tINFO (.*)\tSTARTED (.*)\tCOMPLETED (.*)\n" +
"test run 1\tSUCCESS (.*)\textra info\t(.*)\t(.*)\n" +
"test run 2\tFAILURE (.*)\t (.*)\t(.*)\t(.*)\n"),
"test run 1\tsuccess (.*)\textra info\t(.*)\t(.*)\n" +
"test run 2\tfailure (.*)\t (.*)\t(.*)\t(.*)\n"),
rels: []*release.Release{
releaseMockWithStatus(&release.Status{
Code: release.Status_DEPLOYED,
releaseMockWithStatus(&release.Info{
Status: release.StatusDeployed,
LastTestSuiteRun: &release.TestSuite{
StartedAt: time.Now(),
CompletedAt: time.Now(),
Results: []*release.TestRun{
{
Name: "test run 1",
Status: release.TestRun_SUCCESS,
Status: release.TestRunSuccess,
Info: "extra info",
StartedAt: time.Now(),
CompletedAt: time.Now(),
},
{
Name: "test run 2",
Status: release.TestRun_FAILURE,
Status: release.TestRunFailure,
StartedAt: time.Now(),
CompletedAt: time.Now(),
},
@ -121,13 +121,11 @@ func outputWithStatus(status string) string {
return fmt.Sprintf(`LAST DEPLOYED:(.*)\nNAMESPACE: \nSTATUS: %s`, status)
}
func releaseMockWithStatus(status *release.Status) *release.Release {
func releaseMockWithStatus(info *release.Info) *release.Release {
info.FirstDeployed = time.Now()
info.LastDeployed = time.Now()
return &release.Release{
Name: "flummoxed-chickadee",
Info: &release.Info{
FirstDeployed: time.Now(),
LastDeployed: time.Now(),
Status: status,
},
Info: info,
}
}

@ -17,53 +17,32 @@ package release
import "time"
type HookEvent int
type HookEvent string
const (
Hook_UNKNOWN HookEvent = iota
Hook_PRE_INSTALL
Hook_POST_INSTALL
Hook_PRE_DELETE
Hook_POST_DELETE
Hook_PRE_UPGRADE
Hook_POST_UPGRADE
Hook_PRE_ROLLBACK
Hook_POST_ROLLBACK
Hook_RELEASE_TEST_SUCCESS
Hook_RELEASE_TEST_FAILURE
HookPreInstall HookEvent = "pre-install"
HookPostInstall HookEvent = "post-install"
HookPreDelete HookEvent = "pre-delete"
HookPostDelete HookEvent = "post-delete"
HookPreUpgrade HookEvent = "pre-upgrade"
HookPostUpgrade HookEvent = "post-upgrade"
HookPreRollback HookEvent = "pre-rollback"
HookPostRollback HookEvent = "post-rollback"
HookReleaseTestSuccess HookEvent = "release-test-success"
HookReleaseTestFailure HookEvent = "release-test-failure"
)
var eventNames = [...]string{
"UNKNOWN",
"PRE_INSTALL",
"POST_INSTALL",
"PRE_DELETE",
"POST_DELETE",
"PRE_UPGRADE",
"POST_UPGRADE",
"PRE_ROLLBACK",
"POST_ROLLBACK",
"RELEASE_TEST_SUCCESS",
"RELEASE_TEST_FAILURE",
}
func (x HookEvent) String() string { return eventNames[x] }
func (x HookEvent) String() string { return string(x) }
type HookDeletePolicy int
type HookDeletePolicy string
const (
Hook_SUCCEEDED HookDeletePolicy = iota
Hook_FAILED
Hook_BEFORE_HOOK_CREATION
HookSucceeded HookDeletePolicy = "succeeded"
HookFailed HookDeletePolicy = "failed"
HookBeforeHookCreation HookDeletePolicy = "before-hook-creation"
)
var deletePolicyNames = [...]string{
"SUCCEEDED",
"FAILED",
"BEFORE_HOOK_CREATION",
}
func (x HookDeletePolicy) String() string { return deletePolicyNames[x] }
func (x HookDeletePolicy) String() string { return string(x) }
// Hook defines a hook object.
type Hook struct {

@ -19,11 +19,18 @@ import "time"
// Info describes release information.
type Info struct {
Status *Status `json:"status,omitempty"`
FirstDeployed time.Time `json:"first_deployed,omitempty"`
LastDeployed time.Time `json:"last_deployed,omitempty"`
// Deleted tracks when this object was deleted.
Deleted time.Time `json:"deleted,omitempty"`
// Description is human-friendly "log entry" about this release.
Description string `json:"Description,omitempty"`
// Status is the current state of the release
Status ReleaseStatus `json:"status,omitempty"`
// Cluster resources as kubectl would print them.
Resources string `json:"resources,omitempty"`
// Contains the rendered templates/NOTES.txt if available
Notes string `json:"notes,omitempty"`
// LastTestSuiteRun provides results on the last test run on a release
LastTestSuiteRun *TestSuite `json:"last_test_suite_run,omitempty"`
}

@ -15,50 +15,27 @@ limitations under the License.
package release
type StatusCode int
type ReleaseStatus string
const (
// Status_UNKNOWN indicates that a release is in an uncertain state.
Status_UNKNOWN StatusCode = iota
// Status_DEPLOYED indicates that the release has been pushed to Kubernetes.
Status_DEPLOYED
// Status_DELETED indicates that a release has been deleted from Kubermetes.
Status_DELETED
// Status_SUPERSEDED indicates that this release object is outdated and a newer one exists.
Status_SUPERSEDED
// Status_FAILED indicates that the release was not successfully deployed.
Status_FAILED
// Status_DELETING indicates that a delete operation is underway.
Status_DELETING
// Status_PENDING_INSTALL indicates that an install operation is underway.
Status_PENDING_INSTALL
// Status_PENDING_UPGRADE indicates that an upgrade operation is underway.
Status_PENDING_UPGRADE
// Status_PENDING_ROLLBACK indicates that an rollback operation is underway.
Status_PENDING_ROLLBACK
// StatusUnknown indicates that a release is in an uncertain state.
StatusUnknown ReleaseStatus = "unknown"
// StatusDeployed indicates that the release has been pushed to Kubernetes.
StatusDeployed ReleaseStatus = "deployed"
// StatusDeleted indicates that a release has been deleted from Kubermetes.
StatusDeleted ReleaseStatus = "deleted"
// StatusSuperseded indicates that this release object is outdated and a newer one exists.
StatusSuperseded ReleaseStatus = "superseded"
// StatusFailed indicates that the release was not successfully deployed.
StatusFailed ReleaseStatus = "failed"
// StatusDeleting indicates that a delete operation is underway.
StatusDeleting ReleaseStatus = "deleting"
// StatusPendingInstall indicates that an install operation is underway.
StatusPendingInstall ReleaseStatus = "pending-install"
// StatusPendingUpgrade indicates that an upgrade operation is underway.
StatusPendingUpgrade ReleaseStatus = "pending-upgrade"
// StatusPendingRollback indicates that an rollback operation is underway.
StatusPendingRollback ReleaseStatus = "pending-rollback"
)
var statusCodeNames = [...]string{
"UNKNOWN",
"DEPLOYED",
"DELETED",
"SUPERSEDED",
"FAILED",
"DELETING",
"PENDING_INSTALL",
"PENDING_UPGRADE",
"PENDING_ROLLBACK",
}
func (x StatusCode) String() string { return statusCodeNames[x] }
// Status defines the status of a release.
type Status struct {
Code StatusCode `json:"code,omitempty"`
// Cluster resources as kubectl would print them.
Resources string `json:"resources,omitempty"`
// Contains the rendered templates/NOTES.txt if available
Notes string `json:"notes,omitempty"`
// LastTestSuiteRun provides results on the last test run on a release
LastTestSuiteRun *TestSuite `json:"last_test_suite_run,omitempty"`
}
func (x ReleaseStatus) String() string { return string(x) }

@ -17,23 +17,16 @@ package release
import "time"
type TestRunStatus int
type TestRunStatus string
const (
TestRun_UNKNOWN TestRunStatus = iota
TestRun_SUCCESS
TestRun_FAILURE
TestRun_RUNNING
TestRunUnknown TestRunStatus = "unknown"
TestRunSuccess TestRunStatus = "success"
TestRunFailure TestRunStatus = "failure"
TestRunRunning TestRunStatus = "running"
)
var testRunStatusNames = [...]string{
"UNKNOWN",
"SUCCESS",
"FAILURE",
"RUNNING",
}
func (x TestRunStatus) String() string { return testRunStatusNames[x] }
func (x TestRunStatus) String() string { return string(x) }
type TestRun struct {
Name string `json:"name,omitempty"`

@ -21,37 +21,21 @@ import (
)
// SortBy defines sort operations.
type ListSortBy int
type ListSortBy string
const (
ListSort_UNKNOWN ListSortBy = iota
ListSort_NAME
ListSort_LAST_RELEASED
ListSortName ListSortBy = "name"
ListSortLastReleased ListSortBy = "last-released"
)
var sortByNames = [...]string{
"UNKNOWN",
"NAME",
"LAST_RELEASED",
}
func (x ListSortBy) String() string { return sortByNames[x] }
// SortOrder defines sort orders to augment sorting operations.
type ListSortOrder int
type ListSortOrder string
const (
ListSort_ASC ListSortOrder = iota
ListSort_DESC
ListSortAsc ListSortOrder = "ascending"
ListSortDesc ListSortOrder = "descending"
)
var sortOrderNames = [...]string{
"ASC",
"DESC",
}
func (x ListSortOrder) String() string { return sortOrderNames[x] }
// ListReleasesRequest requests a list of releases.
//
// Releases can be retrieved in chunks by setting limit and offset.
@ -73,8 +57,8 @@ type ListReleasesRequest struct {
// Anything that matches the regexp will be included in the results.
Filter string `json:"filter,omitempty"`
// SortOrder is the ordering directive used for sorting.
SortOrder ListSortOrder `json:"sort_order,omitempty"`
StatusCodes []release.StatusCode `json:"status_codes,omitempty"`
SortOrder ListSortOrder `json:"sort_order,omitempty"`
StatusCodes []release.ReleaseStatus `json:"status_codes,omitempty"`
}
// GetReleaseStatusRequest is a request to get the status of a release.

@ -178,11 +178,11 @@ metadata:
// MockReleaseOptions allows for user-configurable options on mock release objects.
type MockReleaseOptions struct {
Name string
Version int
Chart *chart.Chart
StatusCode release.StatusCode
Namespace string
Name string
Version int
Chart *chart.Chart
Status release.ReleaseStatus
Namespace string
}
// ReleaseMock creates a mock release object based on options set by MockReleaseOptions. This function should typically not be used outside of testing.
@ -217,9 +217,9 @@ func ReleaseMock(opts *MockReleaseOptions) *release.Release {
}
}
scode := release.Status_DEPLOYED
if opts.StatusCode > 0 {
scode = opts.StatusCode
scode := release.StatusDeployed
if len(opts.Status) > 0 {
scode = opts.Status
}
return &release.Release{
@ -227,7 +227,7 @@ func ReleaseMock(opts *MockReleaseOptions) *release.Release {
Info: &release.Info{
FirstDeployed: date,
LastDeployed: date,
Status: &release.Status{Code: scode},
Status: scode,
Description: "Release mock",
},
Chart: ch,
@ -241,7 +241,7 @@ func ReleaseMock(opts *MockReleaseOptions) *release.Release {
Path: "pre-install-hook.yaml",
Manifest: MockHookTemplate,
LastRun: date,
Events: []release.HookEvent{release.Hook_PRE_INSTALL},
Events: []release.HookEvent{release.HookPreInstall},
},
},
Manifest: MockManifest,

@ -40,13 +40,13 @@ func TestListReleases_VerifyOptions(t *testing.T) {
var limit = 2
var offset = "offset"
var filter = "filter"
var sortBy = 2
var sortOrd = 1
var codes = []rls.StatusCode{
rls.Status_FAILED,
rls.Status_DELETED,
rls.Status_DEPLOYED,
rls.Status_SUPERSEDED,
var sortBy = hapi.ListSortLastReleased
var sortOrd = hapi.ListSortAsc
var codes = []rls.ReleaseStatus{
rls.StatusFailed,
rls.StatusDeleted,
rls.StatusDeployed,
rls.StatusSuperseded,
}
// Expected ListReleasesRequest message
@ -54,8 +54,8 @@ func TestListReleases_VerifyOptions(t *testing.T) {
Limit: int64(limit),
Offset: offset,
Filter: filter,
SortBy: hapi.ListSortBy(sortBy),
SortOrder: hapi.ListSortOrder(sortOrd),
SortBy: sortBy,
SortOrder: sortOrd,
StatusCodes: codes,
}

@ -115,24 +115,24 @@ func ReleaseListLimit(limit int) ReleaseListOption {
}
// ReleaseListOrder specifies how to order a list of releases.
func ReleaseListOrder(order int) ReleaseListOption {
func ReleaseListOrder(order hapi.ListSortOrder) ReleaseListOption {
return func(opts *options) {
opts.listReq.SortOrder = hapi.ListSortOrder(order)
opts.listReq.SortOrder = order
}
}
// ReleaseListSort specifies how to sort a release list.
func ReleaseListSort(sort int) ReleaseListOption {
func ReleaseListSort(sort hapi.ListSortBy) ReleaseListOption {
return func(opts *options) {
opts.listReq.SortBy = hapi.ListSortBy(sort)
opts.listReq.SortBy = sort
}
}
// ReleaseListStatuses specifies which status codes should be returned.
func ReleaseListStatuses(statuses []release.StatusCode) ReleaseListOption {
func ReleaseListStatuses(statuses []release.ReleaseStatus) ReleaseListOption {
return func(opts *options) {
if len(statuses) == 0 {
statuses = []release.StatusCode{release.Status_DEPLOYED}
statuses = []release.ReleaseStatus{release.StatusDeployed}
}
opts.listReq.StatusCodes = statuses
}

@ -56,7 +56,7 @@ func FilterTestHooks(hooks []*release.Hook) []*release.Hook {
for _, h := range hooks {
for _, e := range h.Events {
if e == release.Hook_RELEASE_TEST_SUCCESS || e == release.Hook_RELEASE_TEST_FAILURE {
if e == release.HookReleaseTestSuccess || e == release.HookReleaseTestFailure {
testHooks = append(testHooks, h)
continue
}

@ -41,7 +41,7 @@ func (env *Environment) createTestPod(test *test) error {
b := bytes.NewBufferString(test.manifest)
if err := env.KubeClient.Create(env.Namespace, b, env.Timeout, false); err != nil {
test.result.Info = err.Error()
test.result.Status = release.TestRun_FAILURE
test.result.Status = release.TestRunFailure
return err
}
@ -54,7 +54,7 @@ func (env *Environment) getTestPodStatus(test *test) (core.PodPhase, error) {
if err != nil {
log.Printf("Error getting status for pod %s: %s", test.result.Name, err)
test.result.Info = err.Error()
test.result.Status = release.TestRun_UNKNOWN
test.result.Status = release.TestRunUnknown
return status, err
}
@ -63,11 +63,11 @@ func (env *Environment) getTestPodStatus(test *test) (core.PodPhase, error) {
func (env *Environment) streamResult(r *release.TestRun) error {
switch r.Status {
case release.TestRun_SUCCESS:
case release.TestRunSuccess:
if err := env.streamSuccess(r.Name); err != nil {
return err
}
case release.TestRun_FAILURE:
case release.TestRunFailure:
if err := env.streamFailed(r.Name); err != nil {
return err
}
@ -82,27 +82,27 @@ func (env *Environment) streamResult(r *release.TestRun) error {
func (env *Environment) streamRunning(name string) error {
msg := "RUNNING: " + name
return env.streamMessage(msg, release.TestRun_RUNNING)
return env.streamMessage(msg, release.TestRunRunning)
}
func (env *Environment) streamError(info string) error {
msg := "ERROR: " + info
return env.streamMessage(msg, release.TestRun_FAILURE)
return env.streamMessage(msg, release.TestRunFailure)
}
func (env *Environment) streamFailed(name string) error {
msg := fmt.Sprintf("FAILED: %s, run `kubectl logs %s --namespace %s` for more info", name, name, env.Namespace)
return env.streamMessage(msg, release.TestRun_FAILURE)
return env.streamMessage(msg, release.TestRunFailure)
}
func (env *Environment) streamSuccess(name string) error {
msg := fmt.Sprintf("PASSED: %s", name)
return env.streamMessage(msg, release.TestRun_SUCCESS)
return env.streamMessage(msg, release.TestRunSuccess)
}
func (env *Environment) streamUnknown(name, info string) error {
msg := fmt.Sprintf("UNKNOWN: %s: %s", name, info)
return env.streamMessage(msg, release.TestRun_UNKNOWN)
return env.streamMessage(msg, release.TestRunUnknown)
}
func (env *Environment) streamMessage(msg string, status release.TestRunStatus) error {

@ -45,7 +45,7 @@ func TestCreateTestPodFailure(t *testing.T) {
if test.result.Info == "" {
t.Errorf("Expected error to be saved in test result info but found empty string")
}
if test.result.Status != release.TestRun_FAILURE {
if test.result.Status != release.TestRunFailure {
t.Errorf("Expected test result status to be failure but got: %v", test.result.Status)
}
}
@ -55,7 +55,7 @@ func TestStreamMessage(t *testing.T) {
defer close(env.Mesages)
expectedMessage := "testing streamMessage"
expectedStatus := release.TestRun_SUCCESS
expectedStatus := release.TestRunSuccess
if err := env.streamMessage(expectedMessage, expectedStatus); err != nil {
t.Errorf("Expected no errors, got: %s", err)
}

@ -58,7 +58,7 @@ func (ts *TestSuite) Run(env *Environment) error {
if len(ts.TestManifests) == 0 {
// TODO: make this better, adding test run status on test suite is weird
env.streamMessage("No Tests Found", release.TestRun_UNKNOWN)
env.streamMessage("No Tests Found", release.TestRunUnknown)
}
for _, testManifest := range ts.TestManifests {
@ -71,7 +71,7 @@ func (ts *TestSuite) Run(env *Environment) error {
if err := env.streamRunning(test.result.Name); err != nil {
return err
}
test.result.Status = release.TestRun_RUNNING
test.result.Status = release.TestRunRunning
resourceCreated := true
if err := env.createTestPod(test); err != nil {
@ -115,18 +115,18 @@ func (t *test) assignTestResult(podStatus core.PodPhase) error {
switch podStatus {
case core.PodSucceeded:
if t.expectedSuccess {
t.result.Status = release.TestRun_SUCCESS
t.result.Status = release.TestRunSuccess
} else {
t.result.Status = release.TestRun_FAILURE
t.result.Status = release.TestRunFailure
}
case core.PodFailed:
if !t.expectedSuccess {
t.result.Status = release.TestRun_SUCCESS
t.result.Status = release.TestRunSuccess
} else {
t.result.Status = release.TestRun_FAILURE
t.result.Status = release.TestRunFailure
}
default:
t.result.Status = release.TestRun_UNKNOWN
t.result.Status = release.TestRunUnknown
}
return nil

@ -104,7 +104,7 @@ func TestRun(t *testing.T) {
if result.Name != "finding-nemo" {
t.Errorf("Expected test name to be finding-nemo. Got: %v", result.Name)
}
if result.Status != release.TestRun_SUCCESS {
if result.Status != release.TestRunSuccess {
t.Errorf("Expected test result to be successful, got: %v", result.Status)
}
result2 := ts.Results[1]
@ -117,7 +117,7 @@ func TestRun(t *testing.T) {
if result2.Name != "gold-rush" {
t.Errorf("Expected test name to be gold-rush, Got: %v", result2.Name)
}
if result2.Status != release.TestRun_FAILURE {
if result2.Status != release.TestRunFailure {
t.Errorf("Expected test result to be successful, got: %v", result2.Status)
}
}
@ -191,7 +191,7 @@ func TestRunSuccessWithTestFailureHook(t *testing.T) {
if result.Name != "gold-rush" {
t.Errorf("Expected test name to be gold-rush, Got: %v", result.Name)
}
if result.Status != release.TestRun_SUCCESS {
if result.Status != release.TestRunSuccess {
t.Errorf("Expected test result to be successful, got: %v", result.Status)
}
}
@ -208,13 +208,13 @@ var hooksStub = []*release.Hook{
{
Manifest: manifestWithTestSuccessHook,
Events: []release.HookEvent{
release.Hook_RELEASE_TEST_SUCCESS,
release.HookReleaseTestSuccess,
},
},
{
Manifest: manifestWithInstallHooks,
Events: []release.HookEvent{
release.Hook_POST_INSTALL,
release.HookPostInstall,
},
},
}

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

@ -23,24 +23,24 @@ import (
)
func TestFilterAny(t *testing.T) {
ls := Any(StatusFilter(rspb.Status_DELETED)).Filter(releases)
ls := Any(StatusFilter(rspb.StatusDeleted)).Filter(releases)
if len(ls) != 2 {
t.Fatalf("expected 2 results, got '%d'", len(ls))
}
r0, r1 := ls[0], ls[1]
switch {
case r0.Info.Status.Code != rspb.Status_DELETED:
t.Fatalf("expected DELETED result, got '%s'", r1.Info.Status.Code.String())
case r1.Info.Status.Code != rspb.Status_DELETED:
t.Fatalf("expected DELETED result, got '%s'", r1.Info.Status.Code.String())
case r0.Info.Status != rspb.StatusDeleted:
t.Fatalf("expected DELETED result, got '%s'", r1.Info.Status.String())
case r1.Info.Status != rspb.StatusDeleted:
t.Fatalf("expected DELETED result, got '%s'", r1.Info.Status.String())
}
}
func TestFilterAll(t *testing.T) {
fn := FilterFunc(func(rls *rspb.Release) bool {
// true if not deleted and version < 4
v0 := !StatusFilter(rspb.Status_DELETED).Check(rls)
v0 := !StatusFilter(rspb.StatusDeleted).Check(rls)
v1 := rls.Version < 4
return v0 && v1
})
@ -53,7 +53,7 @@ func TestFilterAll(t *testing.T) {
switch r0 := ls[0]; {
case r0.Version == 4:
t.Fatal("got release with status revision 4")
case r0.Info.Status.Code == rspb.Status_DELETED:
case r0.Info.Status == rspb.StatusDeleted:
t.Fatal("got release with status DELTED")
}
}

@ -26,15 +26,15 @@ import (
// note: this test data is shared with filter_test.go.
var releases = []*rspb.Release{
tsRelease("quiet-bear", 2, 2000, rspb.Status_SUPERSEDED),
tsRelease("angry-bird", 4, 3000, rspb.Status_DEPLOYED),
tsRelease("happy-cats", 1, 4000, rspb.Status_DELETED),
tsRelease("vocal-dogs", 3, 6000, rspb.Status_DELETED),
tsRelease("quiet-bear", 2, 2000, rspb.StatusSuperseded),
tsRelease("angry-bird", 4, 3000, rspb.StatusDeployed),
tsRelease("happy-cats", 1, 4000, rspb.StatusDeleted),
tsRelease("vocal-dogs", 3, 6000, rspb.StatusDeleted),
}
func tsRelease(name string, vers int, dur time.Duration, code rspb.StatusCode) *rspb.Release {
func tsRelease(name string, vers int, dur time.Duration, status rspb.ReleaseStatus) *rspb.Release {
tmsp := time.Now().Add(time.Duration(dur))
info := &rspb.Info{Status: &rspb.Status{Code: code}, LastDeployed: tmsp}
info := &rspb.Info{Status: status, LastDeployed: tmsp}
return &rspb.Release{
Name: name,
Version: vers,

@ -85,7 +85,7 @@ func (cfgmaps *ConfigMaps) Get(key string) (*rspb.Release, error) {
// that filter(release) == true. An error is returned if the
// configmap fails to retrieve the releases.
func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) {
lsel := kblabels.Set{"OWNER": "TILLER"}.AsSelector()
lsel := kblabels.Set{"owner": "tiller"}.AsSelector()
opts := metav1.ListOptions{LabelSelector: lsel.String()}
list, err := cfgmaps.impl.List(opts)
@ -131,7 +131,7 @@ func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, err
}
if len(list.Items) == 0 {
return nil, ErrReleaseNotFound(labels["NAME"])
return nil, ErrReleaseNotFound(labels["name"])
}
var results []*rspb.Release
@ -153,7 +153,7 @@ func (cfgmaps *ConfigMaps) Create(key string, rls *rspb.Release) error {
var lbs labels
lbs.init()
lbs.set("CREATED_AT", strconv.Itoa(int(time.Now().Unix())))
lbs.set("createdAt", strconv.Itoa(int(time.Now().Unix())))
// create a new configmap to hold the release
obj, err := newConfigMapsObject(key, rls, lbs)
@ -180,7 +180,7 @@ func (cfgmaps *ConfigMaps) Update(key string, rls *rspb.Release) error {
var lbs labels
lbs.init()
lbs.set("MODIFIED_AT", strconv.Itoa(int(time.Now().Unix())))
lbs.set("modifiedAt", strconv.Itoa(int(time.Now().Unix())))
// create a new configmap object to hold the release
obj, err := newConfigMapsObject(key, rls, lbs)
@ -221,15 +221,15 @@ func (cfgmaps *ConfigMaps) Delete(key string) (rls *rspb.Release, err error) {
//
// The following labels are used within each configmap:
//
// "MODIFIED_AT" - timestamp indicating when this configmap was last modified. (set in Update)
// "CREATED_AT" - timestamp indicating when this configmap was created. (set in Create)
// "VERSION" - version of the release.
// "STATUS" - status of the release (see proto/hapi/release.status.pb.go for variants)
// "OWNER" - owner of the configmap, currently "TILLER".
// "NAME" - name of the release.
// "modifiedAt" - timestamp indicating when this configmap was last modified. (set in Update)
// "createdAt" - timestamp indicating when this configmap was created. (set in Create)
// "version" - version of the release.
// "status" - status of the release (see proto/hapi/release.status.pb.go for variants)
// "owner" - owner of the configmap, currently "tiller".
// "name" - name of the release.
//
func newConfigMapsObject(key string, rls *rspb.Release, lbs labels) (*v1.ConfigMap, error) {
const owner = "TILLER"
const owner = "tiller"
// encode the release
s, err := encodeRelease(rls)
@ -242,10 +242,10 @@ func newConfigMapsObject(key string, rls *rspb.Release, lbs labels) (*v1.ConfigM
}
// apply labels
lbs.set("NAME", rls.Name)
lbs.set("OWNER", owner)
lbs.set("STATUS", rls.Info.Status.Code.String())
lbs.set("VERSION", strconv.Itoa(rls.Version))
lbs.set("name", rls.Name)
lbs.set("owner", owner)
lbs.set("status", rls.Info.Status.String())
lbs.set("version", strconv.Itoa(rls.Version))
// create and return configmap object
return &v1.ConfigMap{

@ -36,7 +36,7 @@ func TestConfigMapGet(t *testing.T) {
name := "smug-pigeon"
namespace := "default"
key := testKey(name, vers)
rel := releaseStub(name, vers, namespace, rspb.Status_DEPLOYED)
rel := releaseStub(name, vers, namespace, rspb.StatusDeployed)
cfgmaps := newTestFixtureCfgMaps(t, []*rspb.Release{rel}...)
@ -56,7 +56,7 @@ func TestUNcompressedConfigMapGet(t *testing.T) {
name := "smug-pigeon"
namespace := "default"
key := testKey(name, vers)
rel := releaseStub(name, vers, namespace, rspb.Status_DEPLOYED)
rel := releaseStub(name, vers, namespace, rspb.StatusDeployed)
// Create a test fixture which contains an uncompressed release
cfgmap, err := newConfigMapsObject(key, rel, nil)
@ -85,17 +85,17 @@ func TestUNcompressedConfigMapGet(t *testing.T) {
func TestConfigMapList(t *testing.T) {
cfgmaps := newTestFixtureCfgMaps(t, []*rspb.Release{
releaseStub("key-1", 1, "default", rspb.Status_DELETED),
releaseStub("key-2", 1, "default", rspb.Status_DELETED),
releaseStub("key-3", 1, "default", rspb.Status_DEPLOYED),
releaseStub("key-4", 1, "default", rspb.Status_DEPLOYED),
releaseStub("key-5", 1, "default", rspb.Status_SUPERSEDED),
releaseStub("key-6", 1, "default", rspb.Status_SUPERSEDED),
releaseStub("key-1", 1, "default", rspb.StatusDeleted),
releaseStub("key-2", 1, "default", rspb.StatusDeleted),
releaseStub("key-3", 1, "default", rspb.StatusDeployed),
releaseStub("key-4", 1, "default", rspb.StatusDeployed),
releaseStub("key-5", 1, "default", rspb.StatusSuperseded),
releaseStub("key-6", 1, "default", rspb.StatusSuperseded),
}...)
// list all deleted releases
del, err := cfgmaps.List(func(rel *rspb.Release) bool {
return rel.Info.Status.Code == rspb.Status_DELETED
return rel.Info.Status == rspb.StatusDeleted
})
// check
if err != nil {
@ -107,7 +107,7 @@ func TestConfigMapList(t *testing.T) {
// list all deployed releases
dpl, err := cfgmaps.List(func(rel *rspb.Release) bool {
return rel.Info.Status.Code == rspb.Status_DEPLOYED
return rel.Info.Status == rspb.StatusDeployed
})
// check
if err != nil {
@ -119,7 +119,7 @@ func TestConfigMapList(t *testing.T) {
// list all superseded releases
ssd, err := cfgmaps.List(func(rel *rspb.Release) bool {
return rel.Info.Status.Code == rspb.Status_SUPERSEDED
return rel.Info.Status == rspb.StatusSuperseded
})
// check
if err != nil {
@ -137,7 +137,7 @@ func TestConfigMapCreate(t *testing.T) {
name := "smug-pigeon"
namespace := "default"
key := testKey(name, vers)
rel := releaseStub(name, vers, namespace, rspb.Status_DEPLOYED)
rel := releaseStub(name, vers, namespace, rspb.StatusDeployed)
// store the release in a configmap
if err := cfgmaps.Create(key, rel); err != nil {
@ -161,12 +161,12 @@ func TestConfigMapUpdate(t *testing.T) {
name := "smug-pigeon"
namespace := "default"
key := testKey(name, vers)
rel := releaseStub(name, vers, namespace, rspb.Status_DEPLOYED)
rel := releaseStub(name, vers, namespace, rspb.StatusDeployed)
cfgmaps := newTestFixtureCfgMaps(t, []*rspb.Release{rel}...)
// modify release status code
rel.Info.Status.Code = rspb.Status_SUPERSEDED
rel.Info.Status = rspb.StatusSuperseded
// perform the update
if err := cfgmaps.Update(key, rel); err != nil {
@ -180,7 +180,7 @@ func TestConfigMapUpdate(t *testing.T) {
}
// check release has actually been updated by comparing modified fields
if 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())
if rel.Info.Status != got.Info.Status {
t.Errorf("Expected status %s, got status %s", rel.Info.Status.String(), got.Info.Status.String())
}
}

@ -38,12 +38,12 @@ func TestMemoryCreate(t *testing.T) {
}{
{
"create should success",
releaseStub("rls-c", 1, "default", rspb.Status_DEPLOYED),
releaseStub("rls-c", 1, "default", rspb.StatusDeployed),
false,
},
{
"create should fail (release already exists)",
releaseStub("rls-a", 1, "default", rspb.Status_DEPLOYED),
releaseStub("rls-a", 1, "default", rspb.StatusDeployed),
true,
},
}
@ -90,7 +90,7 @@ func TestMemoryQuery(t *testing.T) {
{
"should be 2 query results",
2,
map[string]string{"STATUS": "DEPLOYED"},
map[string]string{"status": "deployed"},
},
}
@ -117,13 +117,13 @@ func TestMemoryUpdate(t *testing.T) {
{
"update release status",
"rls-a.v4",
releaseStub("rls-a", 4, "default", rspb.Status_SUPERSEDED),
releaseStub("rls-a", 4, "default", rspb.StatusSuperseded),
false,
},
{
"update release does not exist",
"rls-z.v1",
releaseStub("rls-z", 1, "default", rspb.Status_DELETED),
releaseStub("rls-z", 1, "default", rspb.StatusDeleted),
true,
},
}
@ -159,7 +159,7 @@ func TestMemoryDelete(t *testing.T) {
}
ts := tsFixtureMemory(t)
start, err := ts.Query(map[string]string{"NAME": "rls-a"})
start, err := ts.Query(map[string]string{"name": "rls-a"})
if err != nil {
t.Errorf("Query failed: %s", err)
}
@ -180,7 +180,7 @@ func TestMemoryDelete(t *testing.T) {
}
// Make sure that the deleted records are gone.
end, err := ts.Query(map[string]string{"NAME": "rls-a"})
end, err := ts.Query(map[string]string{"name": "rls-a"})
if err != nil {
t.Errorf("Query failed: %s", err)
}

@ -28,12 +28,12 @@ import (
rspb "k8s.io/helm/pkg/hapi/release"
)
func releaseStub(name string, vers int, namespace string, code rspb.StatusCode) *rspb.Release {
func releaseStub(name string, vers int, namespace string, status rspb.ReleaseStatus) *rspb.Release {
return &rspb.Release{
Name: name,
Version: vers,
Namespace: namespace,
Info: &rspb.Info{Status: &rspb.Status{Code: code}},
Info: &rspb.Info{Status: status},
}
}
@ -44,15 +44,15 @@ func testKey(name string, vers int) string {
func tsFixtureMemory(t *testing.T) *Memory {
hs := []*rspb.Release{
// rls-a
releaseStub("rls-a", 4, "default", rspb.Status_DEPLOYED),
releaseStub("rls-a", 1, "default", rspb.Status_SUPERSEDED),
releaseStub("rls-a", 3, "default", rspb.Status_SUPERSEDED),
releaseStub("rls-a", 2, "default", rspb.Status_SUPERSEDED),
releaseStub("rls-a", 4, "default", rspb.StatusDeployed),
releaseStub("rls-a", 1, "default", rspb.StatusSuperseded),
releaseStub("rls-a", 3, "default", rspb.StatusSuperseded),
releaseStub("rls-a", 2, "default", rspb.StatusSuperseded),
// rls-b
releaseStub("rls-b", 4, "default", rspb.Status_DEPLOYED),
releaseStub("rls-b", 1, "default", rspb.Status_SUPERSEDED),
releaseStub("rls-b", 3, "default", rspb.Status_SUPERSEDED),
releaseStub("rls-b", 2, "default", rspb.Status_SUPERSEDED),
releaseStub("rls-b", 4, "default", rspb.StatusDeployed),
releaseStub("rls-b", 1, "default", rspb.StatusSuperseded),
releaseStub("rls-b", 3, "default", rspb.StatusSuperseded),
releaseStub("rls-b", 2, "default", rspb.StatusSuperseded),
}
mem := NewMemory()

@ -124,10 +124,10 @@ func newRecord(key string, rls *rspb.Release) *record {
var lbs labels
lbs.init()
lbs.set("NAME", rls.Name)
lbs.set("OWNER", "TILLER")
lbs.set("STATUS", rls.Info.Status.Code.String())
lbs.set("VERSION", strconv.Itoa(rls.Version))
lbs.set("name", rls.Name)
lbs.set("owner", "tiller")
lbs.set("status", rls.Info.Status.String())
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: rls}

@ -24,8 +24,8 @@ import (
func TestRecordsAdd(t *testing.T) {
rs := records([]*record{
newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.Status_SUPERSEDED)),
newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.Status_DEPLOYED)),
newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.StatusSuperseded)),
newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.StatusDeployed)),
})
var tests = []struct {
@ -38,13 +38,13 @@ func TestRecordsAdd(t *testing.T) {
"add valid key",
"rls-a.v3",
false,
newRecord("rls-a.v3", releaseStub("rls-a", 3, "default", rspb.Status_SUPERSEDED)),
newRecord("rls-a.v3", releaseStub("rls-a", 3, "default", rspb.StatusSuperseded)),
},
{
"add already existing key",
"rls-a.v1",
true,
newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.Status_DEPLOYED)),
newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.StatusDeployed)),
},
}
@ -69,8 +69,8 @@ func TestRecordsRemove(t *testing.T) {
}
rs := records([]*record{
newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.Status_SUPERSEDED)),
newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.Status_DEPLOYED)),
newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.StatusSuperseded)),
newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.StatusDeployed)),
})
startLen := rs.Len()
@ -97,8 +97,8 @@ func TestRecordsRemove(t *testing.T) {
func TestRecordsRemoveAt(t *testing.T) {
rs := records([]*record{
newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.Status_SUPERSEDED)),
newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.Status_DEPLOYED)),
newRecord("rls-a.v1", releaseStub("rls-a", 1, "default", rspb.StatusSuperseded)),
newRecord("rls-a.v2", releaseStub("rls-a", 2, "default", rspb.StatusDeployed)),
})
if len(rs) != 2 {

@ -85,7 +85,7 @@ func (secrets *Secrets) Get(key string) (*rspb.Release, error) {
// that filter(release) == true. An error is returned if the
// secret fails to retrieve the releases.
func (secrets *Secrets) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) {
lsel := kblabels.Set{"OWNER": "TILLER"}.AsSelector()
lsel := kblabels.Set{"owner": "tiller"}.AsSelector()
opts := metav1.ListOptions{LabelSelector: lsel.String()}
list, err := secrets.impl.List(opts)
@ -131,7 +131,7 @@ func (secrets *Secrets) Query(labels map[string]string) ([]*rspb.Release, error)
}
if len(list.Items) == 0 {
return nil, ErrReleaseNotFound(labels["NAME"])
return nil, ErrReleaseNotFound(labels["name"])
}
var results []*rspb.Release
@ -153,7 +153,7 @@ func (secrets *Secrets) Create(key string, rls *rspb.Release) error {
var lbs labels
lbs.init()
lbs.set("CREATED_AT", strconv.Itoa(int(time.Now().Unix())))
lbs.set("createdAt", strconv.Itoa(int(time.Now().Unix())))
// create a new secret to hold the release
obj, err := newSecretsObject(key, rls, lbs)
@ -180,7 +180,7 @@ func (secrets *Secrets) Update(key string, rls *rspb.Release) error {
var lbs labels
lbs.init()
lbs.set("MODIFIED_AT", strconv.Itoa(int(time.Now().Unix())))
lbs.set("modifiedAt", strconv.Itoa(int(time.Now().Unix())))
// create a new secret object to hold the release
obj, err := newSecretsObject(key, rls, lbs)
@ -221,15 +221,15 @@ func (secrets *Secrets) Delete(key string) (rls *rspb.Release, err error) {
//
// The following labels are used within each secret:
//
// "MODIFIED_AT" - timestamp indicating when this secret was last modified. (set in Update)
// "CREATED_AT" - timestamp indicating when this secret was created. (set in Create)
// "VERSION" - version of the release.
// "STATUS" - status of the release (see proto/hapi/release.status.pb.go for variants)
// "OWNER" - owner of the secret, currently "TILLER".
// "NAME" - name of the release.
// "modifiedAt" - timestamp indicating when this secret was last modified. (set in Update)
// "createdAt" - timestamp indicating when this secret was created. (set in Create)
// "version" - version of the release.
// "status" - status of the release (see proto/hapi/release.status.pb.go for variants)
// "owner" - owner of the secret, currently "tiller".
// "name" - name of the release.
//
func newSecretsObject(key string, rls *rspb.Release, lbs labels) (*v1.Secret, error) {
const owner = "TILLER"
const owner = "tiller"
// encode the release
s, err := encodeRelease(rls)
@ -242,10 +242,10 @@ func newSecretsObject(key string, rls *rspb.Release, lbs labels) (*v1.Secret, er
}
// apply labels
lbs.set("NAME", rls.Name)
lbs.set("OWNER", owner)
lbs.set("STATUS", rls.Info.Status.Code.String())
lbs.set("VERSION", strconv.Itoa(rls.Version))
lbs.set("name", rls.Name)
lbs.set("owner", owner)
lbs.set("status", rls.Info.Status.String())
lbs.set("version", strconv.Itoa(rls.Version))
// create and return secret object
return &v1.Secret{

@ -36,7 +36,7 @@ func TestSecretGet(t *testing.T) {
name := "smug-pigeon"
namespace := "default"
key := testKey(name, vers)
rel := releaseStub(name, vers, namespace, rspb.Status_DEPLOYED)
rel := releaseStub(name, vers, namespace, rspb.StatusDeployed)
secrets := newTestFixtureSecrets(t, []*rspb.Release{rel}...)
@ -56,7 +56,7 @@ func TestUNcompressedSecretGet(t *testing.T) {
name := "smug-pigeon"
namespace := "default"
key := testKey(name, vers)
rel := releaseStub(name, vers, namespace, rspb.Status_DEPLOYED)
rel := releaseStub(name, vers, namespace, rspb.StatusDeployed)
// Create a test fixture which contains an uncompressed release
secret, err := newSecretsObject(key, rel, nil)
@ -85,17 +85,17 @@ func TestUNcompressedSecretGet(t *testing.T) {
func TestSecretList(t *testing.T) {
secrets := newTestFixtureSecrets(t, []*rspb.Release{
releaseStub("key-1", 1, "default", rspb.Status_DELETED),
releaseStub("key-2", 1, "default", rspb.Status_DELETED),
releaseStub("key-3", 1, "default", rspb.Status_DEPLOYED),
releaseStub("key-4", 1, "default", rspb.Status_DEPLOYED),
releaseStub("key-5", 1, "default", rspb.Status_SUPERSEDED),
releaseStub("key-6", 1, "default", rspb.Status_SUPERSEDED),
releaseStub("key-1", 1, "default", rspb.StatusDeleted),
releaseStub("key-2", 1, "default", rspb.StatusDeleted),
releaseStub("key-3", 1, "default", rspb.StatusDeployed),
releaseStub("key-4", 1, "default", rspb.StatusDeployed),
releaseStub("key-5", 1, "default", rspb.StatusSuperseded),
releaseStub("key-6", 1, "default", rspb.StatusSuperseded),
}...)
// list all deleted releases
del, err := secrets.List(func(rel *rspb.Release) bool {
return rel.Info.Status.Code == rspb.Status_DELETED
return rel.Info.Status == rspb.StatusDeleted
})
// check
if err != nil {
@ -107,7 +107,7 @@ func TestSecretList(t *testing.T) {
// list all deployed releases
dpl, err := secrets.List(func(rel *rspb.Release) bool {
return rel.Info.Status.Code == rspb.Status_DEPLOYED
return rel.Info.Status == rspb.StatusDeployed
})
// check
if err != nil {
@ -119,7 +119,7 @@ func TestSecretList(t *testing.T) {
// list all superseded releases
ssd, err := secrets.List(func(rel *rspb.Release) bool {
return rel.Info.Status.Code == rspb.Status_SUPERSEDED
return rel.Info.Status == rspb.StatusSuperseded
})
// check
if err != nil {
@ -137,7 +137,7 @@ func TestSecretCreate(t *testing.T) {
name := "smug-pigeon"
namespace := "default"
key := testKey(name, vers)
rel := releaseStub(name, vers, namespace, rspb.Status_DEPLOYED)
rel := releaseStub(name, vers, namespace, rspb.StatusDeployed)
// store the release in a secret
if err := secrets.Create(key, rel); err != nil {
@ -161,12 +161,12 @@ func TestSecretUpdate(t *testing.T) {
name := "smug-pigeon"
namespace := "default"
key := testKey(name, vers)
rel := releaseStub(name, vers, namespace, rspb.Status_DEPLOYED)
rel := releaseStub(name, vers, namespace, rspb.StatusDeployed)
secrets := newTestFixtureSecrets(t, []*rspb.Release{rel}...)
// modify release status code
rel.Info.Status.Code = rspb.Status_SUPERSEDED
rel.Info.Status = rspb.StatusSuperseded
// perform the update
if err := secrets.Update(key, rel); err != nil {
@ -180,7 +180,7 @@ func TestSecretUpdate(t *testing.T) {
}
// check release has actually been updated by comparing modified fields
if 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())
if rel.Info.Status != got.Info.Status {
t.Errorf("Expected status %s, got status %s", rel.Info.Status.String(), got.Info.Status.String())
}
}

@ -85,7 +85,7 @@ func (s *Storage) ListReleases() ([]*rspb.Release, error) {
func (s *Storage) ListDeleted() ([]*rspb.Release, error) {
s.Log("listing deleted releases in storage")
return s.Driver.List(func(rls *rspb.Release) bool {
return relutil.StatusFilter(rspb.Status_DELETED).Check(rls)
return relutil.StatusFilter(rspb.StatusDeleted).Check(rls)
})
}
@ -94,7 +94,7 @@ func (s *Storage) ListDeleted() ([]*rspb.Release, error) {
func (s *Storage) ListDeployed() ([]*rspb.Release, error) {
s.Log("listing all deployed releases in storage")
return s.Driver.List(func(rls *rspb.Release) bool {
return relutil.StatusFilter(rspb.Status_DEPLOYED).Check(rls)
return relutil.StatusFilter(rspb.StatusDeployed).Check(rls)
})
}
@ -142,9 +142,9 @@ func (s *Storage) DeployedAll(name string) ([]*rspb.Release, error) {
s.Log("getting deployed releases from %q history", name)
ls, err := s.Driver.Query(map[string]string{
"NAME": name,
"OWNER": "TILLER",
"STATUS": "DEPLOYED",
"name": name,
"owner": "tiller",
"status": "deployed",
})
if err == nil {
return ls, nil
@ -160,7 +160,7 @@ func (s *Storage) DeployedAll(name string) ([]*rspb.Release, error) {
func (s *Storage) History(name string) ([]*rspb.Release, error) {
s.Log("getting release history for %q", name)
return s.Driver.Query(map[string]string{"NAME": name, "OWNER": "TILLER"})
return s.Driver.Query(map[string]string{"name": name, "owner": "tiller"})
}
// removeLeastRecent removes items from history until the lengh number of releases

@ -55,13 +55,13 @@ func TestStorageUpdate(t *testing.T) {
rls := ReleaseTestData{
Name: "angry-beaver",
Version: 1,
Status: rspb.Status_DEPLOYED,
Status: rspb.StatusDeployed,
}.ToRelease()
assertErrNil(t.Fatal, storage.Create(rls), "StoreRelease")
// modify the release
rls.Info.Status.Code = rspb.Status_DELETED
rls.Info.Status = rspb.StatusDeleted
assertErrNil(t.Fatal, storage.Update(rls), "UpdateRelease")
// retrieve the updated release
@ -122,13 +122,13 @@ func TestStorageList(t *testing.T) {
// setup storage with test releases
setup := func() {
// release records
rls0 := ReleaseTestData{Name: "happy-catdog", Status: rspb.Status_SUPERSEDED}.ToRelease()
rls1 := ReleaseTestData{Name: "livid-human", Status: rspb.Status_SUPERSEDED}.ToRelease()
rls2 := ReleaseTestData{Name: "relaxed-cat", Status: rspb.Status_SUPERSEDED}.ToRelease()
rls3 := ReleaseTestData{Name: "hungry-hippo", Status: rspb.Status_DEPLOYED}.ToRelease()
rls4 := ReleaseTestData{Name: "angry-beaver", Status: rspb.Status_DEPLOYED}.ToRelease()
rls5 := ReleaseTestData{Name: "opulent-frog", Status: rspb.Status_DELETED}.ToRelease()
rls6 := ReleaseTestData{Name: "happy-liger", Status: rspb.Status_DELETED}.ToRelease()
rls0 := ReleaseTestData{Name: "happy-catdog", Status: rspb.StatusSuperseded}.ToRelease()
rls1 := ReleaseTestData{Name: "livid-human", Status: rspb.StatusSuperseded}.ToRelease()
rls2 := ReleaseTestData{Name: "relaxed-cat", Status: rspb.StatusSuperseded}.ToRelease()
rls3 := ReleaseTestData{Name: "hungry-hippo", Status: rspb.StatusDeployed}.ToRelease()
rls4 := ReleaseTestData{Name: "angry-beaver", Status: rspb.StatusDeployed}.ToRelease()
rls5 := ReleaseTestData{Name: "opulent-frog", Status: rspb.StatusDeleted}.ToRelease()
rls6 := ReleaseTestData{Name: "happy-liger", Status: rspb.StatusDeleted}.ToRelease()
// create the release records in the storage
assertErrNil(t.Fatal, storage.Create(rls0), "Storing release 'rls0'")
@ -174,10 +174,10 @@ func TestStorageDeployed(t *testing.T) {
// setup storage with test releases
setup := func() {
// release records
rls0 := ReleaseTestData{Name: name, Version: 1, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls1 := ReleaseTestData{Name: name, Version: 2, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls2 := ReleaseTestData{Name: name, Version: 3, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls3 := ReleaseTestData{Name: name, Version: 4, Status: rspb.Status_DEPLOYED}.ToRelease()
rls0 := ReleaseTestData{Name: name, Version: 1, Status: rspb.StatusSuperseded}.ToRelease()
rls1 := ReleaseTestData{Name: name, Version: 2, Status: rspb.StatusSuperseded}.ToRelease()
rls2 := ReleaseTestData{Name: name, Version: 3, Status: rspb.StatusSuperseded}.ToRelease()
rls3 := ReleaseTestData{Name: name, Version: 4, Status: rspb.StatusDeployed}.ToRelease()
// create the release records in the storage
assertErrNil(t.Fatal, storage.Create(rls0), "Storing release 'angry-bird' (v1)")
@ -200,8 +200,8 @@ func TestStorageDeployed(t *testing.T) {
t.Fatalf("Expected release name %q, actual %q\n", name, rls.Name)
case rls.Version != vers:
t.Fatalf("Expected release version %d, actual %d\n", vers, rls.Version)
case rls.Info.Status.Code != rspb.Status_DEPLOYED:
t.Fatalf("Expected release status 'DEPLOYED', actual %s\n", rls.Info.Status.Code.String())
case rls.Info.Status != rspb.StatusDeployed:
t.Fatalf("Expected release status 'DEPLOYED', actual %s\n", rls.Info.Status.String())
}
}
@ -213,10 +213,10 @@ func TestStorageHistory(t *testing.T) {
// setup storage with test releases
setup := func() {
// release records
rls0 := ReleaseTestData{Name: name, Version: 1, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls1 := ReleaseTestData{Name: name, Version: 2, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls2 := ReleaseTestData{Name: name, Version: 3, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls3 := ReleaseTestData{Name: name, Version: 4, Status: rspb.Status_DEPLOYED}.ToRelease()
rls0 := ReleaseTestData{Name: name, Version: 1, Status: rspb.StatusSuperseded}.ToRelease()
rls1 := ReleaseTestData{Name: name, Version: 2, Status: rspb.StatusSuperseded}.ToRelease()
rls2 := ReleaseTestData{Name: name, Version: 3, Status: rspb.StatusSuperseded}.ToRelease()
rls3 := ReleaseTestData{Name: name, Version: 4, Status: rspb.StatusDeployed}.ToRelease()
// create the release records in the storage
assertErrNil(t.Fatal, storage.Create(rls0), "Storing release 'angry-bird' (v1)")
@ -248,10 +248,10 @@ func TestStorageRemoveLeastRecent(t *testing.T) {
// setup storage with test releases
setup := func() {
// release records
rls0 := ReleaseTestData{Name: name, Version: 1, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls1 := ReleaseTestData{Name: name, Version: 2, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls2 := ReleaseTestData{Name: name, Version: 3, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls3 := ReleaseTestData{Name: name, Version: 4, Status: rspb.Status_DEPLOYED}.ToRelease()
rls0 := ReleaseTestData{Name: name, Version: 1, Status: rspb.StatusSuperseded}.ToRelease()
rls1 := ReleaseTestData{Name: name, Version: 2, Status: rspb.StatusSuperseded}.ToRelease()
rls2 := ReleaseTestData{Name: name, Version: 3, Status: rspb.StatusSuperseded}.ToRelease()
rls3 := ReleaseTestData{Name: name, Version: 4, Status: rspb.StatusDeployed}.ToRelease()
// create the release records in the storage
assertErrNil(t.Fatal, storage.Create(rls0), "Storing release 'angry-bird' (v1)")
@ -270,7 +270,7 @@ func TestStorageRemoveLeastRecent(t *testing.T) {
}
storage.MaxHistory = 3
rls5 := ReleaseTestData{Name: name, Version: 5, Status: rspb.Status_DEPLOYED}.ToRelease()
rls5 := ReleaseTestData{Name: name, Version: 5, Status: rspb.StatusDeployed}.ToRelease()
assertErrNil(t.Fatal, storage.Create(rls5), "Storing release 'angry-bird' (v5)")
// On inserting the 5th record, we expect two records to be pruned from history.
@ -301,10 +301,10 @@ func TestStorageLast(t *testing.T) {
// Set up storage with test releases.
setup := func() {
// release records
rls0 := ReleaseTestData{Name: name, Version: 1, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls1 := ReleaseTestData{Name: name, Version: 2, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls2 := ReleaseTestData{Name: name, Version: 3, Status: rspb.Status_SUPERSEDED}.ToRelease()
rls3 := ReleaseTestData{Name: name, Version: 4, Status: rspb.Status_FAILED}.ToRelease()
rls0 := ReleaseTestData{Name: name, Version: 1, Status: rspb.StatusSuperseded}.ToRelease()
rls1 := ReleaseTestData{Name: name, Version: 2, Status: rspb.StatusSuperseded}.ToRelease()
rls2 := ReleaseTestData{Name: name, Version: 3, Status: rspb.StatusSuperseded}.ToRelease()
rls3 := ReleaseTestData{Name: name, Version: 4, Status: rspb.StatusFailed}.ToRelease()
// create the release records in the storage
assertErrNil(t.Fatal, storage.Create(rls0), "Storing release 'angry-bird' (v1)")
@ -330,7 +330,7 @@ type ReleaseTestData struct {
Version int
Manifest string
Namespace string
Status rspb.StatusCode
Status rspb.ReleaseStatus
}
func (test ReleaseTestData) ToRelease() *rspb.Release {
@ -339,7 +339,7 @@ func (test ReleaseTestData) ToRelease() *rspb.Release {
Version: test.Version,
Manifest: test.Manifest,
Namespace: test.Namespace,
Info: &rspb.Info{Status: &rspb.Status{Code: test.Status}},
Info: &rspb.Info{Status: test.Status},
}
}

@ -32,23 +32,23 @@ import (
)
var events = map[string]release.HookEvent{
hooks.PreInstall: release.Hook_PRE_INSTALL,
hooks.PostInstall: release.Hook_POST_INSTALL,
hooks.PreDelete: release.Hook_PRE_DELETE,
hooks.PostDelete: release.Hook_POST_DELETE,
hooks.PreUpgrade: release.Hook_PRE_UPGRADE,
hooks.PostUpgrade: release.Hook_POST_UPGRADE,
hooks.PreRollback: release.Hook_PRE_ROLLBACK,
hooks.PostRollback: release.Hook_POST_ROLLBACK,
hooks.ReleaseTestSuccess: release.Hook_RELEASE_TEST_SUCCESS,
hooks.ReleaseTestFailure: release.Hook_RELEASE_TEST_FAILURE,
hooks.PreInstall: release.HookPreInstall,
hooks.PostInstall: release.HookPostInstall,
hooks.PreDelete: release.HookPreDelete,
hooks.PostDelete: release.HookPostDelete,
hooks.PreUpgrade: release.HookPreUpgrade,
hooks.PostUpgrade: release.HookPostUpgrade,
hooks.PreRollback: release.HookPreRollback,
hooks.PostRollback: release.HookPostRollback,
hooks.ReleaseTestSuccess: release.HookReleaseTestSuccess,
hooks.ReleaseTestFailure: release.HookReleaseTestFailure,
}
// deletePolices represents a mapping between the key in the annotation for label deleting policy and its real meaning
var deletePolices = map[string]release.HookDeletePolicy{
hooks.HookSucceeded: release.Hook_SUCCEEDED,
hooks.HookFailed: release.Hook_FAILED,
hooks.BeforeHookCreation: release.Hook_BEFORE_HOOK_CREATION,
hooks.HookSucceeded: release.HookSucceeded,
hooks.HookFailed: release.HookFailed,
hooks.BeforeHookCreation: release.HookBeforeHookCreation,
}
// Manifest represents a manifest file, which has a name and some content.

@ -40,7 +40,7 @@ func TestSortManifests(t *testing.T) {
name: []string{"first"},
path: "one",
kind: []string{"Job"},
hooks: map[string][]release.HookEvent{"first": {release.Hook_PRE_INSTALL}},
hooks: map[string][]release.HookEvent{"first": {release.HookPreInstall}},
manifest: `apiVersion: v1
kind: Job
metadata:
@ -55,7 +55,7 @@ metadata:
name: []string{"second"},
path: "two",
kind: []string{"ReplicaSet"},
hooks: map[string][]release.HookEvent{"second": {release.Hook_POST_INSTALL}},
hooks: map[string][]release.HookEvent{"second": {release.HookPostInstall}},
manifest: `kind: ReplicaSet
apiVersion: v1beta1
metadata:
@ -90,7 +90,7 @@ metadata:
name: []string{"fifth"},
path: "five",
kind: []string{"ReplicaSet"},
hooks: map[string][]release.HookEvent{"fifth": {release.Hook_POST_DELETE, release.Hook_POST_INSTALL}},
hooks: map[string][]release.HookEvent{"fifth": {release.HookPostDelete, release.HookPostInstall}},
manifest: `kind: ReplicaSet
apiVersion: v1beta1
metadata:
@ -117,7 +117,7 @@ metadata:
name: []string{"eighth", "example-test"},
path: "eight",
kind: []string{"ConfigMap", "Pod"},
hooks: map[string][]release.HookEvent{"eighth": nil, "example-test": {release.Hook_RELEASE_TEST_SUCCESS}},
hooks: map[string][]release.HookEvent{"eighth": nil, "example-test": {release.HookReleaseTestSuccess}},
manifest: `kind: ConfigMap
apiVersion: v1
metadata:

@ -25,11 +25,11 @@ import (
)
func TestGetHistory_WithRevisions(t *testing.T) {
mk := func(name string, vers int, code rpb.StatusCode) *rpb.Release {
mk := func(name string, vers int, status rpb.ReleaseStatus) *rpb.Release {
return &rpb.Release{
Name: name,
Version: vers,
Info: &rpb.Info{Status: &rpb.Status{Code: code}},
Info: &rpb.Info{Status: status},
}
}
@ -43,28 +43,28 @@ func TestGetHistory_WithRevisions(t *testing.T) {
desc: "get release with history and default limit (max=256)",
req: &hapi.GetHistoryRequest{Name: "angry-bird", Max: 256},
res: []*rpb.Release{
mk("angry-bird", 4, rpb.Status_DEPLOYED),
mk("angry-bird", 3, rpb.Status_SUPERSEDED),
mk("angry-bird", 2, rpb.Status_SUPERSEDED),
mk("angry-bird", 1, rpb.Status_SUPERSEDED),
mk("angry-bird", 4, rpb.StatusDeployed),
mk("angry-bird", 3, rpb.StatusSuperseded),
mk("angry-bird", 2, rpb.StatusSuperseded),
mk("angry-bird", 1, rpb.StatusSuperseded),
},
},
{
desc: "get release with history using result limit (max=2)",
req: &hapi.GetHistoryRequest{Name: "angry-bird", Max: 2},
res: []*rpb.Release{
mk("angry-bird", 4, rpb.Status_DEPLOYED),
mk("angry-bird", 3, rpb.Status_SUPERSEDED),
mk("angry-bird", 4, rpb.StatusDeployed),
mk("angry-bird", 3, rpb.StatusSuperseded),
},
},
}
// test release history for release 'angry-bird'
hist := []*rpb.Release{
mk("angry-bird", 4, rpb.Status_DEPLOYED),
mk("angry-bird", 3, rpb.Status_SUPERSEDED),
mk("angry-bird", 2, rpb.Status_SUPERSEDED),
mk("angry-bird", 1, rpb.Status_SUPERSEDED),
mk("angry-bird", 4, rpb.StatusDeployed),
mk("angry-bird", 3, rpb.StatusSuperseded),
mk("angry-bird", 2, rpb.StatusSuperseded),
mk("angry-bird", 1, rpb.StatusSuperseded),
}
srv := rsFixture()
@ -98,7 +98,7 @@ func TestGetHistory_WithNoRevisions(t *testing.T) {
}
// create release 'sad-panda' with no revision history
rls := namedReleaseStub("sad-panda", rpb.Status_DEPLOYED)
rls := namedReleaseStub("sad-panda", rpb.StatusDeployed)
srv := rsFixture()
srv.Releases.Create(rls)

@ -94,7 +94,7 @@ func (s *ReleaseServer) prepareRelease(req *hapi.InstallReleaseRequest) (*releas
Info: &release.Info{
FirstDeployed: ts,
LastDeployed: ts,
Status: &release.Status{Code: release.Status_UNKNOWN},
Status: release.StatusUnknown,
Description: fmt.Sprintf("Install failed: %s", err),
},
Version: 0,
@ -114,7 +114,7 @@ func (s *ReleaseServer) prepareRelease(req *hapi.InstallReleaseRequest) (*releas
Info: &release.Info{
FirstDeployed: ts,
LastDeployed: ts,
Status: &release.Status{Code: release.Status_PENDING_INSTALL},
Status: release.StatusPendingInstall,
Description: "Initial install underway", // Will be overwritten.
},
Manifest: manifestDoc.String(),
@ -122,7 +122,7 @@ func (s *ReleaseServer) prepareRelease(req *hapi.InstallReleaseRequest) (*releas
Version: revision,
}
if len(notesTxt) > 0 {
rel.Info.Status.Notes = notesTxt
rel.Info.Notes = notesTxt
}
err = validateManifest(s.KubeClient, req.Namespace, manifestDoc.Bytes())
@ -158,7 +158,7 @@ func (s *ReleaseServer) performRelease(r *release.Release, req *hapi.InstallRele
old := h[0]
// update old release status
old.Info.Status.Code = release.Status_SUPERSEDED
old.Info.Status = release.StatusSuperseded
s.recordRelease(old, true)
// update new release with next revision number
@ -173,8 +173,8 @@ func (s *ReleaseServer) performRelease(r *release.Release, req *hapi.InstallRele
if err := s.updateRelease(old, r, updateReq); err != nil {
msg := fmt.Sprintf("Release replace %q failed: %s", r.Name, err)
s.Log("warning: %s", msg)
old.Info.Status.Code = release.Status_SUPERSEDED
r.Info.Status.Code = release.Status_FAILED
old.Info.Status = release.StatusSuperseded
r.Info.Status = release.StatusFailed
r.Info.Description = msg
s.recordRelease(old, true)
s.recordRelease(r, true)
@ -189,7 +189,7 @@ func (s *ReleaseServer) performRelease(r *release.Release, req *hapi.InstallRele
if err := s.KubeClient.Create(r.Namespace, b, req.Timeout, req.Wait); err != nil {
msg := fmt.Sprintf("Release %q failed: %s", r.Name, err)
s.Log("warning: %s", msg)
r.Info.Status.Code = release.Status_FAILED
r.Info.Status = release.StatusFailed
r.Info.Description = msg
s.recordRelease(r, true)
return r, fmt.Errorf("release %s failed: %s", r.Name, err)
@ -201,14 +201,14 @@ func (s *ReleaseServer) performRelease(r *release.Release, req *hapi.InstallRele
if err := s.execHook(r.Hooks, r.Name, r.Namespace, hooks.PostInstall, req.Timeout); err != nil {
msg := fmt.Sprintf("Release %q failed post-install: %s", r.Name, err)
s.Log("warning: %s", msg)
r.Info.Status.Code = release.Status_FAILED
r.Info.Status = release.StatusFailed
r.Info.Description = msg
s.recordRelease(r, true)
return r, err
}
}
r.Info.Status.Code = release.Status_DEPLOYED
r.Info.Status = release.StatusDeployed
r.Info.Description = "Install complete"
// This is a tricky case. The release has been created, but the result
// cannot be recorded. The truest thing to tell the user is that the

@ -54,10 +54,10 @@ func TestInstallRelease(t *testing.T) {
t.Errorf("Unexpected manifest: %v", rel.Hooks[0].Manifest)
}
if rel.Hooks[0].Events[0] != release.Hook_POST_INSTALL {
if rel.Hooks[0].Events[0] != release.HookPostInstall {
t.Errorf("Expected event 0 is post install")
}
if rel.Hooks[0].Events[1] != release.Hook_PRE_DELETE {
if rel.Hooks[0].Events[1] != release.HookPreDelete {
t.Errorf("Expected event 0 is pre-delete")
}
@ -109,14 +109,14 @@ func TestInstallRelease_WithNotes(t *testing.T) {
t.Errorf("Unexpected manifest: %v", rel.Hooks[0].Manifest)
}
if rel.Info.Status.Notes != notesText {
t.Fatalf("Expected '%s', got '%s'", notesText, rel.Info.Status.Notes)
if rel.Info.Notes != notesText {
t.Fatalf("Expected '%s', got '%s'", notesText, rel.Info.Notes)
}
if rel.Hooks[0].Events[0] != release.Hook_POST_INSTALL {
if rel.Hooks[0].Events[0] != release.HookPostInstall {
t.Errorf("Expected event 0 is post install")
}
if rel.Hooks[0].Events[1] != release.Hook_PRE_DELETE {
if rel.Hooks[0].Events[1] != release.HookPreDelete {
t.Errorf("Expected event 0 is pre-delete")
}
@ -169,14 +169,14 @@ func TestInstallRelease_WithNotesRendered(t *testing.T) {
}
expectedNotes := fmt.Sprintf("%s %s", notesText, res.Name)
if rel.Info.Status.Notes != expectedNotes {
t.Fatalf("Expected '%s', got '%s'", expectedNotes, rel.Info.Status.Notes)
if rel.Info.Notes != expectedNotes {
t.Fatalf("Expected '%s', got '%s'", expectedNotes, rel.Info.Notes)
}
if rel.Hooks[0].Events[0] != release.Hook_POST_INSTALL {
if rel.Hooks[0].Events[0] != release.HookPostInstall {
t.Errorf("Expected event 0 is post install")
}
if rel.Hooks[0].Events[1] != release.Hook_PRE_DELETE {
if rel.Hooks[0].Events[1] != release.HookPreDelete {
t.Errorf("Expected event 0 is pre-delete")
}
@ -219,8 +219,8 @@ func TestInstallRelease_WithChartAndDependencyNotes(t *testing.T) {
t.Logf("rel: %v", rel)
if rel.Info.Status.Notes != notesText {
t.Fatalf("Expected '%s', got '%s'", notesText, rel.Info.Status.Notes)
if rel.Info.Notes != notesText {
t.Fatalf("Expected '%s', got '%s'", notesText, rel.Info.Notes)
}
if rel.Info.Description != "Install complete" {
@ -305,15 +305,16 @@ func TestInstallRelease_FailedHooks(t *testing.T) {
t.Error("Expected failed install")
}
if hl := res.Info.Status.Code; hl != release.Status_FAILED {
t.Errorf("Expected FAILED release. Got %d", hl)
if hl := res.Info.Status; hl != release.StatusFailed {
t.Errorf("Expected FAILED release. Got %s", hl)
}
}
func TestInstallRelease_ReuseName(t *testing.T) {
rs := rsFixture()
rs.Log = t.Logf
rel := releaseStub()
rel.Info.Status.Code = release.Status_DELETED
rel.Info.Status = release.StatusDeleted
rs.Releases.Create(rel)
req := installRequest(
@ -334,8 +335,8 @@ func TestInstallRelease_ReuseName(t *testing.T) {
if err != nil {
t.Errorf("Failed to retrieve release: %s", err)
}
if getres.Info.Status.Code != release.Status_DEPLOYED {
t.Errorf("Release status is %q", getres.Info.Status.Code)
if getres.Info.Status != release.StatusDeployed {
t.Errorf("Release status is %q", getres.Info.Status)
}
}

@ -27,12 +27,12 @@ import (
// ListReleases lists the releases found by the server.
func (s *ReleaseServer) ListReleases(req *hapi.ListReleasesRequest) ([]*release.Release, error) {
if len(req.StatusCodes) == 0 {
req.StatusCodes = []release.StatusCode{release.Status_DEPLOYED}
req.StatusCodes = []release.ReleaseStatus{release.StatusDeployed}
}
rels, err := s.Releases.ListFilterAll(func(r *release.Release) bool {
for _, sc := range req.StatusCodes {
if sc == r.Info.Status.Code {
if sc == r.Info.Status {
return true
}
}
@ -50,13 +50,13 @@ func (s *ReleaseServer) ListReleases(req *hapi.ListReleasesRequest) ([]*release.
}
switch req.SortBy {
case hapi.ListSort_NAME:
case hapi.ListSortName:
relutil.SortByName(rels)
case hapi.ListSort_LAST_RELEASED:
case hapi.ListSortLastReleased:
relutil.SortByDate(rels)
}
if req.SortOrder == hapi.ListSort_DESC {
if req.SortOrder == hapi.ListSortDesc {
ll := len(rels)
rr := make([]*release.Release, ll)
for i, item := range rels {

@ -48,10 +48,10 @@ func TestListReleases(t *testing.T) {
func TestListReleasesByStatus(t *testing.T) {
rs := rsFixture()
stubs := []*release.Release{
namedReleaseStub("kamal", release.Status_DEPLOYED),
namedReleaseStub("astrolabe", release.Status_DELETED),
namedReleaseStub("octant", release.Status_FAILED),
namedReleaseStub("sextant", release.Status_UNKNOWN),
namedReleaseStub("kamal", release.StatusDeployed),
namedReleaseStub("astrolabe", release.StatusDeleted),
namedReleaseStub("octant", release.StatusFailed),
namedReleaseStub("sextant", release.StatusUnknown),
}
for _, stub := range stubs {
if err := rs.Releases.Create(stub); err != nil {
@ -60,28 +60,28 @@ func TestListReleasesByStatus(t *testing.T) {
}
tests := []struct {
statusCodes []release.StatusCode
statusCodes []release.ReleaseStatus
names []string
}{
{
names: []string{"kamal"},
statusCodes: []release.StatusCode{release.Status_DEPLOYED},
statusCodes: []release.ReleaseStatus{release.StatusDeployed},
},
{
names: []string{"astrolabe"},
statusCodes: []release.StatusCode{release.Status_DELETED},
statusCodes: []release.ReleaseStatus{release.StatusDeleted},
},
{
names: []string{"kamal", "octant"},
statusCodes: []release.StatusCode{release.Status_DEPLOYED, release.Status_FAILED},
statusCodes: []release.ReleaseStatus{release.StatusDeployed, release.StatusFailed},
},
{
names: []string{"kamal", "astrolabe", "octant", "sextant"},
statusCodes: []release.StatusCode{
release.Status_DEPLOYED,
release.Status_DELETED,
release.Status_FAILED,
release.Status_UNKNOWN,
statusCodes: []release.ReleaseStatus{
release.StatusDeployed,
release.StatusDeleted,
release.StatusFailed,
release.StatusUnknown,
},
},
}
@ -128,7 +128,7 @@ func TestListReleasesSort(t *testing.T) {
req := &hapi.ListReleasesRequest{
Offset: "",
Limit: int64(limit),
SortBy: hapi.ListSort_NAME,
SortBy: hapi.ListSortName,
}
rels, err := rs.ListReleases(req)
if err != nil {
@ -171,7 +171,7 @@ func TestListReleasesFilter(t *testing.T) {
Offset: "",
Limit: 64,
Filter: "neuro[a-z]+",
SortBy: hapi.ListSort_NAME,
SortBy: hapi.ListSortName,
}
rels, err := rs.ListReleases(req)
if err != nil {

@ -94,10 +94,8 @@ func (s *ReleaseServer) prepareRollback(req *hapi.RollbackReleaseRequest) (*rele
Info: &release.Info{
FirstDeployed: currentRelease.Info.FirstDeployed,
LastDeployed: time.Now(),
Status: &release.Status{
Code: release.Status_PENDING_ROLLBACK,
Notes: previousRelease.Info.Status.Notes,
},
Status: release.StatusPendingRollback,
Notes: previousRelease.Info.Notes,
// Because we lose the reference to previous version elsewhere, we set the
// message here, and only override it later if we experience failure.
Description: fmt.Sprintf("Rollback to %d", previousVersion),
@ -131,8 +129,8 @@ func (s *ReleaseServer) performRollback(currentRelease, targetRelease *release.R
if err := s.KubeClient.Update(targetRelease.Namespace, c, t, req.Force, req.Recreate, req.Timeout, req.Wait); err != nil {
msg := fmt.Sprintf("Rollback %q failed: %s", targetRelease.Name, err)
s.Log("warning: %s", msg)
currentRelease.Info.Status.Code = release.Status_SUPERSEDED
targetRelease.Info.Status.Code = release.Status_FAILED
currentRelease.Info.Status = release.StatusSuperseded
targetRelease.Info.Status = release.StatusFailed
targetRelease.Info.Description = msg
s.recordRelease(currentRelease, true)
s.recordRelease(targetRelease, true)
@ -153,11 +151,11 @@ func (s *ReleaseServer) performRollback(currentRelease, targetRelease *release.R
// Supersede all previous deployments, see issue #2941.
for _, r := range deployed {
s.Log("superseding previous deployment %d", r.Version)
r.Info.Status.Code = release.Status_SUPERSEDED
r.Info.Status = release.StatusSuperseded
s.recordRelease(r, true)
}
targetRelease.Info.Status.Code = release.Status_DEPLOYED
targetRelease.Info.Status = release.StatusDeployed
return targetRelease, nil
}

@ -36,8 +36,8 @@ func TestRollbackRelease(t *testing.T) {
Path: "test-cm",
Manifest: manifestWithRollbackHooks,
Events: []release.HookEvent{
release.Hook_PRE_ROLLBACK,
release.Hook_POST_ROLLBACK,
release.HookPreRollback,
release.HookPostRollback,
},
},
}
@ -109,11 +109,11 @@ func TestRollbackRelease(t *testing.T) {
t.Errorf("Expected release version to be %v, got %v", 3, res.Version)
}
if updated.Hooks[0].Events[0] != release.Hook_PRE_ROLLBACK {
if updated.Hooks[0].Events[0] != release.HookPreRollback {
t.Errorf("Expected event 0 to be pre rollback")
}
if updated.Hooks[0].Events[1] != release.Hook_POST_ROLLBACK {
if updated.Hooks[0].Events[1] != release.HookPostRollback {
t.Errorf("Expected event 1 to be post rollback")
}
@ -146,8 +146,8 @@ func TestRollbackWithReleaseVersion(t *testing.T) {
rs.Releases.Create(v2)
v3 := upgradeReleaseVersion(v2)
// retain the original release as DEPLOYED while the update should fail
v2.Info.Status.Code = release.Status_DEPLOYED
v3.Info.Status.Code = release.Status_FAILED
v2.Info.Status = release.StatusDeployed
v3.Info.Status = release.StatusFailed
rs.Releases.Update(v2)
rs.Releases.Create(v3)
@ -166,16 +166,16 @@ func TestRollbackWithReleaseVersion(t *testing.T) {
if err != nil {
t.Fatalf("Failed to retrieve v1: %s", err)
}
if oldRel.Info.Status.Code != release.Status_SUPERSEDED {
t.Errorf("Expected v2 to be in a SUPERSEDED state, got %q", oldRel.Info.Status.Code)
if oldRel.Info.Status != release.StatusSuperseded {
t.Errorf("Expected v2 to be in a SUPERSEDED state, got %q", oldRel.Info.Status)
}
// make sure we didn't update some other deployments.
otherRel, err := rs.Releases.Get(rel2.Name, 1)
if err != nil {
t.Fatalf("Failed to retrieve other v1: %s", err)
}
if otherRel.Info.Status.Code != release.Status_DEPLOYED {
t.Errorf("Expected other deployed release to stay untouched, got %q", otherRel.Info.Status.Code)
if otherRel.Info.Status != release.StatusDeployed {
t.Errorf("Expected other deployed release to stay untouched, got %q", otherRel.Info.Status)
}
}
@ -189,8 +189,8 @@ func TestRollbackReleaseNoHooks(t *testing.T) {
Path: "test-cm",
Manifest: manifestWithRollbackHooks,
Events: []release.HookEvent{
release.Hook_PRE_ROLLBACK,
release.Hook_POST_ROLLBACK,
release.HookPreRollback,
release.HookPostRollback,
},
},
}
@ -233,7 +233,7 @@ func TestRollbackReleaseFailure(t *testing.T) {
t.Error("Expected failed rollback")
}
if targetStatus := res.Info.Status.Code; targetStatus != release.Status_FAILED {
if targetStatus := res.Info.Status; targetStatus != release.StatusFailed {
t.Errorf("Expected FAILED release. Got %v", targetStatus)
}
@ -241,7 +241,7 @@ func TestRollbackReleaseFailure(t *testing.T) {
if err != nil {
t.Errorf("Expected to be able to get previous release")
}
if oldStatus := oldRelease.Info.Status.Code; oldStatus != release.Status_SUPERSEDED {
if oldStatus := oldRelease.Info.Status; oldStatus != release.StatusSuperseded {
t.Errorf("Expected SUPERSEDED status on previous Release version. Got %v", oldStatus)
}
}

@ -180,7 +180,7 @@ func (s *ReleaseServer) uniqName(start string, reuse bool) (string, error) {
relutil.Reverse(h, relutil.SortByRevision)
rel := h[0]
if st := rel.Info.Status.Code; reuse && (st == release.Status_DELETED || st == release.Status_FAILED) {
if st := rel.Info.Status; reuse && (st == release.StatusDeleted || st == release.StatusFailed) {
// Allowe re-use of names if the previous release is marked deleted.
s.Log("name %s exists but is not in use, reusing name", start)
return start, nil

@ -214,16 +214,16 @@ func chartStub() *chart.Chart {
// releaseStub creates a release stub, complete with the chartStub as its chart.
func releaseStub() *release.Release {
return namedReleaseStub("angry-panda", release.Status_DEPLOYED)
return namedReleaseStub("angry-panda", release.StatusDeployed)
}
func namedReleaseStub(name string, status release.StatusCode) *release.Release {
func namedReleaseStub(name string, status release.ReleaseStatus) *release.Release {
return &release.Release{
Name: name,
Info: &release.Info{
FirstDeployed: time.Now(),
LastDeployed: time.Now(),
Status: &release.Status{Code: status},
Status: status,
Description: "Named Release Stub",
},
Chart: chartStub(),
@ -236,8 +236,8 @@ func namedReleaseStub(name string, status release.StatusCode) *release.Release {
Path: "test-cm",
Manifest: manifestWithHook,
Events: []release.HookEvent{
release.Hook_POST_INSTALL,
release.Hook_PRE_DELETE,
release.HookPostInstall,
release.HookPreDelete,
},
},
{
@ -246,7 +246,7 @@ func namedReleaseStub(name string, status release.StatusCode) *release.Release {
Path: "finding-nemo",
Manifest: manifestWithTestHook,
Events: []release.HookEvent{
release.Hook_RELEASE_TEST_SUCCESS,
release.HookReleaseTestSuccess,
},
},
},
@ -254,13 +254,13 @@ func namedReleaseStub(name string, status release.StatusCode) *release.Release {
}
func upgradeReleaseVersion(rel *release.Release) *release.Release {
rel.Info.Status.Code = release.Status_SUPERSEDED
rel.Info.Status = release.StatusSuperseded
return &release.Release{
Name: rel.Name,
Info: &release.Info{
FirstDeployed: rel.Info.FirstDeployed,
LastDeployed: time.Now(),
Status: &release.Status{Code: release.Status_DEPLOYED},
Status: release.StatusDeployed,
},
Chart: rel.Chart,
Config: rel.Config,
@ -311,7 +311,7 @@ func TestUniqName(t *testing.T) {
rel1 := releaseStub()
rel2 := releaseStub()
rel2.Name = "happy-panda"
rel2.Info.Status.Code = release.Status_DELETED
rel2.Info.Status = release.StatusDeleted
rs.Releases.Create(rel1)
rs.Releases.Create(rel2)
@ -364,7 +364,7 @@ func releaseWithKeepStub(rlsName string) *release.Release {
Info: &release.Info{
FirstDeployed: time.Now(),
LastDeployed: time.Now(),
Status: &release.Status{Code: release.Status_DEPLOYED},
Status: release.StatusDeployed,
},
Chart: ch,
Config: []byte(`name: value`),
@ -514,8 +514,8 @@ metadata:
%sdata:
name: value`, hookName, extraAnnotationsStr),
Events: []release.HookEvent{
release.Hook_PRE_INSTALL,
release.Hook_PRE_UPGRADE,
release.HookPreInstall,
release.HookPreUpgrade,
},
DeletePolicies: DeletePolicies,
}
@ -595,7 +595,7 @@ func TestSuccessfulHookWithSucceededDeletePolicy(t *testing.T) {
ctx := newDeletePolicyContext()
hook := deletePolicyHookStub(ctx.HookName,
map[string]string{"helm.sh/hook-delete-policy": "hook-succeeded"},
[]release.HookDeletePolicy{release.Hook_SUCCEEDED},
[]release.HookDeletePolicy{release.HookSucceeded},
)
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
@ -610,7 +610,7 @@ func TestSuccessfulHookWithFailedDeletePolicy(t *testing.T) {
ctx := newDeletePolicyContext()
hook := deletePolicyHookStub(ctx.HookName,
map[string]string{"helm.sh/hook-delete-policy": "hook-failed"},
[]release.HookDeletePolicy{release.Hook_FAILED},
[]release.HookDeletePolicy{release.HookFailed},
)
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
@ -629,7 +629,7 @@ func TestFailedHookWithSucceededDeletePolicy(t *testing.T) {
"mockHooksKubeClient/Emulate": "hook-failed",
"helm.sh/hook-delete-policy": "hook-succeeded",
},
[]release.HookDeletePolicy{release.Hook_SUCCEEDED},
[]release.HookDeletePolicy{release.HookSucceeded},
)
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
@ -648,7 +648,7 @@ func TestFailedHookWithFailedDeletePolicy(t *testing.T) {
"mockHooksKubeClient/Emulate": "hook-failed",
"helm.sh/hook-delete-policy": "hook-failed",
},
[]release.HookDeletePolicy{release.Hook_FAILED},
[]release.HookDeletePolicy{release.HookFailed},
)
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
@ -666,7 +666,7 @@ func TestSuccessfulHookWithSuccededOrFailedDeletePolicy(t *testing.T) {
map[string]string{
"helm.sh/hook-delete-policy": "hook-succeeded,hook-failed",
},
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_FAILED},
[]release.HookDeletePolicy{release.HookSucceeded, release.HookFailed},
)
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
@ -685,7 +685,7 @@ func TestFailedHookWithSuccededOrFailedDeletePolicy(t *testing.T) {
"mockHooksKubeClient/Emulate": "hook-failed",
"helm.sh/hook-delete-policy": "hook-succeeded,hook-failed",
},
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_FAILED},
[]release.HookDeletePolicy{release.HookSucceeded, release.HookFailed},
)
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
@ -720,7 +720,7 @@ func TestHookDeletingWithBeforeHookCreationDeletePolicy(t *testing.T) {
hook := deletePolicyHookStub(ctx.HookName,
map[string]string{"helm.sh/hook-delete-policy": "before-hook-creation"},
[]release.HookDeletePolicy{release.Hook_BEFORE_HOOK_CREATION},
[]release.HookDeletePolicy{release.HookBeforeHookCreation},
)
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
@ -744,7 +744,7 @@ func TestSuccessfulHookWithMixedDeletePolicies(t *testing.T) {
map[string]string{
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation",
},
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
[]release.HookDeletePolicy{release.HookSucceeded, release.HookBeforeHookCreation},
)
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
@ -769,7 +769,7 @@ func TestFailedHookWithMixedDeletePolicies(t *testing.T) {
"mockHooksKubeClient/Emulate": "hook-failed",
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation",
},
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
[]release.HookDeletePolicy{release.HookSucceeded, release.HookBeforeHookCreation},
)
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
@ -794,7 +794,7 @@ func TestFailedThenSuccessfulHookWithMixedDeletePolicies(t *testing.T) {
"mockHooksKubeClient/Emulate": "hook-failed",
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation",
},
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
[]release.HookDeletePolicy{release.HookSucceeded, release.HookBeforeHookCreation},
)
if err := execHookShouldFail(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreInstall); err != nil {
@ -808,7 +808,7 @@ func TestFailedThenSuccessfulHookWithMixedDeletePolicies(t *testing.T) {
map[string]string{
"helm.sh/hook-delete-policy": "hook-succeeded,before-hook-creation",
},
[]release.HookDeletePolicy{release.Hook_SUCCEEDED, release.Hook_BEFORE_HOOK_CREATION},
[]release.HookDeletePolicy{release.HookSucceeded, release.HookBeforeHookCreation},
)
if err := execHookShouldSucceed(ctx.ReleaseServer, hook, ctx.ReleaseName, ctx.Namespace, hooks.PreUpgrade); err != nil {

@ -54,7 +54,7 @@ func (s *ReleaseServer) GetReleaseStatus(req *hapi.GetReleaseStatusRequest) (*ha
return nil, errors.New("release chart is missing")
}
sc := rel.Info.Status.Code
sc := rel.Info.Status
statusResp := &hapi.GetReleaseStatusResponse{
Name: rel.Name,
Namespace: rel.Namespace,
@ -64,13 +64,13 @@ func (s *ReleaseServer) GetReleaseStatus(req *hapi.GetReleaseStatusRequest) (*ha
// Ok, we got the status of the release as we had jotted down, now we need to match the
// manifest we stashed away with reality from the cluster.
resp, err := s.KubeClient.Get(rel.Namespace, bytes.NewBufferString(rel.Manifest))
if sc == release.Status_DELETED || sc == release.Status_FAILED {
if sc == release.StatusDeleted || sc == release.StatusFailed {
// Skip errors if this is already deleted or failed.
return statusResp, nil
} else if err != nil {
s.Log("warning: Get for %s failed: %v", rel.Name, err)
return nil, err
}
rel.Info.Status.Resources = resp
rel.Info.Resources = resp
return statusResp, nil
}

@ -38,15 +38,15 @@ func TestGetReleaseStatus(t *testing.T) {
if res.Name != rel.Name {
t.Errorf("Expected name %q, got %q", rel.Name, res.Name)
}
if res.Info.Status.Code != release.Status_DEPLOYED {
t.Errorf("Expected %d, got %d", release.Status_DEPLOYED, res.Info.Status.Code)
if res.Info.Status != release.StatusDeployed {
t.Errorf("Expected %s, got %s", release.StatusDeployed, res.Info.Status)
}
}
func TestGetReleaseStatusDeleted(t *testing.T) {
rs := rsFixture()
rel := releaseStub()
rel.Info.Status.Code = release.Status_DELETED
rel.Info.Status = release.StatusDeleted
if err := rs.Releases.Create(rel); err != nil {
t.Fatalf("Could not store mock release: %s", err)
}
@ -56,7 +56,7 @@ func TestGetReleaseStatusDeleted(t *testing.T) {
t.Fatalf("Error getting release content: %s", err)
}
if res.Info.Status.Code != release.Status_DELETED {
t.Errorf("Expected %d, got %d", release.Status_DELETED, res.Info.Status.Code)
if res.Info.Status != release.StatusDeleted {
t.Errorf("Expected %s, got %s", release.StatusDeleted, res.Info.Status)
}
}

@ -58,7 +58,7 @@ func (s *ReleaseServer) RunReleaseTest(req *hapi.TestReleaseRequest) (<-chan *ha
return
}
rel.Info.Status.LastTestSuiteRun = &release.TestSuite{
rel.Info.LastTestSuiteRun = &release.TestSuite{
StartedAt: tSuite.StartedAt,
CompletedAt: tSuite.CompletedAt,
Results: tSuite.Results,

@ -51,7 +51,7 @@ func (s *ReleaseServer) UninstallRelease(req *hapi.UninstallReleaseRequest) (*ha
// TODO: Are there any cases where we want to force a delete even if it's
// already marked deleted?
if rel.Info.Status.Code == release.Status_DELETED {
if rel.Info.Status == release.StatusDeleted {
if req.Purge {
if err := s.purgeReleases(rels...); err != nil {
s.Log("uninstall: Failed to purge the release: %s", err)
@ -63,7 +63,7 @@ func (s *ReleaseServer) UninstallRelease(req *hapi.UninstallReleaseRequest) (*ha
}
s.Log("uninstall: Deleting %s", req.Name)
rel.Info.Status.Code = release.Status_DELETING
rel.Info.Status = release.StatusDeleting
rel.Info.Deleted = time.Now()
rel.Info.Description = "Deletion in progress (or silently failed)"
res := &hapi.UninstallReleaseResponse{Release: rel}
@ -76,7 +76,7 @@ func (s *ReleaseServer) UninstallRelease(req *hapi.UninstallReleaseRequest) (*ha
s.Log("delete hooks disabled for %s", req.Name)
}
// From here on out, the release is currently considered to be in Status_DELETING
// From here on out, the release is currently considered to be in StatusDeleting
// state.
if err := s.Releases.Update(rel); err != nil {
s.Log("uninstall: Failed to store updated release: %s", err)
@ -91,7 +91,7 @@ func (s *ReleaseServer) UninstallRelease(req *hapi.UninstallReleaseRequest) (*ha
}
}
rel.Info.Status.Code = release.Status_DELETED
rel.Info.Status = release.StatusDeleted
rel.Info.Description = "Deletion complete"
if req.Purge {

@ -41,8 +41,8 @@ func TestUninstallRelease(t *testing.T) {
t.Errorf("Expected angry-panda, got %q", res.Release.Name)
}
if res.Release.Info.Status.Code != release.Status_DELETED {
t.Errorf("Expected status code to be DELETED, got %d", res.Release.Info.Status.Code)
if res.Release.Info.Status != release.StatusDeleted {
t.Errorf("Expected status code to be DELETED, got %s", res.Release.Info.Status)
}
if res.Release.Hooks[0].LastRun.IsZero() {
@ -80,8 +80,8 @@ func TestUninstallPurgeRelease(t *testing.T) {
t.Errorf("Expected angry-panda, got %q", res.Release.Name)
}
if res.Release.Info.Status.Code != release.Status_DELETED {
t.Errorf("Expected status code to be DELETED, got %d", res.Release.Info.Status.Code)
if res.Release.Info.Status != release.StatusDeleted {
t.Errorf("Expected status code to be DELETED, got %s", res.Release.Info.Status)
}
if res.Release.Info.Deleted.Second() <= 0 {
@ -138,8 +138,8 @@ func TestUninstallReleaseWithKeepPolicy(t *testing.T) {
t.Errorf("Expected angry-bunny, got %q", res.Release.Name)
}
if res.Release.Info.Status.Code != release.Status_DELETED {
t.Errorf("Expected status code to be DELETED, got %d", res.Release.Info.Status.Code)
if res.Release.Info.Status != release.StatusDeleted {
t.Errorf("Expected status code to be DELETED, got %s", res.Release.Info.Status)
}
if res.Info == "" {

@ -126,7 +126,7 @@ func (s *ReleaseServer) prepareUpdate(req *hapi.UpdateReleaseRequest) (*release.
Info: &release.Info{
FirstDeployed: currentRelease.Info.FirstDeployed,
LastDeployed: ts,
Status: &release.Status{Code: release.Status_PENDING_UPGRADE},
Status: release.StatusPendingUpgrade,
Description: "Preparing upgrade", // This should be overwritten later.
},
Version: revision,
@ -135,7 +135,7 @@ func (s *ReleaseServer) prepareUpdate(req *hapi.UpdateReleaseRequest) (*release.
}
if len(notesTxt) > 0 {
updatedRelease.Info.Status.Notes = notesTxt
updatedRelease.Info.Notes = notesTxt
}
err = validateManifest(s.KubeClient, currentRelease.Namespace, manifestDoc.Bytes())
return currentRelease, updatedRelease, err
@ -170,9 +170,9 @@ func (s *ReleaseServer) performUpdateForce(req *hapi.UpdateReleaseRequest) (*rel
return newRelease, err
}
// From here on out, the release is considered to be in Status_DELETING or Status_DELETED
// From here on out, the release is considered to be in StatusDeleting or StatusDeleted
// state. There is no turning back.
oldRelease.Info.Status.Code = release.Status_DELETING
oldRelease.Info.Status = release.StatusDeleting
oldRelease.Info.Deleted = time.Now()
oldRelease.Info.Description = "Deletion in progress (or silently failed)"
s.recordRelease(oldRelease, true)
@ -189,7 +189,7 @@ func (s *ReleaseServer) performUpdateForce(req *hapi.UpdateReleaseRequest) (*rel
// delete manifests from the old release
_, errs := s.deleteRelease(oldRelease)
oldRelease.Info.Status.Code = release.Status_DELETED
oldRelease.Info.Status = release.StatusDeleted
oldRelease.Info.Description = "Deletion complete"
s.recordRelease(oldRelease, true)
@ -217,7 +217,7 @@ func (s *ReleaseServer) performUpdateForce(req *hapi.UpdateReleaseRequest) (*rel
if err := s.updateRelease(oldRelease, newRelease, req); err != nil {
msg := fmt.Sprintf("Upgrade %q failed: %s", newRelease.Name, err)
s.Log("warning: %s", msg)
newRelease.Info.Status.Code = release.Status_FAILED
newRelease.Info.Status = release.StatusFailed
newRelease.Info.Description = msg
s.recordRelease(newRelease, true)
return newRelease, err
@ -228,14 +228,14 @@ func (s *ReleaseServer) performUpdateForce(req *hapi.UpdateReleaseRequest) (*rel
if err := s.execHook(newRelease.Hooks, newRelease.Name, newRelease.Namespace, hooks.PostInstall, req.Timeout); err != nil {
msg := fmt.Sprintf("Release %q failed post-install: %s", newRelease.Name, err)
s.Log("warning: %s", msg)
newRelease.Info.Status.Code = release.Status_FAILED
newRelease.Info.Status = release.StatusFailed
newRelease.Info.Description = msg
s.recordRelease(newRelease, true)
return newRelease, err
}
}
newRelease.Info.Status.Code = release.Status_DEPLOYED
newRelease.Info.Status = release.StatusDeployed
newRelease.Info.Description = "Upgrade complete"
s.recordRelease(newRelease, true)
@ -261,7 +261,7 @@ func (s *ReleaseServer) performUpdate(originalRelease, updatedRelease *release.R
if err := s.updateRelease(originalRelease, updatedRelease, req); err != nil {
msg := fmt.Sprintf("Upgrade %q failed: %s", updatedRelease.Name, err)
s.Log("warning: %s", msg)
updatedRelease.Info.Status.Code = release.Status_FAILED
updatedRelease.Info.Status = release.StatusFailed
updatedRelease.Info.Description = msg
s.recordRelease(originalRelease, true)
s.recordRelease(updatedRelease, true)
@ -275,10 +275,10 @@ func (s *ReleaseServer) performUpdate(originalRelease, updatedRelease *release.R
}
}
originalRelease.Info.Status.Code = release.Status_SUPERSEDED
originalRelease.Info.Status = release.StatusSuperseded
s.recordRelease(originalRelease, true)
updatedRelease.Info.Status.Code = release.Status_DEPLOYED
updatedRelease.Info.Status = release.StatusDeployed
updatedRelease.Info.Description = "Upgrade complete"
return updatedRelease, nil

@ -68,11 +68,11 @@ func TestUpdateRelease(t *testing.T) {
t.Errorf("Unexpected manifest: %v", updated.Hooks[0].Manifest)
}
if updated.Hooks[0].Events[0] != release.Hook_POST_UPGRADE {
if updated.Hooks[0].Events[0] != release.HookPostUpgrade {
t.Errorf("Expected event 0 to be post upgrade")
}
if updated.Hooks[0].Events[1] != release.Hook_PRE_UPGRADE {
if updated.Hooks[0].Events[1] != release.HookPreUpgrade {
t.Errorf("Expected event 0 to be pre upgrade")
}
@ -309,8 +309,8 @@ func TestUpdateReleaseFailure(t *testing.T) {
t.Error("Expected failed update")
}
if updatedStatus := res.Info.Status.Code; updatedStatus != release.Status_FAILED {
t.Errorf("Expected FAILED release. Got %d", updatedStatus)
if updatedStatus := res.Info.Status; updatedStatus != release.StatusFailed {
t.Errorf("Expected FAILED release. Got %s", updatedStatus)
}
compareStoredAndReturnedRelease(t, *rs, res)
@ -324,14 +324,14 @@ func TestUpdateReleaseFailure(t *testing.T) {
if err != nil {
t.Errorf("Expected to be able to get previous release")
}
if oldStatus := oldRelease.Info.Status.Code; oldStatus != release.Status_DEPLOYED {
if oldStatus := oldRelease.Info.Status; oldStatus != release.StatusDeployed {
t.Errorf("Expected Deployed status on previous Release version. Got %v", oldStatus)
}
}
func TestUpdateReleaseFailure_Force(t *testing.T) {
rs := rsFixture()
rel := namedReleaseStub("forceful-luke", release.Status_FAILED)
rel := namedReleaseStub("forceful-luke", release.StatusFailed)
rs.Releases.Create(rel)
req := &hapi.UpdateReleaseRequest{
@ -351,8 +351,8 @@ func TestUpdateReleaseFailure_Force(t *testing.T) {
t.Errorf("Expected successful update, got %v", err)
}
if updatedStatus := res.Info.Status.Code; updatedStatus != release.Status_DEPLOYED {
t.Errorf("Expected DEPLOYED release. Got %d", updatedStatus)
if updatedStatus := res.Info.Status; updatedStatus != release.StatusDeployed {
t.Errorf("Expected DEPLOYED release. Got %s", updatedStatus)
}
compareStoredAndReturnedRelease(t, *rs, res)
@ -366,7 +366,7 @@ func TestUpdateReleaseFailure_Force(t *testing.T) {
if err != nil {
t.Errorf("Expected to be able to get previous release")
}
if oldStatus := oldRelease.Info.Status.Code; oldStatus != release.Status_DELETED {
if oldStatus := oldRelease.Info.Status; oldStatus != release.StatusDeleted {
t.Errorf("Expected Deleted status on previous Release version. Got %v", oldStatus)
}
}

Loading…
Cancel
Save