-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🌱 Recover v1.10 util packages for conditions, patch and paused to util/deprecated/v1beta1 for provider migrations #12224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
f7425b1
352aa46
d3f233a
2999c97
eec55ae
0a32aa5
f3a2d78
295904c
87f3125
1a418ba
92c5a37
452e0c2
a563a6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -32,10 +32,13 @@ import ( | |||||
"github.com/onsi/ginkgo/v2" | ||||||
"github.com/pkg/errors" | ||||||
admissionv1 "k8s.io/api/admissionregistration/v1" | ||||||
appsv1 "k8s.io/api/apps/v1" | ||||||
corev1 "k8s.io/api/core/v1" | ||||||
rbacv1 "k8s.io/api/rbac/v1" | ||||||
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | ||||||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
"k8s.io/apimachinery/pkg/runtime" | ||||||
kerrors "k8s.io/apimachinery/pkg/util/errors" | ||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||||||
"k8s.io/apimachinery/pkg/util/wait" | ||||||
|
@@ -104,7 +107,7 @@ func init() { | |||||
// Add logger for ginkgo. | ||||||
klog.SetOutput(ginkgo.GinkgoWriter) | ||||||
|
||||||
// Calculate the scheme. | ||||||
// Calculate the global scheme used by fakeclients. | ||||||
utilruntime.Must(apiextensionsv1.AddToScheme(scheme.Scheme)) | ||||||
utilruntime.Must(admissionv1.AddToScheme(scheme.Scheme)) | ||||||
utilruntime.Must(clusterv1.AddToScheme(scheme.Scheme)) | ||||||
|
@@ -114,19 +117,20 @@ func init() { | |||||
utilruntime.Must(admissionv1.AddToScheme(scheme.Scheme)) | ||||||
chrischdi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
utilruntime.Must(runtimev1.AddToScheme(scheme.Scheme)) | ||||||
utilruntime.Must(ipamv1.AddToScheme(scheme.Scheme)) | ||||||
utilruntime.Must(builder.AddTransitionV1Beta2ToScheme(scheme.Scheme)) | ||||||
utilruntime.Must(addonsv1.AddToScheme(scheme.Scheme)) | ||||||
} | ||||||
|
||||||
// RunInput is the input for Run. | ||||||
type RunInput struct { | ||||||
M *testing.M | ||||||
ManagerUncachedObjs []client.Object | ||||||
ManagerCacheOptions cache.Options | ||||||
SetupIndexes func(ctx context.Context, mgr ctrl.Manager) | ||||||
SetupReconcilers func(ctx context.Context, mgr ctrl.Manager) | ||||||
SetupEnv func(e *Environment) | ||||||
MinK8sVersion string | ||||||
M *testing.M | ||||||
ManagerUncachedObjs []client.Object | ||||||
ManagerCacheOptions cache.Options | ||||||
SetupIndexes func(ctx context.Context, mgr ctrl.Manager) | ||||||
SetupReconcilers func(ctx context.Context, mgr ctrl.Manager) | ||||||
SetupEnv func(e *Environment) | ||||||
MinK8sVersion string | ||||||
AdditionalSchemeBuilder runtime.SchemeBuilder | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: should this be
Suggested change
(not blocking it is an internal util, we can always iterate in future) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. runtime.Schemebuilder is already an |
||||||
AdditionalCRDDirectoryPaths []string | ||||||
} | ||||||
|
||||||
// Run executes the tests of the given testing.M in a test environment. | ||||||
|
@@ -147,8 +151,28 @@ func Run(ctx context.Context, input RunInput) int { | |||||
return input.M.Run() | ||||||
} | ||||||
|
||||||
// Calculate the scheme. | ||||||
scheme := runtime.NewScheme() | ||||||
utilruntime.Must(appsv1.AddToScheme(scheme)) | ||||||
chrischdi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
utilruntime.Must(corev1.AddToScheme(scheme)) | ||||||
utilruntime.Must(rbacv1.AddToScheme(scheme)) | ||||||
|
||||||
utilruntime.Must(addonsv1.AddToScheme(scheme)) | ||||||
utilruntime.Must(admissionv1.AddToScheme(scheme)) | ||||||
utilruntime.Must(admissionv1.AddToScheme(scheme)) | ||||||
utilruntime.Must(apiextensionsv1.AddToScheme(scheme)) | ||||||
utilruntime.Must(bootstrapv1.AddToScheme(scheme)) | ||||||
utilruntime.Must(clusterv1.AddToScheme(scheme)) | ||||||
utilruntime.Must(controlplanev1.AddToScheme(scheme)) | ||||||
utilruntime.Must(expv1.AddToScheme(scheme)) | ||||||
utilruntime.Must(ipamv1.AddToScheme(scheme)) | ||||||
utilruntime.Must(runtimev1.AddToScheme(scheme)) | ||||||
if input.AdditionalSchemeBuilder != nil { | ||||||
utilruntime.Must(input.AdditionalSchemeBuilder.AddToScheme(scheme)) | ||||||
} | ||||||
|
||||||
// Bootstrapping test environment | ||||||
env := newEnvironment(input.ManagerCacheOptions, input.ManagerUncachedObjs...) | ||||||
env := newEnvironment(scheme, input.AdditionalCRDDirectoryPaths, input.ManagerCacheOptions, input.ManagerUncachedObjs...) | ||||||
|
||||||
ctx, cancel := context.WithCancelCause(ctx) | ||||||
env.cancelManager = cancel | ||||||
|
@@ -233,20 +257,24 @@ type Environment struct { | |||||
// | ||||||
// This function should be called only once for each package you're running tests within, | ||||||
// usually the environment is initialized in a suite_test.go file within a `BeforeSuite` ginkgo block. | ||||||
func newEnvironment(managerCacheOptions cache.Options, uncachedObjs ...client.Object) *Environment { | ||||||
func newEnvironment(scheme *runtime.Scheme, additionalCRDDirectoryPaths []string, managerCacheOptions cache.Options, uncachedObjs ...client.Object) *Environment { | ||||||
// Get the root of the current file to use in CRD paths. | ||||||
_, filename, _, _ := goruntime.Caller(0) //nolint:dogsled | ||||||
root := path.Join(path.Dir(filename), "..", "..", "..") | ||||||
|
||||||
crdDirectoryPaths := []string{ | ||||||
filepath.Join(root, "config", "crd", "bases"), | ||||||
filepath.Join(root, "controlplane", "kubeadm", "config", "crd", "bases"), | ||||||
filepath.Join(root, "bootstrap", "kubeadm", "config", "crd", "bases"), | ||||||
} | ||||||
for _, path := range additionalCRDDirectoryPaths { | ||||||
crdDirectoryPaths = append(crdDirectoryPaths, filepath.Join(root, path)) | ||||||
} | ||||||
|
||||||
// Create the test environment. | ||||||
env := &envtest.Environment{ | ||||||
ErrorIfCRDPathMissing: true, | ||||||
CRDDirectoryPaths: []string{ | ||||||
filepath.Join(root, "config", "crd", "bases"), | ||||||
filepath.Join(root, "controlplane", "kubeadm", "config", "crd", "bases"), | ||||||
filepath.Join(root, "bootstrap", "kubeadm", "config", "crd", "bases"), | ||||||
filepath.Join(root, "util", "test", "builder", "crd"), | ||||||
}, | ||||||
CRDDirectoryPaths: crdDirectoryPaths, | ||||||
CRDs: []*apiextensionsv1.CustomResourceDefinition{ | ||||||
builder.GenericBootstrapConfigCRD.DeepCopy(), | ||||||
builder.GenericBootstrapConfigTemplateCRD.DeepCopy(), | ||||||
|
@@ -296,7 +324,7 @@ func newEnvironment(managerCacheOptions cache.Options, uncachedObjs ...client.Ob | |||||
Controller: config.Controller{ | ||||||
UsePriorityQueue: ptr.To[bool](feature.Gates.Enabled(feature.PriorityQueue)), | ||||||
}, | ||||||
Scheme: scheme.Scheme, | ||||||
Scheme: scheme, | ||||||
Metrics: metricsserver.Options{ | ||||||
BindAddress: "0", | ||||||
}, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
sbueringer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 conditions implements condition utilities. | ||
// | ||
// Deprecated: This package is deprecated and is going to be removed when support for v1beta1 will be dropped. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details. | ||
package conditions |
Uh oh!
There was an error while loading. Please reload this page.