fix(lint): fix golint errors

pull/922/head
Adnan Abdulhussein 8 years ago
parent 03ca4e892f
commit f273510c97

@ -73,10 +73,10 @@ func lintCmd(cmd *cobra.Command, args []string) error {
msg := fmt.Sprintf("%d chart(s) linted", len(paths))
if failures > 0 {
return fmt.Errorf("%s. %d chart(s) failed.", msg, failures)
return fmt.Errorf("%s, %d chart(s) failed", msg, failures)
}
fmt.Printf("%s. No failures.\n", msg)
fmt.Printf("%s, no failures\n", msg)
return nil
}

@ -90,8 +90,8 @@ func TestTemplateParsing(t *testing.T) {
}
}
var wrongTemplatePath string = filepath.Join(templateTestBasedir, "templates", "fail.yaml")
var ignoredTemplatePath string = filepath.Join(templateTestBasedir, "fail.yaml.ignored")
var wrongTemplatePath = filepath.Join(templateTestBasedir, "templates", "fail.yaml")
var ignoredTemplatePath = filepath.Join(templateTestBasedir, "fail.yaml.ignored")
// Test a template with all the existing features:
// namespaces, partial templates

@ -53,6 +53,7 @@ func (m Message) Error() string {
return fmt.Sprintf("[%s] %s: %s", sev[m.Severity], m.Path, m.Err.Error())
}
// NewMessage creates a new Message struct
func NewMessage(severity int, path string, err error) Message {
return Message{Severity: severity, Path: path, Err: err}
}

@ -22,7 +22,7 @@ import (
)
var linter = Linter{}
var lintError = errors.New("lint failed")
var errLint = errors.New("lint failed")
func TestRunLinterRule(t *testing.T) {
var tests = []struct {
@ -32,17 +32,17 @@ func TestRunLinterRule(t *testing.T) {
ExpectedReturn bool
ExpectedHighestSeverity int
}{
{InfoSev, lintError, 1, false, InfoSev},
{WarningSev, lintError, 2, false, WarningSev},
{ErrorSev, lintError, 3, false, ErrorSev},
{InfoSev, errLint, 1, false, InfoSev},
{WarningSev, errLint, 2, false, WarningSev},
{ErrorSev, errLint, 3, false, ErrorSev},
// No error so it returns true
{ErrorSev, nil, 3, true, ErrorSev},
// Retains highest severity
{InfoSev, lintError, 4, false, ErrorSev},
{InfoSev, errLint, 4, false, ErrorSev},
// Invalid severity values
{4, lintError, 4, false, ErrorSev},
{22, lintError, 4, false, ErrorSev},
{-1, lintError, 4, false, ErrorSev},
{4, errLint, 4, false, ErrorSev},
{22, errLint, 4, false, ErrorSev},
{-1, errLint, 4, false, ErrorSev},
}
for _, test := range tests {

@ -118,6 +118,7 @@ func (r *ChartRepository) saveIndexFile() error {
return ioutil.WriteFile(filepath.Join(r.RootPath, indexPath), index, 0644)
}
// Index generates an index for the chart repository and writes an index.yaml file
func (r *ChartRepository) Index() error {
if r.IndexFile == nil {
r.IndexFile = &IndexFile{Entries: make(map[string]*ChartRef)}

Loading…
Cancel
Save