Feedback from CoPilot

Signed-off-by: Mads Jensen <atombrella@users.noreply.github.com>
pull/31647/head
Mads Jensen 10 months ago
parent 4ec0b32ac7
commit d29e039844

@ -234,7 +234,7 @@ func TestMalformedTemplate(t *testing.T) {
var values map[string]any var values map[string]any
c := time.After(3 * time.Second) c := time.After(3 * time.Second)
ch := make(chan int, 1) ch := make(chan int, 1)
var m []support.MessageError var m []support.LintMessageError
go func() { go func() {
m = RunAll(malformedTemplate, values, namespace).Messages m = RunAll(malformedTemplate, values, namespace).Messages
ch <- 1 ch <- 1

@ -35,27 +35,27 @@ var sev = []string{"UNKNOWN", "INFO", "WARNING", "ERROR"}
// Linter encapsulates a linting run of a particular chart. // Linter encapsulates a linting run of a particular chart.
type Linter struct { type Linter struct {
Messages []MessageError Messages []LintMessageError
// The highest severity of all the failing lint rules // The highest severity of all the failing lint rules
HighestSeverity int HighestSeverity int
ChartDir string ChartDir string
} }
// Message describes an error encountered while linting. // LintMessageError describes an error encountered while linting.
type MessageError struct { type LintMessageError struct {
// Severity is one of the *Sev constants // Severity is one of the *Sev constants
Severity int Severity int
Path string Path string
Err error Err error
} }
func (m MessageError) Error() string { func (m LintMessageError) Error() string {
return fmt.Sprintf("[%s] %s: %s", sev[m.Severity], m.Path, m.Err.Error()) return fmt.Sprintf("[%s] %s: %s", sev[m.Severity], m.Path, m.Err.Error())
} }
// NewMessage creates a new Message struct // NewMessage creates a new Message struct
func NewMessage(severity int, path string, err error) MessageError { func NewMessage(severity int, path string, err error) LintMessageError {
return MessageError{Severity: severity, Path: path, Err: err} return LintMessageError{Severity: severity, Path: path, Err: err}
} }
// RunLinterRule returns true if the validation passed // RunLinterRule returns true if the validation passed

@ -62,17 +62,17 @@ func TestRunLinterRule(t *testing.T) {
} }
func TestMessage(t *testing.T) { func TestMessage(t *testing.T) {
m := MessageError{ErrorSev, "Chart.yaml", errors.New("Foo")} m := LintMessageError{ErrorSev, "Chart.yaml", errors.New("Foo")}
if m.Error() != "[ERROR] Chart.yaml: Foo" { if m.Error() != "[ERROR] Chart.yaml: Foo" {
t.Errorf("Unexpected output: %s", m.Error()) t.Errorf("Unexpected output: %s", m.Error())
} }
m = MessageError{WarningSev, "templates/", errors.New("Bar")} m = LintMessageError{WarningSev, "templates/", errors.New("Bar")}
if m.Error() != "[WARNING] templates/: Bar" { if m.Error() != "[WARNING] templates/: Bar" {
t.Errorf("Unexpected output: %s", m.Error()) t.Errorf("Unexpected output: %s", m.Error())
} }
m = MessageError{InfoSev, "templates/rc.yaml", errors.New("FooBar")} m = LintMessageError{InfoSev, "templates/rc.yaml", errors.New("FooBar")}
if m.Error() != "[INFO] templates/rc.yaml: FooBar" { if m.Error() != "[INFO] templates/rc.yaml: FooBar" {
t.Errorf("Unexpected output: %s", m.Error()) t.Errorf("Unexpected output: %s", m.Error())
} }

@ -255,7 +255,7 @@ func TestProcessDependencyImportValues(t *testing.T) {
case common.NoValueError: case common.NoValueError:
// We found what we expected // We found what we expected
default: default:
t.Errorf("expected an NoValueErr but got %q instead", xerr) t.Errorf("expected a NoValueError but got %q instead", xerr)
} }
c = loadChart(t, "testdata/subpop") c = loadChart(t, "testdata/subpop")

@ -43,7 +43,7 @@ type Lint struct {
// LintResult is the result of Lint // LintResult is the result of Lint
type LintResult struct { type LintResult struct {
TotalChartsLinted int TotalChartsLinted int
Messages []support.MessageError Messages []support.LintMessageError
Errors []error Errors []error
} }

@ -238,7 +238,7 @@ func TestMalformedTemplate(t *testing.T) {
var values map[string]any var values map[string]any
c := time.After(3 * time.Second) c := time.After(3 * time.Second)
ch := make(chan int, 1) ch := make(chan int, 1)
var m []support.MessageError var m []support.LintMessageError
go func() { go func() {
m = RunAll(malformedTemplate, values, namespace).Messages m = RunAll(malformedTemplate, values, namespace).Messages
ch <- 1 ch <- 1

@ -35,27 +35,27 @@ var sev = []string{"UNKNOWN", "INFO", "WARNING", "ERROR"}
// Linter encapsulates a linting run of a particular chart. // Linter encapsulates a linting run of a particular chart.
type Linter struct { type Linter struct {
Messages []MessageError Messages []LintMessageError
// The highest severity of all the failing lint rules // The highest severity of all the failing lint rules
HighestSeverity int HighestSeverity int
ChartDir string ChartDir string
} }
// Message describes an error encountered while linting. // Message describes an error encountered while linting.
type MessageError struct { type LintMessageError struct {
// Severity is one of the *Sev constants // Severity is one of the *Sev constants
Severity int Severity int
Path string Path string
Err error Err error
} }
func (m MessageError) Error() string { func (m LintMessageError) Error() string {
return fmt.Sprintf("[%s] %s: %s", sev[m.Severity], m.Path, m.Err.Error()) return fmt.Sprintf("[%s] %s: %s", sev[m.Severity], m.Path, m.Err.Error())
} }
// NewMessage creates a new Message struct // NewMessage creates a new Message struct
func NewMessage(severity int, path string, err error) MessageError { func NewMessage(severity int, path string, err error) LintMessageError {
return MessageError{Severity: severity, Path: path, Err: err} return LintMessageError{Severity: severity, Path: path, Err: err}
} }
// RunLinterRule returns true if the validation passed // RunLinterRule returns true if the validation passed

@ -62,17 +62,17 @@ func TestRunLinterRule(t *testing.T) {
} }
func TestMessage(t *testing.T) { func TestMessage(t *testing.T) {
m := MessageError{ErrorSev, "Chart.yaml", errors.New("Foo")} m := LintMessageError{ErrorSev, "Chart.yaml", errors.New("Foo")}
if m.Error() != "[ERROR] Chart.yaml: Foo" { if m.Error() != "[ERROR] Chart.yaml: Foo" {
t.Errorf("Unexpected output: %s", m.Error()) t.Errorf("Unexpected output: %s", m.Error())
} }
m = MessageError{WarningSev, "templates/", errors.New("Bar")} m = LintMessageError{WarningSev, "templates/", errors.New("Bar")}
if m.Error() != "[WARNING] templates/: Bar" { if m.Error() != "[WARNING] templates/: Bar" {
t.Errorf("Unexpected output: %s", m.Error()) t.Errorf("Unexpected output: %s", m.Error())
} }
m = MessageError{InfoSev, "templates/rc.yaml", errors.New("FooBar")} m = LintMessageError{InfoSev, "templates/rc.yaml", errors.New("FooBar")}
if m.Error() != "[INFO] templates/rc.yaml: FooBar" { if m.Error() != "[INFO] templates/rc.yaml: FooBar" {
t.Errorf("Unexpected output: %s", m.Error()) t.Errorf("Unexpected output: %s", m.Error())
} }

@ -255,7 +255,7 @@ func TestProcessDependencyImportValues(t *testing.T) {
case common.NoValueError: case common.NoValueError:
// We found what we expected // We found what we expected
default: default:
t.Errorf("expected an NoValueErr but got %q instead", xerr) t.Errorf("expected a NoValueError but got %q instead", xerr)
} }
c = loadChart(t, "testdata/subpop") c = loadChart(t, "testdata/subpop")

Loading…
Cancel
Save