From f3bfae5ea73a8bd5b0f302ea36cfff1e5ddc3542 Mon Sep 17 00:00:00 2001 From: Matt Butcher Date: Mon, 7 Jan 2019 21:40:24 -0700 Subject: [PATCH] fix: fix a number of style errors (#5136) This fixes a dozen or so style errors, almost all of which were just missing comments. I left several which are fixed in other outstanding PRs, or which belong to code that is about to be removed. Signed-off-by: Matt Butcher --- internal/test/test.go | 4 ++++ pkg/chart/chart.go | 2 +- pkg/chart/loader/archive.go | 2 ++ pkg/chart/loader/directory.go | 2 ++ pkg/chart/loader/load.go | 2 ++ pkg/chartutil/dependencies.go | 1 + pkg/chartutil/values.go | 2 +- pkg/hapi/release/status.go | 2 ++ pkg/hapi/release/test_run.go | 4 ++++ pkg/helm/fake.go | 2 +- pkg/kube/client.go | 1 + pkg/kube/wait.go | 2 +- 12 files changed, 22 insertions(+), 4 deletions(-) diff --git a/internal/test/test.go b/internal/test/test.go index 3a9e8ec9e..aa1791a07 100644 --- a/internal/test/test.go +++ b/internal/test/test.go @@ -28,16 +28,19 @@ import ( // UpdateGolden writes out the golden files with the latest values, rather than failing the test. var updateGolden = flag.Bool("update", false, "update golden files") +// TestingT describes a testing object compatible with the critical functions from the testing.T type type TestingT interface { Fatal(...interface{}) Fatalf(string, ...interface{}) HelperT } +// HelperT describes a test with a helper function type HelperT interface { Helper() } +// AssertGoldenBytes asserts that the give actual content matches the contents of the given filename func AssertGoldenBytes(t TestingT, actual []byte, filename string) { t.Helper() @@ -46,6 +49,7 @@ func AssertGoldenBytes(t TestingT, actual []byte, filename string) { } } +// AssertGoldenString asserts that the given string matches the contents of the given file. func AssertGoldenString(t TestingT, actual, filename string) { t.Helper() diff --git a/pkg/chart/chart.go b/pkg/chart/chart.go index 2a190f668..ac2bf8b6b 100644 --- a/pkg/chart/chart.go +++ b/pkg/chart/chart.go @@ -78,7 +78,7 @@ func (ch *Chart) IsRoot() bool { return ch.parent == nil } // Parent returns a subchart's parent chart. func (ch *Chart) Parent() *Chart { return ch.parent } -// Parent sets a subchart's parent chart. +// SetParent sets a subchart's parent chart. func (ch *Chart) SetParent(chart *Chart) { ch.parent = chart } // ChartPath returns the full path to this chart in dot notation. diff --git a/pkg/chart/loader/archive.go b/pkg/chart/loader/archive.go index 82f7572e0..2b2433c72 100644 --- a/pkg/chart/loader/archive.go +++ b/pkg/chart/loader/archive.go @@ -29,8 +29,10 @@ import ( "k8s.io/helm/pkg/chart" ) +// FileLoader loads a chart from a file type FileLoader string +// Load loads a chart func (l FileLoader) Load() (*chart.Chart, error) { return LoadFile(string(l)) } diff --git a/pkg/chart/loader/directory.go b/pkg/chart/loader/directory.go index 1e3f4e4af..b670abfaa 100644 --- a/pkg/chart/loader/directory.go +++ b/pkg/chart/loader/directory.go @@ -29,8 +29,10 @@ import ( "k8s.io/helm/pkg/sympath" ) +// DirLoader loads a chart from a directory type DirLoader string +// Load loads the chart func (l DirLoader) Load() (*chart.Chart, error) { return LoadDir(string(l)) } diff --git a/pkg/chart/loader/load.go b/pkg/chart/loader/load.go index 855d92e57..d5d02cff1 100644 --- a/pkg/chart/loader/load.go +++ b/pkg/chart/loader/load.go @@ -28,10 +28,12 @@ import ( "k8s.io/helm/pkg/chart" ) +// ChartLoader loads a chart. type ChartLoader interface { Load() (*chart.Chart, error) } +// Loader returns a new ChartLoader appropriate for the given chart name func Loader(name string) (ChartLoader, error) { fi, err := os.Stat(name) if err != nil { diff --git a/pkg/chartutil/dependencies.go b/pkg/chartutil/dependencies.go index f87983adb..20041b758 100644 --- a/pkg/chartutil/dependencies.go +++ b/pkg/chartutil/dependencies.go @@ -23,6 +23,7 @@ import ( "k8s.io/helm/pkg/version" ) +// ProcessDependencies checks through this chart's dependencies, processing accordingly. func ProcessDependencies(c *chart.Chart, v Values) error { if err := processDependencyEnabled(c, v); err != nil { return err diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index e9aad0866..da5395f9e 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -275,7 +275,7 @@ func coalesceValues(c *chart.Chart, v map[string]interface{}) { } } -// coalesceTables merges a source map into a destination map. +// CoalesceTables merges a source map into a destination map. // // dest is considered authoritative. func CoalesceTables(dst, src map[string]interface{}) map[string]interface{} { diff --git a/pkg/hapi/release/status.go b/pkg/hapi/release/status.go index 5e2cb6685..301b9e4fe 100644 --- a/pkg/hapi/release/status.go +++ b/pkg/hapi/release/status.go @@ -15,8 +15,10 @@ limitations under the License. package release +// ReleaseStatus is the status of a release type ReleaseStatus string +// Describe the status of a release const ( // StatusUnknown indicates that a release is in an uncertain state. StatusUnknown ReleaseStatus = "unknown" diff --git a/pkg/hapi/release/test_run.go b/pkg/hapi/release/test_run.go index 6fb14416a..ff55301ab 100644 --- a/pkg/hapi/release/test_run.go +++ b/pkg/hapi/release/test_run.go @@ -17,8 +17,10 @@ package release import "time" +// TestRunStatus is the status of a test run type TestRunStatus string +// Indicates the results of a test run const ( TestRunUnknown TestRunStatus = "unknown" TestRunSuccess TestRunStatus = "success" @@ -26,8 +28,10 @@ const ( TestRunRunning TestRunStatus = "running" ) +// Strng converts a test run status to a printable string func (x TestRunStatus) String() string { return string(x) } +// TestRun describes the run of a test type TestRun struct { Name string `json:"name,omitempty"` Status TestRunStatus `json:"status,omitempty"` diff --git a/pkg/helm/fake.go b/pkg/helm/fake.go index 7bc9eae60..982077711 100644 --- a/pkg/helm/fake.go +++ b/pkg/helm/fake.go @@ -189,7 +189,7 @@ func ReleaseMock(opts *MockReleaseOptions) *release.Release { name = "testrelease-" + string(rand.Intn(100)) } - var version int = 1 + version := 1 if opts.Version != 0 { version = opts.Version } diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 3fe2aecf3..4c3a6fd65 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -77,6 +77,7 @@ func New(getter genericclioptions.RESTClientGetter) *Client { } } +// KubernetesClientSet returns a client set from the client factory. func (c *Client) KubernetesClientSet() (*kubernetes.Clientset, error) { return c.Factory.KubernetesClientSet() } diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index ebd12b4b1..45c0d67ac 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -242,7 +242,7 @@ func (c *Client) servicesReady(svc []v1.Service) bool { return true } -// this function aims to check if the service's ClusterIP is set or not +// IsServiceIPSet aims to check if the service's ClusterIP is set or not // the objective is not to perform validation here func IsServiceIPSet(service *v1.Service) bool { return service.Spec.ClusterIP != v1.ClusterIPNone && service.Spec.ClusterIP != ""