Skip to content

Commit d106084

Browse files
authored
Merge pull request #1169 from simingweng/generate-cert-manager-crd-models
generate model classes from CRDs
2 parents 7f29aed + fe7d99b commit d106084

File tree

147 files changed

+28537
-0
lines changed

Some content is hidden

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

147 files changed

+28537
-0
lines changed

client-java-contrib/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM docker:stable
2+
3+
# install git, bash, kind, kubectl and clone the kubernetes-client/gen code base
4+
RUN apk add --no-cache git bash && \
5+
wget -O /usr/bin/kind https://kind.sigs.k8s.io/dl/v0.8.1/kind-linux-amd64 && \
6+
chmod +x /usr/bin/kind && \
7+
wget -O /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl && \
8+
chmod +x /usr/bin/kubectl && \
9+
git clone https://github.com/kubernetes-client/gen.git
10+
11+
COPY generate.sh generate.sh
12+
RUN chmod +x generate.sh
13+
14+
WORKDIR gen/openapi
15+
16+
CMD ["/generate.sh"]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Cert-Manager Model Classes
2+
This module contains the Java model classes generated from the release version of [cert-manager](https://cert-manager.io) CRDs.
3+
4+
It makes it possible to CRUD custom resources defined by `cert-manager` in a strong-typed manner in your Java application, such as create an issuer, request a certificate, etc.
5+
## Usage
6+
To use this library, include the following maven dependency
7+
```xml
8+
<dependency>
9+
<groupId>io.kubernetes</groupId>
10+
<artifactId>client-java-cert-manager-models</artifactId>
11+
<version>0.16.1-SNAPSHOT</version>
12+
</dependency>
13+
```
14+
Please refer to the [CertManagerExample](../../examples/src/main/java/io/kubernetes/client/examples/CertManagerExample.java), which demonstrates how to create a self signed issuer using the model class and Kubernetes Java client generic API.
15+
## Compatibility
16+
Artifact Version|Cert-Manager Release Version|CRD Source
17+
----------------|----------------------------|----------
18+
0.16.1-SNAPSHOT|0.16.1|[Here](https://github.com/jetstack/cert-manager/releases/download/v0.16.1/cert-manager.crds.yaml)
19+
## Code Generation
20+
There is a utility script [update.sh](update.sh) to help with the code generation.
21+
22+
* The only prerequisites required is Docker installed on the host
23+
24+
Under the `cert-manager` directory, execute:
25+
```shell script
26+
./update.sh
27+
```
28+
It will generate the model classes from the CRDs hosted at the URL specified via the `-u` option in the [update.sh](update.sh) script. If newer version of CRDs becomes available, just update the `-u` option accordingly.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>client-java-cert-manager-models</artifactId>
5+
<name>cert-manager-models</name>
6+
<url>https://github.com/kubernetes-client/java</url>
7+
<parent>
8+
<groupId>io.kubernetes</groupId>
9+
<artifactId>client-java-parent</artifactId>
10+
<version>10.0.0-SNAPSHOT</version>
11+
<relativePath>../../pom.xml</relativePath>
12+
</parent>
13+
<!-- the version tracks the release version of the CRDs in the upstream cert-manager project -->
14+
<version>0.16.1-SNAPSHOT</version>
15+
<dependencies>
16+
<dependency>
17+
<groupId>io.kubernetes</groupId>
18+
<artifactId>client-java</artifactId>
19+
<version>${project.parent.version}</version>
20+
<scope>provided</scope>
21+
</dependency>
22+
</dependencies>
23+
</project>
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
package io.cert.manager.models;
14+
15+
import com.google.gson.annotations.SerializedName;
16+
import io.kubernetes.client.openapi.models.V1ObjectMeta;
17+
import io.swagger.annotations.ApiModel;
18+
import io.swagger.annotations.ApiModelProperty;
19+
import java.util.Objects;
20+
21+
/**
22+
* A Certificate resource should be created to ensure an up to date and signed x509 certificate is
23+
* stored in the Kubernetes Secret resource named in &#x60;spec.secretName&#x60;. The stored
24+
* certificate will be renewed before it expires (as configured by &#x60;spec.renewBefore&#x60;).
25+
*/
26+
@ApiModel(
27+
description =
28+
"A Certificate resource should be created to ensure an up to date and signed x509 certificate is stored in the Kubernetes Secret resource named in `spec.secretName`. The stored certificate will be renewed before it expires (as configured by `spec.renewBefore`).")
29+
@javax.annotation.Generated(
30+
value = "org.openapitools.codegen.languages.JavaClientCodegen",
31+
date = "2020-08-18T19:55:23.947Z[Etc/UTC]")
32+
public class V1alpha2Certificate implements io.kubernetes.client.common.KubernetesObject {
33+
public static final String SERIALIZED_NAME_API_VERSION = "apiVersion";
34+
35+
@SerializedName(SERIALIZED_NAME_API_VERSION)
36+
private String apiVersion;
37+
38+
public static final String SERIALIZED_NAME_KIND = "kind";
39+
40+
@SerializedName(SERIALIZED_NAME_KIND)
41+
private String kind;
42+
43+
public static final String SERIALIZED_NAME_METADATA = "metadata";
44+
45+
@SerializedName(SERIALIZED_NAME_METADATA)
46+
private V1ObjectMeta metadata = null;
47+
48+
public static final String SERIALIZED_NAME_SPEC = "spec";
49+
50+
@SerializedName(SERIALIZED_NAME_SPEC)
51+
private V1alpha2CertificateSpec spec;
52+
53+
public static final String SERIALIZED_NAME_STATUS = "status";
54+
55+
@SerializedName(SERIALIZED_NAME_STATUS)
56+
private V1beta1CertificateStatus status;
57+
58+
public V1alpha2Certificate apiVersion(String apiVersion) {
59+
60+
this.apiVersion = apiVersion;
61+
return this;
62+
}
63+
64+
/**
65+
* APIVersion defines the versioned schema of this representation of an object. Servers should
66+
* convert recognized schemas to the latest internal value, and may reject unrecognized values.
67+
* More info:
68+
* https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
69+
*
70+
* @return apiVersion
71+
*/
72+
@javax.annotation.Nullable
73+
@ApiModelProperty(
74+
value =
75+
"APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources")
76+
public String getApiVersion() {
77+
return apiVersion;
78+
}
79+
80+
public void setApiVersion(String apiVersion) {
81+
this.apiVersion = apiVersion;
82+
}
83+
84+
public V1alpha2Certificate kind(String kind) {
85+
86+
this.kind = kind;
87+
return this;
88+
}
89+
90+
/**
91+
* Kind is a string value representing the REST resource this object represents. Servers may infer
92+
* this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More
93+
* info:
94+
* https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
95+
*
96+
* @return kind
97+
*/
98+
@javax.annotation.Nullable
99+
@ApiModelProperty(
100+
value =
101+
"Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds")
102+
public String getKind() {
103+
return kind;
104+
}
105+
106+
public void setKind(String kind) {
107+
this.kind = kind;
108+
}
109+
110+
public V1alpha2Certificate metadata(V1ObjectMeta metadata) {
111+
112+
this.metadata = metadata;
113+
return this;
114+
}
115+
116+
/**
117+
* Get metadata
118+
*
119+
* @return metadata
120+
*/
121+
@javax.annotation.Nullable
122+
@ApiModelProperty(value = "")
123+
public V1ObjectMeta getMetadata() {
124+
return metadata;
125+
}
126+
127+
public void setMetadata(V1ObjectMeta metadata) {
128+
this.metadata = metadata;
129+
}
130+
131+
public V1alpha2Certificate spec(V1alpha2CertificateSpec spec) {
132+
133+
this.spec = spec;
134+
return this;
135+
}
136+
137+
/**
138+
* Get spec
139+
*
140+
* @return spec
141+
*/
142+
@javax.annotation.Nullable
143+
@ApiModelProperty(value = "")
144+
public V1alpha2CertificateSpec getSpec() {
145+
return spec;
146+
}
147+
148+
public void setSpec(V1alpha2CertificateSpec spec) {
149+
this.spec = spec;
150+
}
151+
152+
public V1alpha2Certificate status(V1beta1CertificateStatus status) {
153+
154+
this.status = status;
155+
return this;
156+
}
157+
158+
/**
159+
* Get status
160+
*
161+
* @return status
162+
*/
163+
@javax.annotation.Nullable
164+
@ApiModelProperty(value = "")
165+
public V1beta1CertificateStatus getStatus() {
166+
return status;
167+
}
168+
169+
public void setStatus(V1beta1CertificateStatus status) {
170+
this.status = status;
171+
}
172+
173+
@Override
174+
public boolean equals(java.lang.Object o) {
175+
if (this == o) {
176+
return true;
177+
}
178+
if (o == null || getClass() != o.getClass()) {
179+
return false;
180+
}
181+
V1alpha2Certificate v1alpha2Certificate = (V1alpha2Certificate) o;
182+
return Objects.equals(this.apiVersion, v1alpha2Certificate.apiVersion)
183+
&& Objects.equals(this.kind, v1alpha2Certificate.kind)
184+
&& Objects.equals(this.metadata, v1alpha2Certificate.metadata)
185+
&& Objects.equals(this.spec, v1alpha2Certificate.spec)
186+
&& Objects.equals(this.status, v1alpha2Certificate.status);
187+
}
188+
189+
@Override
190+
public int hashCode() {
191+
return Objects.hash(apiVersion, kind, metadata, spec, status);
192+
}
193+
194+
@Override
195+
public String toString() {
196+
StringBuilder sb = new StringBuilder();
197+
sb.append("class V1alpha2Certificate {\n");
198+
sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n");
199+
sb.append(" kind: ").append(toIndentedString(kind)).append("\n");
200+
sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
201+
sb.append(" spec: ").append(toIndentedString(spec)).append("\n");
202+
sb.append(" status: ").append(toIndentedString(status)).append("\n");
203+
sb.append("}");
204+
return sb.toString();
205+
}
206+
207+
/**
208+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
209+
*/
210+
private String toIndentedString(java.lang.Object o) {
211+
if (o == null) {
212+
return "null";
213+
}
214+
return o.toString().replace("\n", "\n ");
215+
}
216+
}

0 commit comments

Comments
 (0)