-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
9,197 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Copyright (C) 2015 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
declare -a modules=("generator-v1alpha2" "generator-v1alpha3" "generator-v1beta1" "generator-v1") | ||
) | ||
|
||
for module in ${modules[*]} | ||
do | ||
echo "Compiling ${module}" | ||
cd $module | ||
make | ||
cd .. | ||
done |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright (C) 2015 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
SHELL := /bin/bash | ||
|
||
all: build | ||
|
||
build: gobuild | ||
pushd ../model-v1alpha2 && \ | ||
mvn clean install -o && \ | ||
popd | ||
|
||
gobuild: | ||
go mod vendor | ||
CGO_ENABLED=0 GO111MODULE=on GO15VENDOREXPERIMENT=1 go run -mod=vendor -a ./cmd/generate/generate.go > ../model-v1alpha2/src/main/resources/schema/certmanager-schema.json |
79 changes: 79 additions & 0 deletions
79
extensions/certmanager/generator-v1alpha2/cmd/generate/generate.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* Copyright (C) 2015 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/fabric8io/kubernetes-client/generator/pkg/schemagen" | ||
certmanageracme "github.com/jetstack/cert-manager/pkg/apis/acme/v1alpha2" | ||
certmanager "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2" | ||
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"reflect" | ||
) | ||
|
||
func main() { | ||
|
||
// the CRD List types for which the model should be generated | ||
// no other types need to be defined as they are auto discovered | ||
crdLists := map[reflect.Type]schemagen.CrdScope{ | ||
reflect.TypeOf(certmanager.CertificateList{}): schemagen.Namespaced, | ||
reflect.TypeOf(certmanager.CertificateRequestList{}): schemagen.Namespaced, | ||
reflect.TypeOf(certmanager.IssuerList{}): schemagen.Namespaced, | ||
reflect.TypeOf(certmanager.ClusterIssuerList{}): schemagen.Cluster, | ||
reflect.TypeOf(certmanageracme.ChallengeList{}): schemagen.Namespaced, | ||
reflect.TypeOf(certmanageracme.OrderList{}): schemagen.Namespaced, | ||
} | ||
|
||
// constraints and patterns for fields | ||
constraints := map[reflect.Type]map[string]*schemagen.Constraint{} | ||
|
||
// types that are manually defined in the model | ||
providedTypes := []schemagen.ProvidedType{} | ||
|
||
// go packages that are provided and where no generation is required and their corresponding java package | ||
providedPackages := map[string]string{ | ||
// external | ||
"k8s.io/api/core/v1": "io.fabric8.kubernetes.api.model", | ||
"k8s.io/apimachinery/pkg/apis/meta/v1": "io.fabric8.kubernetes.api.model", | ||
"k8s.io/apimachinery/pkg/api/resource": "io.fabric8.kubernetes.api.model", | ||
"k8s.io/apimachinery/pkg/runtime": "io.fabric8.kubernetes.api.model.runtime", | ||
} | ||
|
||
// mapping of go packages of this module to the resulting java package | ||
// optional ApiGroup and ApiVersion for the go package (which is added to the generated java class) | ||
packageMapping := map[string]schemagen.PackageInformation{ | ||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2": {JavaPackage: "io.fabric8.certmanager.api.model.v1alpha2", ApiGroup: "cert-manager.io", ApiVersion: "v1alpha2"}, | ||
"github.com/jetstack/cert-manager/pkg/apis/acme/v1alpha2": {JavaPackage: "io.fabric8.certmanager.api.model.acme.v1alpha2", ApiGroup: "cert-manager.io", ApiVersion: "v1alpha2"}, | ||
"github.com/jetstack/cert-manager/pkg/apis/meta/v1": {JavaPackage: "io.fabric8.certmanager.api.model.meta.v1", ApiGroup: "cert-manager.io", ApiVersion: "v1"}, | ||
} | ||
|
||
// converts all packages starting with <key> to a java package using an automated scheme: | ||
// - replace <key> with <value> aka "package prefix" | ||
// - replace '/' with '.' for a valid java package name | ||
// e.g. knative.dev/eventing/pkg/apis/messaging/v1beta1/ChannelTemplateSpec is mapped to "io.fabric8.knative.internal.eventing.pkg.apis.messaging.v1beta1.ChannelTemplateSpec" | ||
mappingSchema := map[string]string{} | ||
|
||
// overwriting some times | ||
manualTypeMap := map[reflect.Type]string{ | ||
reflect.TypeOf(v1.Time{}): "java.lang.String", | ||
reflect.TypeOf(apiextensions.JSON{}): "com.fasterxml.jackson.databind.JsonNode", | ||
} | ||
|
||
json := schemagen.GenerateSchema("http://fabric8.io/jetstack/CertManagerSchema#", crdLists, providedPackages, manualTypeMap, packageMapping, mappingSchema, providedTypes, constraints) | ||
|
||
fmt.Println(json) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module github.com/fabric8io/kubernetes-client/extensions/jetstack/generator | ||
|
||
require ( | ||
github.com/fabric8io/kubernetes-client/generator v0.0.0 | ||
github.com/jetstack/cert-manager v1.1.1 | ||
k8s.io/apiextensions-apiserver v0.19.0 | ||
k8s.io/apimachinery v0.19.0 | ||
) | ||
|
||
replace github.com/fabric8io/kubernetes-client/generator v0.0.0 => ./../../../generator | ||
|
||
go 1.15 |
Oops, something went wrong.