Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Josdk 1.9.1 #2

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ target
# BlueJ files
*.ctxt

# Eclipse
.classpath
.project
.settings

# Mobile Tools for Java (J2ME)
.mtj.tmp/

Expand Down
67 changes: 52 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-spring-boot-starter-parent</artifactId>
<version>1.8.5-SNAPSHOT</version>
<version>1.9.0-SNAPSHOT</version>
<name>Java Operator SDK Spring Boot Starter - Parent</name>
<packaging>pom</packaging>
<url>https://github.com/java-operator-sdk/operator-framework-spring-boot-starter</url>
Expand All @@ -17,7 +17,12 @@
<url>https://www.apache.org/licenses/LICENSE-2.0.html</url>
</license>
</licenses>

<developers>
<developer>
<name>Daniel Lavoie</name>
<email>dlavoie@live.ca</email>
</developer>
<developer>
<name>Adam Sandor</name>
<email>adam.sandor@container-solutions.com</email>
Expand All @@ -32,33 +37,65 @@
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<spring-boot.version>2.3.4.RELEASE</spring-boot.version>
<josdk.version>1.8.4</josdk.version>
<spring-boot.version>2.5.0</spring-boot.version>
<josdk.version>1.9.0</josdk.version>
daniellavoie marked this conversation as resolved.
Show resolved Hide resolved
<surefire.version>3.0.0-M5</surefire.version>
<fabric8-client.version>5.3.1</fabric8-client.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<modules>
<module>starter</module>
<module>starter-test</module>
<module>samples</module>
</modules>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-spring-boot-starter-test</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework</artifactId>
<version>${josdk.version}</version>
</dependency>
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-samples-common</artifactId>
<version>${josdk.version}</version>
</dependency>

<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-server-mock</artifactId>
<version>${fabric8-client.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
Expand Down
5 changes: 3 additions & 2 deletions samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
<parent>
<artifactId>operator-framework-spring-boot-starter-parent</artifactId>
<groupId>io.javaoperatorsdk</groupId>
<version>1.8.5-SNAPSHOT</version>
<version>1.9.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<artifactId>operator-framework-spring-boot-starter-samples-parent</artifactId>
<name>Java Operator SDK Spring Boot Starter - Samples</name>
<version>1.8.5-SNAPSHOT</version>

<packaging>pom</packaging>

<modules>
Expand Down
33 changes: 11 additions & 22 deletions samples/spring-boot-auto-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,33 @@
<parent>
<artifactId>operator-framework-spring-boot-starter-samples-parent</artifactId>
<groupId>io.javaoperatorsdk</groupId>
<version>1.8.5-SNAPSHOT</version>
<version>1.9.0-SNAPSHOT</version>
</parent>

<artifactId>operator-framework-spring-boot-starter-samples-auto-configuration</artifactId>
<name>Java Operator SDK Spring Boot Starter - Samples - Auto Configuration</name>
<description>Sample usage with Spring Boot</description>
<packaging>jar</packaging>

<properties>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-samples-common</artifactId>
<version>${josdk.version}</version>
</dependency>
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -51,24 +53,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>

<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-spring-boot-starter-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
1 change: 1 addition & 0 deletions starter-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# operator-framework-spring-boot-starter-test
68 changes: 68 additions & 0 deletions starter-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>operator-framework-spring-boot-starter-parent</artifactId>
<groupId>io.javaoperatorsdk</groupId>
<version>1.9.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<name>Java Operator SDK Spring Boot Starter Test</name>
<description>Spring Boot starter for the Java Operator SDK</description>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to adjust the description here to mention that this is the test starter…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed!

<artifactId>operator-framework-spring-boot-starter-test</artifactId>
<url>https://github.com/java-operator-sdk/operator-framework-spring-boot-starter-test</url>

<licenses>
<license>
<name>Apache 2 License</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.html</url>
</license>
</licenses>
<developers>
<developer>
<name>Daniel Lavoie</name>
<email>dlavoie@live.ca</email>
</developer>
<developer>
<name>Adam Sandor</name>
<email>adam.sandor@container-solutions.com</email>
</developer>
<developer>
<name>Attila Meszaros</name>
<email>csviri@gmail.com</email>
</developer>
</developers>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-server-mock</artifactId>
</dependency>
<dependency>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test-autoconfigure</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.javaoperatorsdk.operator.springboot.starter.test;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
import org.springframework.context.annotation.Import;

@Retention(RetentionPolicy.RUNTIME)
@Import(TestConfiguration.class)
@PropertyMapping("javaoperatorsdk.test")
public @interface EnableMockOperator {

/**
* Define a list of files that contain CustomResourceDefinitions for the tested operator. If the
* file to be loaded is shall be loaded from the classpath prefix it with 'classpath', otherwise
* provide a path relative to the current working directory.
*
* @return List of files
*/
@PropertyMapping("crd-paths")
String[] crdPaths() default {};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package io.javaoperatorsdk.operator.springboot.starter.test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Collections;
import java.util.HashMap;
import java.util.stream.Stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;

import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesCrudDispatcher;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.mockwebserver.Context;
import io.javaoperatorsdk.operator.springboot.starter.OperatorAutoConfiguration;
import okhttp3.mockwebserver.MockWebServer;

@Configuration
@ImportAutoConfiguration(OperatorAutoConfiguration.class)
@EnableConfigurationProperties(TestConfigurationProperties.class)
public class TestConfiguration {

private static final Logger log = LoggerFactory.getLogger(TestConfiguration.class);

@Bean
public KubernetesMockServer k8sMockServer() {
var mockServer = new MockWebServer();
final var server = new KubernetesMockServer(new Context(), mockServer, new HashMap<>(),
new KubernetesCrudDispatcher(Collections.emptyList()), true);
server.init();

return server;
}

@Bean
public KubernetesClient kubernetesClient(KubernetesMockServer server, TestConfigurationProperties properties)
throws InterruptedException {
final var client = server.createClient();

Stream.concat(properties.getCrdPaths().stream(), properties.getGlobalCrdPaths().stream()).forEach(crdPath -> {
CustomResourceDefinition crd;
try {
crd = Serialization.unmarshal(new FileInputStream(ResourceUtils.getFile(crdPath)));
} catch (FileNotFoundException e) {
log.warn("CRD with path {} not found!", crdPath);
e.printStackTrace();
return;
}

client.apiextensions().v1().customResourceDefinitions().create(crd);
});

return client;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.javaoperatorsdk.operator.springboot.starter.test;

import java.util.ArrayList;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties("javaoperatorsdk.test")
public class TestConfigurationProperties {

private List<String> globalCrdPaths = new ArrayList<>();

private List<String> crdPaths = new ArrayList<>();

public List<String> getCrdPaths() {
return crdPaths;
}

public void setCrdPaths(List<String> crdPaths) {
this.crdPaths = crdPaths;
}

public List<String> getGlobalCrdPaths() {
return globalCrdPaths;
}

public void setGlobalCrdPaths(List<String> globalCrdPaths) {
this.globalCrdPaths = globalCrdPaths;
}
}
Loading