diff --git a/cmd/helm/history_test.go b/cmd/helm/history_test.go index 6c83f51b2..10dc6fb2d 100644 --- a/cmd/helm/history_test.go +++ b/cmd/helm/history_test.go @@ -24,7 +24,7 @@ import ( ) func TestHistoryCmd(t *testing.T) { - mk := func(name string, vers int, status rpb.ReleaseStatus) *rpb.Release { + mk := func(name string, vers int, status rpb.Status) *rpb.Release { return helm.ReleaseMock(&helm.MockReleaseOptions{ Name: name, Version: vers, diff --git a/internal/version/version.go b/internal/version/version.go index 9f790a022..b7ec040bf 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -46,7 +46,7 @@ func GetVersion() string { return version + "+" + metadata } -// GetBuildInfo returns build info +// Get returns build info func Get() hversion.BuildInfo { return hversion.BuildInfo{ Version: GetVersion(), diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index b793b4dbe..c76da318e 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -136,7 +136,7 @@ func releaseStub() *release.Release { return namedReleaseStub("angry-panda", release.StatusDeployed) } -func namedReleaseStub(name string, status release.ReleaseStatus) *release.Release { +func namedReleaseStub(name string, status release.Status) *release.Release { now := time.Now() return &release.Release{ Name: name, diff --git a/pkg/hapi/release/hook.go b/pkg/hapi/release/hook.go index f62cf2f2d..d4cb73d54 100644 --- a/pkg/hapi/release/hook.go +++ b/pkg/hapi/release/hook.go @@ -17,8 +17,10 @@ package release import "time" +// HookEvent specifies the hook event type HookEvent string +// Hook event types const ( HookPreInstall HookEvent = "pre-install" HookPostInstall HookEvent = "post-install" @@ -34,8 +36,10 @@ const ( func (x HookEvent) String() string { return string(x) } +// HookDeletePolicy specifies the hook delete policy type HookDeletePolicy string +// Hook delete policy types const ( HookSucceeded HookDeletePolicy = "succeeded" HookFailed HookDeletePolicy = "failed" diff --git a/pkg/hapi/release/info.go b/pkg/hapi/release/info.go index 15dbb2377..97191615d 100644 --- a/pkg/hapi/release/info.go +++ b/pkg/hapi/release/info.go @@ -28,7 +28,7 @@ type Info struct { // 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"` + Status Status `json:"status,omitempty"` // Cluster resources as kubectl would print them. Resources string `json:"resources,omitempty"` // Contains the rendered templates/NOTES.txt if available diff --git a/pkg/hapi/release/release.go b/pkg/hapi/release/release.go index 1ab98b8a8..ed660d2ea 100644 --- a/pkg/hapi/release/release.go +++ b/pkg/hapi/release/release.go @@ -40,7 +40,7 @@ type Release struct { } // SetStatus is a helper for setting the status on a release. -func (r *Release) SetStatus(status ReleaseStatus, msg string) { +func (r *Release) SetStatus(status Status, msg string) { r.Info.Status = status r.Info.Description = msg } diff --git a/pkg/hapi/release/status.go b/pkg/hapi/release/status.go index 301b9e4fe..cd025e279 100644 --- a/pkg/hapi/release/status.go +++ b/pkg/hapi/release/status.go @@ -15,29 +15,29 @@ limitations under the License. package release -// ReleaseStatus is the status of a release -type ReleaseStatus string +// Status is the status of a release +type Status string // Describe the status of a release const ( // StatusUnknown indicates that a release is in an uncertain state. - StatusUnknown ReleaseStatus = "unknown" + StatusUnknown Status = "unknown" // StatusDeployed indicates that the release has been pushed to Kubernetes. - StatusDeployed ReleaseStatus = "deployed" + StatusDeployed Status = "deployed" // StatusUninstalled indicates that a release has been uninstalled from Kubermetes. - StatusUninstalled ReleaseStatus = "uninstalled" + StatusUninstalled Status = "uninstalled" // StatusSuperseded indicates that this release object is outdated and a newer one exists. - StatusSuperseded ReleaseStatus = "superseded" + StatusSuperseded Status = "superseded" // StatusFailed indicates that the release was not successfully deployed. - StatusFailed ReleaseStatus = "failed" + StatusFailed Status = "failed" // StatusUninstalling indicates that a uninstall operation is underway. - StatusUninstalling ReleaseStatus = "uninstalling" + StatusUninstalling Status = "uninstalling" // StatusPendingInstall indicates that an install operation is underway. - StatusPendingInstall ReleaseStatus = "pending-install" + StatusPendingInstall Status = "pending-install" // StatusPendingUpgrade indicates that an upgrade operation is underway. - StatusPendingUpgrade ReleaseStatus = "pending-upgrade" + StatusPendingUpgrade Status = "pending-upgrade" // StatusPendingRollback indicates that an rollback operation is underway. - StatusPendingRollback ReleaseStatus = "pending-rollback" + StatusPendingRollback Status = "pending-rollback" ) -func (x ReleaseStatus) String() string { return string(x) } +func (x Status) String() string { return string(x) } diff --git a/pkg/hapi/tiller.go b/pkg/hapi/tiller.go index 964e16a04..544fb6a96 100644 --- a/pkg/hapi/tiller.go +++ b/pkg/hapi/tiller.go @@ -61,8 +61,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 SortOrder `json:"sort_order,omitempty"` - StatusCodes []release.ReleaseStatus `json:"status_codes,omitempty"` + SortOrder SortOrder `json:"sort_order,omitempty"` + StatusCodes []release.Status `json:"status_codes,omitempty"` } // GetReleaseStatusRequest is a request to get the status of a release. diff --git a/pkg/helm/fake.go b/pkg/helm/fake.go index 982077711..a7fbe9e87 100644 --- a/pkg/helm/fake.go +++ b/pkg/helm/fake.go @@ -176,7 +176,7 @@ type MockReleaseOptions struct { Name string Version int Chart *chart.Chart - Status release.ReleaseStatus + Status release.Status Namespace string } diff --git a/pkg/helm/option.go b/pkg/helm/option.go index 8c8dbbd25..49e4e36ad 100644 --- a/pkg/helm/option.go +++ b/pkg/helm/option.go @@ -295,7 +295,7 @@ func UpgradeForce(force bool) UpdateOption { } } -// Limit the maximum number of revisions saved per release +// MaxHistory limits the maximum number of revisions saved per release func MaxHistory(maxHistory int) UpdateOption { return func(opts *options) { opts.updateReq.MaxHistory = maxHistory @@ -320,18 +320,21 @@ type RollbackOption func(*options) // issuing a TestRelease rpc. type ReleaseTestOption func(*options) +// Driver set the driver option func Driver(d driver.Driver) Option { return func(opts *options) { opts.driver = d } } +// KubeClient sets the cluster environment func KubeClient(kc environment.KubeClient) Option { return func(opts *options) { opts.kubeClient = kc } } +// Discovery sets the discovery interface func Discovery(dc discovery.DiscoveryInterface) Option { return func(opts *options) { opts.discovery = dc diff --git a/pkg/registry/reference.go b/pkg/registry/reference.go index e0e4b7ab8..51888c45a 100644 --- a/pkg/registry/reference.go +++ b/pkg/registry/reference.go @@ -25,9 +25,9 @@ import ( ) var ( - validPortRegEx = regexp.MustCompile("^([1-9]\\d{0,3}|0|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$") // adapted from https://stackoverflow.com/a/12968117 - emptyRepoError = errors.New("parsed repo was empty") - tooManyColonsError = errors.New("ref may only contain a single colon character (:) unless specifying a port number") + validPortRegEx = regexp.MustCompile("^([1-9]\\d{0,3}|0|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$") // adapted from https://stackoverflow.com/a/12968117 + errEmptyRepo = errors.New("parsed repo was empty") + errTooManyColons = errors.New("ref may only contain a single colon character (:) unless specifying a port number") ) type ( @@ -103,7 +103,7 @@ func (ref *Reference) validate() error { // validateRepo checks that the Repo field is non-empty func (ref *Reference) validateRepo() error { if ref.Repo == "" { - return emptyRepoError + return errEmptyRepo } return nil } @@ -112,17 +112,17 @@ func (ref *Reference) validateRepo() error { // (or potentially two, there might be a port number specified i.e. :5000) func (ref *Reference) validateNumColons() error { if strings.Contains(ref.Tag, ":") { - return tooManyColonsError + return errTooManyColons } parts := strings.Split(ref.Repo, ":") lastIndex := len(parts) - 1 if 1 < lastIndex { - return tooManyColonsError + return errTooManyColons } if 0 < lastIndex { port := strings.Split(parts[lastIndex], "/")[0] if !isValidPort(port) { - return tooManyColonsError + return errTooManyColons } } return nil diff --git a/pkg/releaseutil/filter.go b/pkg/releaseutil/filter.go index 96a82ff93..40ca3a027 100644 --- a/pkg/releaseutil/filter.go +++ b/pkg/releaseutil/filter.go @@ -68,7 +68,7 @@ func All(filters ...FilterFunc) FilterFunc { } // StatusFilter filters a set of releases by status code. -func StatusFilter(status rspb.ReleaseStatus) FilterFunc { +func StatusFilter(status rspb.Status) FilterFunc { return FilterFunc(func(rls *rspb.Release) bool { if rls == nil { return true diff --git a/pkg/releaseutil/sorter_test.go b/pkg/releaseutil/sorter_test.go index 5198ce0a9..3cfcf77d4 100644 --- a/pkg/releaseutil/sorter_test.go +++ b/pkg/releaseutil/sorter_test.go @@ -32,7 +32,7 @@ var releases = []*rspb.Release{ tsRelease("vocal-dogs", 3, 6000, rspb.StatusUninstalled), } -func tsRelease(name string, vers int, dur time.Duration, status rspb.ReleaseStatus) *rspb.Release { +func tsRelease(name string, vers int, dur time.Duration, status rspb.Status) *rspb.Release { tmsp := time.Now().Add(dur) info := &rspb.Info{Status: status, LastDeployed: tmsp} return &rspb.Release{ diff --git a/pkg/storage/driver/mock_test.go b/pkg/storage/driver/mock_test.go index bdb9236db..d4475b394 100644 --- a/pkg/storage/driver/mock_test.go +++ b/pkg/storage/driver/mock_test.go @@ -28,7 +28,7 @@ import ( rspb "k8s.io/helm/pkg/hapi/release" ) -func releaseStub(name string, vers int, namespace string, status rspb.ReleaseStatus) *rspb.Release { +func releaseStub(name string, vers int, namespace string, status rspb.Status) *rspb.Release { return &rspb.Release{ Name: name, Version: vers, diff --git a/pkg/storage/storage_test.go b/pkg/storage/storage_test.go index bf1aae4bb..30d3cd41c 100644 --- a/pkg/storage/storage_test.go +++ b/pkg/storage/storage_test.go @@ -330,7 +330,7 @@ type ReleaseTestData struct { Version int Manifest string Namespace string - Status rspb.ReleaseStatus + Status rspb.Status } func (test ReleaseTestData) ToRelease() *rspb.Release { diff --git a/pkg/tiller/release_history_test.go b/pkg/tiller/release_history_test.go index 65ae8d69c..11aa72374 100644 --- a/pkg/tiller/release_history_test.go +++ b/pkg/tiller/release_history_test.go @@ -25,7 +25,7 @@ import ( ) func TestGetHistory_WithRevisions(t *testing.T) { - mk := func(name string, vers int, status rpb.ReleaseStatus) *rpb.Release { + mk := func(name string, vers int, status rpb.Status) *rpb.Release { return &rpb.Release{ Name: name, Version: vers, diff --git a/pkg/tiller/release_server_test.go b/pkg/tiller/release_server_test.go index 12bb8b113..6e4652258 100644 --- a/pkg/tiller/release_server_test.go +++ b/pkg/tiller/release_server_test.go @@ -229,7 +229,7 @@ func releaseStub() *release.Release { return namedReleaseStub("angry-panda", release.StatusDeployed) } -func namedReleaseStub(name string, status release.ReleaseStatus) *release.Release { +func namedReleaseStub(name string, status release.Status) *release.Release { return &release.Release{ Name: name, Info: &release.Info{