forked from fabric8io/kubernetes-client
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (kubernetes-model-generator) : Add Kubernetes Model Gateway API …
…module Add java model for Kubernetes Model Sigs Gateway API : https://github.com/kubernetes-sigs/gateway-api This seems to be required by Cert Manager Extension Signed-off-by: Rohan Kumar <[email protected]>
- Loading branch information
1 parent
22f0dcb
commit 02f7244
Showing
120 changed files
with
24,544 additions
and
13 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
kubernetes-model-generator/kubernetes-model-gatewayapi/Makefile
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,27 @@ | ||
# | ||
# 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 | ||
mvn -Pgenerate clean install -DskipTests | ||
|
||
gobuild: | ||
CGO_ENABLED=0 GO15VENDOREXPERIMENT=1 go build -a ./cmd/generate/generate.go | ||
./generate > src/main/resources/schema/kube-schema.json | ||
./generate validation > src/main/resources/schema/validation-schema.json |
99 changes: 99 additions & 0 deletions
99
kubernetes-model-generator/kubernetes-model-gatewayapi/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,99 @@ | ||
/** | ||
* 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 ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
v1alpha2gwapi "sigs.k8s.io/gateway-api/apis/v1alpha2" | ||
v1beta1gwapi "sigs.k8s.io/gateway-api/apis/v1beta1" | ||
|
||
"log" | ||
"reflect" | ||
"strings" | ||
"time" | ||
|
||
"os" | ||
|
||
"github.com/fabric8io/kubernetes-client/kubernetes-model-generator/pkg/schemagen" | ||
) | ||
|
||
type Schema struct { | ||
Gateway v1alpha2gwapi.Gateway | ||
GatewayList v1alpha2gwapi.GatewayList | ||
GatewayClass v1alpha2gwapi.GatewayClass | ||
GatewayClassList v1alpha2gwapi.GatewayClassList | ||
HTTPRoute v1alpha2gwapi.HTTPRoute | ||
HTTPRouteList v1alpha2gwapi.HTTPRouteList | ||
ReferenceGrant v1alpha2gwapi.ReferenceGrant | ||
ReferenceGrantList v1alpha2gwapi.ReferenceGrantList | ||
ReferencePolicy v1alpha2gwapi.ReferencePolicy | ||
ReferencePolicyList v1alpha2gwapi.ReferencePolicyList | ||
TCPRoute v1alpha2gwapi.TCPRoute | ||
TCPRouteList v1alpha2gwapi.TCPRouteList | ||
TLSRoute v1alpha2gwapi.TLSRoute | ||
TLSRouteList v1alpha2gwapi.TLSRouteList | ||
UDPRoute v1alpha2gwapi.UDPRoute | ||
UDPRouteList v1alpha2gwapi.UDPRouteList | ||
V1Beta1Gateway v1beta1gwapi.Gateway | ||
V1Beta1GatewayList v1beta1gwapi.GatewayList | ||
V1Beta1GatewayClass v1beta1gwapi.GatewayClass | ||
V1Beta1GatewayClassList v1beta1gwapi.GatewayClassList | ||
V1Beta1HTTPRoute v1beta1gwapi.HTTPRoute | ||
V1Beta1HTTPRouteList v1beta1gwapi.HTTPRouteList | ||
} | ||
|
||
func main() { | ||
packages := []schemagen.PackageDescriptor{ | ||
{"k8s.io/apimachinery/pkg/api/resource", "", "io.fabric8.kubernetes.api.model", "kubernetes_resource_", false}, | ||
{"k8s.io/apimachinery/pkg/version", "", "io.fabric8.kubernetes.api.model.version", "kubernetes_apimachinery_pkg_version_", false}, | ||
{"k8s.io/apimachinery/pkg/apis/meta/v1", "", "io.fabric8.kubernetes.api.model", "kubernetes_apimachinery_", false}, | ||
{"k8s.io/api/core/v1", "", "io.fabric8.kubernetes.api.model", "kubernetes_core_", false}, | ||
{"sigs.k8s.io/gateway-api/apis/v1alpha2", "gateway.networking.k8s.io", "io.fabric8.kubernetes.api.model.gatewayapi.v1alpha2", "kubernetes_sigs_gatewayapi_v1alpha2_", true}, | ||
{"sigs.k8s.io/gateway-api/apis/v1beta1", "gateway.networking.k8s.io", "io.fabric8.kubernetes.api.model.gatewayapi.v1beta1", "kubernetes_sigs_gatewayapi_v1beta1_", true}, | ||
} | ||
|
||
typeMap := map[reflect.Type]reflect.Type{ | ||
reflect.TypeOf(time.Time{}): reflect.TypeOf(""), | ||
reflect.TypeOf(struct{}{}): reflect.TypeOf(""), | ||
} | ||
schema, err := schemagen.GenerateSchema(reflect.TypeOf(Schema{}), packages, typeMap, map[reflect.Type]string{}, "gatewayapi") | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "An error occurred: %v", err) | ||
return | ||
} | ||
|
||
args := os.Args[1:] | ||
if len(args) < 1 || args[0] != "validation" { | ||
schema.Resources = nil | ||
} | ||
|
||
b, err := json.Marshal(&schema) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
result := string(b) | ||
result = strings.Replace(result, "\"additionalProperty\":", "\"additionalProperties\":", -1) | ||
|
||
var out bytes.Buffer | ||
err = json.Indent(&out, []byte(result), "", " ") | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
fmt.Println(out.String()) | ||
} |
91 changes: 91 additions & 0 deletions
91
kubernetes-model-generator/kubernetes-model-gatewayapi/pom.xml
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,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>kubernetes-model-generator</artifactId> | ||
<version>6.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>kubernetes-model-gatewayapi</artifactId> | ||
<packaging>bundle</packaging> | ||
<name>Fabric8 :: Kubernetes Model :: Sigs :: Gateway API</name> | ||
|
||
<properties> | ||
<clone-kube>true</clone-kube> | ||
<osgi.include.resources> | ||
${osgi.include.resources.default}, | ||
/gatewayapi.properties=target/classes/gatewayapi.properties, | ||
</osgi.include.resources> | ||
<osgi.import>*</osgi.import> | ||
<osgi.export> | ||
io.fabric8.kubernetes.api.model.gatewayapi** | ||
</osgi.export> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>kubernetes-model-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>kubernetes-model-common</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>attach-artifacts</id> | ||
<configuration> | ||
<skipAttach>false</skipAttach> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>generate</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jsonschema2pojo</groupId> | ||
<artifactId>jsonschema2pojo-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
Oops, something went wrong.