diff --git a/hack/conformance/check_conformance_test_requirements.go b/hack/conformance/check_conformance_test_requirements.go index 1cb7445a3e0..86020faebbf 100644 --- a/hack/conformance/check_conformance_test_requirements.go +++ b/hack/conformance/check_conformance_test_requirements.go @@ -32,9 +32,9 @@ import ( const ( //e.g. framework.ConformanceIt("should provide secure master service ", func() { - patternStartConformance = "framework.ConformanceIt\\(.*, func\\(\\) {$" - patternEndConformance = "}\\)$" - patternSkip = "framework.Skip.*\\(" + patternStartConformance = `framework.ConformanceIt\(.*, func\(\) {$` + patternEndConformance = `}\)$` + patternSkip = `framework.Skip.*\(` ) // This function checks the requirement: it works for all providers (e.g., no SkipIfProviderIs/SkipUnlessProviderIs calls) @@ -82,7 +82,7 @@ func checkAllProviders(e2eFile string) error { } func processFile(e2ePath string) error { - regGoFile := regexp.MustCompile(".*\\.go") + regGoFile := regexp.MustCompile(`.*\.go`) files, err := ioutil.ReadDir(e2ePath) if err != nil { diff --git a/pkg/kubectl/cmd/get/customcolumn.go b/pkg/kubectl/cmd/get/customcolumn.go index 9b169006bb0..afe19e1430e 100644 --- a/pkg/kubectl/cmd/get/customcolumn.go +++ b/pkg/kubectl/cmd/get/customcolumn.go @@ -36,7 +36,7 @@ import ( utilprinters "k8s.io/kubectl/pkg/util/printers" ) -var jsonRegexp = regexp.MustCompile("^\\{\\.?([^{}]+)\\}$|^\\.?([^{}]+)$") +var jsonRegexp = regexp.MustCompile(`^\{\.?([^{}]+)\}$|^\.?([^{}]+)$`) // RelaxedJSONPathExpression attempts to be flexible with JSONPath expressions, it accepts: // * metadata.name (no leading '.' or curly braces '{...}' diff --git a/pkg/util/ebtables/ebtables.go b/pkg/util/ebtables/ebtables.go index 4a52df0fc83..ae84b5d0a16 100644 --- a/pkg/util/ebtables/ebtables.go +++ b/pkg/util/ebtables/ebtables.go @@ -110,7 +110,7 @@ func getEbtablesVersionString(exec utilexec.Interface) (string, error) { if err != nil { return "", err } - versionMatcher := regexp.MustCompile("v([0-9]+\\.[0-9]+\\.[0-9]+)") + versionMatcher := regexp.MustCompile(`v([0-9]+\.[0-9]+\.[0-9]+)`) match := versionMatcher.FindStringSubmatch(string(bytes)) if match == nil { return "", fmt.Errorf("no ebtables version found in string: %s", bytes) diff --git a/pkg/util/iptables/iptables.go b/pkg/util/iptables/iptables.go index a060ed4d469..a1424c590f9 100644 --- a/pkg/util/iptables/iptables.go +++ b/pkg/util/iptables/iptables.go @@ -573,6 +573,8 @@ func makeFullArgs(table Table, chain Chain, args ...string) []string { return append([]string{string(chain), "-t", string(table)}, args...) } +const iptablesVersionPattern = `v([0-9]+(\.[0-9]+)+)` + // getIPTablesVersion runs "iptables --version" and parses the returned version func getIPTablesVersion(exec utilexec.Interface, protocol Protocol) (*utilversion.Version, error) { // this doesn't access mutable state so we don't need to use the interface / runner @@ -581,7 +583,7 @@ func getIPTablesVersion(exec utilexec.Interface, protocol Protocol) (*utilversio if err != nil { return nil, err } - versionMatcher := regexp.MustCompile("v([0-9]+(\\.[0-9]+)+)") + versionMatcher := regexp.MustCompile(iptablesVersionPattern) match := versionMatcher.FindStringSubmatch(string(bytes)) if match == nil { return nil, fmt.Errorf("no iptables version found in string: %s", bytes) @@ -641,7 +643,7 @@ func getIPTablesRestoreVersionString(exec utilexec.Interface, protocol Protocol) if err != nil { return "", err } - versionMatcher := regexp.MustCompile("v([0-9]+(\\.[0-9]+)+)") + versionMatcher := regexp.MustCompile(iptablesVersionPattern) match := versionMatcher.FindStringSubmatch(string(bytes)) if match == nil { return "", fmt.Errorf("no iptables version found in string: %s", bytes)