diff --git a/apis/core/v1alpha1/condition.go b/apis/common/v1/condition.go similarity index 99% rename from apis/core/v1alpha1/condition.go rename to apis/common/v1/condition.go index 6ecab4598..b49a74e03 100644 --- a/apis/core/v1alpha1/condition.go +++ b/apis/common/v1/condition.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1 import ( "sort" diff --git a/apis/core/v1alpha1/condition_test.go b/apis/common/v1/condition_test.go similarity index 99% rename from apis/core/v1alpha1/condition_test.go rename to apis/common/v1/condition_test.go index b3bd2705c..5b9ab06dc 100644 --- a/apis/core/v1alpha1/condition_test.go +++ b/apis/common/v1/condition_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1 import ( "testing" diff --git a/apis/core/v1alpha1/doc.go b/apis/common/v1/doc.go similarity index 79% rename from apis/core/v1alpha1/doc.go rename to apis/common/v1/doc.go index b016a01d9..9b99de7be 100644 --- a/apis/core/v1alpha1/doc.go +++ b/apis/common/v1/doc.go @@ -14,8 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha1 contains core API types used by most Crossplane resources. +// Package v1 contains core API types used by most Crossplane resources. // +kubebuilder:object:generate=true -// +groupName=core.crossplane.io -// +versionName=v1alpha1 -package v1alpha1 +package v1 diff --git a/apis/core/v1alpha1/policies.go b/apis/common/v1/policies.go similarity index 98% rename from apis/core/v1alpha1/policies.go rename to apis/common/v1/policies.go index 23e9a6019..126566603 100644 --- a/apis/core/v1alpha1/policies.go +++ b/apis/common/v1/policies.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1 // A DeletionPolicy determines what should happen to the underlying external // resource when a managed resource is deleted. diff --git a/apis/core/v1alpha1/resource.go b/apis/common/v1/resource.go similarity index 99% rename from apis/core/v1alpha1/resource.go rename to apis/common/v1/resource.go index fc89a3e5c..d3d96213b 100644 --- a/apis/core/v1alpha1/resource.go +++ b/apis/common/v1/resource.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1 import ( corev1 "k8s.io/api/core/v1" diff --git a/apis/core/v1alpha1/zz_generated.deepcopy.go b/apis/common/v1/zz_generated.deepcopy.go similarity index 99% rename from apis/core/v1alpha1/zz_generated.deepcopy.go rename to apis/common/v1/zz_generated.deepcopy.go index 6d862171f..6bd879c0f 100644 --- a/apis/core/v1alpha1/zz_generated.deepcopy.go +++ b/apis/common/v1/zz_generated.deepcopy.go @@ -18,10 +18,10 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( - "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -295,7 +295,7 @@ func (in *TargetSpec) DeepCopyInto(out *TargetSpec) { } if in.ResourceReference != nil { in, out := &in.ResourceReference, &out.ResourceReference - *out = new(v1.ObjectReference) + *out = new(corev1.ObjectReference) **out = **in } } diff --git a/pkg/meta/meta.go b/pkg/meta/meta.go index d77fa6c8d..71493990d 100644 --- a/pkg/meta/meta.go +++ b/pkg/meta/meta.go @@ -28,7 +28,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) // AnnotationKeyExternalName is the key in the annotations map of a resource for @@ -64,9 +64,9 @@ func ReferenceTo(o metav1.Object, of schema.GroupVersionKind) *corev1.ObjectRefe // TypedReferenceTo returns a typed object reference to the supplied object, // presumed to be of the supplied group, version, and kind. -func TypedReferenceTo(o metav1.Object, of schema.GroupVersionKind) *v1alpha1.TypedReference { +func TypedReferenceTo(o metav1.Object, of schema.GroupVersionKind) *xpv1.TypedReference { v, k := of.ToAPIVersionAndKind() - return &v1alpha1.TypedReference{ + return &xpv1.TypedReference{ APIVersion: v, Kind: k, Name: o.GetName(), @@ -75,7 +75,7 @@ func TypedReferenceTo(o metav1.Object, of schema.GroupVersionKind) *v1alpha1.Typ } // AsOwner converts the supplied object reference to an owner reference. -func AsOwner(r *v1alpha1.TypedReference) metav1.OwnerReference { +func AsOwner(r *xpv1.TypedReference) metav1.OwnerReference { return metav1.OwnerReference{ APIVersion: r.APIVersion, Kind: r.Kind, @@ -86,7 +86,7 @@ func AsOwner(r *v1alpha1.TypedReference) metav1.OwnerReference { // AsController converts the supplied object reference to a controller // reference. You may also consider using metav1.NewControllerRef. -func AsController(r *v1alpha1.TypedReference) metav1.OwnerReference { +func AsController(r *xpv1.TypedReference) metav1.OwnerReference { c := true ref := AsOwner(r) ref.Controller = &c diff --git a/pkg/meta/meta_test.go b/pkg/meta/meta_test.go index 73dc92ba6..a71fb798d 100644 --- a/pkg/meta/meta_test.go +++ b/pkg/meta/meta_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/test" ) @@ -93,7 +93,7 @@ func TestTypedReferenceTo(t *testing.T) { } tests := map[string]struct { args - want *v1alpha1.TypedReference + want *xpv1.TypedReference }{ "WithTypeMeta": { args: args{ @@ -110,7 +110,7 @@ func TestTypedReferenceTo(t *testing.T) { Kind: kind, }, }, - want: &v1alpha1.TypedReference{ + want: &xpv1.TypedReference{ APIVersion: groupVersion, Kind: kind, Name: name, @@ -131,11 +131,11 @@ func TestTypedReferenceTo(t *testing.T) { func TestAsOwner(t *testing.T) { tests := map[string]struct { - r *v1alpha1.TypedReference + r *xpv1.TypedReference want metav1.OwnerReference }{ "Successful": { - r: &v1alpha1.TypedReference{ + r: &xpv1.TypedReference{ APIVersion: groupVersion, Kind: kind, Name: name, @@ -164,11 +164,11 @@ func TestAsController(t *testing.T) { controller := true tests := map[string]struct { - r *v1alpha1.TypedReference + r *xpv1.TypedReference want metav1.OwnerReference }{ "Successful": { - r: &v1alpha1.TypedReference{ + r: &xpv1.TypedReference{ APIVersion: groupVersion, Kind: kind, Name: name, diff --git a/pkg/reconciler/managed/api.go b/pkg/reconciler/managed/api.go index 5a2ac1d1c..6aff26943 100644 --- a/pkg/reconciler/managed/api.go +++ b/pkg/reconciler/managed/api.go @@ -24,7 +24,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/meta" "github.com/crossplane/crossplane-runtime/pkg/resource" ) @@ -70,7 +70,7 @@ func (a *DefaultProviderConfig) Initialize(ctx context.Context, mg resource.Mana if mg.GetProviderConfigReference() != nil { return nil } - mg.SetProviderConfigReference(&v1alpha1.Reference{Name: "default"}) + mg.SetProviderConfigReference(&xpv1.Reference{Name: "default"}) return errors.Wrap(a.client.Update(ctx, mg), errUpdateManaged) } diff --git a/pkg/reconciler/managed/api_test.go b/pkg/reconciler/managed/api_test.go index c4c4e583c..e9948e6ca 100644 --- a/pkg/reconciler/managed/api_test.go +++ b/pkg/reconciler/managed/api_test.go @@ -26,7 +26,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/meta" "github.com/crossplane/crossplane-runtime/pkg/resource" "github.com/crossplane/crossplane-runtime/pkg/resource/fake" @@ -142,7 +142,7 @@ func TestDefaultProviderConfig(t *testing.T) { }, want: want{ err: errors.Wrap(errBoom, errUpdateManaged), - mg: &fake.Managed{ProviderConfigReferencer: fake.ProviderConfigReferencer{Ref: &v1alpha1.Reference{Name: "default"}}}, + mg: &fake.Managed{ProviderConfigReferencer: fake.ProviderConfigReferencer{Ref: &xpv1.Reference{Name: "default"}}}, }, }, "UpdateSuccessful": { @@ -153,17 +153,17 @@ func TestDefaultProviderConfig(t *testing.T) { }, want: want{ err: nil, - mg: &fake.Managed{ProviderConfigReferencer: fake.ProviderConfigReferencer{Ref: &v1alpha1.Reference{Name: "default"}}}, + mg: &fake.Managed{ProviderConfigReferencer: fake.ProviderConfigReferencer{Ref: &xpv1.Reference{Name: "default"}}}, }, }, "UpdateNotNeeded": { args: args{ ctx: context.Background(), - mg: &fake.Managed{ProviderConfigReferencer: fake.ProviderConfigReferencer{Ref: &v1alpha1.Reference{Name: "some-value"}}}, + mg: &fake.Managed{ProviderConfigReferencer: fake.ProviderConfigReferencer{Ref: &xpv1.Reference{Name: "some-value"}}}, }, want: want{ err: nil, - mg: &fake.Managed{ProviderConfigReferencer: fake.ProviderConfigReferencer{Ref: &v1alpha1.Reference{Name: "some-value"}}}, + mg: &fake.Managed{ProviderConfigReferencer: fake.ProviderConfigReferencer{Ref: &xpv1.Reference{Name: "some-value"}}}, }, }, } @@ -186,7 +186,7 @@ func TestAPISecretPublisher(t *testing.T) { errBoom := errors.New("boom") mg := &fake.Managed{ - ConnectionSecretWriterTo: fake.ConnectionSecretWriterTo{Ref: &v1alpha1.SecretReference{ + ConnectionSecretWriterTo: fake.ConnectionSecretWriterTo{Ref: &xpv1.SecretReference{ Namespace: "coolnamespace", Name: "coolsecret", }}, diff --git a/pkg/reconciler/managed/reconciler.go b/pkg/reconciler/managed/reconciler.go index 5333d88fd..2b67cca69 100644 --- a/pkg/reconciler/managed/reconciler.go +++ b/pkg/reconciler/managed/reconciler.go @@ -30,7 +30,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/event" "github.com/crossplane/crossplane-runtime/pkg/logging" "github.com/crossplane/crossplane-runtime/pkg/meta" @@ -547,7 +547,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // If not, we want to try again after a short wait. log.Debug("Cannot initialize managed resource", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotInitialize, err)) - managed.SetConditions(v1alpha1.ReconcileError(err)) + managed.SetConditions(xpv1.ReconcileError(err)) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } @@ -568,7 +568,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // we'll be requeued implicitly due to the status update. log.Debug("Cannot resolve managed resource references", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotResolveRefs, err)) - managed.SetConditions(v1alpha1.ReconcileError(err)) + managed.SetConditions(xpv1.ReconcileError(err)) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } } @@ -581,7 +581,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // condition. If not, we want to try again after a short wait. log.Debug("Cannot connect to provider", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotConnect, err)) - managed.SetConditions(v1alpha1.ReconcileError(errors.Wrap(err, errReconcileConnect))) + managed.SetConditions(xpv1.ReconcileError(errors.Wrap(err, errReconcileConnect))) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } @@ -594,14 +594,14 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // error condition. If not, we want to try again after a short wait. log.Debug("Cannot observe external resource", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotObserve, err)) - managed.SetConditions(v1alpha1.ReconcileError(errors.Wrap(err, errReconcileObserve))) + managed.SetConditions(xpv1.ReconcileError(errors.Wrap(err, errReconcileObserve))) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } if meta.WasDeleted(managed) { log = log.WithValues("deletion-timestamp", managed.GetDeletionTimestamp()) - if observation.ResourceExists && managed.GetDeletionPolicy() != v1alpha1.DeletionOrphan { + if observation.ResourceExists && managed.GetDeletionPolicy() != xpv1.DeletionOrphan { if err := external.Delete(externalCtx, managed); err != nil { // We'll hit this condition if we can't delete our external // resource, for example if our provider credentials don't have @@ -611,7 +611,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // short wait. log.Debug("Cannot delete external resource", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotDelete, err)) - managed.SetConditions(v1alpha1.ReconcileError(errors.Wrap(err, errReconcileDelete))) + managed.SetConditions(xpv1.ReconcileError(errors.Wrap(err, errReconcileDelete))) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } @@ -624,7 +624,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // block and try again. log.Debug("Successfully requested deletion of external resource", "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Normal(reasonDeleted, "Successfully requested deletion of external resource")) - managed.SetConditions(v1alpha1.ReconcileSuccess()) + managed.SetConditions(xpv1.ReconcileSuccess()) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } if err := r.managed.UnpublishConnection(ctx, managed, observation.ConnectionDetails); err != nil { @@ -633,7 +633,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // condition. If not, we want to try again after a short wait. log.Debug("Cannot unpublish connection details", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotUnpublish, err)) - managed.SetConditions(v1alpha1.ReconcileError(err)) + managed.SetConditions(xpv1.ReconcileError(err)) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(resource.IgnoreNotFound(r.client.Status().Update(ctx, managed)), errUpdateManagedStatus) } if err := r.managed.RemoveFinalizer(ctx, managed); err != nil { @@ -641,7 +641,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // requeued implicitly when we update our status with the new error // condition. If not, we want to try again after a short wait. log.Debug("Cannot remove managed resource finalizer", "error", err, "requeue-after", time.Now().Add(r.shortWait)) - managed.SetConditions(v1alpha1.ReconcileError(err)) + managed.SetConditions(xpv1.ReconcileError(err)) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(resource.IgnoreNotFound(r.client.Status().Update(ctx, managed)), errUpdateManagedStatus) } @@ -659,7 +659,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // not, we want to try again after a short wait. log.Debug("Cannot publish connection details", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotPublish, err)) - managed.SetConditions(v1alpha1.ReconcileError(err)) + managed.SetConditions(xpv1.ReconcileError(err)) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } @@ -668,7 +668,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // requeued implicitly when we update our status with the new error // condition. If not, we want to try again after a short wait. log.Debug("Cannot add finalizer", "error", err, "requeue-after", time.Now().Add(r.shortWait)) - managed.SetConditions(v1alpha1.ReconcileError(err)) + managed.SetConditions(xpv1.ReconcileError(err)) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(resource.IgnoreNotFound(r.client.Status().Update(ctx, managed)), errUpdateManagedStatus) } @@ -683,7 +683,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // short wait. log.Debug("Cannot create external resource", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotCreate, err)) - managed.SetConditions(v1alpha1.ReconcileError(errors.Wrap(err, errReconcileCreate))) + managed.SetConditions(xpv1.ReconcileError(errors.Wrap(err, errReconcileCreate))) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } @@ -704,7 +704,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) if err != nil { log.Debug("Cannot update managed resource", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotUpdateManaged, errors.Wrap(err, errUpdateManagedAfterCreate))) - managed.SetConditions(v1alpha1.ReconcileError(errors.Wrap(err, errUpdateManagedAfterCreate))) + managed.SetConditions(xpv1.ReconcileError(errors.Wrap(err, errUpdateManagedAfterCreate))) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } } @@ -715,7 +715,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // condition. If not, we want to try again after a short wait. log.Debug("Cannot publish connection details", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotPublish, err)) - managed.SetConditions(v1alpha1.ReconcileError(err)) + managed.SetConditions(xpv1.ReconcileError(err)) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } @@ -725,7 +725,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // it's ready for use. log.Debug("Successfully requested creation of external resource", "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Normal(reasonCreated, "Successfully requested creation of external resource")) - managed.SetConditions(v1alpha1.ReconcileSuccess()) + managed.SetConditions(xpv1.ReconcileSuccess()) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } @@ -740,7 +740,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) if err := r.client.Update(ctx, managed); err != nil { log.Debug(errUpdateManaged, "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotUpdateManaged, err)) - managed.SetConditions(v1alpha1.ReconcileError(errors.Wrap(err, errUpdateManaged))) + managed.SetConditions(xpv1.ReconcileError(errors.Wrap(err, errUpdateManaged))) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } } @@ -752,7 +752,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // after a long wait in order to observe it and react accordingly. // https://github.com/crossplane/crossplane/issues/289 log.Debug("External resource is up to date", "requeue-after", time.Now().Add(r.longWait)) - managed.SetConditions(v1alpha1.ReconcileSuccess()) + managed.SetConditions(xpv1.ReconcileSuccess()) return reconcile.Result{RequeueAfter: r.longWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } @@ -765,7 +765,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // condition. If not, we want to try again after a short wait. log.Debug("Cannot update external resource", "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotUpdate, err)) - managed.SetConditions(v1alpha1.ReconcileError(errors.Wrap(err, errReconcileUpdate))) + managed.SetConditions(xpv1.ReconcileError(errors.Wrap(err, errReconcileUpdate))) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } @@ -775,7 +775,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // not, we want to try again after a short wait. log.Debug("Cannot publish connection details", "error", err, "requeue-after", time.Now().Add(r.shortWait)) record.Event(managed, event.Warning(reasonCannotPublish, err)) - managed.SetConditions(v1alpha1.ReconcileError(err)) + managed.SetConditions(xpv1.ReconcileError(err)) return reconcile.Result{RequeueAfter: r.shortWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } @@ -786,6 +786,6 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) // https://github.com/crossplane/crossplane/issues/289 log.Debug("Successfully requested update of external resource", "requeue-after", time.Now().Add(r.longWait)) record.Event(managed, event.Normal(reasonUpdated, "Successfully requested update of external resource")) - managed.SetConditions(v1alpha1.ReconcileSuccess()) + managed.SetConditions(xpv1.ReconcileSuccess()) return reconcile.Result{RequeueAfter: r.longWait}, errors.Wrap(r.client.Status().Update(ctx, managed), errUpdateManagedStatus) } diff --git a/pkg/reconciler/managed/reconciler_test.go b/pkg/reconciler/managed/reconciler_test.go index bdf81f9db..7c8e82793 100644 --- a/pkg/reconciler/managed/reconciler_test.go +++ b/pkg/reconciler/managed/reconciler_test.go @@ -31,7 +31,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/meta" "github.com/crossplane/crossplane-runtime/pkg/resource" "github.com/crossplane/crossplane-runtime/pkg/resource/fake" @@ -90,7 +90,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errBoom)) + want.SetConditions(xpv1.ReconcileError(errBoom)) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors initializing the managed resource should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -117,7 +117,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errBoom)) + want.SetConditions(xpv1.ReconcileError(errBoom)) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors during reference resolution should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -145,7 +145,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, got runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errors.Wrap(errBoom, errReconcileConnect))) + want.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errReconcileConnect))) if diff := cmp.Diff(want, got, test.EquateConditions()); diff != "" { reason := "Errors connecting to the provider should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -173,7 +173,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errors.Wrap(errBoom, errReconcileObserve))) + want.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errReconcileObserve))) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors observing the managed resource should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -206,14 +206,14 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil, func(obj runtime.Object) error { mg := obj.(*fake.Managed) mg.SetDeletionTimestamp(&now) - mg.SetDeletionPolicy(v1alpha1.DeletionDelete) + mg.SetDeletionPolicy(xpv1.DeletionDelete) return nil }), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} want.SetDeletionTimestamp(&now) - want.SetDeletionPolicy(v1alpha1.DeletionDelete) - want.SetConditions(v1alpha1.ReconcileError(errors.Wrap(errBoom, errReconcileDelete))) + want.SetDeletionPolicy(xpv1.DeletionDelete) + want.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errReconcileDelete))) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "An error deleting an external resource should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -250,14 +250,14 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil, func(obj runtime.Object) error { mg := obj.(*fake.Managed) mg.SetDeletionTimestamp(&now) - mg.SetDeletionPolicy(v1alpha1.DeletionDelete) + mg.SetDeletionPolicy(xpv1.DeletionDelete) return nil }), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} want.SetDeletionTimestamp(&now) - want.SetDeletionPolicy(v1alpha1.DeletionDelete) - want.SetConditions(v1alpha1.ReconcileSuccess()) + want.SetDeletionPolicy(xpv1.DeletionDelete) + want.SetConditions(xpv1.ReconcileSuccess()) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "A deleted external resource should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -299,7 +299,7 @@ func TestReconciler(t *testing.T) { MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} want.SetDeletionTimestamp(&now) - want.SetConditions(v1alpha1.ReconcileError(errBoom)) + want.SetConditions(xpv1.ReconcileError(errBoom)) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors unpublishing connection details should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -341,7 +341,7 @@ func TestReconciler(t *testing.T) { MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} want.SetDeletionTimestamp(&now) - want.SetConditions(v1alpha1.ReconcileError(errBoom)) + want.SetConditions(xpv1.ReconcileError(errBoom)) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors removing the managed resource finalizer should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -408,7 +408,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errBoom)) + want.SetConditions(xpv1.ReconcileError(errBoom)) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors publishing connection details after observation should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -438,7 +438,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errBoom)) + want.SetConditions(xpv1.ReconcileError(errBoom)) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors adding a finalizer should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -467,7 +467,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errors.Wrap(errBoom, errReconcileCreate))) + want.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errReconcileCreate))) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors while creating an external resource should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -506,7 +506,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errBoom)) + want.SetConditions(xpv1.ReconcileError(errBoom)) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors publishing connection details after creation should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -556,7 +556,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileSuccess()) + want.SetConditions(xpv1.ReconcileSuccess()) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Successful managed resource creation should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -587,7 +587,7 @@ func TestReconciler(t *testing.T) { MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} meta.SetExternalName(want, "test") - want.SetConditions(v1alpha1.ReconcileSuccess()) + want.SetConditions(xpv1.ReconcileSuccess()) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Successful managed resource creation should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -633,7 +633,7 @@ func TestReconciler(t *testing.T) { MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} meta.SetExternalName(want, "test") - want.SetConditions(v1alpha1.ReconcileError(errors.Wrap(errBoom, errUpdateManagedAfterCreate))) + want.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errUpdateManagedAfterCreate))) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Successful managed resource creation should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -675,7 +675,7 @@ func TestReconciler(t *testing.T) { MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} meta.SetExternalName(want, "test") - want.SetConditions(v1alpha1.ReconcileError(errors.Wrap(errBoom, errUpdateManagedAfterCreate))) + want.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errUpdateManagedAfterCreate))) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Successful managed resource creation should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -716,7 +716,7 @@ func TestReconciler(t *testing.T) { MockUpdate: test.NewMockUpdateFn(errBoom), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errors.Wrap(errBoom, errUpdateManaged))) + want.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errUpdateManaged))) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors updating a managed resource should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -752,7 +752,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileSuccess()) + want.SetConditions(xpv1.ReconcileSuccess()) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "A successful no-op reconcile should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -788,7 +788,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errors.Wrap(errBoom, errReconcileUpdate))) + want.SetConditions(xpv1.ReconcileError(errors.Wrap(errBoom, errReconcileUpdate))) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors while updating an external resource should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -827,7 +827,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileError(errBoom)) + want.SetConditions(xpv1.ReconcileError(errBoom)) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "Errors publishing connection details after an update should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) @@ -877,7 +877,7 @@ func TestReconciler(t *testing.T) { MockGet: test.NewMockGetFn(nil), MockStatusUpdate: test.MockStatusUpdateFn(func(_ context.Context, obj runtime.Object, _ ...client.UpdateOption) error { want := &fake.Managed{} - want.SetConditions(v1alpha1.ReconcileSuccess()) + want.SetConditions(xpv1.ReconcileSuccess()) if diff := cmp.Diff(want, obj, test.EquateConditions()); diff != "" { reason := "A successful managed resource update should be reported as a conditioned status." t.Errorf("\nReason: %s\n-want, +got:\n%s", reason, diff) diff --git a/pkg/reconciler/providerconfig/reconciler.go b/pkg/reconciler/providerconfig/reconciler.go index 03a12efbd..2d2bbb0e2 100644 --- a/pkg/reconciler/providerconfig/reconciler.go +++ b/pkg/reconciler/providerconfig/reconciler.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/event" "github.com/crossplane/crossplane-runtime/pkg/logging" "github.com/crossplane/crossplane-runtime/pkg/meta" @@ -54,14 +54,14 @@ const ( // Condition types and reasons. const ( - TypeTerminating v1alpha1.ConditionType = "Terminating" - ReasonInUse v1alpha1.ConditionReason = "InUse" + TypeTerminating xpv1.ConditionType = "Terminating" + ReasonInUse xpv1.ConditionReason = "InUse" ) // Terminating indicates a ProviderConfig has been deleted, but that the // deletion is being blocked because it is still in use. -func Terminating() v1alpha1.Condition { - return v1alpha1.Condition{ +func Terminating() xpv1.Condition { + return xpv1.Condition{ Type: TypeTerminating, Status: corev1.ConditionTrue, LastTransitionTime: metav1.Now(), @@ -161,7 +161,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) ) l := r.newUsageList() - if err := r.client.List(ctx, l, client.MatchingLabels{v1alpha1.LabelKeyProviderName: pc.GetName()}); err != nil { + if err := r.client.List(ctx, l, client.MatchingLabels{xpv1.LabelKeyProviderName: pc.GetName()}); err != nil { log.Debug(errListPCUs, "error", err) r.record.Event(pc, event.Warning(reasonAccount, errors.Wrap(err, errListPCUs))) return reconcile.Result{RequeueAfter: shortWait}, nil diff --git a/pkg/reference/reference.go b/pkg/reference/reference.go index 4679c1cdc..3b2c239c1 100644 --- a/pkg/reference/reference.go +++ b/pkg/reference/reference.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/meta" "github.com/crossplane/crossplane-runtime/pkg/resource" ) @@ -78,8 +78,8 @@ func ExternalName() ExtractValueFn { // managed resource be resolved. type ResolutionRequest struct { CurrentValue string - Reference *v1alpha1.Reference - Selector *v1alpha1.Selector + Reference *xpv1.Reference + Selector *xpv1.Selector To To Extract ExtractValueFn } @@ -103,7 +103,7 @@ func (rr ResolutionRequest) IsNoOp() bool { // returned values are always safe to set if resolution was successful. type ResolutionResponse struct { ResolvedValue string - ResolvedReference *v1alpha1.Reference + ResolvedReference *xpv1.Reference } // Validate this ResolutionResponse. @@ -119,8 +119,8 @@ func (rr ResolutionResponse) Validate() error { // kind of managed resource be resolved. type MultiResolutionRequest struct { CurrentValues []string - References []v1alpha1.Reference - Selector *v1alpha1.Selector + References []xpv1.Reference + Selector *xpv1.Selector To To Extract ExtractValueFn } @@ -147,7 +147,7 @@ func (rr MultiResolutionRequest) IsNoOp() bool { // successful. type MultiResolutionResponse struct { ResolvedValues []string - ResolvedReferences []v1alpha1.Reference + ResolvedReferences []xpv1.Reference } // Validate this MultiResolutionResponse. @@ -207,7 +207,7 @@ func (r *APIResolver) Resolve(ctx context.Context, req ResolutionRequest) (Resol continue } - rsp := ResolutionResponse{ResolvedValue: req.Extract(to), ResolvedReference: &v1alpha1.Reference{Name: to.GetName()}} + rsp := ResolutionResponse{ResolvedValue: req.Extract(to), ResolvedReference: &xpv1.Reference{Name: to.GetName()}} return rsp, rsp.Validate() } @@ -244,7 +244,7 @@ func (r *APIResolver) ResolveMultiple(ctx context.Context, req MultiResolutionRe } items := req.To.List.GetItems() - refs := make([]v1alpha1.Reference, 0, len(items)) + refs := make([]xpv1.Reference, 0, len(items)) vals := make([]string, 0, len(items)) for _, to := range req.To.List.GetItems() { if ControllersMustMatch(req.Selector) && !meta.HaveSameController(r.from, to) { @@ -252,7 +252,7 @@ func (r *APIResolver) ResolveMultiple(ctx context.Context, req MultiResolutionRe } vals = append(vals, req.Extract(to)) - refs = append(refs, v1alpha1.Reference{Name: to.GetName()}) + refs = append(refs, xpv1.Reference{Name: to.GetName()}) } rsp := MultiResolutionResponse{ResolvedValues: vals, ResolvedReferences: refs} @@ -262,7 +262,7 @@ func (r *APIResolver) ResolveMultiple(ctx context.Context, req MultiResolutionRe // ControllersMustMatch returns true if the supplied Selector requires that a // reference be to a managed resource whose controller reference matches the // referencing resource. -func ControllersMustMatch(s *v1alpha1.Selector) bool { +func ControllersMustMatch(s *xpv1.Selector) bool { if s == nil { return false } diff --git a/pkg/reference/reference_test.go b/pkg/reference/reference_test.go index 5aae047be..3f8f5cf53 100644 --- a/pkg/reference/reference_test.go +++ b/pkg/reference/reference_test.go @@ -28,7 +28,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/meta" "github.com/crossplane/crossplane-runtime/pkg/resource" "github.com/crossplane/crossplane-runtime/pkg/resource/fake" @@ -71,12 +71,12 @@ func TestResolve(t *testing.T) { errBoom := errors.New("boom") now := metav1.Now() value := "coolv" - ref := &v1alpha1.Reference{Name: "cool"} + ref := &xpv1.Reference{Name: "cool"} controlled := &fake.Managed{} controlled.SetName(value) meta.SetExternalName(controlled, value) - meta.AddControllerReference(controlled, meta.AsController(&v1alpha1.TypedReference{UID: types.UID("very-unique")})) + meta.AddControllerReference(controlled, meta.AsController(&xpv1.TypedReference{UID: types.UID("very-unique")})) type args struct { ctx context.Context @@ -193,7 +193,7 @@ func TestResolve(t *testing.T) { from: &fake.Managed{}, args: args{ req: ResolutionRequest{ - Selector: &v1alpha1.Selector{}, + Selector: &xpv1.Selector{}, }, }, want: want{ @@ -209,7 +209,7 @@ func TestResolve(t *testing.T) { from: &fake.Managed{}, args: args{ req: ResolutionRequest{ - Selector: &v1alpha1.Selector{}, + Selector: &xpv1.Selector{}, To: To{List: &FakeManagedList{}}, }, }, @@ -226,7 +226,7 @@ func TestResolve(t *testing.T) { from: controlled, args: args{ req: ResolutionRequest{ - Selector: &v1alpha1.Selector{ + Selector: &xpv1.Selector{ MatchControllerRef: func() *bool { t := true; return &t }(), }, To: To{List: &FakeManagedList{Items: []resource.Managed{ @@ -239,7 +239,7 @@ func TestResolve(t *testing.T) { want: want{ rsp: ResolutionResponse{ ResolvedValue: value, - ResolvedReference: &v1alpha1.Reference{Name: value}, + ResolvedReference: &xpv1.Reference{Name: value}, }, err: nil, }, @@ -262,12 +262,12 @@ func TestResolveMultiple(t *testing.T) { errBoom := errors.New("boom") now := metav1.Now() value := "coolv" - ref := v1alpha1.Reference{Name: "cool"} + ref := xpv1.Reference{Name: "cool"} controlled := &fake.Managed{} controlled.SetName(value) meta.SetExternalName(controlled, value) - meta.AddControllerReference(controlled, meta.AsController(&v1alpha1.TypedReference{UID: types.UID("very-unique")})) + meta.AddControllerReference(controlled, meta.AsController(&xpv1.TypedReference{UID: types.UID("very-unique")})) type args struct { ctx context.Context @@ -324,7 +324,7 @@ func TestResolveMultiple(t *testing.T) { from: &fake.Managed{}, args: args{ req: MultiResolutionRequest{ - References: []v1alpha1.Reference{ref}, + References: []xpv1.Reference{ref}, To: To{Managed: &fake.Managed{}}, Extract: ExternalName(), }, @@ -341,7 +341,7 @@ func TestResolveMultiple(t *testing.T) { from: &fake.Managed{}, args: args{ req: MultiResolutionRequest{ - References: []v1alpha1.Reference{ref}, + References: []xpv1.Reference{ref}, To: To{Managed: &fake.Managed{}}, Extract: func(resource.Managed) string { return "" }, }, @@ -349,7 +349,7 @@ func TestResolveMultiple(t *testing.T) { want: want{ rsp: MultiResolutionResponse{ ResolvedValues: []string{""}, - ResolvedReferences: []v1alpha1.Reference{ref}, + ResolvedReferences: []xpv1.Reference{ref}, }, err: errors.New(errNoValue), }, @@ -365,7 +365,7 @@ func TestResolveMultiple(t *testing.T) { from: &fake.Managed{}, args: args{ req: MultiResolutionRequest{ - References: []v1alpha1.Reference{ref}, + References: []xpv1.Reference{ref}, To: To{Managed: &fake.Managed{}}, Extract: ExternalName(), }, @@ -373,7 +373,7 @@ func TestResolveMultiple(t *testing.T) { want: want{ rsp: MultiResolutionResponse{ ResolvedValues: []string{value}, - ResolvedReferences: []v1alpha1.Reference{ref}, + ResolvedReferences: []xpv1.Reference{ref}, }, }, }, @@ -385,7 +385,7 @@ func TestResolveMultiple(t *testing.T) { from: &fake.Managed{}, args: args{ req: MultiResolutionRequest{ - Selector: &v1alpha1.Selector{}, + Selector: &xpv1.Selector{}, }, }, want: want{ @@ -401,7 +401,7 @@ func TestResolveMultiple(t *testing.T) { from: &fake.Managed{}, args: args{ req: MultiResolutionRequest{ - Selector: &v1alpha1.Selector{}, + Selector: &xpv1.Selector{}, To: To{List: &FakeManagedList{}}, }, }, @@ -418,7 +418,7 @@ func TestResolveMultiple(t *testing.T) { from: controlled, args: args{ req: MultiResolutionRequest{ - Selector: &v1alpha1.Selector{ + Selector: &xpv1.Selector{ MatchControllerRef: func() *bool { t := true; return &t }(), }, To: To{List: &FakeManagedList{Items: []resource.Managed{ @@ -431,7 +431,7 @@ func TestResolveMultiple(t *testing.T) { want: want{ rsp: MultiResolutionResponse{ ResolvedValues: []string{value}, - ResolvedReferences: []v1alpha1.Reference{{Name: value}}, + ResolvedReferences: []xpv1.Reference{{Name: value}}, }, err: nil, }, @@ -453,7 +453,7 @@ func TestResolveMultiple(t *testing.T) { func TestControllersMustMatch(t *testing.T) { cases := map[string]struct { - s *v1alpha1.Selector + s *xpv1.Selector want bool }{ "NilSelector": { @@ -461,15 +461,15 @@ func TestControllersMustMatch(t *testing.T) { want: false, }, "NilMatchControllerRef": { - s: &v1alpha1.Selector{}, + s: &xpv1.Selector{}, want: false, }, "False": { - s: &v1alpha1.Selector{MatchControllerRef: func() *bool { f := false; return &f }()}, + s: &xpv1.Selector{MatchControllerRef: func() *bool { f := false; return &f }()}, want: false, }, "True": { - s: &v1alpha1.Selector{MatchControllerRef: func() *bool { t := true; return &t }()}, + s: &xpv1.Selector{MatchControllerRef: func() *bool { t := true; return &t }()}, want: true, }, } diff --git a/pkg/resource/api_test.go b/pkg/resource/api_test.go index 3899b58b0..024f18f53 100644 --- a/pkg/resource/api_test.go +++ b/pkg/resource/api_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/meta" "github.com/crossplane/crossplane-runtime/pkg/resource/fake" "github.com/crossplane/crossplane-runtime/pkg/test" @@ -52,14 +52,14 @@ func TestPropagateConnection(t *testing.T) { mg := &fake.Managed{ ConnectionSecretWriterTo: fake.ConnectionSecretWriterTo{ - Ref: &v1alpha1.SecretReference{Namespace: mgcsns, Name: mgcsname}, + Ref: &xpv1.SecretReference{Namespace: mgcsns, Name: mgcsname}, }, } cm := &fake.CompositeClaim{ ObjectMeta: metav1.ObjectMeta{Namespace: cmcsns}, LocalConnectionSecretWriterTo: fake.LocalConnectionSecretWriterTo{ - Ref: &v1alpha1.LocalSecretReference{Name: cmcsname}, + Ref: &xpv1.LocalSecretReference{Name: cmcsname}, }, } diff --git a/pkg/resource/enqueue_handlers_test.go b/pkg/resource/enqueue_handlers_test.go index 556daa63a..abcfe7ed4 100644 --- a/pkg/resource/enqueue_handlers_test.go +++ b/pkg/resource/enqueue_handlers_test.go @@ -25,7 +25,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/resource/fake" ) @@ -52,7 +52,7 @@ func TestAddProviderConfig(t *testing.T) { "IsProviderConfigReferencer": { obj: &fake.ProviderConfigUsage{ RequiredProviderConfigReferencer: fake.RequiredProviderConfigReferencer{ - Ref: v1alpha1.Reference{Name: name}, + Ref: xpv1.Reference{Name: name}, }, }, queue: addFn(func(got interface{}) { diff --git a/pkg/resource/fake/mocks.go b/pkg/resource/fake/mocks.go index da84cb904..647114f5c 100644 --- a/pkg/resource/fake/mocks.go +++ b/pkg/resource/fake/mocks.go @@ -30,18 +30,18 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) // Conditioned is a mock that implements Conditioned interface. -type Conditioned struct{ Conditions []v1alpha1.Condition } +type Conditioned struct{ Conditions []xpv1.Condition } // SetConditions sets the Conditions. -func (m *Conditioned) SetConditions(c ...v1alpha1.Condition) { m.Conditions = c } +func (m *Conditioned) SetConditions(c ...xpv1.Condition) { m.Conditions = c } // GetCondition get the Condition with the given ConditionType. -func (m *Conditioned) GetCondition(ct v1alpha1.ConditionType) v1alpha1.Condition { - return v1alpha1.Condition{Type: ct, Status: corev1.ConditionUnknown} +func (m *Conditioned) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return xpv1.Condition{Type: ct, Status: corev1.ConditionUnknown} } // ClaimReferencer is a mock that implements ClaimReferencer interface. @@ -63,87 +63,87 @@ func (m *ManagedResourceReferencer) SetResourceReference(r *corev1.ObjectReferen func (m *ManagedResourceReferencer) GetResourceReference() *corev1.ObjectReference { return m.Ref } // ProviderReferencer is a mock that implements ProviderReferencer interface. -type ProviderReferencer struct{ Ref *v1alpha1.Reference } +type ProviderReferencer struct{ Ref *xpv1.Reference } // SetProviderReference sets the ProviderReference. -func (m *ProviderReferencer) SetProviderReference(p *v1alpha1.Reference) { m.Ref = p } +func (m *ProviderReferencer) SetProviderReference(p *xpv1.Reference) { m.Ref = p } // GetProviderReference gets the ProviderReference. -func (m *ProviderReferencer) GetProviderReference() *v1alpha1.Reference { return m.Ref } +func (m *ProviderReferencer) GetProviderReference() *xpv1.Reference { return m.Ref } // ProviderConfigReferencer is a mock that implements ProviderConfigReferencer interface. -type ProviderConfigReferencer struct{ Ref *v1alpha1.Reference } +type ProviderConfigReferencer struct{ Ref *xpv1.Reference } // SetProviderConfigReference sets the ProviderConfigReference. -func (m *ProviderConfigReferencer) SetProviderConfigReference(p *v1alpha1.Reference) { m.Ref = p } +func (m *ProviderConfigReferencer) SetProviderConfigReference(p *xpv1.Reference) { m.Ref = p } // GetProviderConfigReference gets the ProviderConfigReference. -func (m *ProviderConfigReferencer) GetProviderConfigReference() *v1alpha1.Reference { return m.Ref } +func (m *ProviderConfigReferencer) GetProviderConfigReference() *xpv1.Reference { return m.Ref } // RequiredProviderConfigReferencer is a mock that implements the // RequiredProviderConfigReferencer interface. -type RequiredProviderConfigReferencer struct{ Ref v1alpha1.Reference } +type RequiredProviderConfigReferencer struct{ Ref xpv1.Reference } // SetProviderConfigReference sets the ProviderConfigReference. -func (m *RequiredProviderConfigReferencer) SetProviderConfigReference(p v1alpha1.Reference) { +func (m *RequiredProviderConfigReferencer) SetProviderConfigReference(p xpv1.Reference) { m.Ref = p } // GetProviderConfigReference gets the ProviderConfigReference. -func (m *RequiredProviderConfigReferencer) GetProviderConfigReference() v1alpha1.Reference { +func (m *RequiredProviderConfigReferencer) GetProviderConfigReference() xpv1.Reference { return m.Ref } // RequiredTypedResourceReferencer is a mock that implements the // RequiredTypedResourceReferencer interface. -type RequiredTypedResourceReferencer struct{ Ref v1alpha1.TypedReference } +type RequiredTypedResourceReferencer struct{ Ref xpv1.TypedReference } // SetResourceReference sets the ResourceReference. -func (m *RequiredTypedResourceReferencer) SetResourceReference(p v1alpha1.TypedReference) { +func (m *RequiredTypedResourceReferencer) SetResourceReference(p xpv1.TypedReference) { m.Ref = p } // GetResourceReference gets the ResourceReference. -func (m *RequiredTypedResourceReferencer) GetResourceReference() v1alpha1.TypedReference { +func (m *RequiredTypedResourceReferencer) GetResourceReference() xpv1.TypedReference { return m.Ref } // LocalConnectionSecretWriterTo is a mock that implements LocalConnectionSecretWriterTo interface. type LocalConnectionSecretWriterTo struct { - Ref *v1alpha1.LocalSecretReference + Ref *xpv1.LocalSecretReference } // SetWriteConnectionSecretToReference sets the WriteConnectionSecretToReference. -func (m *LocalConnectionSecretWriterTo) SetWriteConnectionSecretToReference(r *v1alpha1.LocalSecretReference) { +func (m *LocalConnectionSecretWriterTo) SetWriteConnectionSecretToReference(r *xpv1.LocalSecretReference) { m.Ref = r } // GetWriteConnectionSecretToReference gets the WriteConnectionSecretToReference. -func (m *LocalConnectionSecretWriterTo) GetWriteConnectionSecretToReference() *v1alpha1.LocalSecretReference { +func (m *LocalConnectionSecretWriterTo) GetWriteConnectionSecretToReference() *xpv1.LocalSecretReference { return m.Ref } // ConnectionSecretWriterTo is a mock that implements ConnectionSecretWriterTo interface. -type ConnectionSecretWriterTo struct{ Ref *v1alpha1.SecretReference } +type ConnectionSecretWriterTo struct{ Ref *xpv1.SecretReference } // SetWriteConnectionSecretToReference sets the WriteConnectionSecretToReference. -func (m *ConnectionSecretWriterTo) SetWriteConnectionSecretToReference(r *v1alpha1.SecretReference) { +func (m *ConnectionSecretWriterTo) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { m.Ref = r } // GetWriteConnectionSecretToReference gets the WriteConnectionSecretToReference. -func (m *ConnectionSecretWriterTo) GetWriteConnectionSecretToReference() *v1alpha1.SecretReference { +func (m *ConnectionSecretWriterTo) GetWriteConnectionSecretToReference() *xpv1.SecretReference { return m.Ref } // Orphanable implements the Orphanable interface. -type Orphanable struct{ Policy v1alpha1.DeletionPolicy } +type Orphanable struct{ Policy xpv1.DeletionPolicy } // SetDeletionPolicy sets the DeletionPolicy. -func (m *Orphanable) SetDeletionPolicy(p v1alpha1.DeletionPolicy) { m.Policy = p } +func (m *Orphanable) SetDeletionPolicy(p xpv1.DeletionPolicy) { m.Policy = p } // GetDeletionPolicy gets the DeletionPolicy. -func (m *Orphanable) GetDeletionPolicy() v1alpha1.DeletionPolicy { return m.Policy } +func (m *Orphanable) GetDeletionPolicy() xpv1.DeletionPolicy { return m.Policy } // CompositionReferencer is a mock that implements CompositionReferencer interface. type CompositionReferencer struct{ Ref *corev1.ObjectReference } @@ -238,7 +238,7 @@ type Managed struct { ProviderConfigReferencer ConnectionSecretWriterTo Orphanable - v1alpha1.ConditionedStatus + xpv1.ConditionedStatus } // GetObjectKind returns schema.ObjectKind. @@ -266,7 +266,7 @@ type Composite struct { ClaimReferencer ConnectionSecretWriterTo - v1alpha1.ConditionedStatus + xpv1.ConditionedStatus ConnectionDetailsLastPublishedTimer } @@ -290,7 +290,7 @@ func (m *Composite) DeepCopyObject() runtime.Object { type Composed struct { metav1.ObjectMeta ConnectionSecretWriterTo - v1alpha1.ConditionedStatus + xpv1.ConditionedStatus } // GetObjectKind returns schema.ObjectKind. @@ -317,7 +317,7 @@ type CompositeClaim struct { CompositeResourceReferencer LocalConnectionSecretWriterTo - v1alpha1.ConditionedStatus + xpv1.ConditionedStatus ConnectionDetailsLastPublishedTimer } @@ -387,16 +387,16 @@ type MockConnectionSecretOwner struct { runtime.Object metav1.ObjectMeta - Ref *v1alpha1.SecretReference + Ref *xpv1.SecretReference } // GetWriteConnectionSecretToReference returns the connection secret reference. -func (m *MockConnectionSecretOwner) GetWriteConnectionSecretToReference() *v1alpha1.SecretReference { +func (m *MockConnectionSecretOwner) GetWriteConnectionSecretToReference() *xpv1.SecretReference { return m.Ref } // SetWriteConnectionSecretToReference sets the connection secret reference. -func (m *MockConnectionSecretOwner) SetWriteConnectionSecretToReference(r *v1alpha1.SecretReference) { +func (m *MockConnectionSecretOwner) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { m.Ref = r } @@ -422,16 +422,16 @@ type MockLocalConnectionSecretOwner struct { runtime.Object metav1.ObjectMeta - Ref *v1alpha1.LocalSecretReference + Ref *xpv1.LocalSecretReference } // GetWriteConnectionSecretToReference returns the connection secret reference. -func (m *MockLocalConnectionSecretOwner) GetWriteConnectionSecretToReference() *v1alpha1.LocalSecretReference { +func (m *MockLocalConnectionSecretOwner) GetWriteConnectionSecretToReference() *xpv1.LocalSecretReference { return m.Ref } // SetWriteConnectionSecretToReference sets the connection secret reference. -func (m *MockLocalConnectionSecretOwner) SetWriteConnectionSecretToReference(r *v1alpha1.LocalSecretReference) { +func (m *MockLocalConnectionSecretOwner) SetWriteConnectionSecretToReference(r *xpv1.LocalSecretReference) { m.Ref = r } @@ -456,7 +456,7 @@ type ProviderConfig struct { metav1.ObjectMeta UserCounter - v1alpha1.ConditionedStatus + xpv1.ConditionedStatus } // GetObjectKind returns schema.ObjectKind. diff --git a/pkg/resource/interfaces.go b/pkg/resource/interfaces.go index 169d33d93..7e0712e36 100644 --- a/pkg/resource/interfaces.go +++ b/pkg/resource/interfaces.go @@ -23,14 +23,14 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) // A Conditioned may have conditions set or retrieved. Conditions are typically // indicate the status of both a resource and its reconciliation process. type Conditioned interface { - SetConditions(c ...v1alpha1.Condition) - GetCondition(v1alpha1.ConditionType) v1alpha1.Condition + SetConditions(c ...xpv1.Condition) + GetCondition(xpv1.ConditionType) xpv1.Condition } // A ClaimReferencer may reference a resource claim. @@ -48,46 +48,46 @@ type ManagedResourceReferencer interface { // A LocalConnectionSecretWriterTo may write a connection secret to its own // namespace. type LocalConnectionSecretWriterTo interface { - SetWriteConnectionSecretToReference(r *v1alpha1.LocalSecretReference) - GetWriteConnectionSecretToReference() *v1alpha1.LocalSecretReference + SetWriteConnectionSecretToReference(r *xpv1.LocalSecretReference) + GetWriteConnectionSecretToReference() *xpv1.LocalSecretReference } // A ConnectionSecretWriterTo may write a connection secret to an arbitrary // namespace. type ConnectionSecretWriterTo interface { - SetWriteConnectionSecretToReference(r *v1alpha1.SecretReference) - GetWriteConnectionSecretToReference() *v1alpha1.SecretReference + SetWriteConnectionSecretToReference(r *xpv1.SecretReference) + GetWriteConnectionSecretToReference() *xpv1.SecretReference } // An Orphanable resource may specify a DeletionPolicy. type Orphanable interface { - SetDeletionPolicy(p v1alpha1.DeletionPolicy) - GetDeletionPolicy() v1alpha1.DeletionPolicy + SetDeletionPolicy(p xpv1.DeletionPolicy) + GetDeletionPolicy() xpv1.DeletionPolicy } // A ProviderReferencer may reference a provider resource. type ProviderReferencer interface { - GetProviderReference() *v1alpha1.Reference - SetProviderReference(p *v1alpha1.Reference) + GetProviderReference() *xpv1.Reference + SetProviderReference(p *xpv1.Reference) } // A ProviderConfigReferencer may reference a provider config resource. type ProviderConfigReferencer interface { - GetProviderConfigReference() *v1alpha1.Reference - SetProviderConfigReference(p *v1alpha1.Reference) + GetProviderConfigReference() *xpv1.Reference + SetProviderConfigReference(p *xpv1.Reference) } // A RequiredProviderConfigReferencer may reference a provider config resource. // Unlike ProviderConfigReferencer, the reference is required (i.e. not nil). type RequiredProviderConfigReferencer interface { - GetProviderConfigReference() v1alpha1.Reference - SetProviderConfigReference(p v1alpha1.Reference) + GetProviderConfigReference() xpv1.Reference + SetProviderConfigReference(p xpv1.Reference) } // A RequiredTypedResourceReferencer can reference a resource. type RequiredTypedResourceReferencer interface { - SetResourceReference(r v1alpha1.TypedReference) - GetResourceReference() v1alpha1.TypedReference + SetResourceReference(r xpv1.TypedReference) + GetResourceReference() xpv1.TypedReference } // A Finalizer manages the finalizers on the resource. diff --git a/pkg/resource/providerconfig.go b/pkg/resource/providerconfig.go index e8178e967..f5938deb1 100644 --- a/pkg/resource/providerconfig.go +++ b/pkg/resource/providerconfig.go @@ -24,7 +24,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/meta" ) @@ -86,10 +86,10 @@ func (u *ProviderConfigUsageTracker) Track(ctx context.Context, mg Managed) erro } pcu.SetName(string(mg.GetUID())) - pcu.SetLabels(map[string]string{v1alpha1.LabelKeyProviderName: ref.Name}) + pcu.SetLabels(map[string]string{xpv1.LabelKeyProviderName: ref.Name}) pcu.SetOwnerReferences([]metav1.OwnerReference{meta.AsController(meta.TypedReferenceTo(mg, gvk))}) - pcu.SetProviderConfigReference(v1alpha1.Reference{Name: ref.Name}) - pcu.SetResourceReference(v1alpha1.TypedReference{ + pcu.SetProviderConfigReference(xpv1.Reference{Name: ref.Name}) + pcu.SetResourceReference(xpv1.TypedReference{ APIVersion: gvk.GroupVersion().String(), Kind: gvk.Kind, Name: mg.GetName(), diff --git a/pkg/resource/providerconfig_test.go b/pkg/resource/providerconfig_test.go index 5dd15cfe2..599f8fc9d 100644 --- a/pkg/resource/providerconfig_test.go +++ b/pkg/resource/providerconfig_test.go @@ -24,7 +24,7 @@ import ( "github.com/pkg/errors" "k8s.io/apimachinery/pkg/runtime" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/resource/fake" "github.com/crossplane/crossplane-runtime/pkg/test" ) @@ -72,7 +72,7 @@ func TestTrack(t *testing.T) { // new one we would apply. current := &fake.ProviderConfigUsage{ RequiredProviderConfigReferencer: fake.RequiredProviderConfigReferencer{ - Ref: v1alpha1.Reference{Name: name}, + Ref: xpv1.Reference{Name: name}, }, } if err := fn(context.TODO(), current, nil); err != nil { @@ -86,7 +86,7 @@ func TestTrack(t *testing.T) { args: args{ mg: &fake.Managed{ ProviderConfigReferencer: fake.ProviderConfigReferencer{ - Ref: &v1alpha1.Reference{Name: name}, + Ref: &xpv1.Reference{Name: name}, }, }, }, @@ -103,7 +103,7 @@ func TestTrack(t *testing.T) { args: args{ mg: &fake.Managed{ ProviderConfigReferencer: fake.ProviderConfigReferencer{ - Ref: &v1alpha1.Reference{Name: name}, + Ref: &xpv1.Reference{Name: name}, }, }, }, diff --git a/pkg/resource/resource.go b/pkg/resource/resource.go index b0dab1757..48f3973c4 100644 --- a/pkg/resource/resource.go +++ b/pkg/resource/resource.go @@ -29,7 +29,7 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/meta" ) @@ -201,7 +201,7 @@ func IsAPIError(err error) bool { } // IsConditionTrue returns if condition status is true -func IsConditionTrue(c v1alpha1.Condition) bool { +func IsConditionTrue(c xpv1.Condition) bool { return c.Status == corev1.ConditionTrue } diff --git a/pkg/resource/resource_test.go b/pkg/resource/resource_test.go index e6566c256..41fb247f7 100644 --- a/pkg/resource/resource_test.go +++ b/pkg/resource/resource_test.go @@ -29,7 +29,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/resource/fake" "github.com/crossplane/crossplane-runtime/pkg/test" ) @@ -68,7 +68,7 @@ func TestLocalConnectionSecretFor(t *testing.T) { Name: name, UID: uid, }, - Ref: &v1alpha1.LocalSecretReference{Name: secretName}, + Ref: &xpv1.LocalSecretReference{Name: secretName}, }, kind: MockOwnerGVK, }, @@ -121,7 +121,7 @@ func TestConnectionSecretFor(t *testing.T) { Name: name, UID: uid, }, - Ref: &v1alpha1.SecretReference{Namespace: namespace, Name: secretName}, + Ref: &xpv1.SecretReference{Namespace: namespace, Name: secretName}, }, kind: MockOwnerGVK, }, @@ -304,23 +304,23 @@ func TestIgnore(t *testing.T) { func TestIsConditionTrue(t *testing.T) { cases := map[string]struct { - c v1alpha1.Condition + c xpv1.Condition want bool }{ "IsTrue": { - c: v1alpha1.Condition{Status: corev1.ConditionTrue}, + c: xpv1.Condition{Status: corev1.ConditionTrue}, want: true, }, "IsFalse": { - c: v1alpha1.Condition{Status: corev1.ConditionFalse}, + c: xpv1.Condition{Status: corev1.ConditionFalse}, want: false, }, "IsUnknown": { - c: v1alpha1.Condition{Status: corev1.ConditionUnknown}, + c: xpv1.Condition{Status: corev1.ConditionUnknown}, want: false, }, "IsUnset": { - c: v1alpha1.Condition{}, + c: xpv1.Condition{}, want: false, }, } @@ -568,7 +568,7 @@ func TestGetExternalTags(t *testing.T) { o: &fake.Managed{ObjectMeta: metav1.ObjectMeta{ Name: name, }, - ProviderReferencer: fake.ProviderReferencer{Ref: &v1alpha1.Reference{Name: provName}}, + ProviderReferencer: fake.ProviderReferencer{Ref: &xpv1.Reference{Name: provName}}, }, want: map[string]string{ ExternalResourceTagKeyKind: strings.ToLower((&fake.Managed{}).GetObjectKind().GroupVersionKind().GroupKind().String()), @@ -580,7 +580,7 @@ func TestGetExternalTags(t *testing.T) { o: &fake.Managed{ObjectMeta: metav1.ObjectMeta{ Name: name, }, - ProviderConfigReferencer: fake.ProviderConfigReferencer{Ref: &v1alpha1.Reference{Name: provName}}, + ProviderConfigReferencer: fake.ProviderConfigReferencer{Ref: &xpv1.Reference{Name: provName}}, }, want: map[string]string{ ExternalResourceTagKeyKind: strings.ToLower((&fake.Managed{}).GetObjectKind().GroupVersionKind().GroupKind().String()), diff --git a/pkg/resource/unstructured/claim/claim.go b/pkg/resource/unstructured/claim/claim.go index 8fc8df983..9d7867a98 100644 --- a/pkg/resource/unstructured/claim/claim.go +++ b/pkg/resource/unstructured/claim/claim.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/fieldpath" ) @@ -40,7 +40,7 @@ func WithGroupVersionKind(gvk schema.GroupVersionKind) Option { // WithConditions returns an Option that sets the supplied conditions on an // unstructured composite resource claim. -func WithConditions(c ...v1alpha1.Condition) Option { +func WithConditions(c ...xpv1.Condition) Option { return func(cr *Unstructured) { cr.SetConditions(c...) } @@ -108,8 +108,8 @@ func (c *Unstructured) SetResourceReference(ref *corev1.ObjectReference) { } // GetWriteConnectionSecretToReference of this composite resource claim. -func (c *Unstructured) GetWriteConnectionSecretToReference() *v1alpha1.LocalSecretReference { - out := &v1alpha1.LocalSecretReference{} +func (c *Unstructured) GetWriteConnectionSecretToReference() *xpv1.LocalSecretReference { + out := &xpv1.LocalSecretReference{} if err := fieldpath.Pave(c.Object).GetValueInto("spec.writeConnectionSecretToRef", out); err != nil { return nil } @@ -117,23 +117,23 @@ func (c *Unstructured) GetWriteConnectionSecretToReference() *v1alpha1.LocalSecr } // SetWriteConnectionSecretToReference of this composite resource claim. -func (c *Unstructured) SetWriteConnectionSecretToReference(ref *v1alpha1.LocalSecretReference) { +func (c *Unstructured) SetWriteConnectionSecretToReference(ref *xpv1.LocalSecretReference) { _ = fieldpath.Pave(c.Object).SetValue("spec.writeConnectionSecretToRef", ref) } // GetCondition of this composite resource claim. -func (c *Unstructured) GetCondition(ct v1alpha1.ConditionType) v1alpha1.Condition { - conditioned := v1alpha1.ConditionedStatus{} +func (c *Unstructured) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + conditioned := xpv1.ConditionedStatus{} // The path is directly `status` because conditions are inline. if err := fieldpath.Pave(c.Object).GetValueInto("status", &conditioned); err != nil { - return v1alpha1.Condition{} + return xpv1.Condition{} } return conditioned.GetCondition(ct) } // SetConditions of this composite resource claim. -func (c *Unstructured) SetConditions(conditions ...v1alpha1.Condition) { - conditioned := v1alpha1.ConditionedStatus{} +func (c *Unstructured) SetConditions(conditions ...xpv1.Condition) { + conditioned := xpv1.ConditionedStatus{} // The path is directly `status` because conditions are inline. _ = fieldpath.Pave(c.Object).GetValueInto("status", &conditioned) conditioned.SetConditions(conditions...) diff --git a/pkg/resource/unstructured/claim/claim_test.go b/pkg/resource/unstructured/claim/claim_test.go index 2db0a56fc..14487d5ba 100644 --- a/pkg/resource/unstructured/claim/claim_test.go +++ b/pkg/resource/unstructured/claim/claim_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) func TestWithGroupVersionKind(t *testing.T) { @@ -66,32 +66,32 @@ func TestConditions(t *testing.T) { cases := map[string]struct { reason string u *Unstructured - set []v1alpha1.Condition - get v1alpha1.ConditionType - want v1alpha1.Condition + set []xpv1.Condition + get xpv1.ConditionType + want xpv1.Condition }{ "NewCondition": { reason: "It should be possible to set a condition of an empty Unstructured.", u: New(), - set: []v1alpha1.Condition{v1alpha1.Available(), v1alpha1.ReconcileSuccess()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Available(), + set: []xpv1.Condition{xpv1.Available(), xpv1.ReconcileSuccess()}, + get: xpv1.TypeReady, + want: xpv1.Available(), }, "ExistingCondition": { reason: "It should be possible to overwrite a condition that is already set.", - u: New(WithConditions(v1alpha1.Creating())), - set: []v1alpha1.Condition{v1alpha1.Available()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Available(), + u: New(WithConditions(xpv1.Creating())), + set: []xpv1.Condition{xpv1.Available()}, + get: xpv1.TypeReady, + want: xpv1.Available(), }, "WeirdStatus": { reason: "It should not be possible to set a condition when status is not an object.", u: &Unstructured{unstructured.Unstructured{Object: map[string]interface{}{ "status": "wat", }}}, - set: []v1alpha1.Condition{v1alpha1.Available()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Condition{}, + set: []xpv1.Condition{xpv1.Available()}, + get: xpv1.TypeReady, + want: xpv1.Condition{}, }, "WeirdStatusConditions": { reason: "Conditions should be overwritten if they are not an object.", @@ -100,9 +100,9 @@ func TestConditions(t *testing.T) { "conditions": "wat", }, }}}, - set: []v1alpha1.Condition{v1alpha1.Available()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Available(), + set: []xpv1.Condition{xpv1.Available()}, + get: xpv1.TypeReady, + want: xpv1.Available(), }, } @@ -192,11 +192,11 @@ func TestResourceReference(t *testing.T) { } func TestWriteConnectionSecretToReference(t *testing.T) { - ref := &v1alpha1.LocalSecretReference{Name: "cool"} + ref := &xpv1.LocalSecretReference{Name: "cool"} cases := map[string]struct { u *Unstructured - set *v1alpha1.LocalSecretReference - want *v1alpha1.LocalSecretReference + set *xpv1.LocalSecretReference + want *xpv1.LocalSecretReference }{ "NewRef": { u: New(), diff --git a/pkg/resource/unstructured/composed/composed.go b/pkg/resource/unstructured/composed/composed.go index 53b20d68b..cf3795da4 100644 --- a/pkg/resource/unstructured/composed/composed.go +++ b/pkg/resource/unstructured/composed/composed.go @@ -21,7 +21,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/fieldpath" ) @@ -41,7 +41,7 @@ func FromReference(ref corev1.ObjectReference) Option { // WithConditions returns an Option that sets the supplied conditions on an // unstructured composed resource. -func WithConditions(c ...v1alpha1.Condition) Option { +func WithConditions(c ...xpv1.Condition) Option { return func(cr *Unstructured) { cr.SetConditions(c...) } @@ -67,18 +67,18 @@ func (cr *Unstructured) GetUnstructured() *unstructured.Unstructured { } // GetCondition of this Composed resource. -func (cr *Unstructured) GetCondition(ct v1alpha1.ConditionType) v1alpha1.Condition { - conditioned := v1alpha1.ConditionedStatus{} +func (cr *Unstructured) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + conditioned := xpv1.ConditionedStatus{} // The path is directly `status` because conditions are inline. if err := fieldpath.Pave(cr.Object).GetValueInto("status", &conditioned); err != nil { - return v1alpha1.Condition{} + return xpv1.Condition{} } return conditioned.GetCondition(ct) } // SetConditions of this Composed resource. -func (cr *Unstructured) SetConditions(c ...v1alpha1.Condition) { - conditioned := v1alpha1.ConditionedStatus{} +func (cr *Unstructured) SetConditions(c ...xpv1.Condition) { + conditioned := xpv1.ConditionedStatus{} // The path is directly `status` because conditions are inline. _ = fieldpath.Pave(cr.Object).GetValueInto("status", &conditioned) conditioned.SetConditions(c...) @@ -86,8 +86,8 @@ func (cr *Unstructured) SetConditions(c ...v1alpha1.Condition) { } // GetWriteConnectionSecretToReference of this Composed resource. -func (cr *Unstructured) GetWriteConnectionSecretToReference() *v1alpha1.SecretReference { - out := &v1alpha1.SecretReference{} +func (cr *Unstructured) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + out := &xpv1.SecretReference{} if err := fieldpath.Pave(cr.Object).GetValueInto("spec.writeConnectionSecretToRef", out); err != nil { return nil } @@ -95,6 +95,6 @@ func (cr *Unstructured) GetWriteConnectionSecretToReference() *v1alpha1.SecretRe } // SetWriteConnectionSecretToReference of this Composed resource. -func (cr *Unstructured) SetWriteConnectionSecretToReference(r *v1alpha1.SecretReference) { +func (cr *Unstructured) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { _ = fieldpath.Pave(cr.Object).SetValue("spec.writeConnectionSecretToRef", r) } diff --git a/pkg/resource/unstructured/composed/composed_test.go b/pkg/resource/unstructured/composed/composed_test.go index 265cdbec8..18d6ded3d 100644 --- a/pkg/resource/unstructured/composed/composed_test.go +++ b/pkg/resource/unstructured/composed/composed_test.go @@ -23,7 +23,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) func TestFromReference(t *testing.T) { @@ -67,32 +67,32 @@ func TestConditions(t *testing.T) { cases := map[string]struct { reason string u *Unstructured - set []v1alpha1.Condition - get v1alpha1.ConditionType - want v1alpha1.Condition + set []xpv1.Condition + get xpv1.ConditionType + want xpv1.Condition }{ "NewCondition": { reason: "It should be possible to set a condition of an empty Unstructured.", u: New(), - set: []v1alpha1.Condition{v1alpha1.Available(), v1alpha1.ReconcileSuccess()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Available(), + set: []xpv1.Condition{xpv1.Available(), xpv1.ReconcileSuccess()}, + get: xpv1.TypeReady, + want: xpv1.Available(), }, "ExistingCondition": { reason: "It should be possible to overwrite a condition that is already set.", - u: New(WithConditions(v1alpha1.Creating())), - set: []v1alpha1.Condition{v1alpha1.Available()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Available(), + u: New(WithConditions(xpv1.Creating())), + set: []xpv1.Condition{xpv1.Available()}, + get: xpv1.TypeReady, + want: xpv1.Available(), }, "WeirdStatus": { reason: "It should not be possible to set a condition when status is not an object.", u: &Unstructured{unstructured.Unstructured{Object: map[string]interface{}{ "status": "wat", }}}, - set: []v1alpha1.Condition{v1alpha1.Available()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Condition{}, + set: []xpv1.Condition{xpv1.Available()}, + get: xpv1.TypeReady, + want: xpv1.Condition{}, }, "WeirdStatusConditions": { reason: "Conditions should be overwritten if they are not an object.", @@ -101,9 +101,9 @@ func TestConditions(t *testing.T) { "conditions": "wat", }, }}}, - set: []v1alpha1.Condition{v1alpha1.Available()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Available(), + set: []xpv1.Condition{xpv1.Available()}, + get: xpv1.TypeReady, + want: xpv1.Available(), }, } @@ -119,11 +119,11 @@ func TestConditions(t *testing.T) { } func TestWriteConnectionSecretToReference(t *testing.T) { - ref := &v1alpha1.SecretReference{Namespace: "ns", Name: "cool"} + ref := &xpv1.SecretReference{Namespace: "ns", Name: "cool"} cases := map[string]struct { u *Unstructured - set *v1alpha1.SecretReference - want *v1alpha1.SecretReference + set *xpv1.SecretReference + want *xpv1.SecretReference }{ "NewRef": { u: New(), diff --git a/pkg/resource/unstructured/composite/composite.go b/pkg/resource/unstructured/composite/composite.go index bb1b0e0a1..d4a0ffbca 100644 --- a/pkg/resource/unstructured/composite/composite.go +++ b/pkg/resource/unstructured/composite/composite.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/fieldpath" ) @@ -40,7 +40,7 @@ func WithGroupVersionKind(gvk schema.GroupVersionKind) Option { // WithConditions returns an Option that sets the supplied conditions on an // unstructured composite resource. -func WithConditions(c ...v1alpha1.Condition) Option { +func WithConditions(c ...xpv1.Condition) Option { return func(cr *Unstructured) { cr.SetConditions(c...) } @@ -130,8 +130,8 @@ func (c *Unstructured) SetResourceReferences(refs []corev1.ObjectReference) { } // GetWriteConnectionSecretToReference of this Composite resource. -func (c *Unstructured) GetWriteConnectionSecretToReference() *v1alpha1.SecretReference { - out := &v1alpha1.SecretReference{} +func (c *Unstructured) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + out := &xpv1.SecretReference{} if err := fieldpath.Pave(c.Object).GetValueInto("spec.writeConnectionSecretToRef", out); err != nil { return nil } @@ -139,23 +139,23 @@ func (c *Unstructured) GetWriteConnectionSecretToReference() *v1alpha1.SecretRef } // SetWriteConnectionSecretToReference of this Composite resource. -func (c *Unstructured) SetWriteConnectionSecretToReference(ref *v1alpha1.SecretReference) { +func (c *Unstructured) SetWriteConnectionSecretToReference(ref *xpv1.SecretReference) { _ = fieldpath.Pave(c.Object).SetValue("spec.writeConnectionSecretToRef", ref) } // GetCondition of this Composite resource. -func (c *Unstructured) GetCondition(ct v1alpha1.ConditionType) v1alpha1.Condition { - conditioned := v1alpha1.ConditionedStatus{} +func (c *Unstructured) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + conditioned := xpv1.ConditionedStatus{} // The path is directly `status` because conditions are inline. if err := fieldpath.Pave(c.Object).GetValueInto("status", &conditioned); err != nil { - return v1alpha1.Condition{} + return xpv1.Condition{} } return conditioned.GetCondition(ct) } // SetConditions of this Composite resource. -func (c *Unstructured) SetConditions(conditions ...v1alpha1.Condition) { - conditioned := v1alpha1.ConditionedStatus{} +func (c *Unstructured) SetConditions(conditions ...xpv1.Condition) { + conditioned := xpv1.ConditionedStatus{} // The path is directly `status` because conditions are inline. _ = fieldpath.Pave(c.Object).GetValueInto("status", &conditioned) conditioned.SetConditions(conditions...) diff --git a/pkg/resource/unstructured/composite/composite_test.go b/pkg/resource/unstructured/composite/composite_test.go index cec197dc0..15b701e2c 100644 --- a/pkg/resource/unstructured/composite/composite_test.go +++ b/pkg/resource/unstructured/composite/composite_test.go @@ -27,7 +27,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" - "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) func TestWithGroupVersionKind(t *testing.T) { @@ -66,32 +66,32 @@ func TestConditions(t *testing.T) { cases := map[string]struct { reason string u *Unstructured - set []v1alpha1.Condition - get v1alpha1.ConditionType - want v1alpha1.Condition + set []xpv1.Condition + get xpv1.ConditionType + want xpv1.Condition }{ "NewCondition": { reason: "It should be possible to set a condition of an empty Unstructured.", u: New(), - set: []v1alpha1.Condition{v1alpha1.Available(), v1alpha1.ReconcileSuccess()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Available(), + set: []xpv1.Condition{xpv1.Available(), xpv1.ReconcileSuccess()}, + get: xpv1.TypeReady, + want: xpv1.Available(), }, "ExistingCondition": { reason: "It should be possible to overwrite a condition that is already set.", - u: New(WithConditions(v1alpha1.Creating())), - set: []v1alpha1.Condition{v1alpha1.Available()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Available(), + u: New(WithConditions(xpv1.Creating())), + set: []xpv1.Condition{xpv1.Available()}, + get: xpv1.TypeReady, + want: xpv1.Available(), }, "WeirdStatus": { reason: "It should not be possible to set a condition when status is not an object.", u: &Unstructured{unstructured.Unstructured{Object: map[string]interface{}{ "status": "wat", }}}, - set: []v1alpha1.Condition{v1alpha1.Available()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Condition{}, + set: []xpv1.Condition{xpv1.Available()}, + get: xpv1.TypeReady, + want: xpv1.Condition{}, }, "WeirdStatusConditions": { reason: "Conditions should be overwritten if they are not an object.", @@ -100,9 +100,9 @@ func TestConditions(t *testing.T) { "conditions": "wat", }, }}}, - set: []v1alpha1.Condition{v1alpha1.Available()}, - get: v1alpha1.TypeReady, - want: v1alpha1.Available(), + set: []xpv1.Condition{xpv1.Available()}, + get: xpv1.TypeReady, + want: xpv1.Available(), }, } @@ -217,11 +217,11 @@ func TestResourceReferences(t *testing.T) { } func TestWriteConnectionSecretToReference(t *testing.T) { - ref := &v1alpha1.SecretReference{Namespace: "ns", Name: "cool"} + ref := &xpv1.SecretReference{Namespace: "ns", Name: "cool"} cases := map[string]struct { u *Unstructured - set *v1alpha1.SecretReference - want *v1alpha1.SecretReference + set *xpv1.SecretReference + want *xpv1.SecretReference }{ "NewRef": { u: New(), diff --git a/pkg/test/cmp.go b/pkg/test/cmp.go index 8b32bf561..8717674ab 100644 --- a/pkg/test/cmp.go +++ b/pkg/test/cmp.go @@ -22,7 +22,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - corev1alpha1 "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) // TODO(negz): Replace this if a similar option is added to cmpopts per @@ -50,5 +50,5 @@ func EquateErrors() cmp.Option { // EquateConditions sorts any slices of Condition before comparing them. func EquateConditions() cmp.Option { - return cmpopts.SortSlices(func(i, j corev1alpha1.Condition) bool { return i.Type < j.Type }) + return cmpopts.SortSlices(func(i, j xpv1.Condition) bool { return i.Type < j.Type }) }