fix(*): fix various style issues from make test-style

Closes #847.
pull/905/head
Matt Butcher 9 years ago
parent 2eada26477
commit 2c07a32a6b

@ -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.

@ -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.

@ -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))

@ -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)

@ -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 {

@ -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.

@ -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) {

@ -21,7 +21,7 @@ import (
"testing"
)
var linter Linter = Linter{}
var linter = Linter{}
var lintError LintError = fmt.Errorf("Foobar")
func TestRunLinterRule(t *testing.T) {

Loading…
Cancel
Save