Skip to content

Commit

Permalink
Replace MinioCustomizer with properties
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Oct 14, 2020
1 parent cb8b1ab commit 8c63df6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
df -h
- name: Get Camel K
run: |
export CAMEL_K_VERSION=1.0.0-nightly.202005130003
curl -L https://github.com/apache/camel-k/releases/download/${CAMEL_K_VERSION}/camel-k-client-${CAMEL_K_VERSION}-linux-64bit.tar.gz -o camel-k-client.tar.gz
export CAMEL_K_VERSION=1.2.0
curl -L https://github.com/apache/camel-k/releases/download/v${CAMEL_K_VERSION}/camel-k-client-${CAMEL_K_VERSION}-linux-64bit.tar.gz -o camel-k-client.tar.gz
tar -zxf camel-k-client.tar.gz
sudo mv kamel /usr/local/bin/
- name: Get YAKS
Expand Down
19 changes: 8 additions & 11 deletions API.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// camel-k: language=java
// camel-k: language=java dependency=camel-openapi-java

import org.apache.camel.builder.AggregationStrategies;
import org.apache.camel.builder.RouteBuilder;
Expand All @@ -12,8 +12,7 @@ public void configure() throws Exception {

// List the object names available in the S3 bucket
from("direct:list")
.to("aws-s3://{{api.bucket}}?operation=listObjects")
.transform().simple("${body.objectSummaries}")
.to("aws2-s3://{{api.bucket}}?operation=listObjects")
.split(simple("${body}"), AggregationStrategies.groupedBody())
.transform().simple("${body.key}")
.end()
Expand All @@ -23,22 +22,20 @@ public void configure() throws Exception {
// Get an object from the S3 bucket
from("direct:get")
.setHeader("CamelAwsS3Key", simple("${header.name}"))
.to("aws-s3://{{api.bucket}}?operation=getObject")
.setHeader("Content-Type", simple("${body.objectMetadata.contentType}"))
.transform().simple("${body.objectContent}");

.to("aws2-s3://{{api.bucket}}?operation=getObject")
.convertBodyTo(String.class);

// Upload a new object into the S3 bucket
from("direct:create")
.setHeader("CamelAwsS3Key", simple("${header.name}"))
.to("aws-s3://{{api.bucket}}");
.to("aws2-s3://{{api.bucket}}");


// Delete an object from the S3 bucket
from("direct:delete")
.setHeader("CamelAwsS3Key", simple("${header.name}"))
.to("aws-s3://{{api.bucket}}?operation=deleteObject")
.setBody().constant("");
.setHeader("CamelAwsS3Key", simple("${header.name}"))
.to("aws2-s3://{{api.bucket}}?operation=deleteObject")
.setBody().constant("");

}
}
14 changes: 7 additions & 7 deletions readme.didact.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ To run the integration, you need to link it to the proper configuration, that de

### 4.1 [Alternative 1] Using the test Minio server

