Skip to content

Commit

Permalink
Merge pull request #230 from hasheddan/unversioned-core
Browse files Browse the repository at this point in the history
Move embedded API types to common/v1
  • Loading branch information
hasheddan authored Nov 20, 2020
2 parents 1b691ef + 0b27607 commit 67c3928
Show file tree
Hide file tree
Showing 30 changed files with 286 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package v1

import (
"sort"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1
package v1

import (
"testing"
Expand Down
6 changes: 2 additions & 4 deletions apis/core/v1alpha1/doc.go → apis/common/v1/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
Loading

0 comments on commit 67c3928

Please sign in to comment.