Skip to content

Use the fabric8 java-generator instead of committing a jar #417

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

Merged
merged 4 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
35 changes: 3 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,39 +211,10 @@ tests.

### Update the rhoas-model dependency

1. Clone the operator the bf2/operator from here:https://github.com/bf2fc6cc711aee1a0c2a/operator
```
git clone https://github.com/redhat-developer/app-services-operator.git
cd app-services-operator
```

2. Checkout the right version you want to update to

**Example:**
```
git checkout 0.5.0
```

3. Build the all the JARs (See operator README.md for the required maven and java versions)
```
mvn package
```

4. Copy the built **rhoas-model.VERSION.jar** to the e2e-test-suite **lib/** directory

**Example:**
```
cp source/model/target/rhoas-model-1.0.0-SNAPSHOT.jar path/to/e2e-test-suite/lib
```

6. If the rhoas-model version has changed you need to update the pom.xml in the e2e-test-suite repository

5. Switch then to the e2e-test-suite repo and verify the build
```
mvn verify -Psmoke
```
Pick the latest available version folder from:
https://github.com/redhat-developer/app-services-operator/tree/main/olm/olm-catalog/rhoas-operator

6. If the build pass, commit the changes and open a PR, otherwise fix the issues and then open a PR
and update the property `rhoas-model.version` in `pom.xml`.

## Maintainers

Expand Down
Binary file removed lib/rhoas-model-1.0.0-SNAPSHOT.jar
Binary file not shown.
100 changes: 90 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<maven.compiler.target>11</maven.compiler.target>
<maven.checkstyle.version>3.2.0</maven.checkstyle.version>
<maven.failsafe.version>3.0.0-M7</maven.failsafe.version>
<download.maven.plugin.version>1.6.8</download.maven.plugin.version>
<fabric8.version>6.2.0</fabric8.version>
<sundrio.version>0.93.1</sundrio.version>
<!-- See 'Update the rhoas-model dependency' in the README.md on how to build and update the rhoas-model -->
<rhoas-model.version>0.9.7</rhoas-model.version>
</properties>

<dependencies>
Expand All @@ -33,12 +38,12 @@
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-client</artifactId>
<version>6.0.0</version>
<version>${fabric8.version}</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model</artifactId>
<version>6.0.0</version>
<version>${fabric8.version}</version>
</dependency>
<dependency>
<groupId>io.strimzi</groupId>
Expand Down Expand Up @@ -120,14 +125,6 @@
<artifactId>okhttp</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>com.openshift.cloud</groupId>
<artifactId>rhoas-operator-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<!-- See 'Update the rhoas-model dependency' in the README.md on how to build and update the rhoas-model -->
<systemPath>${basedir}/lib/rhoas-model-1.0.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
Expand Down Expand Up @@ -216,6 +213,17 @@
<artifactId>org.eclipse.jgit</artifactId>
<version>4.8.0.201706111038-r</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>generator-annotations</artifactId>
<version>${fabric8.version}</version>
</dependency>
<dependency>
<groupId>io.sundr</groupId>
<artifactId>builder-annotations</artifactId>
<version>${sundrio.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -280,6 +288,78 @@
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>${download.maven.plugin.version}</version>
<executions>
<execution>
<id>generate-sources-rhoas-cloudserviceaccountrequest</id>
<phase>generate-sources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://raw.githubusercontent.com/redhat-developer/app-services-operator/main/olm/olm-catalog/rhoas-operator/${rhoas-model.version}/manifests/rhoas-operator.cloudserviceaccountrequest.crd.yaml</url>
<outputFileName>rhoas-operator.cloudserviceaccountrequest.crd.yaml</outputFileName>
<outputDirectory>${project.build.directory}/manifests</outputDirectory>
</configuration>
</execution>
<execution>
<id>generate-sources-rhoas-cloudservicesrequests</id>
<phase>generate-sources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://raw.githubusercontent.com/redhat-developer/app-services-operator/main/olm/olm-catalog/rhoas-operator/${rhoas-model.version}/manifests/rhoas-operator.cloudservicesrequests.crd.yaml</url>
<outputFileName>rhoas-operator.cloudservicesrequests.crd.yaml</outputFileName>
<outputDirectory>${project.build.directory}/manifests</outputDirectory>
</configuration>
</execution>
<execution>
<id>generate-sources-rhoas-kafkaconnections</id>
<phase>generate-sources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://raw.githubusercontent.com/redhat-developer/app-services-operator/main/olm/olm-catalog/rhoas-operator/${rhoas-model.version}/manifests/rhoas-operator.kafkaconnections.crd.yaml</url>
<outputFileName>rhoas-operator.kafkaconnections.crd.yaml</outputFileName>
<outputDirectory>${project.build.directory}/manifests</outputDirectory>
</configuration>
</execution>
<execution>
<id>generate-sources-rhoas-serviceregistryconnections</id>
<phase>generate-sources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>https://raw.githubusercontent.com/redhat-developer/app-services-operator/main/olm/olm-catalog/rhoas-operator/${rhoas-model.version}/manifests/rhoas-operator.serviceregistryconnections.crd.yaml</url>
<outputFileName>rhoas-operator.serviceregistryconnections.crd.yaml</outputFileName>
<outputDirectory>${project.build.directory}/manifests</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>java-generator-maven-plugin</artifactId>
<version>${fabric8.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${project.build.directory}/manifests</source>
<extraAnnotations>true</extraAnnotations>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
29 changes: 13 additions & 16 deletions src/main/java/io/managed/services/test/operator/OperatorUtils.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package io.managed.services.test.operator;

import com.openshift.cloud.v1alpha.models.CloudServiceAccountRequest;
import com.openshift.cloud.v1alpha.models.CloudServiceAccountRequestList;
import com.openshift.cloud.v1alpha.models.CloudServicesRequest;
import com.openshift.cloud.v1alpha.models.CloudServicesRequestList;
import com.openshift.cloud.v1alpha.models.KafkaConnection;
import com.openshift.cloud.v1alpha.models.KafkaConnectionList;
import com.openshift.cloud.v1alpha.models.ServiceRegistryConnection;
import com.openshift.cloud.v1alpha.models.ServiceRegistryConnectionList;
import com.redhat.rhoas.v1alpha1.CloudServiceAccountRequest;
import com.redhat.rhoas.v1alpha1.CloudServicesRequest;
import com.redhat.rhoas.v1alpha1.KafkaConnection;
import com.redhat.rhoas.v1alpha1.ServiceRegistryConnection;
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.kubernetes.api.model.SecretBuilder;
Expand All @@ -23,20 +20,20 @@
public class OperatorUtils {
private static final Logger LOGGER = LogManager.getLogger(OperatorUtils.class);

public static MixedOperation<CloudServiceAccountRequest, CloudServiceAccountRequestList, Resource<CloudServiceAccountRequest>> cloudServiceAccountRequest(KubernetesClient client) {
return client.resources(CloudServiceAccountRequest.class, CloudServiceAccountRequestList.class);
public static MixedOperation<CloudServiceAccountRequest, KubernetesResourceList<CloudServiceAccountRequest>, Resource<CloudServiceAccountRequest>> cloudServiceAccountRequest(KubernetesClient client) {
return client.resources(CloudServiceAccountRequest.class);
}

public static MixedOperation<CloudServicesRequest, CloudServicesRequestList, Resource<CloudServicesRequest>> cloudServicesRequest(KubernetesClient client) {
return client.resources(CloudServicesRequest.class, CloudServicesRequestList.class);
public static MixedOperation<CloudServicesRequest, KubernetesResourceList<CloudServicesRequest>, Resource<CloudServicesRequest>> cloudServicesRequest(KubernetesClient client) {
return client.resources(CloudServicesRequest.class);
}

public static MixedOperation<KafkaConnection, KafkaConnectionList, Resource<KafkaConnection>> kafkaConnection(KubernetesClient client) {
return client.resources(KafkaConnection.class, KafkaConnectionList.class);
public static MixedOperation<KafkaConnection, KubernetesResourceList<KafkaConnection>, Resource<KafkaConnection>> kafkaConnection(KubernetesClient client) {
return client.resources(KafkaConnection.class);
}

public static MixedOperation<ServiceRegistryConnection, ServiceRegistryConnectionList, Resource<ServiceRegistryConnection>> serviceRegistryConnection(KubernetesClient client) {
return client.resources(ServiceRegistryConnection.class, ServiceRegistryConnectionList.class);
public static MixedOperation<ServiceRegistryConnection, KubernetesResourceList<ServiceRegistryConnection>, Resource<ServiceRegistryConnection>> serviceRegistryConnection(KubernetesClient client) {
return client.resources(ServiceRegistryConnection.class);
}

public static MixedOperation<ServiceBinding, ServiceBindingList, Resource<ServiceBinding>> serviceBinding(KubernetesClient client) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.managed.services.test.devexp;


import com.openshift.cloud.v1alpha.models.CloudServiceAccountRequest;
import com.openshift.cloud.v1alpha.models.CloudServiceAccountRequestSpec;
import com.openshift.cloud.v1alpha.models.CloudServicesRequest;
import com.openshift.cloud.v1alpha.models.CloudServicesRequestSpec;
import com.openshift.cloud.v1alpha.models.Credentials;
import com.openshift.cloud.v1alpha.models.KafkaConnection;
import com.openshift.cloud.v1alpha.models.KafkaConnectionSpec;
import com.redhat.rhoas.v1alpha1.CloudServiceAccountRequest;
import com.redhat.rhoas.v1alpha1.CloudServiceAccountRequestSpec;
import com.redhat.rhoas.v1alpha1.CloudServicesRequest;
import com.redhat.rhoas.v1alpha1.CloudServicesRequestSpec;
import com.redhat.rhoas.v1alpha1.KafkaConnectionBuilder;
import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.openshift.client.DefaultOpenShiftClient;
Expand Down Expand Up @@ -287,12 +285,18 @@ public void testCreateManagedKafkaConnection() throws Throwable {
throw new TestException(message("failed to find the user kafka instance {} in the CloudServicesRequest {}", KAFKA_INSTANCE_NAME, CLOUD_SERVICES_REQUEST_NAME));
}

var c = new KafkaConnection();
c.getMetadata().setName(KAFKA_CONNECTION_NAME);
c.setSpec(new KafkaConnectionSpec());
c.getSpec().setAccessTokenSecretName(ACCESS_TOKEN_SECRET_NAME);
c.getSpec().setKafkaId(userKafka.orElseThrow().getId());
c.getSpec().setCredentials(new Credentials(SERVICE_ACCOUNT_SECRET_NAME));
var c = new KafkaConnectionBuilder()
.withNewMetadata()
.withName(KAFKA_CONNECTION_NAME)
.endMetadata()
.withNewSpec()
.withAccessTokenSecretName(ACCESS_TOKEN_SECRET_NAME)
.withKafkaId(userKafka.orElseThrow().getId())
.withNewCredentials()
.withServiceAccountSecretName(SERVICE_ACCOUNT_SECRET_NAME)
.endCredentials()
.endSpec()
.build();

LOGGER.info("create ManagedKafkaConnection with name: {}", KAFKA_CONNECTION_NAME);
c = OperatorUtils.kafkaConnection(oc).create(c);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package io.managed.services.test.devexp;


import com.openshift.cloud.v1alpha.models.CloudServiceAccountRequest;
import com.openshift.cloud.v1alpha.models.CloudServiceAccountRequestSpec;
import com.openshift.cloud.v1alpha.models.CloudServicesRequest;
import com.openshift.cloud.v1alpha.models.CloudServicesRequestSpec;
import com.openshift.cloud.v1alpha.models.Credentials;
import com.openshift.cloud.v1alpha.models.ServiceRegistryConnection;
import com.openshift.cloud.v1alpha.models.ServiceRegistryConnectionSpec;
import com.redhat.rhoas.v1alpha1.CloudServiceAccountRequest;
import com.redhat.rhoas.v1alpha1.CloudServiceAccountRequestSpec;
import com.redhat.rhoas.v1alpha1.CloudServicesRequest;
import com.redhat.rhoas.v1alpha1.CloudServicesRequestSpec;
import com.redhat.rhoas.v1alpha1.ServiceRegistryConnectionBuilder;
import com.redhat.rhoas.v1alpha1.serviceregistryconnectionspec.CredentialsBuilder;
import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder;
Expand Down Expand Up @@ -289,13 +288,20 @@ public void testCreateServiceRegistryConnection() throws Throwable {
throw new TestException(message("failed to find the user service registry {} in the CloudServicesRequest {}", SERVICE_REGISTRY_NAME, CLOUD_SERVICES_REQUEST_NAME));
}

var c = new ServiceRegistryConnection();

c.getMetadata().setName(SERVICE_REGISTRY_CONNECTION_NAME);
c.setSpec(new ServiceRegistryConnectionSpec());
c.getSpec().setAccessTokenSecretName(ACCESS_TOKEN_SECRET_NAME);
c.getSpec().setServiceRegistryId(serviceRegistry.orElseThrow().getId());
c.getSpec().setCredentials(new Credentials(SERVICE_ACCOUNT_SECRET_NAME));
var c = new ServiceRegistryConnectionBuilder()
.withNewMetadata()
.withName(SERVICE_REGISTRY_CONNECTION_NAME)
.endMetadata()
.withNewSpec()
.withAccessTokenSecretName(ACCESS_TOKEN_SECRET_NAME)
.withServiceRegistryId(serviceRegistry.orElseThrow().getId())
.withCredentials(
new CredentialsBuilder()
.withServiceAccountSecretName(SERVICE_ACCOUNT_SECRET_NAME)
.build()
)
.endSpec()
.build();

LOGGER.info("create ManagedServiceRegistryConnection with name: {}", SERVICE_REGISTRY_CONNECTION_NAME);
c = OperatorUtils.serviceRegistryConnection(oc).create(c);
Expand Down