Merge pull request #13516 from TerryHowe/new-lint

chore: fix problems with latest lint
pull/13283/head
George Jenkins 8 months ago committed by GitHub
commit 415c7e10fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -177,22 +177,15 @@ func formatAppVersion(c *chart.Chart) string {
return c.AppVersion()
}
func min(x, y int) int {
if x < y {
return x
}
return y
}
func compListRevisions(_ string, cfg *action.Configuration, releaseName string) ([]string, cobra.ShellCompDirective) {
client := action.NewHistory(cfg)
var revisions []string
if hist, err := client.Run(releaseName); err == nil {
for _, release := range hist {
appVersion := fmt.Sprintf("App: %s", release.Chart.Metadata.AppVersion)
chartDesc := fmt.Sprintf("Chart: %s-%s", release.Chart.Metadata.Name, release.Chart.Metadata.Version)
revisions = append(revisions, fmt.Sprintf("%s\t%s, %s", strconv.Itoa(release.Version), appVersion, chartDesc))
for _, version := range hist {
appVersion := fmt.Sprintf("App: %s", version.Chart.Metadata.AppVersion)
chartDesc := fmt.Sprintf("Chart: %s-%s", version.Chart.Metadata.Name, version.Chart.Metadata.Version)
revisions = append(revisions, fmt.Sprintf("%s\t%s, %s", strconv.Itoa(version.Version), appVersion, chartDesc))
}
return revisions, cobra.ShellCompDirectiveNoFileComp
}

@ -162,9 +162,9 @@ func TestRepoIndexCmd(t *testing.T) {
}
}
func linkOrCopy(old, new string) error {
if err := os.Link(old, new); err != nil {
return copyFile(old, new)
func linkOrCopy(source, target string) error {
if err := os.Link(source, target); err != nil {
return copyFile(source, target)
}
return nil

@ -215,7 +215,7 @@ func isTestHook(h *release.Hook) bool {
// bug introduced by #8156. As part of the todo to refactor renderResources
// this duplicate code should be removed. It is added here so that the API
// surface area is as minimally impacted as possible in fixing the issue.
func writeToFile(outputDir string, name string, data string, append bool) error {
func writeToFile(outputDir string, name string, data string, appendData bool) error {
outfileName := strings.Join([]string{outputDir, name}, string(filepath.Separator))
err := ensureDirectoryForFile(outfileName)
@ -223,7 +223,7 @@ func writeToFile(outputDir string, name string, data string, append bool) error
return err
}
f, err := createOrOpenFile(outfileName, append)
f, err := createOrOpenFile(outfileName, appendData)
if err != nil {
return err
}
@ -240,8 +240,8 @@ func writeToFile(outputDir string, name string, data string, append bool) error
return nil
}
func createOrOpenFile(filename string, append bool) (*os.File, error) {
if append {
func createOrOpenFile(filename string, appendData bool) (*os.File, error) {
if appendData {
return os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0600)
}
return os.Create(filename)

@ -108,12 +108,12 @@ func checkMarks(t *testing.T, report bool) {
}
// Assumes that each node name is unique. Good enough for a test.
// If clear is true, any incoming error is cleared before return. The errors
// are always accumulated, though.
func mark(info os.FileInfo, err error, errors *[]error, clear bool) error {
// If clearIncomingError is true, any incoming error is cleared before
// return. The errors are always accumulated, though.
func mark(info os.FileInfo, err error, errors *[]error, clearIncomingError bool) error {
if err != nil {
*errors = append(*errors, err)
if clear {
if clearIncomingError {
return nil
}
return err
@ -130,9 +130,8 @@ func mark(info os.FileInfo, err error, errors *[]error, clear bool) error {
func TestWalk(t *testing.T) {
makeTree(t)
errors := make([]error, 0, 10)
clear := true
markFn := func(_ string, info os.FileInfo, err error) error {
return mark(info, err, &errors, clear)
return mark(info, err, &errors, true)
}
// Expect no errors.
err := Walk(tree.name, markFn)

@ -602,8 +602,8 @@ func (i *Install) replaceRelease(rel *release.Release) error {
return i.recordRelease(last)
}
// write the <data> to <output-dir>/<name>. <append> controls if the file is created or content will be appended
func writeToFile(outputDir string, name string, data string, append bool) error {
// write the <data> to <output-dir>/<name>. <appendData> controls if the file is created or content will be appended
func writeToFile(outputDir string, name string, data string, appendData bool) error {
outfileName := strings.Join([]string{outputDir, name}, string(filepath.Separator))
err := ensureDirectoryForFile(outfileName)
@ -611,7 +611,7 @@ func writeToFile(outputDir string, name string, data string, append bool) error
return err
}
f, err := createOrOpenFile(outfileName, append)
f, err := createOrOpenFile(outfileName, appendData)
if err != nil {
return err
}
@ -628,8 +628,8 @@ func writeToFile(outputDir string, name string, data string, append bool) error
return nil
}
func createOrOpenFile(filename string, append bool) (*os.File, error) {
if append {
func createOrOpenFile(filename string, appendData bool) (*os.File, error) {
if appendData {
return os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0600)
}
return os.Create(filename)

@ -73,16 +73,16 @@ func validateNoDeprecations(resource *K8sYamlStruct, kubeVersion *chartutil.Kube
return err
}
maj, err := strconv.Atoi(majorVersion)
major, err := strconv.Atoi(majorVersion)
if err != nil {
return err
}
min, err := strconv.Atoi(minorVersion)
minor, err := strconv.Atoi(minorVersion)
if err != nil {
return err
}
if !deprecation.IsDeprecated(runtimeObject, maj, min) {
if !deprecation.IsDeprecated(runtimeObject, major, minor) {
return nil
}
gvk := fmt.Sprintf("%s %s", resource.APIVersion, resource.Kind)

@ -161,15 +161,15 @@ func (s *Storage) History(name string) ([]*rspb.Release, error) {
//
// We allow max to be set explicitly so that calling functions can "make space"
// for the new records they are going to write.
func (s *Storage) removeLeastRecent(name string, max int) error {
if max < 0 {
func (s *Storage) removeLeastRecent(name string, maximum int) error {
if maximum < 0 {
return nil
}
h, err := s.History(name)
if err != nil {
return err
}
if len(h) <= max {
if len(h) <= maximum {
return nil
}
@ -183,8 +183,8 @@ func (s *Storage) removeLeastRecent(name string, max int) error {
var toDelete []*rspb.Release
for _, rel := range h {
// once we have enough releases to delete to reach the max, stop
if len(h)-len(toDelete) == max {
// once we have enough releases to delete to reach the maximum, stop
if len(h)-len(toDelete) == maximum {
break
}
if lastDeployed != nil {

@ -30,7 +30,7 @@ import (
var emptyString = `""`
// Time is a convenience wrapper around stdlib time, but with different
// marshalling and unmarshaling for zero values
// marshalling and unmarshalling for zero values
type Time struct {
time.Time
}
@ -70,8 +70,8 @@ func ParseInLocation(layout, value string, loc *time.Location) (Time, error) {
return Time{Time: t}, err
}
func Date(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) Time {
return Time{Time: time.Date(year, month, day, hour, min, sec, nsec, loc)}
func Date(year int, month time.Month, day, hour, minute, second, nanoSecond int, loc *time.Location) Time {
return Time{Time: time.Date(year, month, day, hour, minute, second, nanoSecond, loc)}
}
func Unix(sec int64, nsec int64) Time { return Time{Time: time.Unix(sec, nsec)} }

Loading…
Cancel
Save