Skip to content

Commit f552426

Browse files
rohanKanojiamanusa
authored andcommitted
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 <rohaan@redhat.com>
1 parent 5a993d3 commit f552426

File tree

120 files changed

+24544
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+24544
-13
lines changed

kubernetes-model-generator/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
[![javadoc](https://javadoc.io/badge2/io.fabric8/kubernetes-model-events/javadoc.svg)](https://javadoc.io/doc/io.fabric8/kubernetes-model-events)
2323
* kubernetes-model-extensions: [![Maven Central](https://img.shields.io/maven-central/v/io.fabric8/kubernetes-model-extensions.svg?maxAge=2592000)](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aio.fabric8%20a%3Akubernetes-model-extensions)
2424
[![javadoc](https://javadoc.io/badge2/io.fabric8/kubernetes-model-extensions/javadoc.svg)](https://javadoc.io/doc/io.fabric8/kubernetes-model-extensions)
25+
* kubernetes-model-gatewayapi: [![Maven Central](https://img.shields.io/maven-central/v/io.fabric8/kubernetes-model-gatewayapi.svg?maxAge=2592000)](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aio.fabric8%20a%3Akubernetes-model-gatewayapi)
26+
[![javadoc](https://javadoc.io/badge2/io.fabric8/kubernetes-model-gatewayapi/javadoc.svg)](https://javadoc.io/doc/io.fabric8/kubernetes-model-gatewayapi)
2527
* kubernetes-model-metrics: [![Maven Central](https://img.shields.io/maven-central/v/io.fabric8/kubernetes-model-metrics.svg?maxAge=2592000)](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aio.fabric8%20a%3Akubernetes-model-metrics)
2628
[![javadoc](https://javadoc.io/badge2/io.fabric8/kubernetes-model-metrics/javadoc.svg)](https://javadoc.io/doc/io.fabric8/kubernetes-model-metrics)
2729
* kubernetes-model-networking: [![Maven Central](https://img.shields.io/maven-central/v/io.fabric8/kubernetes-model-networking.svg?maxAge=2592000)](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aio.fabric8%20a%3Akubernetes-model-networking)

kubernetes-model-generator/generateModel.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ declare -a modules=(
3535
"kubernetes-model-events"
3636
"kubernetes-model-extensions"
3737
"kubernetes-model-flowcontrol"
38+
"kubernetes-model-gatewayapi"
3839
"kubernetes-model-networking"
3940
"kubernetes-model-metrics"
4041
"kubernetes-model-node"

kubernetes-model-generator/go.mod

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/fabric8io/kubernetes-client/kubernetes-model-generator
33
go 1.17
44

55
require (
6+
github.com/docker/docker v20.10.2+incompatible // indirect
67
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.2.0
78
github.com/k8snetworkplumbingwg/whereabouts v0.4.3-0.20211129155010-abd29e856f36
89
github.com/metal3-io/baremetal-operator/apis v0.0.0
@@ -18,12 +19,13 @@ require (
1819
github.com/operator-framework/api v0.10.7
1920
github.com/operator-framework/operator-lifecycle-manager v0.19.1
2021
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.52.1
21-
k8s.io/api v0.24.0
22-
k8s.io/apiextensions-apiserver v0.24.0
23-
k8s.io/apimachinery v0.24.0
22+
k8s.io/api v0.24.1
23+
k8s.io/apiextensions-apiserver v0.24.1
24+
k8s.io/apimachinery v0.24.1
2425
k8s.io/client-go v12.0.0+incompatible
2526
k8s.io/kube-aggregator v0.24.0
2627
k8s.io/metrics v0.24.0
28+
sigs.k8s.io/gateway-api v0.5.0
2729
sigs.k8s.io/kube-storage-version-migrator v0.0.5
2830
)
2931

@@ -35,8 +37,7 @@ require (
3537
github.com/blang/semver/v4 v4.0.0 // indirect
3638
github.com/cespare/xxhash/v2 v2.1.2 // indirect
3739
github.com/davecgh/go-spew v1.1.1 // indirect
38-
github.com/docker/docker v20.10.2+incompatible // indirect
39-
github.com/emicklei/go-restful v2.10.0+incompatible // indirect
40+
github.com/emicklei/go-restful v2.14.2+incompatible // indirect
4041
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
4142
github.com/fsnotify/fsnotify v1.5.1 // indirect
4243
github.com/go-logr/logr v1.2.0 // indirect
@@ -84,11 +85,11 @@ require (
8485
gopkg.in/inf.v0 v0.9.1 // indirect
8586
gopkg.in/yaml.v2 v2.4.0 // indirect
8687
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
87-
k8s.io/component-base v0.24.0 // indirect
88+
k8s.io/component-base v0.24.1 // indirect
8889
k8s.io/klog/v2 v2.60.1 // indirect
8990
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
9091
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
91-
sigs.k8s.io/controller-runtime v0.10.0 // indirect
92+
sigs.k8s.io/controller-runtime v0.12.1 // indirect
9293
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
9394
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
9495
sigs.k8s.io/yaml v1.3.0 // indirect

kubernetes-model-generator/go.sum

Lines changed: 1362 additions & 6 deletions
Large diffs are not rendered by default.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Copyright (C) 2015 Red Hat, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
SHELL := /bin/bash
18+
19+
all: build
20+
21+
build: gobuild
22+
mvn -Pgenerate clean install -DskipTests
23+
24+
gobuild:
25+
CGO_ENABLED=0 GO15VENDOREXPERIMENT=1 go build -a ./cmd/generate/generate.go
26+
./generate > src/main/resources/schema/kube-schema.json
27+
./generate validation > src/main/resources/schema/validation-schema.json
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/**
2+
* Copyright (C) 2015 Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package main
17+
18+
import (
19+
"bytes"
20+
"encoding/json"
21+
"fmt"
22+
v1alpha2gwapi "sigs.k8s.io/gateway-api/apis/v1alpha2"
23+
v1beta1gwapi "sigs.k8s.io/gateway-api/apis/v1beta1"
24+
25+
"log"
26+
"reflect"
27+
"strings"
28+
"time"
29+
30+
"os"
31+
32+
"github.com/fabric8io/kubernetes-client/kubernetes-model-generator/pkg/schemagen"
33+
)
34+
35+
type Schema struct {
36+
Gateway v1alpha2gwapi.Gateway
37+
GatewayList v1alpha2gwapi.GatewayList
38+
GatewayClass v1alpha2gwapi.GatewayClass
39+
GatewayClassList v1alpha2gwapi.GatewayClassList
40+
HTTPRoute v1alpha2gwapi.HTTPRoute
41+
HTTPRouteList v1alpha2gwapi.HTTPRouteList
42+
ReferenceGrant v1alpha2gwapi.ReferenceGrant
43+
ReferenceGrantList v1alpha2gwapi.ReferenceGrantList
44+
ReferencePolicy v1alpha2gwapi.ReferencePolicy
45+
ReferencePolicyList v1alpha2gwapi.ReferencePolicyList
46+
TCPRoute v1alpha2gwapi.TCPRoute
47+
TCPRouteList v1alpha2gwapi.TCPRouteList
48+
TLSRoute v1alpha2gwapi.TLSRoute
49+
TLSRouteList v1alpha2gwapi.TLSRouteList
50+
UDPRoute v1alpha2gwapi.UDPRoute
51+
UDPRouteList v1alpha2gwapi.UDPRouteList
52+
V1Beta1Gateway v1beta1gwapi.Gateway
53+
V1Beta1GatewayList v1beta1gwapi.GatewayList
54+
V1Beta1GatewayClass v1beta1gwapi.GatewayClass
55+
V1Beta1GatewayClassList v1beta1gwapi.GatewayClassList
56+
V1Beta1HTTPRoute v1beta1gwapi.HTTPRoute
57+
V1Beta1HTTPRouteList v1beta1gwapi.HTTPRouteList
58+
}
59+
60+
func main() {
61+
packages := []schemagen.PackageDescriptor{
62+
{"k8s.io/apimachinery/pkg/api/resource", "", "io.fabric8.kubernetes.api.model", "kubernetes_resource_", false},
63+
{"k8s.io/apimachinery/pkg/version", "", "io.fabric8.kubernetes.api.model.version", "kubernetes_apimachinery_pkg_version_", false},
64+
{"k8s.io/apimachinery/pkg/apis/meta/v1", "", "io.fabric8.kubernetes.api.model", "kubernetes_apimachinery_", false},
65+
{"k8s.io/api/core/v1", "", "io.fabric8.kubernetes.api.model", "kubernetes_core_", false},
66+
{"sigs.k8s.io/gateway-api/apis/v1alpha2", "gateway.networking.k8s.io", "io.fabric8.kubernetes.api.model.gatewayapi.v1alpha2", "kubernetes_sigs_gatewayapi_v1alpha2_", true},
67+
{"sigs.k8s.io/gateway-api/apis/v1beta1", "gateway.networking.k8s.io", "io.fabric8.kubernetes.api.model.gatewayapi.v1beta1", "kubernetes_sigs_gatewayapi_v1beta1_", true},
68+
}
69+
70+
typeMap := map[reflect.Type]reflect.Type{
71+
reflect.TypeOf(time.Time{}): reflect.TypeOf(""),
72+
reflect.TypeOf(struct{}{}): reflect.TypeOf(""),
73+
}
74+
schema, err := schemagen.GenerateSchema(reflect.TypeOf(Schema{}), packages, typeMap, map[reflect.Type]string{}, "gatewayapi")
75+
if err != nil {
76+
fmt.Fprintf(os.Stderr, "An error occurred: %v", err)
77+
return
78+
}
79+
80+
args := os.Args[1:]
81+
if len(args) < 1 || args[0] != "validation" {
82+
schema.Resources = nil
83+
}
84+
85+
b, err := json.Marshal(&schema)
86+
if err != nil {
87+
log.Fatal(err)
88+
}
89+
result := string(b)
90+
result = strings.Replace(result, "\"additionalProperty\":", "\"additionalProperties\":", -1)
91+
92+
var out bytes.Buffer
93+
err = json.Indent(&out, []byte(result), "", " ")
94+
if err != nil {
95+
log.Fatal(err)
96+
}
97+
98+
fmt.Println(out.String())
99+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (C) 2015 Red Hat, Inc.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
22+
<modelVersion>4.0.0</modelVersion>
23+
<parent>
24+
<groupId>io.fabric8</groupId>
25+
<artifactId>kubernetes-model-generator</artifactId>
26+
<version>6.1-SNAPSHOT</version>
27+
</parent>
28+
29+
<artifactId>kubernetes-model-gatewayapi</artifactId>
30+
<packaging>bundle</packaging>
31+
<name>Fabric8 :: Kubernetes Model :: Sigs :: Gateway API</name>
32+
33+
<properties>
34+
<clone-kube>true</clone-kube>
35+
<osgi.include.resources>
36+
${osgi.include.resources.default},
37+
/gatewayapi.properties=target/classes/gatewayapi.properties,
38+
</osgi.include.resources>
39+
<osgi.import>*</osgi.import>
40+
<osgi.export>
41+
io.fabric8.kubernetes.api.model.gatewayapi**
42+
</osgi.export>
43+
</properties>
44+
45+
<dependencies>
46+
<dependency>
47+
<groupId>io.fabric8</groupId>
48+
<artifactId>kubernetes-model-core</artifactId>
49+
</dependency>
50+
<dependency>
51+
<groupId>io.fabric8</groupId>
52+
<artifactId>kubernetes-model-common</artifactId>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.assertj</groupId>
56+
<artifactId>assertj-core</artifactId>
57+
<scope>test</scope>
58+
</dependency>
59+
</dependencies>
60+
61+
<build>
62+
<plugins>
63+
<plugin>
64+
<groupId>org.codehaus.mojo</groupId>
65+
<artifactId>build-helper-maven-plugin</artifactId>
66+
<executions>
67+
<execution>
68+
<id>attach-artifacts</id>
69+
<configuration>
70+
<skipAttach>false</skipAttach>
71+
</configuration>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
</plugins>
76+
</build>
77+
78+
<profiles>
79+
<profile>
80+
<id>generate</id>
81+
<build>
82+
<plugins>
83+
<plugin>
84+
<groupId>org.jsonschema2pojo</groupId>
85+
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
86+
</plugin>
87+
</plugins>
88+
</build>
89+
</profile>
90+
</profiles>
91+
</project>

0 commit comments

Comments
 (0)