mirror of
https://git.mirrors.martin98.com/https://github.com/ceph/ceph-csi.git
synced 2025-08-14 07:06:03 +08:00

Several packages are only used while running the e2e suite. These packages are less important to update, as the they can not influence the final executable that is part of the Ceph-CSI container-image. By moving these dependencies out of the main Ceph-CSI go.mod, it is easier to identify if a reported CVE affects Ceph-CSI, or only the testing (like most of the Kubernetes CVEs). Signed-off-by: Niels de Vos <ndevos@ibm.com>
30 lines
594 B
Go
30 lines
594 B
Go
package restful
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
)
|
|
|
|
var (
|
|
customVerbReg = regexp.MustCompile(":([A-Za-z]+)$")
|
|
)
|
|
|
|
func hasCustomVerb(routeToken string) bool {
|
|
return customVerbReg.MatchString(routeToken)
|
|
}
|
|
|
|
func isMatchCustomVerb(routeToken string, pathToken string) bool {
|
|
rs := customVerbReg.FindStringSubmatch(routeToken)
|
|
if len(rs) < 2 {
|
|
return false
|
|
}
|
|
|
|
customVerb := rs[1]
|
|
specificVerbReg := regexp.MustCompile(fmt.Sprintf(":%s$", customVerb))
|
|
return specificVerbReg.MatchString(pathToken)
|
|
}
|
|
|
|
func removeCustomVerb(str string) string {
|
|
return customVerbReg.ReplaceAllString(str, "")
|
|
}
|