fix: issues affecting code quality (#5827)

Fix various lint issues:

- Remove unnecessary calls to fmt.Sprint
- Fix check for empty string
- Fix unnecessary calls to Printf
- Combine multiple `append`s into a single call

Signed-off-by: shubhendra <withshubh@gmail.com>
This commit is contained in:
Shubhendra Singh Chauhan 2021-03-16 03:05:40 +05:30 committed by GitHub
parent 7f0529ed7c
commit ad3b9accd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 7 deletions

View File

@ -99,7 +99,7 @@ linkerd upgrade.`,
return fmt.Errorf("Failed to render overrides: %s", err)
}
fmt.Printf(string(overrides))
fmt.Print(string(overrides))
return nil
},

View File

@ -148,8 +148,7 @@ func startDocker(testNum int, wd string, testWorkRootDir string, tempCNINetDir s
if _, ok := os.LookupEnv(cniConfName); ok {
args = append(args, "-e", cniConfName)
}
args = append(args, dockerImage)
args = append(args, "install-cni.sh")
args = append(args, dockerImage, "install-cni.sh")
// Create a temporary log file to write docker command error log.
errFile, err := os.Create(errFileName)

View File

@ -34,7 +34,7 @@ var (
injectDisableAnnotationPresent: fmt.Sprintf("pod has the annotation \"%s:%s\"", k8s.ProxyInjectAnnotation, k8s.ProxyInjectDisabled),
invalidInjectAnnotationWorkload: fmt.Sprintf("invalid value for annotation \"%s\" at workload", k8s.ProxyInjectAnnotation),
invalidInjectAnnotationNamespace: fmt.Sprintf("invalid value for annotation \"%s\" at namespace", k8s.ProxyInjectAnnotation),
disabledAutomountServiceAccountToken: fmt.Sprintf("automountServiceAccountToken set to \"false\""),
disabledAutomountServiceAccountToken: "automountServiceAccountToken set to \"false\"",
udpPortsEnabled: "UDP port(s) configured on pod spec",
}
)

View File

@ -208,7 +208,7 @@ func GetPodStatus(pod corev1.Pod) string {
continue
case container.State.Terminated != nil:
// initialization is failed
if len(container.State.Terminated.Reason) == 0 {
if container.State.Terminated.Reason == "" {
if container.State.Terminated.Signal != 0 {
reason = fmt.Sprintf("Init:Signal:%d", container.State.Terminated.Signal)
} else {

View File

@ -253,7 +253,7 @@ func writeEdgesToBuffer(rows []*pb.Edge, w *tabwriter.Writer, options *edgesOpti
clientID := r.ClientId
serverID := r.ServerId
msg := r.NoIdentityMsg
if len(msg) == 0 && options.outputFormat != jsonOutput {
if msg == "" && options.outputFormat != jsonOutput {
msg = okStatus
}
if len(clientID) > 0 {

View File

@ -205,7 +205,7 @@ func serverAuth(ctx context.Context, k8sAPI *k8s.API) (string, []string, string,
// copied from https://github.com/kubernetes/apiserver/blob/781c3cd1b3dc5b6f79c68ab0d16fe544600421ef/pkg/server/options/authentication.go#L360
func deserializeStrings(in string) ([]string, error) {
if len(in) == 0 {
if in == "" {
return nil, nil
}
var ret []string