Skip to content

Commit

Permalink
Move crds to api folder (#1209)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Aug 3, 2018
1 parent 38f381a commit 07767c7
Show file tree
Hide file tree
Showing 6 changed files with 459 additions and 456 deletions.
437 changes: 437 additions & 0 deletions api/crds/certificate.yaml

Large diffs are not rendered by default.

437 changes: 0 additions & 437 deletions apis/voyager/v1beta1/crds.yaml → api/crds/ingress.yaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions apis/voyager/v1beta1/certificate.go
Expand Up @@ -6,9 +6,9 @@ import (
)

const (
ResourceKindCertificate = "Certificate"
ResourceSingularCertificate = "certificate"
ResourcePluralCertificate = "certificates"
ResourceKindCertificate = "Certificate"
ResourceCertificate = "certificate"
ResourceCertificates = "certificates"
)

// +genclient
Expand Down
8 changes: 4 additions & 4 deletions apis/voyager/v1beta1/crd.go
Expand Up @@ -14,8 +14,8 @@ var (
func (r Ingress) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crdutils.NewCustomResourceDefinition(crdutils.Config{
Group: SchemeGroupVersion.Group,
Plural: ResourcePluralIngress,
Singular: ResourceSingularIngress,
Plural: ResourceIngresses,
Singular: ResourceIngress,
Kind: ResourceKindIngress,
ShortNames: []string{"ing"},
ResourceScope: string(apiextensions.NamespaceScoped),
Expand Down Expand Up @@ -57,8 +57,8 @@ func (r Ingress) CustomResourceDefinition() *apiextensions.CustomResourceDefinit
func (c Certificate) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crdutils.NewCustomResourceDefinition(crdutils.Config{
Group: SchemeGroupVersion.Group,
Plural: ResourcePluralCertificate,
Singular: ResourceSingularCertificate,
Plural: ResourceCertificates,
Singular: ResourceCertificate,
Kind: ResourceKindCertificate,
ShortNames: []string{"cert"},
ResourceScope: string(apiextensions.NamespaceScoped),
Expand Down
6 changes: 3 additions & 3 deletions apis/voyager/v1beta1/ingress.go
Expand Up @@ -7,9 +7,9 @@ import (
)

const (
ResourceKindIngress = "Ingress"
ResourceSingularIngress = "ingress"
ResourcePluralIngress = "ingresses"
ResourceKindIngress = "Ingress"
ResourceIngress = "ingress"
ResourceIngresses = "ingresses"
)

// +genclient
Expand Down
21 changes: 12 additions & 9 deletions hack/gencrd/main.go
Expand Up @@ -22,36 +22,39 @@ import (

func generateCRDDefinitions() {
filename := gort.GOPath() + "/src/github.com/appscode/voyager/apis/voyager/v1beta1/crds.yaml"
os.Remove(filename)

f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
err := os.MkdirAll(filepath.Join(gort.GOPath(), "/src/github.com/appscode/voyager/api/crds"), 0755)
if err != nil {
log.Fatal(err)
}
defer f.Close()

crds := []*crd_api.CustomResourceDefinition{
api.Ingress{}.CustomResourceDefinition(),
api.Certificate{}.CustomResourceDefinition(),
}
for _, crd := range crds {
err = crdutils.MarshallCrd(f, crd, "yaml")
filename := filepath.Join(gort.GOPath(), "/src/github.com/appscode/voyager/api/crds", crd.Spec.Names.Singular+".yaml")
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
log.Fatal(err)
}
crdutils.MarshallCrd(f, crd, "yaml")
f.Close()
}
}

func generateSwaggerJson() {
var (
Scheme = runtime.NewScheme()
Codecs = serializer.NewCodecFactory(Scheme)
Scheme = runtime.NewScheme()
Codecs = serializer.NewCodecFactory(Scheme)
)

install.Install(Scheme)

apispec, err := openapi.RenderOpenAPISpec(openapi.Config{
Scheme: Scheme,
Codecs: Codecs,
Scheme: Scheme,
Codecs: Codecs,
Info: spec.InfoProps{
Title: "Voyager",
Version: "v7.4.0",
Expand All @@ -69,8 +72,8 @@ func generateSwaggerJson() {
v1beta1.GetOpenAPIDefinitions,
},
Resources: []openapi.TypeInfo{
{v1beta1.SchemeGroupVersion, v1beta1.ResourcePluralCertificate, v1beta1.ResourceKindCertificate, true},
{v1beta1.SchemeGroupVersion, v1beta1.ResourcePluralIngress, v1beta1.ResourceKindIngress, true},
{v1beta1.SchemeGroupVersion, v1beta1.ResourceCertificates, v1beta1.ResourceKindCertificate, true},
{v1beta1.SchemeGroupVersion, v1beta1.ResourceIngresses, v1beta1.ResourceKindIngress, true},
},
})
if err != nil {
Expand Down

0 comments on commit 07767c7

Please sign in to comment.