Skip to content

Commit

Permalink
fix new lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
spowelljr committed Aug 14, 2024
1 parent e126545 commit d8c94a6
Show file tree
Hide file tree
Showing 25 changed files with 137 additions and 75 deletions.
3 changes: 1 addition & 2 deletions cmd/auto-pause/auto-pause-hook/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
"log"

v1 "k8s.io/api/admissionregistration/v1"
Expand Down Expand Up @@ -59,7 +58,7 @@ func apiServerCert(clientset *kubernetes.Clientset) []byte {

pem, ok := c.Data["requestheader-client-ca-file"]
if !ok {
klog.Fatalf(fmt.Sprintf("cannot find the ca.crt in the configmap, configMap.Data is %#v", c.Data))
klog.Fatalf("cannot find the ca.crt in the configmap, configMap.Data is %#v", c.Data)
}
klog.Info("client-ca-file=", pem)
return []byte(pem)
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/config/profile_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func warnInvalidProfiles(invalidProfiles []*config.Profile) {

out.ErrT(style.Tip, "You can delete them using the following command(s): ")
for _, p := range invalidProfiles {
out.Err(fmt.Sprintf("\t $ minikube delete -p %s \n", p.Name))
out.Errf("\t $ minikube delete -p %s \n", p.Name)
}
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/minikube/cmd/config/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func AskForYesNoConfirmation(s string, posResponses, negResponses []string) bool
reader := bufio.NewReader(os.Stdin)

for {
out.String("%s [y/n]: ", s)
out.Stringf("%s [y/n]: ", s)

response, err := reader.ReadString('\n')
if err != nil {
Expand Down Expand Up @@ -78,7 +78,7 @@ func AskForStaticValueOptional(s string) string {
}

func getStaticValue(reader *bufio.Reader, s string) string {
out.String("%s", s)
out.String(s)

response, err := reader.ReadString('\n')
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ func killProcess(path string) error {
// if multiple errors were encountered, combine them into a single error
out.Styled(style.Failure, "Multiple errors encountered:")
for _, e := range errs {
out.Err("%v\n", e)
out.Errf("%v\n", e)
}
return errors.New("multiple errors encountered while closing mount processes")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/minikube/cmd/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ var buildImageCmd = &cobra.Command{
if runtime.GOOS == "windows" && strings.Contains(dockerFile, "\\") {
// if dockerFile is a DOS path, translate it into UNIX path
// because we are going to build this image in UNIX environment
out.String("minikube detects that you are using DOS-style path %s. minikube will convert it to UNIX-style by replacing all \\ to /", dockerFile)
out.Stringf("minikube detects that you are using DOS-style path %s. minikube will convert it to UNIX-style by replacing all \\ to /", dockerFile)
dockerFile = strings.ReplaceAll(dockerFile, "\\", "/")
}
if err := machine.BuildImage(img, dockerFile, tag, push, buildEnv, buildOpt, []*config.Profile{profile}, allNodes, nodeName); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions cmd/minikube/cmd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ You may select another namespace by using 'minikube service {{.service}} -n <nam
data = append(data, []string{svc.Namespace, svc.Name, servicePortNames, serviceURLs})

if serviceURLMode && !driver.NeedsPortForward(co.Config.Driver) {
out.String(fmt.Sprintf("%s\n", serviceURLs))
out.Stringf("%s\n", serviceURLs)
}
}
// check whether there are running pods for this service
Expand Down Expand Up @@ -229,7 +229,7 @@ func startKicServiceTunnel(services service.URLs, configName, driverName string)
service.PrintServiceList(os.Stdout, data)
} else {
for _, row := range data {
out.String(fmt.Sprintf("%s\n", row[3]))
out.Stringf("%s\n", row[3])
}
}

Expand Down Expand Up @@ -286,12 +286,12 @@ func openURLs(urls [][]string) {
_, err := url.Parse(u[3])
if err != nil {
klog.Warningf("failed to parse url %q: %v (will not open)", u[3], err)
out.String(fmt.Sprintf("%s\n", u))
out.Stringf("%s\n", u)
continue
}

if serviceURLMode {
out.String(fmt.Sprintf("%s\n", u))
out.Stringf("%s\n", u)
continue
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/addons/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestSetAndSave(t *testing.T) {

// enable
if err := SetAndSave(profile, "dashboard", "true"); err != nil {
t.Errorf("Disable returned unexpected error: " + err.Error())
t.Errorf("Disable returned unexpected error: %v", err)
}

c, err := config.DefaultLoader.LoadConfigFromFile(profile)
Expand All @@ -113,7 +113,7 @@ func TestSetAndSave(t *testing.T) {

// disable
if err := SetAndSave(profile, "dashboard", "false"); err != nil {
t.Errorf("Disable returned unexpected error: " + err.Error())
t.Errorf("Disable returned unexpected error: %v", err)
}

c, err = config.DefaultLoader.LoadConfigFromFile(profile)
Expand Down
3 changes: 2 additions & 1 deletion pkg/addons/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package addons

import (
"errors"
"fmt"
"strconv"

Expand Down Expand Up @@ -53,7 +54,7 @@ func isRuntimeContainerd(cc *config.ClusterConfig, _, _ string) error {
}
_, ok := r.(*cruntime.Containerd)
if !ok {
return fmt.Errorf(containerdOnlyAddonMsg)
return errors.New(containerdOnlyAddonMsg)
}
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/minikube/bootstrapper/bsutil/kverify/pod_ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package kverify

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -95,7 +96,7 @@ func waitPodCondition(cs *kubernetes.Clientset, name, namespace string, conditio
// return immediately: status == core.ConditionUnknown
if status == core.ConditionUnknown {
klog.Info(reason)
return false, fmt.Errorf(reason)
return false, errors.New(reason)
}
// reduce log spam
if time.Since(lap) > (2 * time.Second) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/bootstrapper/bsutil/kverify/system_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func WaitForSystemPods(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg con

klog.Infof("%d kube-system pods found", len(pods.Items))
for _, pod := range pods.Items {
klog.Infof(podStatusMsg(pod))
klog.Info(podStatusMsg(pod))
}

if len(pods.Items) < 2 {
Expand Down Expand Up @@ -86,7 +86,7 @@ func ExpectAppsRunning(cs *kubernetes.Clientset, expected []string) error {
klog.Infof("%d kube-system pods found", len(pods.Items))

for _, pod := range pods.Items {
klog.Infof(podStatusMsg(pod))
klog.Info(podStatusMsg(pod))

if pod.Status.Phase != core.PodRunning {
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/download/iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func ISO(urls []string, skipChecksum bool) (string, error) {
msg.WriteString(fmt.Sprintf(" %s: %s\n", u, err))
}

return "", fmt.Errorf(msg.String())
return "", errors.New(msg.String())
}

// downloadISO downloads an ISO URL
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/exit/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func Message(r reason.Kind, format string, args ...out.V) {
// Code will exit with a code
func Code(code int) {
if shell {
out.Output(os.Stdout, fmt.Sprintf("false exit code %d\n", code))
out.Outputf(os.Stdout, "false exit code %d\n", code)
}
os.Exit(code)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/minikube/machine/cache_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,21 +762,21 @@ func ListImages(profile *config.Profile, format string) error {
klog.Warningf("Error marshalling images list: %v", err.Error())
return nil
}
fmt.Printf(string(json) + "\n")
fmt.Printf("%s\n", string(json))
case "yaml":
yaml, err := yaml.Marshal(uniqueImages)
if err != nil {
klog.Warningf("Error marshalling images list: %v", err.Error())
return nil
}
fmt.Printf(string(yaml) + "\n")
fmt.Printf("%s\n", string(yaml))
default:
res := []string{}
for _, item := range uniqueImages {
res = append(res, item.RepoTags...)
}
sort.Sort(sort.Reverse(sort.StringSlice(res)))
fmt.Printf(strings.Join(res, "\n") + "\n")
fmt.Printf("%s\n", strings.Join(res, "\n"))
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/machine/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (api *LocalClient) Create(h *host.Host) error {
// CA cert and client cert should be generated atomically, otherwise might cause bad certificate error.
lockErr := api.flock.LockWithTimeout(time.Second * 5)
if lockErr != nil {
return fmt.Errorf("failed to acquire bootstrap client lock: %v " + lockErr.Error())
return fmt.Errorf("failed to acquire bootstrap client lock: %v", lockErr)
}
defer func() {
lockErr = api.flock.Unlock()
Expand Down
5 changes: 2 additions & 3 deletions pkg/minikube/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package machine

import (
"fmt"
"os/exec"
"path"
"strings"
Expand Down Expand Up @@ -173,7 +172,7 @@ func backup(h host.Host, files []string) error {
}
}
if len(errs) > 0 {
return errors.Errorf(fmt.Sprintf("%v", errs))
return errors.Errorf("%v", errs)
}
return nil
}
Expand Down Expand Up @@ -208,7 +207,7 @@ func restore(h host.Host) error {
}
}
if len(errs) > 0 {
return errors.Errorf(fmt.Sprintf("%v", errs))
return errors.Errorf("%v", errs)
}
return nil
}
2 changes: 1 addition & 1 deletion pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ func setupKubeconfig(h host.Host, cc config.ClusterConfig, n config.Node, cluste
exit.Message(reason.DrvCPEndpoint, fmt.Sprintf("failed to construct cluster server address: %v", err), out.V{"profileArg": fmt.Sprintf("--profile=%s", clusterName)})
}
}
addr := fmt.Sprintf("https://" + net.JoinHostPort(host, strconv.Itoa(port)))
addr := fmt.Sprintf("https://%s", net.JoinHostPort(host, strconv.Itoa(port)))

if cc.KubernetesConfig.APIServerName != constants.APIServerName {
addr = strings.ReplaceAll(addr, host, cc.KubernetesConfig.APIServerName)
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/notify/notify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestLatestVersionFromURLCorrect(t *testing.T) {

latestVersion, err := latestVersionFromURL(server.URL)
if err != nil {
t.Fatalf(err.Error())
t.Fatal(err.Error())
}
expectedVersion, _ := semver.Make(versionFromURL)
if latestVersion.Compare(expectedVersion) != 0 {
Expand Down
Loading

0 comments on commit d8c94a6

Please sign in to comment.