From 38de5581b4eb66ed8f8361b3baca41c0927a4271 Mon Sep 17 00:00:00 2001 From: tianshapjq Date: Wed, 29 Nov 2017 10:47:25 +0800 Subject: [PATCH] cleanup useless functions --- pkg/apis/core/helper/helpers.go | 59 ------------------------------ pkg/apis/core/v1/helper/helpers.go | 23 ------------ 2 files changed, 82 deletions(-) diff --git a/pkg/apis/core/helper/helpers.go b/pkg/apis/core/helper/helpers.go index ca397c8eb7..d0c004cf99 100644 --- a/pkg/apis/core/helper/helpers.go +++ b/pkg/apis/core/helper/helpers.go @@ -254,46 +254,18 @@ func IsIntegerResourceName(str string) bool { return integerResources.Has(str) || IsExtendedResourceName(core.ResourceName(str)) } -// Extended and HugePages resources -func IsScalarResourceName(name core.ResourceName) bool { - return IsExtendedResourceName(name) || IsHugePageResourceName(name) -} - // this function aims to check if the service's ClusterIP is set or not // the objective is not to perform validation here func IsServiceIPSet(service *core.Service) bool { return service.Spec.ClusterIP != core.ClusterIPNone && service.Spec.ClusterIP != "" } -// this function aims to check if the service's cluster IP is requested or not -func IsServiceIPRequested(service *core.Service) bool { - // ExternalName services are CNAME aliases to external ones. Ignore the IP. - if service.Spec.Type == core.ServiceTypeExternalName { - return false - } - return service.Spec.ClusterIP == "" -} - var standardFinalizers = sets.NewString( string(core.FinalizerKubernetes), metav1.FinalizerOrphanDependents, metav1.FinalizerDeleteDependents, ) -// HasAnnotation returns a bool if passed in annotation exists -func HasAnnotation(obj core.ObjectMeta, ann string) bool { - _, found := obj.Annotations[ann] - return found -} - -// SetMetaDataAnnotation sets the annotation and value -func SetMetaDataAnnotation(obj *core.ObjectMeta, ann string, value string) { - if obj.Annotations == nil { - obj.Annotations = make(map[string]string) - } - obj.Annotations[ann] = value -} - func IsStandardFinalizerName(str string) bool { return standardFinalizers.Has(str) } @@ -482,37 +454,6 @@ func AddOrUpdateTolerationInPod(pod *core.Pod, toleration *core.Toleration) bool return true } -// TolerationToleratesTaint checks if the toleration tolerates the taint. -func TolerationToleratesTaint(toleration *core.Toleration, taint *core.Taint) bool { - if len(toleration.Effect) != 0 && toleration.Effect != taint.Effect { - return false - } - - if toleration.Key != taint.Key { - return false - } - // TODO: Use proper defaulting when Toleration becomes a field of PodSpec - if (len(toleration.Operator) == 0 || toleration.Operator == core.TolerationOpEqual) && toleration.Value == taint.Value { - return true - } - if toleration.Operator == core.TolerationOpExists { - return true - } - return false -} - -// TaintToleratedByTolerations checks if taint is tolerated by any of the tolerations. -func TaintToleratedByTolerations(taint *core.Taint, tolerations []core.Toleration) bool { - tolerated := false - for i := range tolerations { - if TolerationToleratesTaint(&tolerations[i], taint) { - tolerated = true - break - } - } - return tolerated -} - // GetTaintsFromNodeAnnotations gets the json serialized taints data from Pod.Annotations // and converts it to the []Taint type in core. func GetTaintsFromNodeAnnotations(annotations map[string]string) ([]core.Taint, error) { diff --git a/pkg/apis/core/v1/helper/helpers.go b/pkg/apis/core/v1/helper/helpers.go index 4b21aefcfc..b90a6de1f9 100644 --- a/pkg/apis/core/v1/helper/helpers.go +++ b/pkg/apis/core/v1/helper/helpers.go @@ -89,15 +89,6 @@ func IsServiceIPSet(service *v1.Service) bool { return service.Spec.ClusterIP != v1.ClusterIPNone && service.Spec.ClusterIP != "" } -// this function aims to check if the service's cluster IP is requested or not -func IsServiceIPRequested(service *v1.Service) bool { - // ExternalName services are CNAME aliases to external ones. Ignore the IP. - if service.Spec.Type == v1.ServiceTypeExternalName { - return false - } - return service.Spec.ClusterIP == "" -} - // AddToNodeAddresses appends the NodeAddresses to the passed-by-pointer slice, // only if they do not already exist func AddToNodeAddresses(addresses *[]v1.NodeAddress, addAddresses ...v1.NodeAddress) { @@ -416,20 +407,6 @@ func GetPersistentVolumeClaimClass(claim *v1.PersistentVolumeClaim) string { return "" } -// PersistentVolumeClaimHasClass returns true if given claim has set StorageClassName field. -func PersistentVolumeClaimHasClass(claim *v1.PersistentVolumeClaim) bool { - // Use beta annotation first - if _, found := claim.Annotations[v1.BetaStorageClassAnnotation]; found { - return true - } - - if claim.Spec.StorageClassName != nil { - return true - } - - return false -} - // GetStorageNodeAffinityFromAnnotation gets the json serialized data from PersistentVolume.Annotations // and converts it to the NodeAffinity type in api. // TODO: update when storage node affinity graduates to beta