From 9e40d959e29a9f0d5001c3fcebf6734a0ea50bb0 Mon Sep 17 00:00:00 2001 From: changzhen Date: Thu, 17 Mar 2022 16:42:10 +0800 Subject: [PATCH] add file to record lifted flie list Signed-off-by: changzhen --- .../{resourcehelpers.go => corehelpers.go} | 46 +----------- ...validatepodname.go => corehelpers_test.go} | 31 ++++++-- pkg/util/lifted/corev1helpers.go | 71 +++++++++++++++++++ ...ehelpers_test.go => corev1helpers_test.go} | 22 +----- ...dateresourcequota.go => corevalidation.go} | 40 ++++++----- ...cequota_test.go => corevalidation_test.go} | 0 pkg/util/lifted/deployment.go | 4 +- pkg/util/lifted/discovery.go | 28 ++++++-- pkg/util/lifted/doc.go | 63 ++++++++++++++++ pkg/util/lifted/nodeselector.go | 4 +- pkg/util/lifted/objectwatcher.go | 4 +- pkg/util/lifted/podtemplate.go | 4 +- pkg/util/lifted/resourcename.go | 2 +- pkg/util/lifted/taint.go | 2 +- pkg/util/lifted/taint_test.go | 2 +- pkg/util/lifted/validateclustertaints.go | 10 ++- pkg/util/lifted/visitpod.go | 2 +- 17 files changed, 228 insertions(+), 107 deletions(-) rename pkg/util/lifted/{resourcehelpers.go => corehelpers.go} (66%) rename pkg/util/lifted/{validatepodname.go => corehelpers_test.go} (52%) create mode 100644 pkg/util/lifted/corev1helpers.go rename pkg/util/lifted/{resourcehelpers_test.go => corev1helpers_test.go} (76%) rename pkg/util/lifted/{validateresourcequota.go => corevalidation.go} (91%) rename pkg/util/lifted/{validateresourcequota_test.go => corevalidation_test.go} (100%) create mode 100644 pkg/util/lifted/doc.go diff --git a/pkg/util/lifted/resourcehelpers.go b/pkg/util/lifted/corehelpers.go similarity index 66% rename from pkg/util/lifted/resourcehelpers.go rename to pkg/util/lifted/corehelpers.go index 892bef266..fb20f43ca 100644 --- a/pkg/util/lifted/resourcehelpers.go +++ b/pkg/util/lifted/corehelpers.go @@ -16,61 +16,17 @@ limitations under the License. // This code is directly lifted from the Kubernetes codebase in order to avoid relying on the k8s.io/kubernetes package. // For reference: -// https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/v1/helper/helpers.go +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go package lifted import ( - "fmt" "strings" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/apimachinery/pkg/util/validation" ) -// IsExtendedResourceName returns true if: -// 1. the resource name is not in the default namespace; -// 2. resource name does not have "requests." prefix, -// to avoid confusion with the convention in quota -// 3. it satisfies the rules in IsQualifiedName() after converted into quota resource name -func IsExtendedResourceName(name corev1.ResourceName) bool { - if IsNativeResource(name) || strings.HasPrefix(string(name), corev1.DefaultResourceRequestsPrefix) { - return false - } - // Ensure it satisfies the rules in IsQualifiedName() after converted into quota resource name - nameForQuota := fmt.Sprintf("%s%s", corev1.DefaultResourceRequestsPrefix, string(name)) - if errs := validation.IsQualifiedName(string(nameForQuota)); len(errs) != 0 { - return false - } - return true -} - -// IsPrefixedNativeResource returns true if the resource name is in the -// *kubernetes.io/ namespace. -func IsPrefixedNativeResource(name corev1.ResourceName) bool { - return strings.Contains(string(name), corev1.ResourceDefaultNamespacePrefix) -} - -// IsNativeResource returns true if the resource name is in the -// *kubernetes.io/ namespace. Partially-qualified (unprefixed) names are -// implicitly in the kubernetes.io/ namespace. -func IsNativeResource(name corev1.ResourceName) bool { - return !strings.Contains(string(name), "/") || - IsPrefixedNativeResource(name) -} - -// IsHugePageResourceName returns true if the resource name has the huge page -// resource prefix. -func IsHugePageResourceName(name corev1.ResourceName) bool { - return strings.HasPrefix(string(name), corev1.ResourceHugePagesPrefix) -} - -// IsAttachableVolumeResourceName returns true when the resource name is prefixed in attachable volume -func IsAttachableVolumeResourceName(name corev1.ResourceName) bool { - return strings.HasPrefix(string(name), corev1.ResourceAttachableVolumesPrefix) -} - // IsQuotaHugePageResourceName returns true if the resource name has the quota // related huge page resource prefix. func IsQuotaHugePageResourceName(name corev1.ResourceName) bool { diff --git a/pkg/util/lifted/validatepodname.go b/pkg/util/lifted/corehelpers_test.go similarity index 52% rename from pkg/util/lifted/validatepodname.go rename to pkg/util/lifted/corehelpers_test.go index 94a92dae4..635c33138 100644 --- a/pkg/util/lifted/validatepodname.go +++ b/pkg/util/lifted/corehelpers_test.go @@ -1,5 +1,5 @@ /* -Copyright 2014 The Kubernetes Authors. +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. @@ -16,13 +16,30 @@ limitations under the License. // This code is directly lifted from the Kubernetes codebase in order to avoid relying on the k8s.io/kubernetes package. // For reference: -// https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L225-L228 +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers_test.go package lifted -import apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation" +import ( + "testing" +) -// ValidatePodName can be used to check whether the given pod name is valid. -// Prefix indicates this name will be used as part of generation, in which case -// trailing dashes are allowed. -var ValidatePodName = apimachineryvalidation.NameIsDNSSubdomain +func TestIsStandardResource(t *testing.T) { + testCases := []struct { + input string + output bool + }{ + {"cpu", true}, + {"memory", true}, + {"disk", false}, + {"blah", false}, + {"x.y.z", false}, + {"hugepages-2Mi", true}, + {"requests.hugepages-2Mi", true}, + } + for i, tc := range testCases { + if IsStandardResourceName(tc.input) != tc.output { + t.Errorf("case[%d], input: %s, expected: %t, got: %t", i, tc.input, tc.output, !tc.output) + } + } +} diff --git a/pkg/util/lifted/corev1helpers.go b/pkg/util/lifted/corev1helpers.go new file mode 100644 index 000000000..fd3e50b93 --- /dev/null +++ b/pkg/util/lifted/corev1helpers.go @@ -0,0 +1,71 @@ +/* +Copyright 2014 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. +*/ + +// This code is directly lifted from the Kubernetes codebase in order to avoid relying on the k8s.io/kubernetes package. +// For reference: +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/v1/helper/helpers.go + +package lifted + +import ( + "fmt" + "strings" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/util/validation" +) + +// IsExtendedResourceName returns true if: +// 1. the resource name is not in the default namespace; +// 2. resource name does not have "requests." prefix, +// to avoid confusion with the convention in quota +// 3. it satisfies the rules in IsQualifiedName() after converted into quota resource name +func IsExtendedResourceName(name corev1.ResourceName) bool { + if IsNativeResource(name) || strings.HasPrefix(string(name), corev1.DefaultResourceRequestsPrefix) { + return false + } + // Ensure it satisfies the rules in IsQualifiedName() after converted into quota resource name + nameForQuota := fmt.Sprintf("%s%s", corev1.DefaultResourceRequestsPrefix, string(name)) + if errs := validation.IsQualifiedName(string(nameForQuota)); len(errs) != 0 { + return false + } + return true +} + +// IsPrefixedNativeResource returns true if the resource name is in the +// *kubernetes.io/ namespace. +func IsPrefixedNativeResource(name corev1.ResourceName) bool { + return strings.Contains(string(name), corev1.ResourceDefaultNamespacePrefix) +} + +// IsNativeResource returns true if the resource name is in the +// *kubernetes.io/ namespace. Partially-qualified (unprefixed) names are +// implicitly in the kubernetes.io/ namespace. +func IsNativeResource(name corev1.ResourceName) bool { + return !strings.Contains(string(name), "/") || + IsPrefixedNativeResource(name) +} + +// IsHugePageResourceName returns true if the resource name has the huge page +// resource prefix. +func IsHugePageResourceName(name corev1.ResourceName) bool { + return strings.HasPrefix(string(name), corev1.ResourceHugePagesPrefix) +} + +// IsAttachableVolumeResourceName returns true when the resource name is prefixed in attachable volume +func IsAttachableVolumeResourceName(name corev1.ResourceName) bool { + return strings.HasPrefix(string(name), corev1.ResourceAttachableVolumesPrefix) +} diff --git a/pkg/util/lifted/resourcehelpers_test.go b/pkg/util/lifted/corev1helpers_test.go similarity index 76% rename from pkg/util/lifted/resourcehelpers_test.go rename to pkg/util/lifted/corev1helpers_test.go index 157212eda..a0d2f15e6 100644 --- a/pkg/util/lifted/resourcehelpers_test.go +++ b/pkg/util/lifted/corev1helpers_test.go @@ -16,7 +16,7 @@ limitations under the License. // This code is directly lifted from the Kubernetes codebase in order to avoid relying on the k8s.io/kubernetes package. // For reference: -// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers_test.go +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/v1/helper/helpers_test.go package lifted @@ -64,23 +64,3 @@ func TestIsNativeResource(t *testing.T) { }) } } - -func TestIsStandardResource(t *testing.T) { - testCases := []struct { - input string - output bool - }{ - {"cpu", true}, - {"memory", true}, - {"disk", false}, - {"blah", false}, - {"x.y.z", false}, - {"hugepages-2Mi", true}, - {"requests.hugepages-2Mi", true}, - } - for i, tc := range testCases { - if IsStandardResourceName(tc.input) != tc.output { - t.Errorf("case[%d], input: %s, expected: %t, got: %t", i, tc.input, tc.output, !tc.output) - } - } -} diff --git a/pkg/util/lifted/validateresourcequota.go b/pkg/util/lifted/corevalidation.go similarity index 91% rename from pkg/util/lifted/validateresourcequota.go rename to pkg/util/lifted/corevalidation.go index d4df37e7a..1431981d8 100644 --- a/pkg/util/lifted/validateresourcequota.go +++ b/pkg/util/lifted/corevalidation.go @@ -18,6 +18,7 @@ limitations under the License. // For reference: // https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L59-L60 // https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L62 +// https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L225-L228 // https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L311-L318 // https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L5036-L5054 // https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L5073-L5084 @@ -38,15 +39,16 @@ const isNegativeErrorMsg string = apimachineryvalidation.IsNegativeErrorMsg const isInvalidQuotaResource string = `must be a standard resource for quota` const isNotIntegerErrorMsg string = `must be an integer` -// ValidateResourceQuotaResourceName Validate resource names that can go in a resource quota -// Refer to docs/design/resources.md for more details. -func ValidateResourceQuotaResourceName(value string, fldPath *field.Path) field.ErrorList { - allErrs := validateResourceName(value, fldPath) +// ValidatePodName can be used to check whether the given pod name is valid. +// Prefix indicates this name will be used as part of generation, in which case +// trailing dashes are allowed. +var ValidatePodName = apimachineryvalidation.NameIsDNSSubdomain - if len(strings.Split(value, "/")) == 1 { - if !IsStandardQuotaResourceName(value) { - return append(allErrs, field.Invalid(fldPath, value, isInvalidQuotaResource)) - } +// ValidateNonnegativeQuantity Validates that a Quantity is not negative +func ValidateNonnegativeQuantity(value resource.Quantity, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + if value.Cmp(resource.Quantity{}) < 0 { + allErrs = append(allErrs, field.Invalid(fldPath, value.String(), isNegativeErrorMsg)) } return allErrs } @@ -71,6 +73,19 @@ func validateResourceName(value string, fldPath *field.Path) field.ErrorList { return allErrs } +// ValidateResourceQuotaResourceName Validate resource names that can go in a resource quota +// Refer to docs/design/resources.md for more details. +func ValidateResourceQuotaResourceName(value string, fldPath *field.Path) field.ErrorList { + allErrs := validateResourceName(value, fldPath) + + if len(strings.Split(value, "/")) == 1 { + if !IsStandardQuotaResourceName(value) { + return append(allErrs, field.Invalid(fldPath, value, isInvalidQuotaResource)) + } + } + return allErrs +} + // ValidateResourceQuantityValue enforces that specified quantity is valid for specified resource func ValidateResourceQuantityValue(resource string, value resource.Quantity, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} @@ -82,12 +97,3 @@ func ValidateResourceQuantityValue(resource string, value resource.Quantity, fld } return allErrs } - -// ValidateNonnegativeQuantity Validates that a Quantity is not negative -func ValidateNonnegativeQuantity(value resource.Quantity, fldPath *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - if value.Cmp(resource.Quantity{}) < 0 { - allErrs = append(allErrs, field.Invalid(fldPath, value.String(), isNegativeErrorMsg)) - } - return allErrs -} diff --git a/pkg/util/lifted/validateresourcequota_test.go b/pkg/util/lifted/corevalidation_test.go similarity index 100% rename from pkg/util/lifted/validateresourcequota_test.go rename to pkg/util/lifted/corevalidation_test.go diff --git a/pkg/util/lifted/deployment.go b/pkg/util/lifted/deployment.go index 0c9af46ea..73d3950c1 100644 --- a/pkg/util/lifted/deployment.go +++ b/pkg/util/lifted/deployment.go @@ -16,7 +16,9 @@ limitations under the License. // This code is lifted from the Kubernetes codebase in order to avoid relying on the k8s.io/kubernetes package. // However the code has been revised for using Lister instead of API interface. -// For reference: https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/deployment/util/deployment_util.go +// For reference: +// https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/controller_utils.go#L1003-L1012 +// https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/deployment/util/deployment_util.go package lifted diff --git a/pkg/util/lifted/discovery.go b/pkg/util/lifted/discovery.go index 9484f6006..2ec355e59 100644 --- a/pkg/util/lifted/discovery.go +++ b/pkg/util/lifted/discovery.go @@ -1,3 +1,23 @@ +/* +Copyright 2016 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. +*/ + +// This code is lifted from the Kubernetes codebase in order to avoid relying on the k8s.io/kubernetes package. +// For reference: +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/garbagecollector/garbagecollector.go#L696-L732 + package lifted import ( @@ -6,15 +26,13 @@ import ( "k8s.io/klog/v2" ) -// GetDeletableResources returns all resources from discoveryClient. -// More specifically, all preferred resources which support the 'delete', 'list', and 'watch' verbs. +// GetDeletableResources returns all resources from discoveryClient that the +// garbage collector should recognize and work with. More specifically, all +// preferred resources which support the 'delete', 'list', and 'watch' verbs. // // All discovery errors are considered temporary. Upon encountering any error, // GetDeletableResources will log and return any discovered resources it was // able to process (which may be none). -// -// This code is directly lifted from the Kubernetes codebase. -// For reference: https://github.com/kubernetes/kubernetes/blob/1e11e4a2108024935ecfcb2912226cedeafd99df/pkg/controller/garbagecollector/garbagecollector.go#L638-L667 func GetDeletableResources(discoveryClient discovery.ServerResourcesInterface) map[schema.GroupVersionResource]struct{} { preferredResources, err := discoveryClient.ServerPreferredResources() if err != nil { diff --git a/pkg/util/lifted/doc.go b/pkg/util/lifted/doc.go new file mode 100644 index 000000000..5a3d767fb --- /dev/null +++ b/pkg/util/lifted/doc.go @@ -0,0 +1,63 @@ +// Package lifted contains the files lifted from other projects. +package lifted + +/* +| lifted file | source file | const/var/type/func | changed | +--------------------------- -------------------------------------------------------------------------------------------------------------------------- ----------------------------------------- ---------- +| corehelpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go#L57-L61 | func IsQuotaHugePageResourceName | N | +| corehelpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go#L212-L232 | var standardQuotaResources | N | +| corehelpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go#L234-L238 | func IsStandardQuotaResourceName | N | +| corehelpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go#L240-L261 | var standardResources | N | +| corehelpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go#L263-L266 | func IsStandardResourceName | N | +| corehelpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go#L268-L278 | var integerResources | N | +| corehelpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go#L280-L283 | func IsIntegerResourceName | N | +| corev1helpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/v1/helper/helpers.go#L31-L46 | func IsExtendedResourceName | N | +| corev1helpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/v1/helper/helpers.go#L48-L51 | func IsPrefixedNativeResource | N | +| corev1helpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/v1/helper/helpers.go#L54-L60 | func IsNativeResource | N | +| corev1helpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/v1/helper/helpers.go#L62-L66 | func IsHugePageResourceName | N | +| corev1helpers.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/v1/helper/helpers.go#L132-L135 | func IsAttachableVolumeResourceName | N | +| corevalidation.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L59 | const isNegativeErrorMsg | N | +| corevalidation.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L60 | const isInvalidQuotaResource | N | +| corevalidation.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L62 | const isNotIntegerErrorMsg | N | +| corevalidation.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L225-L228 | var ValidatePodName | N | +| corevalidation.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L311-L318 | var ValidateNonnegativeQuantity | N | +| corevalidation.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L5036-L5054 | func validateResourceName | Y | +| corevalidation.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L5073-L5084 | func ValidateResourceQuotaResourceName | Y | +| corevalidation.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/apis/core/validation/validation.go#L5651-L5661 | func ValidateResourceQuantityValue | Y | +| deployment.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/controller_utils.go#L1003-L1012 | type ReplicaSetsByCreationTimestamp | N | +| deployment.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/deployment/util/deployment_util.go#L569-L594 | func ListReplicaSetsByDeployment | Y | +| deployment.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/deployment/util/deployment_util.go#L596-L628 | func ListPodsByRS | Y | +| deployment.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/deployment/util/deployment_util.go#L630-L642 | func EqualIgnoreHash | N | +| deployment.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/deployment/util/deployment_util.go#L536-L544 | func GetNewReplicaSet | Y | +| deployment.go | https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/deployment/util/deployment_util.go#L644-L658 | func FindNewReplicaSet | N | +| discovery.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/garbagecollector/garbagecollector.go#L696-L732 | func GetDeletableResources | N | +| nodeselector.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go#L365-L397 | func NodeSelectorRequirementsAsSelector | N | +| objectwatcher.go | https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/util/propagatedversion.go#L35-L43 | func ObjectVersion | N | +| objectwatcher.go | https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/util/propagatedversion.go#L45-L59 | func ObjectNeedsUpdate | N | +| objectwatcher.go | https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/util/meta.go#L63-L80 | func objectMetaObjEquivalent | Y | +| podtemplate.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/controller_utils.go#L466-L472 | func getPodsLabelSet | N | +| podtemplate.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/controller_utils.go#L474-L478 | func getPodsFinalizers | N | +| podtemplate.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/controller_utils.go#L480-L486 | func getPodsAnnotationSet | N | +| podtemplate.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/controller_utils.go#L488-L495 | func getPodsPrefix | N | +| podtemplate.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/controller_utils.go#L539-L562 | func GetPodFromTemplate | Y | +| resourcename.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/scheduler/util/utils.go#L144-L148 | func IsScalarResourceName | Y | +| retain.go | https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/sync/dispatch/retain.go | func RetainServiceFields | Y | +| retain.go | https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/sync/dispatch/retain.go | func retainServiceHealthCheckNodePort | Y | +| retain.go | https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/sync/dispatch/retain.go | func retainServiceClusterIP | Y | +| retain.go | https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/sync/dispatch/retain.go | func RetainServiceAccountFields | Y | +| taint.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/cmd/taint/utils.go#L37-L73 | func ParseTaints | N | +| taint.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/cmd/taint/utils.go#L75-L118 | func parseTaint | N | +| taint.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/cmd/taint/utils.go#L120-L126 | func validateTaintEffect | N | +| validateclustertaints.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/validation/validation.go#L5001-L5033 | func ValidateClusterTaints | Y | +| validateclustertaints.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/validation/validation.go#L3305-L3326 | func validateClusterTaintEffect | Y | +| visitpod.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go#L53-L63 | type ContainerType | N | +| visitpod.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go#L65-L66 | const AllContainers | N | +| visitpod.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go#L78-L80 | type ContainerVisitor | N | +| visitpod.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go#L82-L83 | type Visitor | N | +| visitpod.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go#L85-L94 | func skipEmptyNames | N | +| visitpod.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go#L96-L123 | func VisitContainers | N | +| visitpod.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go#L125-L195 | func VisitPodSecretNames | N | +| visitpod.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go#L197-L213 | func visitContainerSecretNames | N | +| visitpod.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go#L215-L243 | func VisitPodConfigmapNames | N | +| visitpod.go | https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go#L245-L261 | func visitContainerConfigmapNames | N | +*/ diff --git a/pkg/util/lifted/nodeselector.go b/pkg/util/lifted/nodeselector.go index 10e61f682..81f04904e 100644 --- a/pkg/util/lifted/nodeselector.go +++ b/pkg/util/lifted/nodeselector.go @@ -16,7 +16,7 @@ limitations under the License. // This code is directly lifted from the Kubernetes codebase in order to avoid relying on the k8s.io/kubernetes package. // For reference: -// https://github.com/kubernetes/kubernetes/blob/release-1.20/staging/src/k8s.io/component-helpers/scheduling/corev1/nodeaffinity/nodeaffinity.go#L193-L225 +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/helper/helpers.go#L365-L397 package lifted @@ -28,7 +28,7 @@ import ( "k8s.io/apimachinery/pkg/selection" ) -// NodeSelectorRequirementsAsSelector converts the []NodeSelectorRequirement api type into a struct that implements +// NodeSelectorRequirementsAsSelector converts the []NodeSelectorRequirement core type into a struct that implements // labels.Selector. func NodeSelectorRequirementsAsSelector(nsm []corev1.NodeSelectorRequirement) (labels.Selector, error) { if len(nsm) == 0 { diff --git a/pkg/util/lifted/objectwatcher.go b/pkg/util/lifted/objectwatcher.go index dee3101fd..cadd8ce68 100644 --- a/pkg/util/lifted/objectwatcher.go +++ b/pkg/util/lifted/objectwatcher.go @@ -16,7 +16,9 @@ limitations under the License. // This code is lifted from the kubefed codebase. It's a list of functions to determine whether the provided cluster // object needs to be updated according to the desired object and the recorded version. -// For reference: https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/util/propagatedversion.go#L30-L59 +// For reference: +// https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/util/propagatedversion.go#L30-L59 +// https://github.com/kubernetes-sigs/kubefed/blob/master/pkg/controller/util/meta.go#L63-L80 package lifted diff --git a/pkg/util/lifted/podtemplate.go b/pkg/util/lifted/podtemplate.go index e4d888b15..3daf54dd4 100644 --- a/pkg/util/lifted/podtemplate.go +++ b/pkg/util/lifted/podtemplate.go @@ -16,8 +16,8 @@ limitations under the License. // This code is directly lifted from the Kubernetes codebase in order to avoid relying on the k8s.io/kubernetes package. // For reference: -// https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/controller_utils.go#L466-L495 -// https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/controller/controller_utils.go#L539-L562 +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/controller_utils.go#L466-L495 +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/controller/controller_utils.go#L539-L562 package lifted diff --git a/pkg/util/lifted/resourcename.go b/pkg/util/lifted/resourcename.go index 5b8e63dba..9224fb9cb 100644 --- a/pkg/util/lifted/resourcename.go +++ b/pkg/util/lifted/resourcename.go @@ -16,7 +16,7 @@ limitations under the License. // This code is directly lifted from the Kubernetes codebase in order to avoid relying on the k8s.io/kubernetes package. // For reference: -// https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/scheduler/util/utils.go#L144-L148 +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/scheduler/util/utils.go#L144-L148 package lifted diff --git a/pkg/util/lifted/taint.go b/pkg/util/lifted/taint.go index 1b6a2649c..c58bf48a6 100644 --- a/pkg/util/lifted/taint.go +++ b/pkg/util/lifted/taint.go @@ -16,7 +16,7 @@ limitations under the License. // This code is directly lifted from the Kubernetes codebase. // For reference: -// https://github.com/kubernetes/kubernetes/blob/ed42bbd722a14640f8b5315a521745e7526ff31b/staging/src/k8s.io/kubectl/pkg/cmd/taint/utils.go#L37-L126 +// https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/cmd/taint/utils.go#L37-L126 package lifted diff --git a/pkg/util/lifted/taint_test.go b/pkg/util/lifted/taint_test.go index 417bfb832..d94258d98 100644 --- a/pkg/util/lifted/taint_test.go +++ b/pkg/util/lifted/taint_test.go @@ -16,7 +16,7 @@ limitations under the License. // This code is directly lifted from the Kubernetes codebase. // For reference: -// https://github.com/kubernetes/kubernetes/blob/ed42bbd722a14640f8b5315a521745e7526ff31b/staging/src/k8s.io/kubectl/pkg/cmd/taint/utils_test.go#L372-L533 +// https://github.com/kubernetes/kubernetes/blob/release-1.23/staging/src/k8s.io/kubectl/pkg/cmd/taint/utils_test.go#L372-L533 package lifted diff --git a/pkg/util/lifted/validateclustertaints.go b/pkg/util/lifted/validateclustertaints.go index f2f21bdd5..e6cd3d3a8 100644 --- a/pkg/util/lifted/validateclustertaints.go +++ b/pkg/util/lifted/validateclustertaints.go @@ -1,9 +1,12 @@ /* Copyright 2014 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. @@ -11,6 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ +// This code is directly lifted from the Kubernetes codebase. +// For reference: +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/validation/validation.go#L5001-L5033 +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/apis/core/validation/validation.go#L3305-L3326 + package lifted import ( @@ -23,8 +31,6 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" ) -// This code logic is lifted from https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/validation/validation.go#L5003 - // ValidateClusterTaints tests if given taints have valid data. func ValidateClusterTaints(taints []corev1.Taint, fldPath *field.Path) field.ErrorList { allErrors := field.ErrorList{} diff --git a/pkg/util/lifted/visitpod.go b/pkg/util/lifted/visitpod.go index 7b539bab8..4a9e22ff2 100644 --- a/pkg/util/lifted/visitpod.go +++ b/pkg/util/lifted/visitpod.go @@ -16,7 +16,7 @@ limitations under the License. // This code is directly lifted from the Kubernetes codebase in order to avoid relying on the k8s.io/kubernetes package. // For reference: -// https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/api/v1/pod/util.go +// https://github.com/kubernetes/kubernetes/blob/release-1.23/pkg/api/v1/pod/util.go package lifted