Skip to content

Commit

Permalink
Fix linter errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisGe4 committed Nov 15, 2024
1 parent 883b481 commit 16a7495
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmd/skaffold/app/cmd/inspect_config_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func cmdConfigDependenciesAdd() *cobra.Command {
WithArgs(func(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
errMsg := "`config-dependencies add` requires exactly one file path argument"
olog.Entry(context.TODO()).Errorf(errMsg)
olog.Entry(context.TODO()).Error(errMsg)
return errors.New(errMsg)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion hack/versions/pkg/diff/godiff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ type TestStructure struct {

t.CheckErrorAndDeepEqual(test.shouldErr, err, test.same, diff == "")
if test.same != (diff == "") {
t.Errorf(diff)
t.Error(diff)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion integration/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func setupGitRepo(t *testing.T, dir string) {
cmd := exec.Command("git", args...)
cmd.Dir = dir
if buf, err := util.RunCmdOut(context.Background(), cmd); err != nil {
t.Logf(string(buf))
t.Log(string(buf))
t.Fatal(err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions integration/skaffold/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (b *RunBuilder) RunOrFailOutput(t *testing.T) []byte {
out, err := cmd.Output()
if err != nil {
if ee, ok := err.(*exec.ExitError); ok {
defer t.Errorf(string(ee.Stderr))
defer t.Error(string(ee.Stderr))
}
t.Fatalf("skaffold %s: %v, %s", b.command, err, out)
}
Expand All @@ -339,7 +339,7 @@ func (b *RunBuilder) RunWithStdoutAndStderrOrFail(t *testing.T, stdout, stderr i
err := cmd.Run()
if err != nil {
if ee, ok := err.(*exec.ExitError); ok {
defer t.Errorf(string(ee.Stderr))
defer t.Error(string(ee.Stderr))
}
t.Fatalf("skaffold %s: %v, %s", b.command, err, stderr)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/deploy/cloudrun/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ func TestCleanupMultipleResources(tOuter *testing.T) {
}
for key, val := range test.expectedPath {
if val > 0 {
t.Fatalf("Missing expected call for path " + key)
t.Fatalf("Missing expected call for path %s", key)
}
}
})
Expand Down
6 changes: 3 additions & 3 deletions pkg/skaffold/filemon/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ func sortEvents(e Events) {
}

func logEvents(e Events) {
if e.Added != nil && len(e.Added) > 0 {
if len(e.Added) > 0 {
log.Entry(context.TODO()).Infof("files added: %v", e.Added)
}
if e.Modified != nil && len(e.Modified) > 0 {
if len(e.Modified) > 0 {
log.Entry(context.TODO()).Infof("files modified: %v", e.Modified)
}
if e.Deleted != nil && len(e.Deleted) > 0 {
if len(e.Deleted) > 0 {
log.Entry(context.TODO()).Infof("files deleted: %v", e.Deleted)
}
}
3 changes: 2 additions & 1 deletion pkg/skaffold/inspect/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package inspect

import (
"errors"
"fmt"

sErrors "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/errors"
Expand All @@ -31,7 +32,7 @@ func BuildEnvAlreadyExists(b BuildEnv, filename string, profile string) error {
} else {
msg = fmt.Sprintf("trying to create a %q build environment definition that already exists, in profile %q in file %s", b, profile, filename)
}
return sErrors.NewError(fmt.Errorf(msg),
return sErrors.NewError(errors.New(msg),
&proto.ActionableErr{
Message: msg,
ErrCode: proto.StatusCode_INSPECT_BUILD_ENV_ALREADY_EXISTS_ERR,
Expand Down
3 changes: 2 additions & 1 deletion pkg/skaffold/lsp/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func GetHandler(conn jsonrpc2.Conn, out io.Writer, opts config.SkaffoldOptions,
err := recover()
if err != nil {
log.Entry(ctx).Errorf("recovered from panic at %s: %v\n", req.Method(), err)
log.Entry(ctx).Errorf("stacktrace from panic: \n" + string(debug.Stack()))
log.Entry(ctx).Errorf("stacktrace from panic: \n%s", string(debug.Stack()))
}
}()
log.Entry(ctx).Debugf("req.Method(): %q\n", req.Method())
Expand Down Expand Up @@ -192,6 +192,7 @@ func GetHandler(conn jsonrpc2.Conn, out io.Writer, opts config.SkaffoldOptions,
}
}

//nolint:unparam
func (h *Handler) updateDocument(ctx context.Context, documentURI, content string) error {
h.documentManager.UpdateDocument(documentURI, content)
log.Entry(ctx).Debugf("updated document for %q with %d chars\n", documentURI, len(content))
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/parser/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1445,11 +1445,11 @@ func TestConfigLocationsParse(t *testing.T) {
fp := t.TempFile("skaffoldyaml-", []byte(test.skaffoldYamlText))
cfgs, err := GetConfigSet(context.TODO(), config.SkaffoldOptions{ConfigurationFile: fp, Profiles: test.profiles})
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
root, err := kyaml.Parse(test.skaffoldYamlText)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
var seen bool
for _, filters := range test.expected {
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/render/renderer/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (h Helm) generateHelmManifest(ctx context.Context, builds []graph.Artifact,
if !release.SkipBuildDependencies && release.ChartPath != "" {
log.Entry(ctx).Info("Building helm dependencies...")
if err := helm.ExecWithStdoutAndStderr(ctx, h, io.Discard, errBuffer, false, env, "dep", "build", release.ChartPath); err != nil {
log.Entry(ctx).Infof(errBuffer.String())
log.Entry(ctx).Info(errBuffer.String())
return nil, helm.UserErr("building helm dependencies", err)
}
}
Expand All @@ -217,7 +217,7 @@ func (h Helm) generateHelmManifest(ctx context.Context, builds []graph.Artifact,
errorMsg := errBuffer.String()

if len(errorMsg) > 0 {
log.Entry(ctx).Infof(errorMsg)
log.Entry(ctx).Info(errorMsg)
}

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/render/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (v *Transformer) Append(ts ...latest.Transformer) error {
}

func (v *Transformer) IsEmpty() bool {
return v.config == nil || len(v.config) == 0
return len(v.config) == 0
}

func (v *Transformer) Transform(ctx context.Context, ml manifest.ManifestList) (manifest.ManifestList, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/render/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (v Validator) GetDeclarativeValidators() []kptfile.Function {
}

func (v Validator) Validate(ctx context.Context, ml manifest.ManifestList) error {
if v.kptFn == nil || len(v.kptFn) == 0 {
if len(v.kptFn) == 0 {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/survey/survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func recentlyPrompted(gc *sConfig.SurveyConfig) bool {

func (s *Runner) DisplaySurveyPrompt(out io.Writer, id string) error {
if sc, ok := getSurvey(id); ok {
output.Green.Fprintf(out, sc.prompt())
output.Green.Fprintf(out, "%s", sc.prompt())
return updateSurveyPrompted(s.configFile)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/sync/syncer_mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (s SyncerMux) Sync(ctx context.Context, out io.Writer, item *Item) error {
}

// Otherwise log the error as a warning
log.Entry(ctx).Warnf(err.Error())
log.Entry(ctx).Warn(err.Error())
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ func DownloadLatestVersion() (string, error) {
}

func releaseURL(v semver.Version) string {
return fmt.Sprintf("https://github.com/GoogleContainerTools/skaffold/releases/tag/v" + v.String())
return fmt.Sprintf("https://github.com/GoogleContainerTools/skaffold/releases/tag/v%s", v.String())
}

0 comments on commit 16a7495

Please sign in to comment.