Apply fixes suggested by staticcheck
This commit is contained in:
parent
82c22e3969
commit
3d7a09347d
19 changed files with 26 additions and 315 deletions
|
|
@ -80,6 +80,6 @@ func backends(flags *genericclioptions.ConfigFlags, podName string, deployment s
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Printf(out)
|
||||
fmt.Print(out)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,11 +148,7 @@ func removedAnnotation(annotationName string, issueNumber int, version string) I
|
|||
func satisfyDirective(ing networking.Ingress) bool {
|
||||
for name, val := range ing.Annotations {
|
||||
if strings.HasSuffix(name, "/configuration-snippet") {
|
||||
if strings.Index(val, "satisfy") != -1 {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
return strings.Contains(val, "satisfy")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func GetNamedPod(flags *genericclioptions.ConfigFlags, name string) (apiv1.Pod,
|
|||
}
|
||||
}
|
||||
|
||||
return apiv1.Pod{}, fmt.Errorf("Pod %v not found in namespace %v", name, util.GetNamespace(flags))
|
||||
return apiv1.Pod{}, fmt.Errorf("pod %v not found in namespace %v", name, util.GetNamespace(flags))
|
||||
}
|
||||
|
||||
// GetDeploymentPod finds a pod from a given deployment
|
||||
|
|
@ -64,7 +64,7 @@ func GetDeploymentPod(flags *genericclioptions.ConfigFlags, deployment string) (
|
|||
}
|
||||
|
||||
if len(ings) == 0 {
|
||||
return apiv1.Pod{}, fmt.Errorf("No pods for deployment %v found in namespace %v", deployment, util.GetNamespace(flags))
|
||||
return apiv1.Pod{}, fmt.Errorf("no pods for deployment %v found in namespace %v", deployment, util.GetNamespace(flags))
|
||||
}
|
||||
|
||||
return ings[0], nil
|
||||
|
|
@ -222,7 +222,7 @@ func GetServiceByName(flags *genericclioptions.ConfigFlags, name string, service
|
|||
}
|
||||
}
|
||||
|
||||
return apiv1.Service{}, fmt.Errorf("Could not find service %v in namespace %v", name, util.GetNamespace(flags))
|
||||
return apiv1.Service{}, fmt.Errorf("could not find service %v in namespace %v", name, util.GetNamespace(flags))
|
||||
}
|
||||
|
||||
func getPods(flags *genericclioptions.ConfigFlags) ([]apiv1.Pod, error) {
|
||||
|
|
|
|||
|
|
@ -45,27 +45,12 @@ func PrintError(e error) {
|
|||
}
|
||||
}
|
||||
|
||||
func printWithError(s string, e error) {
|
||||
if e != nil {
|
||||
fmt.Println(e)
|
||||
}
|
||||
fmt.Print(s)
|
||||
}
|
||||
|
||||
func printOrError(s string, e error) error {
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
fmt.Print(s)
|
||||
return nil
|
||||
}
|
||||
|
||||
// ParseVersionString returns the major, minor, and patch numbers of a version string
|
||||
func ParseVersionString(v string) (int, int, int, error) {
|
||||
parts := versionRegex.FindStringSubmatch(v)
|
||||
|
||||
if len(parts) != 4 {
|
||||
return 0, 0, 0, fmt.Errorf("Could not parse %v as a version string (like 0.20.3)", v)
|
||||
return 0, 0, 0, fmt.Errorf("could not parse %v as a version string (like 0.20.3)", v)
|
||||
}
|
||||
|
||||
major, _ := strconv.Atoi(parts[1])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue