Fix linter warnings

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
pull/5299/head
Martin Hickey 7 years ago
parent 16b59bfe5b
commit 45fb4b1c44

@ -24,7 +24,7 @@ import (
) )
func TestHistoryCmd(t *testing.T) { 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{ return helm.ReleaseMock(&helm.MockReleaseOptions{
Name: name, Name: name,
Version: vers, Version: vers,

@ -46,7 +46,7 @@ func GetVersion() string {
return version + "+" + metadata return version + "+" + metadata
} }
// GetBuildInfo returns build info // Get returns build info
func Get() hversion.BuildInfo { func Get() hversion.BuildInfo {
return hversion.BuildInfo{ return hversion.BuildInfo{
Version: GetVersion(), Version: GetVersion(),

@ -136,7 +136,7 @@ func releaseStub() *release.Release {
return namedReleaseStub("angry-panda", release.StatusDeployed) 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() now := time.Now()
return &release.Release{ return &release.Release{
Name: name, Name: name,

@ -17,8 +17,10 @@ package release
import "time" import "time"
// HookEvent specifies the hook event
type HookEvent string type HookEvent string
// Hook event types
const ( const (
HookPreInstall HookEvent = "pre-install" HookPreInstall HookEvent = "pre-install"
HookPostInstall HookEvent = "post-install" HookPostInstall HookEvent = "post-install"
@ -34,8 +36,10 @@ const (
func (x HookEvent) String() string { return string(x) } func (x HookEvent) String() string { return string(x) }
// HookDeletePolicy specifies the hook delete policy
type HookDeletePolicy string type HookDeletePolicy string
// Hook delete policy types
const ( const (
HookSucceeded HookDeletePolicy = "succeeded" HookSucceeded HookDeletePolicy = "succeeded"
HookFailed HookDeletePolicy = "failed" HookFailed HookDeletePolicy = "failed"

@ -28,7 +28,7 @@ type Info struct {
// Description is human-friendly "log entry" about this release. // Description is human-friendly "log entry" about this release.
Description string `json:"Description,omitempty"` Description string `json:"Description,omitempty"`
// Status is the current state of the release // 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. // Cluster resources as kubectl would print them.
Resources string `json:"resources,omitempty"` Resources string `json:"resources,omitempty"`
// Contains the rendered templates/NOTES.txt if available // Contains the rendered templates/NOTES.txt if available

@ -40,7 +40,7 @@ type Release struct {
} }
// SetStatus is a helper for setting the status on a release. // 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.Status = status
r.Info.Description = msg r.Info.Description = msg
} }

@ -15,29 +15,29 @@ limitations under the License.
package release package release
// ReleaseStatus is the status of a release // Status is the status of a release
type ReleaseStatus string type Status string
// Describe the status of a release // Describe the status of a release
const ( const (
// StatusUnknown indicates that a release is in an uncertain state. // 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 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 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 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 indicates that the release was not successfully deployed.
StatusFailed ReleaseStatus = "failed" StatusFailed Status = "failed"
// StatusUninstalling indicates that a uninstall operation is underway. // StatusUninstalling indicates that a uninstall operation is underway.
StatusUninstalling ReleaseStatus = "uninstalling" StatusUninstalling Status = "uninstalling"
// StatusPendingInstall indicates that an install operation is underway. // 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 indicates that an upgrade operation is underway.
StatusPendingUpgrade ReleaseStatus = "pending-upgrade" StatusPendingUpgrade Status = "pending-upgrade"
// StatusPendingRollback indicates that an rollback operation is underway. // 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) }

@ -61,8 +61,8 @@ type ListReleasesRequest struct {
// Anything that matches the regexp will be included in the results. // Anything that matches the regexp will be included in the results.
Filter string `json:"filter,omitempty"` Filter string `json:"filter,omitempty"`
// SortOrder is the ordering directive used for sorting. // SortOrder is the ordering directive used for sorting.
SortOrder SortOrder `json:"sort_order,omitempty"` SortOrder SortOrder `json:"sort_order,omitempty"`
StatusCodes []release.ReleaseStatus `json:"status_codes,omitempty"` StatusCodes []release.Status `json:"status_codes,omitempty"`
} }
// GetReleaseStatusRequest is a request to get the status of a release. // GetReleaseStatusRequest is a request to get the status of a release.

@ -176,7 +176,7 @@ type MockReleaseOptions struct {
Name string Name string
Version int Version int
Chart *chart.Chart Chart *chart.Chart
Status release.ReleaseStatus Status release.Status
Namespace string Namespace string
} }

@ -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 { func MaxHistory(maxHistory int) UpdateOption {
return func(opts *options) { return func(opts *options) {
opts.updateReq.MaxHistory = maxHistory opts.updateReq.MaxHistory = maxHistory
@ -320,18 +320,21 @@ type RollbackOption func(*options)
// issuing a TestRelease rpc. // issuing a TestRelease rpc.
type ReleaseTestOption func(*options) type ReleaseTestOption func(*options)
// Driver set the driver option
func Driver(d driver.Driver) Option { func Driver(d driver.Driver) Option {
return func(opts *options) { return func(opts *options) {
opts.driver = d opts.driver = d
} }
} }
// KubeClient sets the cluster environment
func KubeClient(kc environment.KubeClient) Option { func KubeClient(kc environment.KubeClient) Option {
return func(opts *options) { return func(opts *options) {
opts.kubeClient = kc opts.kubeClient = kc
} }
} }
// Discovery sets the discovery interface
func Discovery(dc discovery.DiscoveryInterface) Option { func Discovery(dc discovery.DiscoveryInterface) Option {
return func(opts *options) { return func(opts *options) {
opts.discovery = dc opts.discovery = dc

@ -25,9 +25,9 @@ import (
) )
var ( 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 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") errEmptyRepo = errors.New("parsed repo was empty")
tooManyColonsError = errors.New("ref may only contain a single colon character (:) unless specifying a port number") errTooManyColons = errors.New("ref may only contain a single colon character (:) unless specifying a port number")
) )
type ( type (
@ -103,7 +103,7 @@ func (ref *Reference) validate() error {
// validateRepo checks that the Repo field is non-empty // validateRepo checks that the Repo field is non-empty
func (ref *Reference) validateRepo() error { func (ref *Reference) validateRepo() error {
if ref.Repo == "" { if ref.Repo == "" {
return emptyRepoError return errEmptyRepo
} }
return nil return nil
} }
@ -112,17 +112,17 @@ func (ref *Reference) validateRepo() error {
// (or potentially two, there might be a port number specified i.e. :5000) // (or potentially two, there might be a port number specified i.e. :5000)
func (ref *Reference) validateNumColons() error { func (ref *Reference) validateNumColons() error {
if strings.Contains(ref.Tag, ":") { if strings.Contains(ref.Tag, ":") {
return tooManyColonsError return errTooManyColons
} }
parts := strings.Split(ref.Repo, ":") parts := strings.Split(ref.Repo, ":")
lastIndex := len(parts) - 1 lastIndex := len(parts) - 1
if 1 < lastIndex { if 1 < lastIndex {
return tooManyColonsError return errTooManyColons
} }
if 0 < lastIndex { if 0 < lastIndex {
port := strings.Split(parts[lastIndex], "/")[0] port := strings.Split(parts[lastIndex], "/")[0]
if !isValidPort(port) { if !isValidPort(port) {
return tooManyColonsError return errTooManyColons
} }
} }
return nil return nil

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

@ -32,7 +32,7 @@ var releases = []*rspb.Release{
tsRelease("vocal-dogs", 3, 6000, rspb.StatusUninstalled), 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) tmsp := time.Now().Add(dur)
info := &rspb.Info{Status: status, LastDeployed: tmsp} info := &rspb.Info{Status: status, LastDeployed: tmsp}
return &rspb.Release{ return &rspb.Release{

@ -28,7 +28,7 @@ import (
rspb "k8s.io/helm/pkg/hapi/release" 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{ return &rspb.Release{
Name: name, Name: name,
Version: vers, Version: vers,

@ -330,7 +330,7 @@ type ReleaseTestData struct {
Version int Version int
Manifest string Manifest string
Namespace string Namespace string
Status rspb.ReleaseStatus Status rspb.Status
} }
func (test ReleaseTestData) ToRelease() *rspb.Release { func (test ReleaseTestData) ToRelease() *rspb.Release {

@ -25,7 +25,7 @@ import (
) )
func TestGetHistory_WithRevisions(t *testing.T) { 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{ return &rpb.Release{
Name: name, Name: name,
Version: vers, Version: vers,

@ -229,7 +229,7 @@ func releaseStub() *release.Release {
return namedReleaseStub("angry-panda", release.StatusDeployed) 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{ return &release.Release{
Name: name, Name: name,
Info: &release.Info{ Info: &release.Info{

Loading…
Cancel
Save