From 40becff2a1b754fa87a273dc0e519b3668b09858 Mon Sep 17 00:00:00 2001 From: Garrybest Date: Sun, 30 Oct 2022 21:31:46 +0800 Subject: [PATCH] add vendor files Signed-off-by: Garrybest --- go.mod | 2 +- .../node/topology/helpers.go | 57 +++++++++++++++++++ vendor/modules.txt | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 vendor/k8s.io/component-helpers/node/topology/helpers.go diff --git a/go.mod b/go.mod index b44cce38c..af2f32d93 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/gogo/protobuf v1.3.2 github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.5.6 - github.com/google/uuid v1.1.2 github.com/kr/pretty v0.3.0 github.com/olekukonko/tablewriter v0.0.4 github.com/onsi/ginkgo/v2 v2.1.3 @@ -87,6 +86,7 @@ require ( github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect + github.com/google/uuid v1.1.2 // indirect github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect diff --git a/vendor/k8s.io/component-helpers/node/topology/helpers.go b/vendor/k8s.io/component-helpers/node/topology/helpers.go new file mode 100644 index 000000000..18c838cca --- /dev/null +++ b/vendor/k8s.io/component-helpers/node/topology/helpers.go @@ -0,0 +1,57 @@ +/* +Copyright 2020 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 topology + +import ( + "k8s.io/api/core/v1" +) + +// GetZoneKey is a helper function that builds a string identifier that is unique per failure-zone; +// it returns empty-string for no zone. +// Since there are currently two separate zone keys: +// * "failure-domain.beta.kubernetes.io/zone" +// * "topology.kubernetes.io/zone" +// GetZoneKey will first check failure-domain.beta.kubernetes.io/zone and if not exists, will then check +// topology.kubernetes.io/zone +func GetZoneKey(node *v1.Node) string { + labels := node.Labels + if labels == nil { + return "" + } + + // TODO: "failure-domain.beta..." names are deprecated, but will + // stick around a long time due to existing on old extant objects like PVs. + // Maybe one day we can stop considering them (see #88493). + zone, ok := labels[v1.LabelFailureDomainBetaZone] + if !ok { + zone, _ = labels[v1.LabelTopologyZone] + } + + region, ok := labels[v1.LabelFailureDomainBetaRegion] + if !ok { + region, _ = labels[v1.LabelTopologyRegion] + } + + if region == "" && zone == "" { + return "" + } + + // We include the null character just in case region or failureDomain has a colon + // (We do assume there's no null characters in a region or failureDomain) + // As a nice side-benefit, the null character is not printed by fmt.Print or glog + return region + ":\x00:" + zone +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 0d481f6ea..4de5ddc43 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1383,6 +1383,7 @@ k8s.io/component-base/version # k8s.io/component-helpers v0.24.2 ## explicit; go 1.16 k8s.io/component-helpers/apimachinery/lease +k8s.io/component-helpers/node/topology k8s.io/component-helpers/scheduling/corev1 k8s.io/component-helpers/scheduling/corev1/nodeaffinity # k8s.io/gengo v0.0.0-20211129171323-c02415ce4185