Skip to content

Commit

Permalink
Merge pull request #96 from fabiobrz/generate-operator-josdk.infinispan
Browse files Browse the repository at this point in the history
[issue 67] - Replacing Infinispan Operator JOSDK with generated one
  • Loading branch information
tommaso-borgato authored Oct 13, 2023
2 parents 6dc3b4a + b7a9634 commit fb67818
Show file tree
Hide file tree
Showing 49 changed files with 2,477 additions and 1,356 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
import java.util.Map;
import java.util.Objects;

import org.infinispan.v1.Infinispan;
import org.infinispan.v1.infinispanspec.Service;
import org.infinispan.v2alpha1.Cache;
import org.jboss.intersmash.tools.application.openshift.InfinispanOperatorApplication;
import org.jboss.intersmash.tools.junit5.IntersmashExtension;
import org.jboss.intersmash.tools.provision.openshift.InfinispanOperatorProvisioner;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.cache.Cache;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.cache.CacheBuilder;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.infinispan.Infinispan;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.infinispan.InfinispanBuilder;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.infinispan.spec.AutoscaleBuilder;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.infinispan.spec.InfinispanServiceSpecBuilder;
Expand Down Expand Up @@ -175,7 +176,7 @@ public void testMinimalTwoReplicasCacheServiceInfinispan() {
name = "example-infinispan";
Infinispan infinispan = new InfinispanBuilder(name, matchLabels)
.replicas(2)
.service(new InfinispanServiceSpecBuilder().type(InfinispanServiceSpecBuilder.ServiceType.Cache)
.service(new InfinispanServiceSpecBuilder().type(Service.Type.Cache)
.build())
.build();

Expand All @@ -200,13 +201,13 @@ public void testMinimalCacheServiceInfinispanWithAutoscale() {
Infinispan infinispan = new InfinispanBuilder(name, matchLabels)
.replicas(2)
.service(new InfinispanServiceSpecBuilder()
.type(InfinispanServiceSpecBuilder.ServiceType.Cache)
.type(Service.Type.Cache)
.build())
.autoscale(new AutoscaleBuilder()
.maxReplicas(5)
.maxMemUsagePercent(70)
.maxMemUsagePercent(70L)
.minReplicas(2)
.minMemUsagePercent(30).build())
.minMemUsagePercent(30L).build())
.build();

verifyMinimalCacheServiceInfinispanWithAutoscale(infinispan, true);
Expand All @@ -229,7 +230,7 @@ public void testCacheWithBasicSecretFromTemplate() {
final String clusterName = "example-infinispan";
Infinispan infinispan = new InfinispanBuilder(clusterName, matchLabels)
.replicas(1)
.service(new InfinispanServiceSpecBuilder().type(InfinispanServiceSpecBuilder.ServiceType.DataGrid)
.service(new InfinispanServiceSpecBuilder().type(Service.Type.DataGrid)
.build())
.build();
createAndVerifyInfinispan(infinispan);
Expand Down
6 changes: 6 additions & 0 deletions tools/intersmash-tools-provisioners/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@
<configuration>
<target>target/generated-sources</target>
<source>src/main/resources/crds</source>
<!--
This is needed to force the Java generator from CRD to stick with the original names
for enums, and avoi to uppercase them, since this could generate duplicate names,
as in https://github.com/infinispan/infinispan-operator/blob/2.3.4.Final/config/crd/bases/infinispan.org_infinispans.yaml#L1473-L1477
-->
<enumUppercase>false</enumUppercase>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

import java.util.List;

import org.infinispan.v1.Infinispan;
import org.infinispan.v2alpha1.Cache;
import org.jboss.intersmash.tools.provision.openshift.InfinispanOperatorProvisioner;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.cache.Cache;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.infinispan.Infinispan;

/**
* End user Application interface which presents Infinispan operator application on OpenShift Container Platform.
* Only relevant model APIs are currently exposed, more would be added on demand (e.g.: backups, restores, etc.)
*
* The application will be deployed by:
* <ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
import java.util.stream.Collectors;

import org.assertj.core.util.Lists;
import org.infinispan.v1.Infinispan;
import org.infinispan.v1.infinispanspec.Expose;
import org.infinispan.v2alpha1.Cache;
import org.jboss.intersmash.tools.IntersmashConfig;
import org.jboss.intersmash.tools.application.openshift.InfinispanOperatorApplication;
import org.jboss.intersmash.tools.provision.openshift.operator.OperatorProvisioner;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.cache.Cache;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.cache.CacheList;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.infinispan.Infinispan;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.infinispan.InfinispanList;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.infinispan.spec.ExposeSpecBuilder;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.infinispan.spec.InfinispanConditionBuilder;
import org.slf4j.event.Level;

Expand Down Expand Up @@ -171,8 +171,8 @@ public URL getURL() {
String internalUrl = "http://" + defaultInternalService.getSpec().getClusterIP() + ":11222";
String externalUrl = null;
if (getApplication().getInfinispan().getSpec().getExpose() != null) {
final String exposedType = getApplication().getInfinispan().getSpec().getExpose().getType();
switch (ExposeSpecBuilder.ExposeType.valueOf(exposedType)) {
final Expose.Type exposedType = getApplication().getInfinispan().getSpec().getExpose().getType();
switch (exposedType) {
case NodePort:
// TODO - check
// see see https://github.com/infinispan/infinispan-operator/blob/2.0.x/pkg/apis/infinispan/v1/infinispan_types.go#L107
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

import java.util.Map;

import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.cache.spec.AdminAuth;
import org.jboss.intersmash.tools.provision.openshift.operator.infinispan.cache.spec.CacheSpec;
import org.infinispan.v2alpha1.Cache;
import org.infinispan.v2alpha1.CacheSpec;
import org.infinispan.v2alpha1.cachespec.AdminAuth;

import io.fabric8.kubernetes.api.model.ObjectMeta;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.infinispan.cache;

import org.infinispan.v2alpha1.Cache;

import io.fabric8.kubernetes.client.CustomResourceList;

public class CacheList extends CustomResourceList<Cache> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.infinispan.cache.spec;

import org.infinispan.v2alpha1.cachespec.AdminAuth;
import org.infinispan.v2alpha1.cachespec.adminauth.Password;
import org.infinispan.v2alpha1.cachespec.adminauth.Username;

public final class AdminAuthBuilder {
private String secretName;
private String username;
private String password;
private Username username;
private Password password;

/**
* Set the name of the secret containing both admin username and password
Expand All @@ -37,7 +41,7 @@ public AdminAuthBuilder secretName(String secretName) {
* @param username Secret and key containing the admin username for authentication
* @return this
*/
public AdminAuthBuilder username(String username) {
public AdminAuthBuilder username(Username username) {
this.username = username;
return this;
}
Expand All @@ -48,7 +52,7 @@ public AdminAuthBuilder username(String username) {
* @param password Secret and key containing the admin password for authentication
* @return this
*/
public AdminAuthBuilder password(String password) {
public AdminAuthBuilder password(Password password) {
this.password = password;
return this;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.jboss.intersmash.tools.provision.openshift.operator.infinispan.cache.spec;

import org.infinispan.v2alpha1.cachestatus.Conditions;

public final class CacheConditionBuilder {
private String type;
private String status;
Expand Down Expand Up @@ -53,8 +55,8 @@ public CacheConditionBuilder message(String message) {
return this;
}

public CacheCondition build() {
CacheCondition cacheCondition = new CacheCondition();
public Conditions build() {
Conditions cacheCondition = new Conditions();
cacheCondition.setType(type);
cacheCondition.setStatus(status);
cacheCondition.setMessage(message);
Expand Down
Loading

0 comments on commit fb67818

Please sign in to comment.