As alternative, to connect the integration to the **test Minio server** deployed before using the [test/MinioCustomizer.java](didact://?commandId=vscode.open&projectFilePath=test/MinioCustomizer.java "Opens the customizer file"){.didact} class:
As alternative, to connect the integration to the **test Minio server** deployed before:

```
kamel run --name api test/MinioCustomizer.java API.java --property-file test/minio.properties --open-api openapi.yaml -d camel-openapi-java
kamel run --name api API.java --property-file test/minio.properties --open-api openapi.yaml -d camel-openapi-java
```
([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString&text=camelTerm$$kamel%20run%20--name%20api%20test/MinioCustomizer.java%20API.java%20--property-file%20test/minio.properties%20--open-api%20openapi.yaml%20-d%20camel-openapi-java&completion=Integration%20run. "Opens a new terminal and sends the command above"){.didact})
([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString&text=camelTerm$$kamel%20run%20--name%20api%20API.java%20--property-file%20test/minio.properties%20--open-api%20openapi.yaml%20-d%20camel-openapi-java&completion=Integration%20run. "Opens a new terminal and sends the command above"){.didact})

### 4.2 [Alternative 2] Using the S3 service

Expand Down Expand Up @@ -302,18 +302,18 @@ and manage it. This process is accomplished via the `3scale` trait in Camel K.
As alternative, to connect the integration to the **test Minio server**:

```
kamel run --name api test/MinioCustomizer.java API.java --property-file test/minio.properties --open-api openapi.yaml -d camel-openapi-java -t 3scale.enabled=true -t 3scale.description-path=/openapi.json --profile OpenShift
kamel run --name api API.java --property-file test/minio.properties --open-api openapi.yaml -t 3scale.enabled=true -t 3scale.description-path=/openapi.json --profile OpenShift
```
([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString&text=camelTerm$$kamel%20run%20--name%20api%20test%2FMinioCustomizer.java%20API.java%20--property-file%20test%2Fminio.properties%20--open-api%20openapi.yaml%20-d%20camel-openapi-java%20-t%203scale.enabled%3Dtrue%20-t%203scale.description-path%3D%2Fopenapi.json%20--profile%20OpenShift&completion=Integration%20run. "Opens a new terminal and sends the command above"){.didact})
([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString&text=camelTerm$$kamel%20run%20--name%20api%20API.java%20--property-file%20test%2Fminio.properties%20--open-api%20openapi.yaml%20-t%203scale.enabled%3Dtrue%20-t%203scale.description-path%3D%2Fopenapi.json%20--profile%20OpenShift&completion=Integration%20run. "Opens a new terminal and sends the command above"){.didact})

### 7.2 [Alternative 2] Using the S3 service

To connect the integration to the **AWS S3 service**:

```
kamel run API.java --property-file s3.properties --open-api openapi.yaml -d camel-openapi-java -t 3scale.enabled=true -t 3scale.description-path=/openapi.json --profile OpenShift
kamel run API.java --property-file s3.properties --open-api openapi.yaml -t 3scale.enabled=true -t 3scale.description-path=/openapi.json --profile OpenShift
```
([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString&text=camelTerm$$kamel%20run%20API.java%20--property-file%20s3.properties%20--open-api%20openapi.yaml%20-d%20camel-openapi-java%20-t%203scale.enabled%3Dtrue%20-t%203scale.description-path%3D%2Fopenapi.json%20--profile%20OpenShift&completion=Integration%20run. "Opens a new terminal and sends the command above"){.didact})
([^ execute](didact://?commandId=vscode.didact.sendNamedTerminalAString&text=camelTerm$$kamel%20run%20API.java%20--property-file%20s3.properties%20--open-api%20openapi.yaml%20-t%203scale.enabled%3Dtrue%20-t%203scale.description-path%3D%2Fopenapi.json%20--profile%20OpenShift&completion=Integration%20run. "Opens a new terminal and sends the command above"){.didact})


After the integration is updated, when looking in the 3scale API manager, you should find the new service.
Expand Down
36 changes: 0 additions & 36 deletions test/MinioCustomizer.java

This file was deleted.

8 changes: 7 additions & 1 deletion test/minio.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
# Bucket (referenced in the routes)
api.bucket=camel-k

# Minio information injected into the MinioCustomizer
# Minio information
minio.endpoint=http://minio:9000
minio.access-key=minio
minio.secret-key=minio123

# Camel AWS2 S3
camel.component.aws2-s3.region=EU_WEST_1
camel.component.aws2-s3.access-key={{minio.access-key}}
camel.component.aws2-s3.secret-key={{minio.secret-key}}
camel.component.aws2-s3.uri-endpoint-override = {{minio.endpoint}}
camel.component.aws2-s3.override-endpoint = true

# General configuration
camel.context.rest-configuration.api-context-path=/openapi.json
2 changes: 1 addition & 1 deletion test/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ pre:
run: |
kamel install -w -n ${YAKS_NAMESPACE}
kamel run --name api MinioCustomizer.java ../API.java --property-file minio.properties --open-api ../openapi.yaml -d camel-openapi-java -w -n ${YAKS_NAMESPACE}
kamel run --name api ../API.java --property-file minio.properties --open-api ../openapi.yaml -d camel-openapi-java -w -n ${YAKS_NAMESPACE}

0 comments on commit 8c63df6

Please sign in to comment.