Skip to content

Commit

Permalink
Update core/v1alpha1 imports to common/v1
Browse files Browse the repository at this point in the history
Updates all core/v1alpha1 imports to the common/v1, which is the new
home of these embedded API types.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
  • Loading branch information
hasheddan committed Nov 20, 2020
1 parent 52cc9b8 commit 0b27607
Show file tree
Hide file tree
Showing 24 changed files with 277 additions and 277 deletions.
10 changes: 5 additions & 5 deletions pkg/meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions pkg/meta/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -93,7 +93,7 @@ func TestTypedReferenceTo(t *testing.T) {
}
tests := map[string]struct {
args
want *v1alpha1.TypedReference
want *xpv1.TypedReference
}{
"WithTypeMeta": {
args: args{
Expand All @@ -110,7 +110,7 @@ func TestTypedReferenceTo(t *testing.T) {
Kind: kind,
},
},
want: &v1alpha1.TypedReference{
want: &xpv1.TypedReference{
APIVersion: groupVersion,
Kind: kind,
Name: name,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/managed/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/reconciler/managed/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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": {
Expand All @@ -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"}}},
},
},
}
Expand All @@ -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",
}},
Expand Down
42 changes: 21 additions & 21 deletions pkg/reconciler/managed/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}
}
Expand All @@ -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)
}

Expand All @@ -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
Expand All @@ -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)
}

Expand All @@ -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 {
Expand All @@ -633,15 +633,15 @@ 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 {
// If this is the first time we encounter this issue we'll be
// 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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}
}
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}
}
Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}
Loading

0 comments on commit 0b27607

Please sign in to comment.