Skip to content

Commit 64895f2

Browse files
committed
webserver example now runs on java 8
1 parent fd62130 commit 64895f2

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

samples/webserver/crd/webserver.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ spec:
1111
<body>
1212
Hellooooo!! Operators!!
1313
</body>
14-
</html>
14+
</html>

samples/webserver/pom.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
<name>Operator SDK - Samples - Web Server</name>
1111

1212
<properties>
13-
<java.version>11</java.version>
13+
<java.version>8</java.version>
14+
<maven.compiler.source>1.8</maven.compiler.source>
15+
<maven.compiler.target>1.8</maven.compiler.target>
1416
</properties>
1517

1618
<dependencies>
@@ -42,9 +44,6 @@
4244
<groupId>org.apache.maven.plugins</groupId>
4345
<artifactId>maven-compiler-plugin</artifactId>
4446
<version>3.8.1</version>
45-
<configuration>
46-
<release>${java.version}</release>
47-
</configuration>
4847
</plugin>
4948
<plugin>
5049
<groupId>com.spotify</groupId>

samples/webserver/src/main/java/com/github/containersolutions/operator/sample/WebServerController.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
import com.github.containersolutions.operator.api.ResourceController;
66
import io.fabric8.kubernetes.api.model.*;
77
import io.fabric8.kubernetes.api.model.apps.Deployment;
8+
import io.fabric8.kubernetes.api.model.apps.DoneableDeployment;
9+
import io.fabric8.kubernetes.client.dsl.Resource;
10+
import io.fabric8.kubernetes.client.dsl.RollableScalableResource;
11+
import io.fabric8.kubernetes.client.dsl.ServiceResource;
812
import io.fabric8.kubernetes.client.utils.Serialization;
913
import org.apache.commons.lang3.StringUtils;
1014
import org.slf4j.Logger;
@@ -79,7 +83,7 @@ public Optional<WebServer> createOrUpdateResource(WebServer webServer, Context<W
7983
}
8084
}
8185

82-
var status = new WebServerStatus();
86+
WebServerStatus status = new WebServerStatus();
8387
status.setHtmlConfigMap(htmlConfigMap.getMetadata().getName());
8488
status.setAreWeGood("Yes!");
8589
webServer.setStatus(status);
@@ -92,23 +96,23 @@ public boolean deleteResource(WebServer nginx, Context<WebServer> context) {
9296
log.info("Execution deleteResource for: {}", nginx.getMetadata().getName());
9397

9498
log.info("Deleting ConfigMap {}", configMapName(nginx));
95-
var configMap = context.getK8sClient().configMaps()
99+
Resource<ConfigMap, DoneableConfigMap> configMap = context.getK8sClient().configMaps()
96100
.inNamespace(nginx.getMetadata().getNamespace())
97101
.withName(configMapName(nginx));
98102
if (configMap.get() != null) {
99103
configMap.delete();
100104
}
101105

102106
log.info("Deleting Deployment {}", deploymentName(nginx));
103-
var deployment = context.getK8sClient().apps().deployments()
107+
RollableScalableResource<Deployment, DoneableDeployment> deployment = context.getK8sClient().apps().deployments()
104108
.inNamespace(nginx.getMetadata().getNamespace())
105109
.withName(deploymentName(nginx));
106110
if (deployment.get() != null) {
107111
deployment.cascading(true).delete();
108112
}
109113

110114
log.info("Deleting Service {}", serviceName(nginx));
111-
var service = context.getK8sClient().services()
115+
ServiceResource<Service, DoneableService> service = context.getK8sClient().services()
112116
.inNamespace(nginx.getMetadata().getNamespace())
113117
.withName(serviceName(nginx));
114118
if (service.get() != null) {

0 commit comments

Comments
 (0)