Bump sigs.k8s.io/controller-runtime to v0.14.4 (#5507)
* Bump sigs.k8s.io/controller-runtime to v0.14.4 * Update gofmt
This commit is contained in:
14
vendor/sigs.k8s.io/controller-runtime/pkg/envtest/crd.go
generated
vendored
14
vendor/sigs.k8s.io/controller-runtime/pkg/envtest/crd.go
generated
vendored
@@ -84,8 +84,10 @@ type CRDInstallOptions struct {
|
||||
WebhookOptions WebhookInstallOptions
|
||||
}
|
||||
|
||||
const defaultPollInterval = 100 * time.Millisecond
|
||||
const defaultMaxWait = 10 * time.Second
|
||||
const (
|
||||
defaultPollInterval = 100 * time.Millisecond
|
||||
defaultMaxWait = 10 * time.Second
|
||||
)
|
||||
|
||||
// InstallCRDs installs a collection of CRDs into a cluster by reading the crd yaml files from a directory.
|
||||
func InstallCRDs(config *rest.Config, options CRDInstallOptions) ([]*apiextensionsv1.CustomResourceDefinition, error) {
|
||||
@@ -142,7 +144,7 @@ func defaultCRDOptions(o *CRDInstallOptions) {
|
||||
// WaitForCRDs waits for the CRDs to appear in discovery.
|
||||
func WaitForCRDs(config *rest.Config, crds []*apiextensionsv1.CustomResourceDefinition, options CRDInstallOptions) error {
|
||||
// Add each CRD to a map of GroupVersion to Resource
|
||||
waitingFor := map[schema.GroupVersion]*sets.String{}
|
||||
waitingFor := map[schema.GroupVersion]*sets.Set[string]{}
|
||||
for _, crd := range crds {
|
||||
gvs := []schema.GroupVersion{}
|
||||
for _, version := range crd.Spec.Versions {
|
||||
@@ -155,7 +157,7 @@ func WaitForCRDs(config *rest.Config, crds []*apiextensionsv1.CustomResourceDefi
|
||||
log.V(1).Info("adding API in waitlist", "GV", gv)
|
||||
if _, found := waitingFor[gv]; !found {
|
||||
// Initialize the set
|
||||
waitingFor[gv] = &sets.String{}
|
||||
waitingFor[gv] = &sets.Set[string]{}
|
||||
}
|
||||
// Add the Resource
|
||||
waitingFor[gv].Insert(crd.Spec.Names.Plural)
|
||||
@@ -173,7 +175,7 @@ type poller struct {
|
||||
config *rest.Config
|
||||
|
||||
// waitingFor is the map of resources keyed by group version that have not yet been found in discovery
|
||||
waitingFor map[schema.GroupVersion]*sets.String
|
||||
waitingFor map[schema.GroupVersion]*sets.Set[string]
|
||||
}
|
||||
|
||||
// poll checks if all the resources have been found in discovery, and returns false if not.
|
||||
@@ -362,7 +364,7 @@ func modifyConversionWebhooks(crds []*apiextensionsv1.CustomResourceDefinition,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
url := pointer.StringPtr(fmt.Sprintf("https://%s/convert", hostPort))
|
||||
url := pointer.String(fmt.Sprintf("https://%s/convert", hostPort))
|
||||
|
||||
for i := range crds {
|
||||
// Continue if we're preserving unknown fields.
|
||||
|
||||
53
vendor/sigs.k8s.io/controller-runtime/pkg/envtest/printer/ginkgo.go
generated
vendored
53
vendor/sigs.k8s.io/controller-runtime/pkg/envtest/printer/ginkgo.go
generated
vendored
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// Package printer contains setup for a friendlier Ginkgo printer that's easier
|
||||
// to parse by test automation.
|
||||
package printer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
)
|
||||
|
||||
var _ ginkgo.Reporter = NewlineReporter{}
|
||||
|
||||
// NewlineReporter is Reporter that Prints a newline after the default Reporter output so that the results
|
||||
// are correctly parsed by test automation.
|
||||
// See issue https://github.com/jstemmer/go-junit-report/issues/31
|
||||
type NewlineReporter struct{}
|
||||
|
||||
// SpecSuiteWillBegin implements ginkgo.Reporter.
|
||||
func (NewlineReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
|
||||
}
|
||||
|
||||
// BeforeSuiteDidRun implements ginkgo.Reporter.
|
||||
func (NewlineReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) {}
|
||||
|
||||
// AfterSuiteDidRun implements ginkgo.Reporter.
|
||||
func (NewlineReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) {}
|
||||
|
||||
// SpecWillRun implements ginkgo.Reporter.
|
||||
func (NewlineReporter) SpecWillRun(specSummary *types.SpecSummary) {}
|
||||
|
||||
// SpecDidComplete implements ginkgo.Reporter.
|
||||
func (NewlineReporter) SpecDidComplete(specSummary *types.SpecSummary) {}
|
||||
|
||||
// SpecSuiteDidEnd Prints a newline between "35 Passed | 0 Failed | 0 Pending | 0 Skipped" and "--- PASS:".
|
||||
func (NewlineReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) { fmt.Printf("\n") }
|
||||
109
vendor/sigs.k8s.io/controller-runtime/pkg/envtest/printer/prow.go
generated
vendored
109
vendor/sigs.k8s.io/controller-runtime/pkg/envtest/printer/prow.go
generated
vendored
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
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 printer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/ginkgo/config"
|
||||
"github.com/onsi/ginkgo/reporters"
|
||||
"github.com/onsi/ginkgo/types"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
)
|
||||
|
||||
var (
|
||||
allRegisteredSuites = sets.String{}
|
||||
allRegisteredSuitesLock = &sync.Mutex{}
|
||||
)
|
||||
|
||||
type prowReporter struct {
|
||||
junitReporter *reporters.JUnitReporter
|
||||
}
|
||||
|
||||
// NewProwReporter returns a prowReporter that will write out junit if running in Prow and do
|
||||
// nothing otherwise.
|
||||
// WARNING: It seems this does not always properly fail the test runs when there are failures,
|
||||
// see https://github.com/onsi/ginkgo/issues/706
|
||||
// When using this you must make sure to grep for failures in your junit xmls and fail the run
|
||||
// if there are any.
|
||||
func NewProwReporter(suiteName string) ginkgo.Reporter {
|
||||
allRegisteredSuitesLock.Lock()
|
||||
if allRegisteredSuites.Has(suiteName) {
|
||||
panic(fmt.Sprintf("Suite named %q registered more than once", suiteName))
|
||||
}
|
||||
allRegisteredSuites.Insert(suiteName)
|
||||
allRegisteredSuitesLock.Unlock()
|
||||
|
||||
if os.Getenv("CI") == "" {
|
||||
return &prowReporter{}
|
||||
}
|
||||
artifactsDir := os.Getenv("ARTIFACTS")
|
||||
if artifactsDir == "" {
|
||||
return &prowReporter{}
|
||||
}
|
||||
|
||||
path := filepath.Join(artifactsDir, fmt.Sprintf("junit_%s_%d.xml", suiteName, config.GinkgoConfig.ParallelNode))
|
||||
return &prowReporter{
|
||||
junitReporter: reporters.NewJUnitReporter(path),
|
||||
}
|
||||
}
|
||||
|
||||
func (pr *prowReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
|
||||
if pr.junitReporter != nil {
|
||||
pr.junitReporter.SpecSuiteWillBegin(config, summary)
|
||||
}
|
||||
}
|
||||
|
||||
// BeforeSuiteDidRun implements ginkgo.Reporter.
|
||||
func (pr *prowReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) {
|
||||
if pr.junitReporter != nil {
|
||||
pr.junitReporter.BeforeSuiteDidRun(setupSummary)
|
||||
}
|
||||
}
|
||||
|
||||
// AfterSuiteDidRun implements ginkgo.Reporter.
|
||||
func (pr *prowReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) {
|
||||
if pr.junitReporter != nil {
|
||||
pr.junitReporter.AfterSuiteDidRun(setupSummary)
|
||||
}
|
||||
}
|
||||
|
||||
// SpecWillRun implements ginkgo.Reporter.
|
||||
func (pr *prowReporter) SpecWillRun(specSummary *types.SpecSummary) {
|
||||
if pr.junitReporter != nil {
|
||||
pr.junitReporter.SpecWillRun(specSummary)
|
||||
}
|
||||
}
|
||||
|
||||
// SpecDidComplete implements ginkgo.Reporter.
|
||||
func (pr *prowReporter) SpecDidComplete(specSummary *types.SpecSummary) {
|
||||
if pr.junitReporter != nil {
|
||||
pr.junitReporter.SpecDidComplete(specSummary)
|
||||
}
|
||||
}
|
||||
|
||||
// SpecSuiteDidEnd Prints a newline between "35 Passed | 0 Failed | 0 Pending | 0 Skipped" and "--- PASS:".
|
||||
func (pr *prowReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) {
|
||||
if pr.junitReporter != nil {
|
||||
pr.junitReporter.SpecSuiteDidEnd(summary)
|
||||
}
|
||||
}
|
||||
17
vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go
generated
vendored
17
vendor/sigs.k8s.io/controller-runtime/pkg/envtest/server.go
generated
vendored
@@ -37,15 +37,14 @@ var log = logf.RuntimeLog.WithName("test-env")
|
||||
|
||||
/*
|
||||
It's possible to override some defaults, by setting the following environment variables:
|
||||
USE_EXISTING_CLUSTER (boolean): if set to true, envtest will use an existing cluster
|
||||
TEST_ASSET_KUBE_APISERVER (string): path to the api-server binary to use
|
||||
TEST_ASSET_ETCD (string): path to the etcd binary to use
|
||||
TEST_ASSET_KUBECTL (string): path to the kubectl binary to use
|
||||
KUBEBUILDER_ASSETS (string): directory containing the binaries to use (api-server, etcd and kubectl). Defaults to /usr/local/kubebuilder/bin.
|
||||
KUBEBUILDER_CONTROLPLANE_START_TIMEOUT (string supported by time.ParseDuration): timeout for test control plane to start. Defaults to 20s.
|
||||
KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT (string supported by time.ParseDuration): timeout for test control plane to start. Defaults to 20s.
|
||||
KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT (boolean): if set to true, the control plane's stdout and stderr are attached to os.Stdout and os.Stderr
|
||||
|
||||
* USE_EXISTING_CLUSTER (boolean): if set to true, envtest will use an existing cluster
|
||||
* TEST_ASSET_KUBE_APISERVER (string): path to the api-server binary to use
|
||||
* TEST_ASSET_ETCD (string): path to the etcd binary to use
|
||||
* TEST_ASSET_KUBECTL (string): path to the kubectl binary to use
|
||||
* KUBEBUILDER_ASSETS (string): directory containing the binaries to use (api-server, etcd and kubectl). Defaults to /usr/local/kubebuilder/bin.
|
||||
* KUBEBUILDER_CONTROLPLANE_START_TIMEOUT (string supported by time.ParseDuration): timeout for test control plane to start. Defaults to 20s.
|
||||
* KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT (string supported by time.ParseDuration): timeout for test control plane to start. Defaults to 20s.
|
||||
* KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT (boolean): if set to true, the control plane's stdout and stderr are attached to os.Stdout and os.Stderr
|
||||
*/
|
||||
const (
|
||||
envUseExistingCluster = "USE_EXISTING_CLUSTER"
|
||||
|
||||
10
vendor/sigs.k8s.io/controller-runtime/pkg/envtest/webhook.go
generated
vendored
10
vendor/sigs.k8s.io/controller-runtime/pkg/envtest/webhook.go
generated
vendored
@@ -173,7 +173,7 @@ func WaitForWebhooks(config *rest.Config,
|
||||
mutatingWebhooks []*admissionv1.MutatingWebhookConfiguration,
|
||||
validatingWebhooks []*admissionv1.ValidatingWebhookConfiguration,
|
||||
options WebhookInstallOptions) error {
|
||||
waitingFor := map[schema.GroupVersionKind]*sets.String{}
|
||||
waitingFor := map[schema.GroupVersionKind]*sets.Set[string]{}
|
||||
|
||||
for _, hook := range mutatingWebhooks {
|
||||
h := hook
|
||||
@@ -183,7 +183,7 @@ func WaitForWebhooks(config *rest.Config,
|
||||
}
|
||||
|
||||
if _, ok := waitingFor[gvk]; !ok {
|
||||
waitingFor[gvk] = &sets.String{}
|
||||
waitingFor[gvk] = &sets.Set[string]{}
|
||||
}
|
||||
waitingFor[gvk].Insert(h.GetName())
|
||||
}
|
||||
@@ -196,7 +196,7 @@ func WaitForWebhooks(config *rest.Config,
|
||||
}
|
||||
|
||||
if _, ok := waitingFor[gvk]; !ok {
|
||||
waitingFor[gvk] = &sets.String{}
|
||||
waitingFor[gvk] = &sets.Set[string]{}
|
||||
}
|
||||
waitingFor[gvk].Insert(hook.GetName())
|
||||
}
|
||||
@@ -212,7 +212,7 @@ type webhookPoller struct {
|
||||
config *rest.Config
|
||||
|
||||
// waitingFor is the map of resources keyed by group version that have not yet been found in discovery
|
||||
waitingFor map[schema.GroupVersionKind]*sets.String
|
||||
waitingFor map[schema.GroupVersionKind]*sets.Set[string]
|
||||
}
|
||||
|
||||
// poll checks if all the resources have been found in discovery, and returns false if not.
|
||||
@@ -229,7 +229,7 @@ func (p *webhookPoller) poll() (done bool, err error) {
|
||||
delete(p.waitingFor, gvk)
|
||||
continue
|
||||
}
|
||||
for _, name := range names.List() {
|
||||
for _, name := range names.UnsortedList() {
|
||||
var obj = &unstructured.Unstructured{}
|
||||
obj.SetGroupVersionKind(gvk)
|
||||
err := c.Get(context.Background(), client.ObjectKey{
|
||||
|
||||
Reference in New Issue
Block a user