Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace TPR with CRD #419

Merged
merged 23 commits into from Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 0 additions & 19 deletions api/extensions/tprs.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions api/install/install.go

This file was deleted.

28 changes: 0 additions & 28 deletions api/register_v1beta1.go

This file was deleted.

7 changes: 6 additions & 1 deletion api/certificate.go → apis/voyager/certificate.go
@@ -1,4 +1,4 @@
package api
package voyager

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -11,6 +11,9 @@ const (
ResourceTypeCertificate = "certificates"
)

// +genclient=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type Certificate struct {
metav1.TypeMeta `json:",inline,omitempty"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down Expand Up @@ -58,6 +61,8 @@ type ACMECertificateDetails struct {
AccountRef string `json:"accountRef,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type CertificateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions apis/voyager/doc.go
@@ -0,0 +1,5 @@
// Package voyager is the internal version of the API.

// +k8s:deepcopy-gen=package,register
// +groupName=voyager.appscode.com
package voyager
7 changes: 6 additions & 1 deletion api/ingress.go → apis/voyager/ingress.go
@@ -1,4 +1,4 @@
package api
package voyager

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -12,6 +12,9 @@ const (
ResourceTypeIngress = "ingresses"
)

// +genclient=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Custom Ingress type for Voyager.
type Ingress struct {
metav1.TypeMeta `json:",inline"`
Expand All @@ -28,6 +31,8 @@ type Ingress struct {
Status IngressStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// IngressList is a collection of Ingress.
type IngressList struct {
metav1.TypeMeta `json:",inline"`
Expand Down
28 changes: 28 additions & 0 deletions apis/voyager/install/install.go
@@ -0,0 +1,28 @@
package install

import (
sapi "github.com/appscode/voyager/apis/voyager"
"github.com/appscode/voyager/apis/voyager/v1beta1"
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
)

// Install registers the API group and adds types to a scheme
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{
GroupName: sapi.GroupName,
VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version},
ImportPrefix: "github.com/appscode/voyager/apis/voyager",
RootScopedKinds: sets.NewString("CustomResourceDefinition"),
AddInternalObjectsToScheme: sapi.AddToScheme,
},
announced.VersionToSchemeFunc{
v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme,
},
).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil {
panic(err)
}
}
20 changes: 7 additions & 13 deletions api/register.go → apis/voyager/register.go
@@ -1,4 +1,4 @@
package api
package voyager

import (
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -11,12 +11,12 @@ const GroupName = "voyager.appscode.com"
// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
// Kind takes an unqualified kind and returns a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns back a Group qualified GroupResource
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
Expand All @@ -26,20 +26,14 @@ var (
AddToScheme = SchemeBuilder.AddToScheme
)

// Adds the list of known types to apiv1.Scheme.
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Ingress{},
&IngressList{},

&Certificate{},
&CertificateList{},

&Ingress{},
&IngressList{},
)
return nil
}

func (r *Ingress) GetObjectKind() schema.ObjectKind { return &r.TypeMeta }
func (obj *IngressList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }

func (obj *Certificate) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }
func (obj *CertificateList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta }