Skip to content

Commit

Permalink
Fix build failures due to duplicate files getting generated
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanKanojia committed Mar 18, 2021
1 parent d35e958 commit cf50243
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# limitations under the License.
#

VolumeSnapshotExtensionAdapter
io.fabric8.certmanager.client.CertManagerExtensionAdapter
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*#
#foreach ($i in ${model.values()})
io.fabric8.volumesnapshot.client.handlers.${i.name}Handler
#foreach ($m in ${model.values()})
#set ($group = $m.getPackageName().split("\.")[3])
#set ($annotations = $m.annotations)
#foreach ($annotation in $annotations)
#if ($annotation.getClassRef().getName().endsWith("Version"))
#set ($version = $annotation.getParameters().get("value"))
#end
#end

io.fabric8.certmanager.client.${group}.${version}.handlers.${m.name}Handler
#end
26 changes: 11 additions & 15 deletions extensions/certmanager/generator/cmd/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ package main
import (
"fmt"
"github.com/fabric8io/kubernetes-client/generator/pkg/schemagen"
certmanageracme "github.com/jetstack/cert-manager/pkg/apis/acme/v1"
certmanager "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
metav1 "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
certmanageracme "github.com/jetstack/cert-manager/pkg/apis/acme/v1"
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"reflect"
Expand All @@ -31,12 +30,12 @@ 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.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,
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
Expand All @@ -58,23 +57,20 @@ func main() {
// 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/v1": {JavaPackage: "io.fabric8.certmanager.api.model.v1", ApiGroup: "cert-manager.io", ApiVersion: "v1"},
"github.com/jetstack/cert-manager/pkg/apis/acme/v1": {JavaPackage: "io.fabric8.certmanager.api.model.acme.v1", ApiGroup: "cert-manager.io", ApiVersion: "v1"},
"github.com/jetstack/cert-manager/pkg/apis/meta/v1": {JavaPackage: "io.fabric8.certmanager.api.model.meta.v1", ApiGroup: "cert-manager.io", ApiVersion: "v1"},
"github.com/jetstack/cert-manager/pkg/apis/acme/v1": {JavaPackage: "io.fabric8.certmanager.api.model.acme.v1", ApiGroup: "cert-manager.io", ApiVersion: "v1"},
"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{
}
mappingSchema := map[string]string{}

// overwriting some times
manualTypeMap := map[reflect.Type]string{
reflect.TypeOf(v1.Time{}): "java.lang.String",
reflect.TypeOf(metav1.ObjectReference{}): "java.lang.String",
reflect.TypeOf(metav1.SecretKeySelector{}): "java.lang.String",
reflect.TypeOf(apiextensions.JSON{}): "com.fasterxml.jackson.databind.JsonNode",
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)
Expand Down
33 changes: 33 additions & 0 deletions extensions/certmanager/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,39 @@
<delete
file="${project.build.directory}/generated-sources/io/fabric8/certmanager/api/model/acme/v1/ACMEChallengeSolverHTTP01Ingress.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/kubernetes/api/model/EditableVolume.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/kubernetes/api/model/EditableObjectMeta.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/kubernetes/api/model/EditableContainer.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/kubernetes/api/model/EditableContainerPort.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/kubernetes/api/model/EditableVolumeMount.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/kubernetes/api/model/EditableLabelSelector.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/kubernetes/api/model/EditableEnvVar.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/certmanager/api/model/acme/v1/ACMEChallengeSolverHTTP01IngressFluentImpl.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/certmanager/api/model/acme/v1/ACMEChallengeSolverHTTP01IngressFluent.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/certmanager/api/model/acme/v1/ACMEChallengeSolverHTTP01IngressBuilder.java"
verbose="true" />
<delete
file="${project.build.directory}/generated-sources/io/fabric8/certmanager/api/model/acme/v1/EditableACMEChallengeSolverHTTP01Ingress.java"
verbose="true" />
</target>
</configuration>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@
"type": "string"
},
"keySecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"javaType": "io.fabric8.certmanager.api.model.acme.v1.ACMEExternalAccountBinding",
Expand Down Expand Up @@ -290,7 +291,8 @@
"type": "string"
},
"privateKeySecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
},
"server": {
"type": "string"
Expand All @@ -316,7 +318,8 @@
"type": "object",
"properties": {
"accountSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
},
"host": {
"type": "string"
Expand All @@ -331,13 +334,16 @@
"type": "object",
"properties": {
"accessTokenSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
},
"clientSecretSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
},
"clientTokenSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
},
"serviceConsumerDomain": {
"type": "string"
Expand All @@ -355,7 +361,8 @@
"type": "string"
},
"clientSecretSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
},
"environment": {
"type": "string"
Expand Down Expand Up @@ -388,7 +395,8 @@
"type": "string"
},
"serviceAccountSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"javaType": "io.fabric8.certmanager.api.model.acme.v1.ACMEIssuerDNS01ProviderCloudDNS",
Expand All @@ -400,10 +408,12 @@
"type": "object",
"properties": {
"apiKeySecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
},
"apiTokenSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
},
"email": {
"type": "string"
Expand All @@ -418,7 +428,8 @@
"type": "object",
"properties": {
"tokenSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"javaType": "io.fabric8.certmanager.api.model.acme.v1.ACMEIssuerDNS01ProviderDigitalOcean",
Expand All @@ -439,7 +450,8 @@
"type": "string"
},
"tsigSecretSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"javaType": "io.fabric8.certmanager.api.model.acme.v1.ACMEIssuerDNS01ProviderRFC2136",
Expand All @@ -463,7 +475,8 @@
"type": "string"
},
"secretAccessKeySecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"javaType": "io.fabric8.certmanager.api.model.acme.v1.ACMEIssuerDNS01ProviderRoute53",
Expand Down Expand Up @@ -602,7 +615,8 @@
"type": "string"
},
"issuerRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_ObjectReference",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.ObjectReference"
},
"key": {
"type": "string"
Expand Down Expand Up @@ -735,7 +749,8 @@
}
},
"issuerRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_ObjectReference",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.ObjectReference"
},
"request": {
"type": "array",
Expand Down Expand Up @@ -1025,7 +1040,8 @@
"type": "boolean"
},
"issuerRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_ObjectReference",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.ObjectReference"
},
"request": {
"type": "array",
Expand Down Expand Up @@ -1118,7 +1134,8 @@
"type": "boolean"
},
"issuerRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_ObjectReference",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.ObjectReference"
},
"keystores": {
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_certmanager_v1_CertificateKeystores",
Expand Down Expand Up @@ -1397,7 +1414,8 @@
"type": "boolean"
},
"passwordSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"javaType": "io.fabric8.certmanager.api.model.v1.JKSKeystore",
Expand All @@ -1412,7 +1430,8 @@
"type": "boolean"
},
"passwordSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"javaType": "io.fabric8.certmanager.api.model.v1.PKCS12Keystore",
Expand Down Expand Up @@ -1446,7 +1465,8 @@
"type": "string"
},
"secretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"javaType": "io.fabric8.certmanager.api.model.v1.VaultAppRole",
Expand All @@ -1466,7 +1486,8 @@
"existingJavaType": "io.fabric8.certmanager.api.model.v1.VaultKubernetesAuth"
},
"tokenSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"javaType": "io.fabric8.certmanager.api.model.v1.VaultAuth",
Expand Down Expand Up @@ -1513,7 +1534,8 @@
"type": "string"
},
"secretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"javaType": "io.fabric8.certmanager.api.model.v1.VaultKubernetesAuth",
Expand All @@ -1525,7 +1547,8 @@
"type": "object",
"properties": {
"apiTokenSecretRef": {
"existingJavaType": "java.lang.String"
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
},
"url": {
"type": "string"
Expand Down Expand Up @@ -1651,6 +1674,39 @@
"javaInterfaces": [
"io.fabric8.kubernetes.api.model.KubernetesResource"
]
},
"github_com_jetstack_cert-manager_pkg_apis_meta_v1_ObjectReference": {
"type": "object",
"properties": {
"group": {
"type": "string"
},
"kind": {
"type": "string"
},
"name": {
"type": "string"
}
},
"javaType": "io.fabric8.certmanager.api.model.meta.v1.ObjectReference",
"javaInterfaces": [
"io.fabric8.kubernetes.api.model.KubernetesResource"
]
},
"github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
}
},
"javaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector",
"javaInterfaces": [
"io.fabric8.kubernetes.api.model.KubernetesResource"
]
}
},
"type": "object",
Expand Down Expand Up @@ -1910,6 +1966,14 @@
"github_com_jetstack_cert-manager_pkg_apis_meta_v1_LocalObjectReference": {
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_LocalObjectReference",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.LocalObjectReference"
},
"github_com_jetstack_cert-manager_pkg_apis_meta_v1_ObjectReference": {
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_ObjectReference",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.ObjectReference"
},
"github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector": {
"$ref": "#/definitions/github_com_jetstack_cert-manager_pkg_apis_meta_v1_SecretKeySelector",
"existingJavaType": "io.fabric8.certmanager.api.model.meta.v1.SecretKeySelector"
}
},
"additionalProperties": false
Expand Down

0 comments on commit cf50243

Please sign in to comment.