mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
vendor cleanup: remove unused,non-go and test files
This commit is contained in:
32
vendor/k8s.io/apimachinery/pkg/api/validation/path/BUILD
generated
vendored
32
vendor/k8s.io/apimachinery/pkg/api/validation/path/BUILD
generated
vendored
@ -1,32 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["name_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["name.go"],
|
||||
importpath = "k8s.io/apimachinery/pkg/api/validation/path",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
68
vendor/k8s.io/apimachinery/pkg/api/validation/path/name.go
generated
vendored
68
vendor/k8s.io/apimachinery/pkg/api/validation/path/name.go
generated
vendored
@ -1,68 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package path
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// NameMayNotBe specifies strings that cannot be used as names specified as path segments (like the REST API or etcd store)
|
||||
var NameMayNotBe = []string{".", ".."}
|
||||
|
||||
// NameMayNotContain specifies substrings that cannot be used in names specified as path segments (like the REST API or etcd store)
|
||||
var NameMayNotContain = []string{"/", "%"}
|
||||
|
||||
// IsValidPathSegmentName validates the name can be safely encoded as a path segment
|
||||
func IsValidPathSegmentName(name string) []string {
|
||||
for _, illegalName := range NameMayNotBe {
|
||||
if name == illegalName {
|
||||
return []string{fmt.Sprintf(`may not be '%s'`, illegalName)}
|
||||
}
|
||||
}
|
||||
|
||||
var errors []string
|
||||
for _, illegalContent := range NameMayNotContain {
|
||||
if strings.Contains(name, illegalContent) {
|
||||
errors = append(errors, fmt.Sprintf(`may not contain '%s'`, illegalContent))
|
||||
}
|
||||
}
|
||||
|
||||
return errors
|
||||
}
|
||||
|
||||
// IsValidPathSegmentPrefix validates the name can be used as a prefix for a name which will be encoded as a path segment
|
||||
// It does not check for exact matches with disallowed names, since an arbitrary suffix might make the name valid
|
||||
func IsValidPathSegmentPrefix(name string) []string {
|
||||
var errors []string
|
||||
for _, illegalContent := range NameMayNotContain {
|
||||
if strings.Contains(name, illegalContent) {
|
||||
errors = append(errors, fmt.Sprintf(`may not contain '%s'`, illegalContent))
|
||||
}
|
||||
}
|
||||
|
||||
return errors
|
||||
}
|
||||
|
||||
// ValidatePathSegmentName validates the name can be safely encoded as a path segment
|
||||
func ValidatePathSegmentName(name string, prefix bool) []string {
|
||||
if prefix {
|
||||
return IsValidPathSegmentPrefix(name)
|
||||
} else {
|
||||
return IsValidPathSegmentName(name)
|
||||
}
|
||||
}
|
168
vendor/k8s.io/apimachinery/pkg/api/validation/path/name_test.go
generated
vendored
168
vendor/k8s.io/apimachinery/pkg/api/validation/path/name_test.go
generated
vendored
@ -1,168 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package path
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestValidatePathSegmentName(t *testing.T) {
|
||||
testcases := map[string]struct {
|
||||
Name string
|
||||
Prefix bool
|
||||
ExpectedMsg string
|
||||
}{
|
||||
"empty": {
|
||||
Name: "",
|
||||
Prefix: false,
|
||||
ExpectedMsg: "",
|
||||
},
|
||||
"empty,prefix": {
|
||||
Name: "",
|
||||
Prefix: true,
|
||||
ExpectedMsg: "",
|
||||
},
|
||||
|
||||
"valid": {
|
||||
Name: "foo.bar.baz",
|
||||
Prefix: false,
|
||||
ExpectedMsg: "",
|
||||
},
|
||||
"valid,prefix": {
|
||||
Name: "foo.bar.baz",
|
||||
Prefix: true,
|
||||
ExpectedMsg: "",
|
||||
},
|
||||
|
||||
// Make sure mixed case, non DNS subdomain characters are tolerated
|
||||
"valid complex": {
|
||||
Name: "sha256:ABCDEF012345@ABCDEF012345",
|
||||
Prefix: false,
|
||||
ExpectedMsg: "",
|
||||
},
|
||||
// Make sure non-ascii characters are tolerated
|
||||
"valid extended charset": {
|
||||
Name: "Iñtërnâtiônàlizætiøn",
|
||||
Prefix: false,
|
||||
ExpectedMsg: "",
|
||||
},
|
||||
|
||||
"dot": {
|
||||
Name: ".",
|
||||
Prefix: false,
|
||||
ExpectedMsg: ".",
|
||||
},
|
||||
"dot leading": {
|
||||
Name: ".test",
|
||||
Prefix: false,
|
||||
ExpectedMsg: "",
|
||||
},
|
||||
"dot,prefix": {
|
||||
Name: ".",
|
||||
Prefix: true,
|
||||
ExpectedMsg: "",
|
||||
},
|
||||
|
||||
"dot dot": {
|
||||
Name: "..",
|
||||
Prefix: false,
|
||||
ExpectedMsg: "..",
|
||||
},
|
||||
"dot dot leading": {
|
||||
Name: "..test",
|
||||
Prefix: false,
|
||||
ExpectedMsg: "",
|
||||
},
|
||||
"dot dot,prefix": {
|
||||
Name: "..",
|
||||
Prefix: true,
|
||||
ExpectedMsg: "",
|
||||
},
|
||||
|
||||
"slash": {
|
||||
Name: "foo/bar",
|
||||
Prefix: false,
|
||||
ExpectedMsg: "/",
|
||||
},
|
||||
"slash,prefix": {
|
||||
Name: "foo/bar",
|
||||
Prefix: true,
|
||||
ExpectedMsg: "/",
|
||||
},
|
||||
|
||||
"percent": {
|
||||
Name: "foo%bar",
|
||||
Prefix: false,
|
||||
ExpectedMsg: "%",
|
||||
},
|
||||
"percent,prefix": {
|
||||
Name: "foo%bar",
|
||||
Prefix: true,
|
||||
ExpectedMsg: "%",
|
||||
},
|
||||
}
|
||||
|
||||
for k, tc := range testcases {
|
||||
msgs := ValidatePathSegmentName(tc.Name, tc.Prefix)
|
||||
if len(tc.ExpectedMsg) == 0 && len(msgs) > 0 {
|
||||
t.Errorf("%s: expected no message, got %v", k, msgs)
|
||||
}
|
||||
if len(tc.ExpectedMsg) > 0 && len(msgs) == 0 {
|
||||
t.Errorf("%s: expected error message, got none", k)
|
||||
}
|
||||
if len(tc.ExpectedMsg) > 0 && !strings.Contains(msgs[0], tc.ExpectedMsg) {
|
||||
t.Errorf("%s: expected message containing %q, got %v", k, tc.ExpectedMsg, msgs[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateWithMultiErrors(t *testing.T) {
|
||||
testcases := map[string]struct {
|
||||
Name string
|
||||
Prefix bool
|
||||
ExpectedMsg []string
|
||||
}{
|
||||
"slash,percent": {
|
||||
Name: "foo//bar%",
|
||||
Prefix: false,
|
||||
ExpectedMsg: []string{"may not contain '/'", "may not contain '%'"},
|
||||
},
|
||||
"slash,percent,prefix": {
|
||||
Name: "foo//bar%",
|
||||
Prefix: true,
|
||||
ExpectedMsg: []string{"may not contain '/'", "may not contain '%'"},
|
||||
},
|
||||
}
|
||||
|
||||
for k, tc := range testcases {
|
||||
msgs := ValidatePathSegmentName(tc.Name, tc.Prefix)
|
||||
if len(tc.ExpectedMsg) == 0 && len(msgs) > 0 {
|
||||
t.Errorf("%s: expected no message, got %v", k, msgs)
|
||||
}
|
||||
if len(tc.ExpectedMsg) > 0 && len(msgs) == 0 {
|
||||
t.Errorf("%s: expected error message, got none", k)
|
||||
}
|
||||
if len(tc.ExpectedMsg) > 0 {
|
||||
for i := 0; i < len(tc.ExpectedMsg); i++ {
|
||||
if msgs[i] != tc.ExpectedMsg[i] {
|
||||
t.Errorf("%s: expected message containing %q, got %v", k, tc.ExpectedMsg[i], msgs[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user