Merge pull request #115168 from HirazawaUi/delte-pkg-apis-other-unused-functions
remove unused not api functions in the pkg/apis directory
This commit is contained in:
		| @@ -54,12 +54,6 @@ func ValidateSelfSubjectAccessReviewSpec(spec authorizationapi.SelfSubjectAccess | ||||
| 	return allErrs | ||||
| } | ||||
|  | ||||
| // ValidateSelfSubjectRulesReview validates a SelfSubjectRulesReview and returns an | ||||
| // ErrorList with any errors. | ||||
| func ValidateSelfSubjectRulesReview(review *authorizationapi.SelfSubjectRulesReview) field.ErrorList { | ||||
| 	return field.ErrorList{} | ||||
| } | ||||
|  | ||||
| // ValidateSubjectAccessReview validates a SubjectAccessReview and returns an | ||||
| // ErrorList with any errors. | ||||
| func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) field.ErrorList { | ||||
|   | ||||
| @@ -68,16 +68,10 @@ func DefaultSignerNameFromSpec(obj *certificatesv1beta1.CertificateSigningReques | ||||
| func IsKubeletServingCSR(req *x509.CertificateRequest, usages []certificatesv1beta1.KeyUsage) bool { | ||||
| 	return certificates.IsKubeletServingCSR(req, usagesToSet(usages)) | ||||
| } | ||||
| func ValidateKubeletServingCSR(req *x509.CertificateRequest, usages []certificatesv1beta1.KeyUsage) error { | ||||
| 	return certificates.ValidateKubeletServingCSR(req, usagesToSet(usages)) | ||||
| } | ||||
|  | ||||
| func IsKubeletClientCSR(req *x509.CertificateRequest, usages []certificatesv1beta1.KeyUsage) bool { | ||||
| 	return certificates.IsKubeletClientCSR(req, usagesToSet(usages)) | ||||
| } | ||||
| func ValidateKubeletClientCSR(req *x509.CertificateRequest, usages []certificatesv1beta1.KeyUsage) error { | ||||
| 	return certificates.ValidateKubeletClientCSR(req, usagesToSet(usages)) | ||||
| } | ||||
|  | ||||
| func usagesToSet(usages []certificatesv1beta1.KeyUsage) sets.String { | ||||
| 	result := sets.NewString() | ||||
|   | ||||
| @@ -453,41 +453,6 @@ func PersistentVolumeClaimHasClass(claim *core.PersistentVolumeClaim) bool { | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| func toResourceNames(resources core.ResourceList) []core.ResourceName { | ||||
| 	result := []core.ResourceName{} | ||||
| 	for resourceName := range resources { | ||||
| 		result = append(result, resourceName) | ||||
| 	} | ||||
| 	return result | ||||
| } | ||||
|  | ||||
| func toSet(resourceNames []core.ResourceName) sets.String { | ||||
| 	result := sets.NewString() | ||||
| 	for _, resourceName := range resourceNames { | ||||
| 		result.Insert(string(resourceName)) | ||||
| 	} | ||||
| 	return result | ||||
| } | ||||
|  | ||||
| // toContainerResourcesSet returns a set of resources names in container resource requirements | ||||
| func toContainerResourcesSet(ctr *core.Container) sets.String { | ||||
| 	resourceNames := toResourceNames(ctr.Resources.Requests) | ||||
| 	resourceNames = append(resourceNames, toResourceNames(ctr.Resources.Limits)...) | ||||
| 	return toSet(resourceNames) | ||||
| } | ||||
|  | ||||
| // ToPodResourcesSet returns a set of resource names in all containers in a pod. | ||||
| func ToPodResourcesSet(podSpec *core.PodSpec) sets.String { | ||||
| 	result := sets.NewString() | ||||
| 	for i := range podSpec.InitContainers { | ||||
| 		result = result.Union(toContainerResourcesSet(&podSpec.InitContainers[i])) | ||||
| 	} | ||||
| 	for i := range podSpec.Containers { | ||||
| 		result = result.Union(toContainerResourcesSet(&podSpec.Containers[i])) | ||||
| 	} | ||||
| 	return result | ||||
| } | ||||
|  | ||||
| // GetDeletionCostFromPodAnnotations returns the integer value of pod-deletion-cost. Returns 0 | ||||
| // if not set or the value is invalid. | ||||
| func GetDeletionCostFromPodAnnotations(annotations map[string]string) (int32, error) { | ||||
|   | ||||
| @@ -315,12 +315,6 @@ func AddOrUpdateTolerationInPodSpec(spec *v1.PodSpec, toleration *v1.Toleration) | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| // AddOrUpdateTolerationInPod tries to add a toleration to the pod's toleration list. | ||||
| // Returns true if something was updated, false otherwise. | ||||
| func AddOrUpdateTolerationInPod(pod *v1.Pod, toleration *v1.Toleration) bool { | ||||
| 	return AddOrUpdateTolerationInPodSpec(&pod.Spec, toleration) | ||||
| } | ||||
|  | ||||
| // GetMatchingTolerations returns true and list of Tolerations matching all Taints if all are tolerated, or false otherwise. | ||||
| func GetMatchingTolerations(taints []v1.Taint, tolerations []v1.Toleration) (bool, []v1.Toleration) { | ||||
| 	if len(taints) == 0 { | ||||
|   | ||||
| @@ -21,13 +21,8 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	rbacv1 "k8s.io/api/rbac/v1" | ||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||
| ) | ||||
|  | ||||
| func RoleRefGroupKind(roleRef rbacv1.RoleRef) schema.GroupKind { | ||||
| 	return schema.GroupKind{Group: roleRef.APIGroup, Kind: roleRef.Kind} | ||||
| } | ||||
|  | ||||
| func VerbMatches(rule *rbacv1.PolicyRule, requestedVerb string) bool { | ||||
| 	for _, ruleVerb := range rule.Verbs { | ||||
| 		if ruleVerb == rbacv1.VerbAll { | ||||
| @@ -112,36 +107,6 @@ func NonResourceURLMatches(rule *rbacv1.PolicyRule, requestedURL string) bool { | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| // subjectsStrings returns users, groups, serviceaccounts, unknown for display purposes. | ||||
| func SubjectsStrings(subjects []rbacv1.Subject) ([]string, []string, []string, []string) { | ||||
| 	users := []string{} | ||||
| 	groups := []string{} | ||||
| 	sas := []string{} | ||||
| 	others := []string{} | ||||
|  | ||||
| 	for _, subject := range subjects { | ||||
| 		switch subject.Kind { | ||||
| 		case rbacv1.ServiceAccountKind: | ||||
| 			sas = append(sas, fmt.Sprintf("%s/%s", subject.Namespace, subject.Name)) | ||||
|  | ||||
| 		case rbacv1.UserKind: | ||||
| 			users = append(users, subject.Name) | ||||
|  | ||||
| 		case rbacv1.GroupKind: | ||||
| 			groups = append(groups, subject.Name) | ||||
|  | ||||
| 		default: | ||||
| 			others = append(others, fmt.Sprintf("%s/%s/%s", subject.Kind, subject.Namespace, subject.Name)) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return users, groups, sas, others | ||||
| } | ||||
|  | ||||
| func String(r rbacv1.PolicyRule) string { | ||||
| 	return "PolicyRule" + CompactString(r) | ||||
| } | ||||
|  | ||||
| // CompactString exposes a compact string representation for use in escalation error messages | ||||
| func CompactString(r rbacv1.PolicyRule) string { | ||||
| 	formatStringParts := []string{} | ||||
|   | ||||
| @@ -186,22 +186,6 @@ func NewRoleBinding(roleName, namespace string) *RoleBindingBuilder { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func NewRoleBindingForClusterRole(roleName, namespace string) *RoleBindingBuilder { | ||||
| 	return &RoleBindingBuilder{ | ||||
| 		RoleBinding: rbacv1.RoleBinding{ | ||||
| 			ObjectMeta: metav1.ObjectMeta{ | ||||
| 				Name:      roleName, | ||||
| 				Namespace: namespace, | ||||
| 			}, | ||||
| 			RoleRef: rbacv1.RoleRef{ | ||||
| 				APIGroup: GroupName, | ||||
| 				Kind:     "ClusterRole", | ||||
| 				Name:     roleName, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Groups adds the specified groups as the subjects of the RoleBinding. | ||||
| func (r *RoleBindingBuilder) Groups(groups ...string) *RoleBindingBuilder { | ||||
| 	for _, group := range groups { | ||||
|   | ||||
| @@ -20,8 +20,6 @@ import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| ) | ||||
|  | ||||
| // PolicyRuleBuilder let's us attach methods.  A no-no for API types. | ||||
| @@ -31,12 +29,6 @@ type PolicyRuleBuilder struct { | ||||
| 	PolicyRule rbacv1alpha1.PolicyRule `protobuf:"bytes,1,opt,name=policyRule"` | ||||
| } | ||||
|  | ||||
| func NewRule(verbs ...string) *PolicyRuleBuilder { | ||||
| 	return &PolicyRuleBuilder{ | ||||
| 		PolicyRule: rbacv1alpha1.PolicyRule{Verbs: verbs}, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (r *PolicyRuleBuilder) Groups(groups ...string) *PolicyRuleBuilder { | ||||
| 	r.PolicyRule.APIGroups = append(r.PolicyRule.APIGroups, groups...) | ||||
| 	return r | ||||
| @@ -97,19 +89,6 @@ type ClusterRoleBindingBuilder struct { | ||||
| 	ClusterRoleBinding rbacv1alpha1.ClusterRoleBinding `protobuf:"bytes,1,opt,name=clusterRoleBinding"` | ||||
| } | ||||
|  | ||||
| func NewClusterBinding(clusterRoleName string) *ClusterRoleBindingBuilder { | ||||
| 	return &ClusterRoleBindingBuilder{ | ||||
| 		ClusterRoleBinding: rbacv1alpha1.ClusterRoleBinding{ | ||||
| 			ObjectMeta: metav1.ObjectMeta{Name: clusterRoleName}, | ||||
| 			RoleRef: rbacv1alpha1.RoleRef{ | ||||
| 				APIGroup: GroupName, | ||||
| 				Kind:     "ClusterRole", | ||||
| 				Name:     clusterRoleName, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (r *ClusterRoleBindingBuilder) Groups(groups ...string) *ClusterRoleBindingBuilder { | ||||
| 	for _, group := range groups { | ||||
| 		r.ClusterRoleBinding.Subjects = append(r.ClusterRoleBinding.Subjects, rbacv1alpha1.Subject{Kind: rbacv1alpha1.GroupKind, Name: group}) | ||||
|   | ||||
| @@ -20,8 +20,6 @@ import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	rbacv1beta1 "k8s.io/api/rbac/v1beta1" | ||||
|  | ||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
| ) | ||||
|  | ||||
| // PolicyRuleBuilder let's us attach methods.  A no-no for API types. | ||||
| @@ -31,12 +29,6 @@ type PolicyRuleBuilder struct { | ||||
| 	PolicyRule rbacv1beta1.PolicyRule `protobuf:"bytes,1,opt,name=policyRule"` | ||||
| } | ||||
|  | ||||
| func NewRule(verbs ...string) *PolicyRuleBuilder { | ||||
| 	return &PolicyRuleBuilder{ | ||||
| 		PolicyRule: rbacv1beta1.PolicyRule{Verbs: verbs}, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (r *PolicyRuleBuilder) Groups(groups ...string) *PolicyRuleBuilder { | ||||
| 	r.PolicyRule.APIGroups = append(r.PolicyRule.APIGroups, groups...) | ||||
| 	return r | ||||
| @@ -97,19 +89,6 @@ type ClusterRoleBindingBuilder struct { | ||||
| 	ClusterRoleBinding rbacv1beta1.ClusterRoleBinding `protobuf:"bytes,1,opt,name=clusterRoleBinding"` | ||||
| } | ||||
|  | ||||
| func NewClusterBinding(clusterRoleName string) *ClusterRoleBindingBuilder { | ||||
| 	return &ClusterRoleBindingBuilder{ | ||||
| 		ClusterRoleBinding: rbacv1beta1.ClusterRoleBinding{ | ||||
| 			ObjectMeta: metav1.ObjectMeta{Name: clusterRoleName}, | ||||
| 			RoleRef: rbacv1beta1.RoleRef{ | ||||
| 				APIGroup: GroupName, | ||||
| 				Kind:     "ClusterRole", | ||||
| 				Name:     clusterRoleName, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (r *ClusterRoleBindingBuilder) Groups(groups ...string) *ClusterRoleBindingBuilder { | ||||
| 	for _, group := range groups { | ||||
| 		r.ClusterRoleBinding.Subjects = append(r.ClusterRoleBinding.Subjects, rbacv1beta1.Subject{Kind: rbacv1beta1.GroupKind, Name: group}) | ||||
|   | ||||
| @@ -26,20 +26,6 @@ const IsDefaultStorageClassAnnotation = "storageclass.kubernetes.io/is-default-c | ||||
| // TODO: remove Beta when no longer used | ||||
| const BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class" | ||||
|  | ||||
| // IsDefaultAnnotationText returns a pretty Yes/No String if | ||||
| // the annotation is set | ||||
| // TODO: remove Beta when no longer needed | ||||
| func IsDefaultAnnotationText(obj metav1.ObjectMeta) string { | ||||
| 	if obj.Annotations[IsDefaultStorageClassAnnotation] == "true" { | ||||
| 		return "Yes" | ||||
| 	} | ||||
| 	if obj.Annotations[BetaIsDefaultStorageClassAnnotation] == "true" { | ||||
| 		return "Yes" | ||||
| 	} | ||||
|  | ||||
| 	return "No" | ||||
| } | ||||
|  | ||||
| // IsDefaultAnnotation returns a boolean if | ||||
| // the annotation is set | ||||
| // TODO: remove Beta when no longer needed | ||||
|   | ||||
| @@ -352,11 +352,6 @@ func validateCSINodeDriverNodeID(nodeID string, fldPath *field.Path, validationO | ||||
| 	return allErrs | ||||
| } | ||||
|  | ||||
| // CSINodeLongerID will check if the nodeID is longer than csiNodeIDMaxLength | ||||
| func CSINodeLongerID(nodeID string) bool { | ||||
| 	return len(nodeID) > csiNodeIDMaxLength | ||||
| } | ||||
|  | ||||
| // validateCSINodeDriverAllocatable tests if Allocatable in CSINodeDriver has valid volume limits. | ||||
| func validateCSINodeDriverAllocatable(a *storage.VolumeNodeResources, fldPath *field.Path) field.ErrorList { | ||||
| 	allErrs := field.ErrorList{} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot