diff --git a/cmd/helm/package.go b/cmd/helm/package.go index 770bb5d3f..beff30e31 100644 --- a/cmd/helm/package.go +++ b/cmd/helm/package.go @@ -71,7 +71,7 @@ func runPackage(cmd *cobra.Command, args []string) error { } if filepath.Base(path) != ch.Metadata.Name { - return fmt.Errorf("directory name (%s) and Chart.yaml name (%s) must match.", filepath.Base(path), ch.Metadata.Name) + return fmt.Errorf("directory name (%s) and Chart.yaml name (%s) must match", filepath.Base(path), ch.Metadata.Name) } // Save to the current working directory. diff --git a/pkg/helm/client.go b/pkg/helm/client.go index bcfd41e08..91fd1923c 100644 --- a/pkg/helm/client.go +++ b/pkg/helm/client.go @@ -24,29 +24,30 @@ import ( ) const ( - // $HELM_HOST envvar + // HelmHostEnvVar is the $HELM_HOST envvar HelmHostEnvVar = "HELM_HOST" - // $HELM_HOME envvar + // HelmHomeEnvVar is the $HELM_HOME envvar HelmHomeEnvVar = "HELM_HOME" - // Default tiller server host address. + // DefaultHelmHost is the default tiller server host address. DefaultHelmHost = ":44134" - // Default $HELM_HOME envvar value + // DefaultHelmHome is the default $HELM_HOME envvar value DefaultHelmHome = "$HOME/.helm" ) -// Helm client manages client side of the helm-tiller protocol +// Client manages client side of the helm-tiller protocol type Client struct { opts options } +// NewClient creates a new client. func NewClient(opts ...Option) *Client { return new(Client).Init().Option(opts...) } -// Configure the helm client with the provided options +// Option configures the helm client with the provided options func (h *Client) Option(opts ...Option) *Client { for _, opt := range opts { opt(&h.opts) @@ -54,7 +55,7 @@ func (h *Client) Option(opts ...Option) *Client { return h } -// Initializes the helm client with default options +// Init initializes the helm client with default options func (h *Client) Init() *Client { return h.Option(HelmHost(DefaultHelmHost)). Option(HelmHome(os.ExpandEnv(DefaultHelmHome))) @@ -87,7 +88,7 @@ func (h *Client) InstallRelease(chStr string, opts ...InstallOption) (*rls.Insta return h.opts.rpcInstallRelease(chart, rls.NewReleaseServiceClient(c), opts...) } -// UninstallRelease uninstalls a named release and returns the response. +// DeleteRelease uninstalls a named release and returns the response. // // Note: there aren't currently any supported DeleteOptions, but they are // kept in the API signature as a placeholder for future additions. diff --git a/pkg/helm/compat.go b/pkg/helm/compat.go index 9d4b7a3c5..5e3088107 100644 --- a/pkg/helm/compat.go +++ b/pkg/helm/compat.go @@ -23,10 +23,13 @@ import ( // These APIs are a temporary abstraction layer that captures the interaction between the current cmd/helm and old // pkg/helm implementations. Post refactor the cmd/helm package will use the APIs exposed on helm.Client directly. +// Config is the base configuration var Config struct { ServAddr string } +// ListReleases lists releases. DEPRECATED. +// // Soon to be deprecated helm ListReleases API. func ListReleases(limit int, offset string, sort rls.ListSort_SortBy, order rls.ListSort_SortOrder, filter string) (*rls.ListReleasesResponse, error) { opts := []ReleaseListOption{ @@ -39,21 +42,26 @@ func ListReleases(limit int, offset string, sort rls.ListSort_SortBy, order rls. return NewClient(HelmHost(Config.ServAddr)).ListReleases(opts...) } +// GetReleaseStatus gets a release status. DEPRECATED +// // Soon to be deprecated helm GetReleaseStatus API. func GetReleaseStatus(rlsName string) (*rls.GetReleaseStatusResponse, error) { return NewClient(HelmHost(Config.ServAddr)).ReleaseStatus(rlsName) } +// GetReleaseContent gets the content of a release. // Soon to be deprecated helm GetReleaseContent API. func GetReleaseContent(rlsName string) (*rls.GetReleaseContentResponse, error) { return NewClient(HelmHost(Config.ServAddr)).ReleaseContent(rlsName) } +// UpdateRelease updates a release. // Soon to be deprecated helm UpdateRelease API. func UpdateRelease(rlsName string) (*rls.UpdateReleaseResponse, error) { return NewClient(HelmHost(Config.ServAddr)).UpdateRelease(rlsName) } +// InstallRelease runs an install for a release. // Soon to be deprecated helm InstallRelease API. func InstallRelease(vals []byte, rlsName, chStr string, dryRun bool) (*rls.InstallReleaseResponse, error) { client := NewClient(HelmHost(Config.ServAddr)) @@ -63,6 +71,7 @@ func InstallRelease(vals []byte, rlsName, chStr string, dryRun bool) (*rls.Insta return client.InstallRelease(chStr, ValueOverrides(vals), ReleaseName(rlsName)) } +// UninstallRelease destroys an existing release. // Soon to be deprecated helm UninstallRelease API. func UninstallRelease(rlsName string, dryRun bool) (*rls.UninstallReleaseResponse, error) { client := NewClient(HelmHost(Config.ServAddr)) diff --git a/pkg/lint/rules/chartfile_test.go b/pkg/lint/rules/chartfile_test.go index 6d49a55f4..02b5f2c12 100644 --- a/pkg/lint/rules/chartfile_test.go +++ b/pkg/lint/rules/chartfile_test.go @@ -28,12 +28,16 @@ import ( "k8s.io/helm/pkg/proto/hapi/chart" ) -const badChartDir = "testdata/badchartfile" -const goodChartDir = "testdata/goodone" +const ( + badChartDir = "testdata/badchartfile" + goodChartDir = "testdata/goodone" +) -var badChartFilePath string = filepath.Join(badChartDir, "Chart.yaml") -var goodChartFilePath string = filepath.Join(goodChartDir, "Chart.yaml") -var nonExistingChartFilePath string = filepath.Join(os.TempDir(), "Chart.yaml") +var ( + badChartFilePath = filepath.Join(badChartDir, "Chart.yaml") + goodChartFilePath = filepath.Join(goodChartDir, "Chart.yaml") + nonExistingChartFilePath = filepath.Join(os.TempDir(), "Chart.yaml") +) var badChart, chatLoadRrr = chartutil.LoadChartfile(badChartFilePath) var goodChart, _ = chartutil.LoadChartfile(goodChartFilePath) diff --git a/pkg/lint/rules/template.go b/pkg/lint/rules/template.go index 47140eba8..d231a4a28 100644 --- a/pkg/lint/rules/template.go +++ b/pkg/lint/rules/template.go @@ -32,6 +32,7 @@ import ( "text/template" ) +// Templates lints the templates in the Linter. func Templates(linter *support.Linter) { templatesPath := filepath.Join(linter.ChartDir, "templates") @@ -222,18 +223,19 @@ func validateNoError(readError error) (lintError support.LintError) { func validateYamlContent(filePath string, err error) (lintError support.LintError) { if err != nil { - lintError = fmt.Errorf("templates: \"%s\". Wrong YAML content.", filePath) + lintError = fmt.Errorf("templates: \"%s\". Wrong YAML content", filePath) } return } func validateNoNamespace(filePath string, yamlStruct K8sYamlStruct) (lintError support.LintError) { if yamlStruct.Metadata.Namespace != "" { - lintError = fmt.Errorf("templates: \"%s\". namespace option is currently NOT supported.", filePath) + lintError = fmt.Errorf("templates: \"%s\". namespace option is currently NOT supported", filePath) } return } +// K8sYamlStruct stubs a Kubernetes YAML file. // Need to access for now to Namespace only type K8sYamlStruct struct { Metadata struct { diff --git a/pkg/lint/support/doc.go b/pkg/lint/support/doc.go index a71f0f75d..c843f6468 100644 --- a/pkg/lint/support/doc.go +++ b/pkg/lint/support/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -/*Package lint contains tools for linting charts. +/*Package support contains tools for linting charts. Linting is the process of testing charts for errors or warnings regarding formatting, compilation, or standards compliance. diff --git a/pkg/lint/support/message.go b/pkg/lint/support/message.go index 1df57458e..1c3fdcd58 100644 --- a/pkg/lint/support/message.go +++ b/pkg/lint/support/message.go @@ -41,11 +41,13 @@ type Message struct { Text string } +// Linter encapsulates a linting run of a particular chart. type Linter struct { Messages []Message ChartDir string } +// LintError describes an error encountered while linting. type LintError interface { error } @@ -57,7 +59,7 @@ func (m Message) String() string { return fmt.Sprintf("[%s] %s", sev[m.Severity], m.Text) } -// Returns true if the validation passed +// RunLinterRule returns true if the validation passed func (l *Linter) RunLinterRule(severity int, lintError LintError) bool { // severity is out of bound if severity < 0 || severity >= len(sev) { diff --git a/pkg/lint/support/message_test.go b/pkg/lint/support/message_test.go index 9a18e01ed..e97b173a7 100644 --- a/pkg/lint/support/message_test.go +++ b/pkg/lint/support/message_test.go @@ -21,7 +21,7 @@ import ( "testing" ) -var linter Linter = Linter{} +var linter = Linter{} var lintError LintError = fmt.Errorf("Foobar") func TestRunLinterRule(t *testing.T) {