Skip to content

Commit

Permalink
Merge pull request kubernetes#115168 from HirazawaUi/delte-pkg-apis-o…
Browse files Browse the repository at this point in the history
…ther-unused-functions

remove unused not api functions in the pkg/apis directory
  • Loading branch information
k8s-ci-robot authored Apr 24, 2023
2 parents 6662b29 + c50c19d commit 56e17d6
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 165 deletions.
6 changes: 0 additions & 6 deletions pkg/apis/authorization/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 0 additions & 6 deletions pkg/apis/certificates/v1beta1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
35 changes: 0 additions & 35 deletions pkg/apis/core/helper/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 0 additions & 6 deletions pkg/apis/core/v1/helper/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
35 changes: 0 additions & 35 deletions pkg/apis/rbac/v1/evaluation_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{}
Expand Down
16 changes: 0 additions & 16 deletions pkg/apis/rbac/v1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 0 additions & 21 deletions pkg/apis/rbac/v1alpha1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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})
Expand Down
21 changes: 0 additions & 21 deletions pkg/apis/rbac/v1beta1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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})
Expand Down
14 changes: 0 additions & 14 deletions pkg/apis/storage/util/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions pkg/apis/storage/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down

0 comments on commit 56e17d6

Please sign in to comment.