From 09b49827824c363e738e7430220bf52ed61e3e9d Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Thu, 15 Oct 2020 13:14:15 +0200 Subject: [PATCH] Fix syntax highlighting for all code examples in guides Fixes #12733 --- docs/src/main/asciidoc/amazon-dynamodb.adoc | 6 +- docs/src/main/asciidoc/amazon-kms.adoc | 12 +-- .../src/main/asciidoc/amazon-lambda-http.adoc | 24 ++--- docs/src/main/asciidoc/amazon-lambda.adoc | 66 ++++++------ docs/src/main/asciidoc/amazon-s3.adoc | 8 +- docs/src/main/asciidoc/amazon-ses.adoc | 10 +- docs/src/main/asciidoc/amazon-sns.adoc | 10 +- docs/src/main/asciidoc/amazon-sqs.adoc | 10 +- docs/src/main/asciidoc/amqp.adoc | 8 +- .../main/asciidoc/azure-functions-http.adoc | 6 +- .../asciidoc/building-my-first-extension.adoc | 16 +-- .../main/asciidoc/building-native-image.adoc | 44 ++++---- .../asciidoc/building-substrate-howto.adoc | 12 +-- docs/src/main/asciidoc/cache.adoc | 4 +- docs/src/main/asciidoc/cassandra.adoc | 6 +- .../asciidoc/centralized-log-management.adoc | 8 +- docs/src/main/asciidoc/cli-tooling.adoc | 24 ++--- docs/src/main/asciidoc/config.adoc | 14 +-- docs/src/main/asciidoc/consul-config.adoc | 4 +- docs/src/main/asciidoc/container-image.adoc | 12 +-- docs/src/main/asciidoc/datasource.adoc | 6 +- .../asciidoc/deploying-to-azure-cloud.adoc | 22 ++-- .../asciidoc/deploying-to-kubernetes.adoc | 56 +++++----- .../main/asciidoc/deploying-to-openshift.adoc | 44 ++++---- docs/src/main/asciidoc/elasticsearch.adoc | 4 +- .../main/asciidoc/funqy-amazon-lambda.adoc | 36 +++---- .../main/asciidoc/funqy-gcp-functions.adoc | 36 ++++--- docs/src/main/asciidoc/funqy-http.adoc | 22 ++-- .../main/asciidoc/funqy-knative-events.adoc | 20 ++-- .../src/main/asciidoc/gcp-functions-http.adoc | 12 +-- docs/src/main/asciidoc/gcp-functions.adoc | 32 +++--- .../asciidoc/getting-started-reactive.adoc | 22 ++-- docs/src/main/asciidoc/getting-started.adoc | 19 ++-- docs/src/main/asciidoc/gradle-tooling.adoc | 24 ++--- .../asciidoc/grpc-service-implementation.adoc | 4 +- docs/src/main/asciidoc/hibernate-orm.adoc | 6 +- .../hibernate-search-elasticsearch.adoc | 6 +- docs/src/main/asciidoc/http-reference.adoc | 2 +- docs/src/main/asciidoc/jms.adoc | 22 ++-- docs/src/main/asciidoc/kafka-streams.adoc | 54 +++++----- docs/src/main/asciidoc/kafka.adoc | 8 +- docs/src/main/asciidoc/kogito.adoc | 2 +- docs/src/main/asciidoc/kotlin.adoc | 2 +- docs/src/main/asciidoc/kubernetes-client.adoc | 4 +- docs/src/main/asciidoc/kubernetes-config.adoc | 2 +- docs/src/main/asciidoc/lifecycle.adoc | 2 +- docs/src/main/asciidoc/mailer.adoc | 16 +-- docs/src/main/asciidoc/maven-tooling.adoc | 20 ++-- docs/src/main/asciidoc/micrometer.adoc | 8 +- .../microprofile-fault-tolerance.adoc | 6 +- .../main/asciidoc/microprofile-graphql.adoc | 4 +- .../main/asciidoc/microprofile-health.adoc | 2 +- .../main/asciidoc/microprofile-metrics.adoc | 6 +- docs/src/main/asciidoc/mongodb-panache.adoc | 2 +- docs/src/main/asciidoc/mongodb.adoc | 4 +- docs/src/main/asciidoc/native-and-ssl.adoc | 101 ++++++++++++------ docs/src/main/asciidoc/neo4j.adoc | 18 ++-- docs/src/main/asciidoc/openapi-swaggerui.adoc | 12 +-- docs/src/main/asciidoc/opentracing.adoc | 15 +-- docs/src/main/asciidoc/optaplanner.adoc | 4 +- .../main/asciidoc/performance-measure.adoc | 10 +- docs/src/main/asciidoc/quartz.adoc | 8 +- docs/src/main/asciidoc/qute.adoc | 2 +- .../src/main/asciidoc/reactive-event-bus.adoc | 10 +- .../main/asciidoc/reactive-sql-clients.adoc | 16 +-- docs/src/main/asciidoc/redis.adoc | 24 ++--- .../main/asciidoc/rest-client-multipart.adoc | 8 +- docs/src/main/asciidoc/rest-client.adoc | 4 +- docs/src/main/asciidoc/rest-json.adoc | 6 +- docs/src/main/asciidoc/scheduler.adoc | 4 +- docs/src/main/asciidoc/scripting.adoc | 20 ++-- docs/src/main/asciidoc/security-jdbc.adoc | 12 +-- docs/src/main/asciidoc/security-jpa.adoc | 12 +-- docs/src/main/asciidoc/security-jwt.adoc | 54 +++++----- docs/src/main/asciidoc/security-ldap.adoc | 12 +-- docs/src/main/asciidoc/security-oauth2.adoc | 18 ++-- .../security-openid-connect-multitenancy.adoc | 2 +- ...ity-openid-connect-web-authentication.adoc | 2 +- .../asciidoc/security-openid-connect.adoc | 2 +- .../main/asciidoc/spring-boot-properties.adoc | 6 +- docs/src/main/asciidoc/spring-cache.adoc | 2 +- .../asciidoc/spring-cloud-config-client.adoc | 2 +- docs/src/main/asciidoc/spring-data-jpa.adoc | 7 +- docs/src/main/asciidoc/spring-di.adoc | 2 +- docs/src/main/asciidoc/spring-scheduled.adoc | 4 +- docs/src/main/asciidoc/spring-security.adoc | 2 +- docs/src/main/asciidoc/spring-web.adoc | 2 +- .../main/asciidoc/tests-with-coverage.adoc | 6 +- docs/src/main/asciidoc/tika.adoc | 10 +- docs/src/main/asciidoc/validation.adoc | 2 +- docs/src/main/asciidoc/vault-auth.adoc | 38 +++---- docs/src/main/asciidoc/vault-datasource.adoc | 20 ++-- docs/src/main/asciidoc/vault-transit.adoc | 24 ++--- docs/src/main/asciidoc/vault.adoc | 40 +++---- docs/src/main/asciidoc/vertx.adoc | 20 ++-- docs/src/main/asciidoc/websockets.adoc | 7 +- .../src/main/asciidoc/writing-extensions.adoc | 12 +-- .../writing-native-applications-tips.adoc | 2 +- 98 files changed, 740 insertions(+), 685 deletions(-) diff --git a/docs/src/main/asciidoc/amazon-dynamodb.adoc b/docs/src/main/asciidoc/amazon-dynamodb.adoc index d82c8bb79fdd33..ce6d5ce60a0a9c 100644 --- a/docs/src/main/asciidoc/amazon-dynamodb.adoc +++ b/docs/src/main/asciidoc/amazon-dynamodb.adoc @@ -40,7 +40,7 @@ To complete this guide, you need: The easiest way to start working with DynamoDB is to run a local instance as a container. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- docker run --publish 8000:8000 amazon/dynamodb-local:1.11.477 -jar DynamoDBLocal.jar -inMemory -sharedDb ---- @@ -76,7 +76,7 @@ For more information, see https://docs.aws.amazon.com/amazondynamodb/latest/deve We recommend to use the AWS CLI to provision the table: -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- aws dynamodb create-table --table-name QuarkusFruits \ --attribute-definitions AttributeName=fruitName,AttributeType=S \ @@ -98,7 +98,7 @@ The solution is located in the `amazon-dynamodb-quickstart` {quickstarts-tree-ur First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/amazon-kms.adoc b/docs/src/main/asciidoc/amazon-kms.adoc index 0dba85a11eabe1..2be7852e9d8e27 100644 --- a/docs/src/main/asciidoc/amazon-kms.adoc +++ b/docs/src/main/asciidoc/amazon-kms.adoc @@ -39,14 +39,14 @@ To complete this guide, you need: The easiest way to start working with KMS is to run a local instance as a container. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- docker run --rm --name local-kms --publish 8011:4599 -e SERVICES=kms -e START_WEB=0 -d localstack/localstack:0.11.1 ---- This starts a KMS instance that is accessible on port `8011`. Create an AWS profile for your local instance using AWS CLI: -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- $ aws configure --profile localstack AWS Access Key ID [None]: test-key @@ -59,18 +59,18 @@ Default output format [None]: Create a KMS master key queue using AWS CLI and store in `MASTER_KEY_ARN` environment variable. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- MASTER_KEY_ARN=`aws kms create-key --profile localstack --endpoint-url=http://localhost:8011 | cut -f3` ---- Generate a key data as 256-bit symmetric key (AES 256) -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- aws kms generate-data-key --key-id $MASTER_KEY_ARN --key-spec AES_256 --profile localstack --endpoint-url=http://localhost:8011 ---- Or, if you want to use your AWS account create a key using your default profile -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- MASTER_KEY_ARN=`aws kms create-key | cut -f3` aws kms generate-data-key --key-id $MASTER_KEY_ARN --key-spec AES_256 @@ -90,7 +90,7 @@ The solution is located in the `amazon-kms-quickstart` {quickstarts-tree-url}/am First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/amazon-lambda-http.adoc b/docs/src/main/asciidoc/amazon-lambda-http.adoc index f70d34ac007511..c7af37f78c0522 100644 --- a/docs/src/main/asciidoc/amazon-lambda-http.adoc +++ b/docs/src/main/asciidoc/amazon-lambda-http.adoc @@ -42,7 +42,7 @@ for installing AWS SAM CLI. Create the Quarkus AWS Lambda maven project using our Maven Archetype. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn archetype:generate \ -DarchetypeGroupId=io.quarkus \ @@ -54,7 +54,7 @@ mvn archetype:generate \ Build the project using maven. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean install ---- @@ -66,7 +66,7 @@ available with this extension. If you want to build for native too, make sure you have GraalVM installed correctly and just add a `native` property to the build -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean install -Dnative ---- @@ -75,7 +75,7 @@ NOTE: If you are building on a non-Linux system, you will need to also pass in a Lambda requires linux binaries. You can do this by passing this property to your Maven build: `-Dnative-image.docker-build=true`, or for Gradle: `--docker-build=true`. This requires you to have docker installed locally, however. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean install -Dnative -Dnative-image.docker-build=true ---- @@ -94,7 +94,7 @@ are in the the build directory: `target/` for maven, `build/` for gradle. The AWS SAM CLI allows you to run your lambda's locally on your laptop in a simulated Lambda environment. This requires docker to be installed (see their install docs). After you have built your maven project, execute this command -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sam local start-api --template target/sam.jvm.yaml ---- @@ -110,7 +110,7 @@ lambda as pure Java. If you want to deploy a native executable of your lambda, use a different yaml template that is provided in your generated project: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sam local start-api --template target/sam.native.yaml ---- @@ -121,7 +121,7 @@ There are a few steps to get your lambda running on AWS. === Package your deployment. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sam package --template-file target/sam.jvm.yaml --output-template-file packaged.yaml --s3-bucket ---- @@ -131,7 +131,7 @@ Type the simple name of your S3 bucket you created during. If you've built a na === Deploy your package -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sam deploy --template-file packaged.yaml --capabilities CAPABILITY_IAM --stack-name ---- @@ -143,7 +143,7 @@ The stack name can be anything you want. If `sam deploy`, run the `describe-stack-events` command to get information about your deployment and what happened. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- aws cloudformation describe-stack-events --stack-name ---- @@ -165,7 +165,7 @@ To fix this error you'll need to create an S3 bucket in that region and redo ste Another annoying this is that if there is an error in deployment, you also have to completely delete it before trying to deploy again: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- aws cloudformation delete-stack --stack-name ---- @@ -174,13 +174,13 @@ aws cloudformation delete-stack --stack-name To get the root URL for your service, type the following command and see the following output: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- aws cloudformation describe-stacks --stack-name ---- It should give you something like the following output: -[source, subs=attributes+] +[source,subs=attributes+] ---- { "Stacks": [ diff --git a/docs/src/main/asciidoc/amazon-lambda.adoc b/docs/src/main/asciidoc/amazon-lambda.adoc index 9d011a7682b892..fda3a9f151416b 100644 --- a/docs/src/main/asciidoc/amazon-lambda.adoc +++ b/docs/src/main/asciidoc/amazon-lambda.adoc @@ -43,7 +43,7 @@ for installing AWS CLI. Create the Quarkus AWS Lambda maven project using our Maven Archetype. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn archetype:generate \ -DarchetypeGroupId=io.quarkus \ @@ -79,7 +79,7 @@ project and use configuration or an environment variable to pick the handler you The generated project has three lambdas within it. Two that implement the `RequestHandler` interface, and one that implements the `RequestStreamHandler` interface. One that is used and two that are unused. If you open up `src/main/resources/application.properties` you'll see this: -[source, subs=attributes+] +[source,properties,subs=attributes+] ---- quarkus.lambda.handler=test ---- @@ -89,7 +89,7 @@ with an environment variable too. If you look at the three generated handler classes in the project, you'll see that they are `@Named` differently. -[source, subs=attributes+] +[source,java,subs=attributes+] ---- @Named("test") public class TestLambda implements RequestHandler { @@ -116,7 +116,7 @@ create, update, delete, and invoke your lambdas for pure Java and native deploym Build the project using maven. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package ---- @@ -135,7 +135,7 @@ a lambda with AWS CLI. Specifically, make sure you have created an `Execution R a `LAMBDA_ROLE_ARN` environment variable in your profile or console window, Alternatively, you can edit the `manage.sh` script that is generated by the build and put the role value directly there: -[source] +[source,bash] ---- LAMBDA_ROLE_ARN="arn:aws:iam::1234567890:role/lambda-role" ---- @@ -166,21 +166,21 @@ A usage statement will be printed to guide you accordingly. NOTE: If using Gradle, the path to the binaries in the `manage.sh` must be changed from `target` to `build` To see the `usage` statement, and validate AWS configuration: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh ---- You can `create` your function using the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh create ---- or if you do not have `LAMBDA_ROLE_ARN` already defined in this shell: -[source] +[source,bash] ---- LAMBDA_ROLE_ARN="arn:aws:iam::1234567890:role/lambda-role" sh target/manage.sh create ---- @@ -191,13 +191,13 @@ handler bootstraps Quarkus and wraps your actual handler so that injection can b If there are any problems creating the function, you must delete it with the `delete` function before re-running the `create` command. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh delete ---- Commands may also be stacked: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh delete create ---- @@ -206,7 +206,7 @@ sh target/manage.sh delete create Use the `invoke` command to invoke your function. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh invoke ---- @@ -216,14 +216,14 @@ in the root directory of the project. The lambda can also be invoked locally with the SAM CLI like this: -[source] +[source,bash] ---- sam local invoke --template target/sam.jvm.yaml --event payload.json ---- If you are working with your native image build, simply replace the template name with the native version: -[source] +[source,bash] ---- sam local invoke --template target/sam.native.yaml --event payload.json ---- @@ -233,7 +233,7 @@ sam local invoke --template target/sam.native.yaml --event payload.json You can update the Java code as you see fit. Once you've rebuilt, you can redeploy your lambda by executing the `update` command. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh update ---- @@ -245,13 +245,13 @@ code to a native executable. Just make sure to rebuild your project with the `- For Linux hosts execute: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn package -Pnative ---- or, if using Gradle: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./gradlew build -Dquarkus.package.type=native ---- @@ -260,13 +260,13 @@ NOTE: If you are building on a non-Linux system, you will need to also pass in a Lambda requires linux binaries. You can do this by passing this property to your Maven build: `-Dnative-image.docker-build=true`, or for Gradle: `--docker-build=true`. This requires you to have docker installed locally, however. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean install -Pnative -Dnative-image.docker-build=true ---- or, if using Gradle: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true ---- @@ -278,7 +278,7 @@ Custom (Provided) Runtime. The instructions here are exactly as above with one change: you'll need to add `native` as the first parameter to the `manage.sh` script: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh native create ---- @@ -293,7 +293,7 @@ to create, delete, and update your lambdas. One thing to note about the create command for native is that the `aws lambda create-function` call must set a specific environment variable: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- --environment 'Variables={DISABLE_SIGNAL_HANDLERS=true}' ---- @@ -315,7 +315,7 @@ for your lambda deployment. Example Gradle dependencies: -[source, groovy] +[source,groovy] ---- dependencies { implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") @@ -340,7 +340,7 @@ The test replicates the execution environment, for the function that is selected To use the integration tests in your project there is a required property, in `src/test/resources/application.properties`. If not included, the integration tests will be in a constant loop. -[source,shell] +[source,properties] ---- quarkus.lambda.enable-polling-jvm-mode=true ---- @@ -433,14 +433,14 @@ The `event` parameter takes any JSON file, in this case the sample `payload.json NOTE: If using Gradle, the path to the binaries in the YAML templates must be changed from `target` to `build` -[source] +[source,bash] ---- sam local invoke --template target/sam.jvm.yaml --event payload.json ---- The native image can also be locally tested using the `sam.native.yaml` template: -[source] +[source,bash] ---- sam local invoke --template target/sam.native.yaml --event payload.json ---- @@ -471,7 +471,7 @@ you will need to include `quarkus-amazon-lambda-xray` as a dependency in your po library is not fully compatible with GraalVM so we had to do some integration work to make this work. In addition, remember to enable the AWS X-Ray tracing parameter in `manage.sh`, in the `cmd_create()` function. This can also be set in the AWS Management Console. -[source] +[source,bash] ---- --tracing-config Mode=Active ---- @@ -494,7 +494,7 @@ For further information, please consult the link:native-and-ssl[Quarkus SSL guid Open src/main/resources/application.properties and add the following line to enable SSL in your native image. -[source] +[source,properties] ---- quarkus.ssl.native=true ---- @@ -605,7 +605,7 @@ The native executable requires some additional steps to enable client ssl that S To do this, first create a directory `src/main/zip.native/` with your build. Next create a shell script file called `bootstrap` within `src/main/zip.native/`, like below. An example is create automatically in your build folder (target or build), called `bootstrap-example.sh` -[source, shell] +[source,bash] ---- #!/usr/bin/env bash @@ -618,7 +618,7 @@ Next you must copy some files from your GraalVM distribution into `src/main/zip. NOTE: GraalVM versions can have different paths for these files, and whether you using the Java 8 or 11 version. Adjust accordingly. -[source, shell] +[source,bash] ---- cp $GRAALVM_HOME/lib/libsunec.so $PROJECT_DIR/src/main/zip.native/ cp $GRAALVM_HOME/lib/security/cacerts $PROJECT_DIR/src/main/zip.native/ @@ -631,7 +631,7 @@ NOTE: If you are using a Docker image to build, then you must extract these file To extract the required ssl, you must start up a Docker container in the background, and attach to that container to copy the artifacts. First, let's start the GraalVM container, noting the container id output. -[source, shell,subs=attributes+] +[source,bash,subs=attributes+] ---- docker run -it -d --entrypoint bash quay.io/quarkus/ubi-quarkus-native-image:{graalvm-flavor} @@ -641,19 +641,19 @@ docker run -it -d --entrypoint bash quay.io/quarkus/ubi-quarkus-native-image:{gr First, libsunec.so, the C library used for the SSL implementation: -[source] +[source,bash] ---- docker cp {container-id-from-above}:/opt/graalvm/jre/lib/amd64/libsunec.so src/main/zip.native/ ---- Second, cacerts, the certificate store. You may need to periodically obtain an updated copy, also. -[source] +[source,bash] ---- docker cp {container-id-from-above}:/opt/graalvm/jre/lib/security/cacerts src/main/zip.native/ ---- Your final archive will look like this: -[source, shell] +[source,bash] ---- jar tvf target/function.zip @@ -667,7 +667,7 @@ jar tvf target/function.zip To use Alexa with Quarkus native, please add the following extension. -[source, xml] +[source,xml] ---- io.quarkus diff --git a/docs/src/main/asciidoc/amazon-s3.adoc b/docs/src/main/asciidoc/amazon-s3.adoc index 2460697a6c84e7..f2f3bc72493bf1 100644 --- a/docs/src/main/asciidoc/amazon-s3.adoc +++ b/docs/src/main/asciidoc/amazon-s3.adoc @@ -37,7 +37,7 @@ To complete this guide, you need: The easiest way to start working with S3 is to run a local instance as a container. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- docker run -it --publish 8008:4566 -e SERVICES=s3 -e START_WEB=0 localstack/localstack:0.11.5 ---- @@ -46,7 +46,7 @@ This starts a S3 instance that is accessible on port `8008`. **Note**: Versions of localstack newer than v0.11.5 require port `4566` instead of port `4572`. See this https://github.com/localstack/localstack/issues/2983[GitHub issue] for details on this change Create an AWS profile for your local instance using AWS CLI: -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- $ aws configure --profile localstack AWS Access Key ID [None]: test-key @@ -59,7 +59,7 @@ Default output format [None]: Create a S3 bucket using AWS CLI -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- aws s3 mb s3://quarkus.s3.quickstart --profile localstack --endpoint-url=http://localhost:8008 ---- @@ -79,7 +79,7 @@ The solution is located in the `amazon-s3-quickstart` {quickstarts-tree-url}/ama First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/amazon-ses.adoc b/docs/src/main/asciidoc/amazon-ses.adoc index d3a62a6064f2c4..e876141441eddb 100644 --- a/docs/src/main/asciidoc/amazon-ses.adoc +++ b/docs/src/main/asciidoc/amazon-ses.adoc @@ -38,14 +38,14 @@ To complete this guide, you need: The easiest way to start working with SES is to run a local instance as a container. However, local instance of SES is only mocks the SES APIs without the actual email sending capabilities. You can still use it for this guide to verify an API communication or integration test purposes. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- docker run --rm --name local-ses -p 8012:4579 -e SERVICES=ses -e START_WEB=0 -d localstack/localstack:0.11.1 ---- This starts a SES instance that is accessible on port `8012`. Create an AWS profile for your local instance using AWS CLI: -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- $ aws configure --profile localstack AWS Access Key ID [None]: test-key @@ -69,7 +69,7 @@ Going production, you'd need to get your account of the sandbox following the ht We assume you are going to use AWS SES sandbox for the sake of this guide. But before sending any email, you must verify sender and recipient email addresses using AWS CLI. You can use your personal email or any temporary email service available if you wish. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- aws ses verify-email-identity --email-address aws ses verify-email-identity --email-address @@ -79,7 +79,7 @@ Now, you need to open a mailboxes of those email addresses in order to follow co If you are using local SES you still need to verify email addresses, otherwise your send email in order to let local SES accepting your request. However, no emails to be send as it only mocks the service APIs. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- aws ses verify-email-identity --email-address --profile localstack --endpoint-url=http://localhost:8012 aws ses verify-email-identity --email-address --profile localstack --endpoint-url=http://localhost:8012 @@ -99,7 +99,7 @@ The solution is located in the `amazon-ses-quickstart` {quickstarts-tree-url}/am First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/amazon-sns.adoc b/docs/src/main/asciidoc/amazon-sns.adoc index 5f1e9e03bf37bb..02240580a06bc3 100644 --- a/docs/src/main/asciidoc/amazon-sns.adoc +++ b/docs/src/main/asciidoc/amazon-sns.adoc @@ -41,14 +41,14 @@ To complete this guide, you need: The easiest way to start working with SNS is to run a local instance as a container. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- docker run -it --publish 8009:4575 -e SERVICES=sns -e START_WEB=0 localstack/localstack:0.11.1 ---- This starts a SNS instance that is accessible on port `8009`. Create an AWS profile for your local instance using AWS CLI: -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- $ aws configure --profile localstack AWS Access Key ID [None]: test-key @@ -61,13 +61,13 @@ Default output format [None]: Create a SNS topic using AWS CLI and store in `TOPIC_ARN` environment variable -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- TOPIC_ARN=`aws sns create-topic --name=QuarksCollider --profile localstack --endpoint-url=http://localhost:8009` ---- If you want to run the demo using SNS on your AWS account, you can create a topic using AWS default profile -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- TOPIC_ARN=`aws sns create-topic --name=QuarksCollider` ---- @@ -87,7 +87,7 @@ The solution is located in the `amazon-sns-quickstart` {quickstarts-tree-url}/am First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/amazon-sqs.adoc b/docs/src/main/asciidoc/amazon-sqs.adoc index 7ca3b4bd12e15c..60fc7535661c57 100644 --- a/docs/src/main/asciidoc/amazon-sqs.adoc +++ b/docs/src/main/asciidoc/amazon-sqs.adoc @@ -42,14 +42,14 @@ To complete this guide, you need: The easiest way to start working with SQS is to run a local instance as a container. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- docker run --rm --name local-sqs -p 8010:4576 -e SERVICES=sqs -e START_WEB=0 -d localstack/localstack:0.11.1 ---- This starts a SQS instance that is accessible on port `8010`. Create an AWS profile for your local instance using AWS CLI: -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- $ aws configure --profile localstack AWS Access Key ID [None]: test-key @@ -62,13 +62,13 @@ Default output format [None]: Create a SQS queue using AWS CLI and store in `QUEUE_URL` environment variable. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- QUEUE_URL=`aws sqs create-queue --queue-name=ColliderQueue --profile localstack --endpoint-url=http://localhost:8010` ---- Or, if you want to use your SQS queue on your AWS account create a queue using your default profile -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- QUEUE_URL=`aws sqs create-queue --queue-name=ColliderQueue` ---- @@ -88,7 +88,7 @@ The solution is located in the `amazon-sqs-quickstart` {quickstarts-tree-url}/am First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/amqp.adoc b/docs/src/main/asciidoc/amqp.adoc index fbce8a63d1bfa6..fbf13b4f443cc5 100644 --- a/docs/src/main/asciidoc/amqp.adoc +++ b/docs/src/main/asciidoc/amqp.adoc @@ -46,7 +46,7 @@ The solution is located in the `amqp-quickstart` {quickstarts-tree-url}/amqp-qui First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -223,7 +223,7 @@ The `channel-name` segment must match the value set in the `@Incoming` and `@Out * `generated-price` -> sink in which we write the prices * `prices` -> source in which we read the prices -[source] +[source,properties] ---- # Configures the AMQP broker credentials. amqp-username=quarkus @@ -287,7 +287,7 @@ Nothing spectacular here. On each received price, it updates the page. If you followed the instructions, you should have the AMQP broker running. Then, you just need to run the application using: -[source, shell] +[source,bash] ---- ./mvnw quarkus:dev ---- @@ -300,7 +300,7 @@ NOTE: If you started the AMQP broker with docker compose, stop it using `CTRL+C` You can build the native executable with: -[source, shell] +[source,bash] ---- ./mvnw package -Pnative ---- diff --git a/docs/src/main/asciidoc/azure-functions-http.adoc b/docs/src/main/asciidoc/azure-functions-http.adoc index 300fd138649f53..e38c28be855120 100644 --- a/docs/src/main/asciidoc/azure-functions-http.adoc +++ b/docs/src/main/asciidoc/azure-functions-http.adoc @@ -36,7 +36,7 @@ to Azure. Create the azure maven project for your Quarkus application using our Maven Archetype. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn archetype:generate \ -DarchetypeGroupId=io.quarkus \ @@ -61,7 +61,7 @@ The values above are defined as properties in the generated `pom.xml` file. If you don't login to Azure you won't be able to deploy. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- az login ---- @@ -72,7 +72,7 @@ The `pom.xml` you generated in the previous step pulls in the `azure-functions-m generates config files and a staging directory required by the `azure-functions-maven-plugin`. Here's how to execute it. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean install azure-functions:deploy ---- diff --git a/docs/src/main/asciidoc/building-my-first-extension.adoc b/docs/src/main/asciidoc/building-my-first-extension.adoc index a593181827aa8f..c61d2ecf7bc62c 100644 --- a/docs/src/main/asciidoc/building-my-first-extension.adoc +++ b/docs/src/main/asciidoc/building-my-first-extension.adoc @@ -100,7 +100,7 @@ Now that everything is explained, we can start coding! Quarkus provides `create-extension` Maven Mojo to initialize your extension project. -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- $ mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create-extension -N \ -DgroupId=org.acme \ #<1> @@ -590,7 +590,7 @@ Let's add the testing dependencies into the `./quarkus-greeting/deployment/pom. Currently, the `create-extension` Maven Mojo does not create the test structure. We'll create it ourselves: -[source, shell] +[source,bash] ---- mkdir -p ./quarkus-greeting/deployment/src/test/java/org/acme/quarkus/greeting/deployment ---- @@ -629,7 +629,7 @@ public class GreetingTest { Time to test! -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- $ mvn clean test [INFO] Scanning for projects... @@ -690,7 +690,7 @@ That means if your want to debug this phase you need to launch your build tool w You can activate Maven remote debugging by using `mvnDebug`. You can launch your application with the following command line: -[source, shell] +[source,bash] ---- mvnDebug clean compile quarkus:dev ---- @@ -703,7 +703,7 @@ Now, you can run your IDE `Remote` configuration to attach it to `localhost:8000 You can activate Gradle remote debugging by using the flags `org.gradle.debug=true` or `org.gradle.daemon.debug=true` in daemon mode. You can launch your application with the following command line: -[source, shell] +[source,bash] ---- ./gradlew quarkusDev -Dorg.gradle.daemon.debug=true ---- @@ -717,7 +717,7 @@ Now, you can run your IDE `Remote` configuration to attach it to `localhost:5005 We have seen together how to test your extension and sometimes things don't go so well and you want to debug your tests. Same principle here, the trick is to enable the Maven Surefire remote debugging in order to attach an IDE `Remote` configuration. -[source, shell] +[source,bash] ---- $ cd ./greeting $ mvn clean test -Dmaven.surefire.debug @@ -734,7 +734,7 @@ Now that you just finish to build your first extension you should be eager to us Because your extension produces traditional JARs, the easiest way to share your extension is to publish it to a Maven repository. Once published you can simply declare it with your project dependencies. Let's demonstrate that by creating a simple Quarkus application -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- $mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -764,7 +764,7 @@ NOTE: `quarkus-greeting` extension has to be installed in the local Maven reposi Run the application and notice the `Install Features` list contains the `quarkus-greeting` extension. -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- $ mvn clean compile quarkus:dev [INFO] Scanning for projects... diff --git a/docs/src/main/asciidoc/building-native-image.adoc b/docs/src/main/asciidoc/building-native-image.adoc index d9ca8abeff9f7d..e3c9cd42fc30df 100644 --- a/docs/src/main/asciidoc/building-native-image.adoc +++ b/docs/src/main/asciidoc/building-native-image.adoc @@ -90,7 +90,7 @@ What does having a working C developer environment mean? * On Linux, you will need GCC, and the glibc and zlib headers. Examples for common distributions: + -[source,shell] +[source,bash] ---- # dnf (rpm-based) sudo dnf install gcc glibc-devel zlib-devel libstdc++-static @@ -99,7 +99,7 @@ sudo apt-get install build-essential libz-dev zlib1g-dev ---- * XCode provides the required dependencies on macOS: + -[source,shell] +[source,bash] ---- xcode-select --install ---- @@ -122,14 +122,14 @@ Version {graalvm-version} is required. Using the community edition is enough. Make sure to download and install at Java 11 version. 2. Configure the runtime environment. Set `GRAALVM_HOME` environment variable to the GraalVM installation directory, for example: + -[source,shell] +[source,bash] ---- export GRAALVM_HOME=$HOME/Development/graalvm/ ---- + On macOS, point the variable to the `Home` sub-directory: + -[source,shell] +[source,bash] ---- export GRAALVM_HOME=$HOME/Development/graalvm/Contents/Home/ ---- @@ -142,7 +142,7 @@ Installing via scoop will do this for you. ==== 3. Install the `native-image` tool using `gu install`: + -[source,shell] +[source,bash] ---- ${GRAALVM_HOME}/bin/gu install native-image ---- @@ -150,13 +150,13 @@ ${GRAALVM_HOME}/bin/gu install native-image Some previous releases of GraalVM included the `native-image` tool by default. This is no longer the case; it must be installed as a second step after GraalVM itself is installed. Note: there is an outstanding issue xref:graal-and-catalina[using GraalVM with macOS Catalina]. 4. (Optional) Set the `JAVA_HOME` environment variable to the GraalVM installation directory. + -[source,shell] +[source,bash] ---- export JAVA_HOME=${GRAALVM_HOME} ---- 5. (Optional) Add the GraalVM `bin` directory to the path + -[source,shell] +[source,bash] ---- export PATH=${GRAALVM_HOME}/bin:$PATH ---- @@ -167,14 +167,14 @@ export PATH=${GRAALVM_HOME}/bin:$PATH ==== GraalVM binaries are not (yet) notarized for macOS Catalina as reported in this https://github.com/oracle/graal/issues/1724[GraalVM issue]. This means that you may see the following error when using `gu`: -[source,shell] +[source,bash] ---- “gu” cannot be opened because the developer cannot be verified ---- Use the following command to recursively delete the `com.apple.quarantine` extended attribute on the GraalVM install directory as a workaround: -[source,shell] +[source,bash] ----- xattr -r -d com.apple.quarantine ${GRAALVM_HOME}/../.. ----- @@ -234,7 +234,7 @@ the `x64 Native Tools Command Prompt` that was installed with the Visual Studio Another solution is to write a script to do this for you: -[source,shell] +[source,bash] ---- cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" && mvn package -Pnative' ---- @@ -296,7 +296,7 @@ The executable is retrieved using the `native.image.path` system property config <2> We extend our previous tests, but you can also implement your tests To see the `NativeGreetingResourceIT` run against the native executable, use `./mvnw verify -Pnative`: -[source,shell] +[source,bash] ---- ./mvnw verify -Pnative ... @@ -368,7 +368,7 @@ to install as little software as possible). To this end, Quarkus provides a very convenient way of creating a native Linux executable by leveraging a container runtime such as Docker or podman. The easiest way of accomplishing this task is to execute: -[source, shell] +[source,bash] ---- ./mvnw package -Pnative -Dquarkus.native.container-build=true ---- @@ -376,7 +376,7 @@ The easiest way of accomplishing this task is to execute: [TIP] ==== You can also select the container runtime to use with: -[source,shell] +[source,bash] ---- # Docker ./mvnw package -Pnative -Dquarkus.native.container-runtime=docker @@ -392,7 +392,7 @@ it is recommended you add these to your `application.properties` in order to avo [TIP] ==== Building with Mandrel requires a custom builder image parameter to be passed additionally: -[source,shell] +[source,bash] ---- ./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel:{mandrel-flavor} ---- @@ -413,7 +413,7 @@ By far the easiest way to create a container-image from your Quarkus application If one of those extensions is present, then creating a container image for the native executable is essentially a matter of executing a single command: -[source, shell] +[source,bash] ---- ./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true ---- @@ -464,14 +464,14 @@ You can read more about UBI on: Then, if you didn't delete the generated native executable, you can build the docker image with: -[source,shell] +[source,bash] ---- docker build -f src/main/docker/Dockerfile.native -t quarkus-quickstart/getting-started . ---- And finally, run it with: -[source,shell] +[source,bash] ---- docker run -i --rm -p 8080:8080 quarkus-quickstart/getting-started ---- @@ -548,14 +548,14 @@ If you are using Gradle in your project, you can use this sample Dockerfile. Sa Before launching our Docker build, we need to update the default `.dockerignore` file as it filters everything except the `target` directory and as we plan to build inside a container we need to be able to copy the `src` directory. So edit your `.dockerignore` and remove or comment its content. ==== -[source,shell] +[source,bash] ---- docker build -f src/main/docker/Dockerfile.multistage -t quarkus-quickstart/getting-started . ---- And finally, run it with: -[source,shell] +[source,bash] ---- docker run -i --rm -p 8080:8080 quarkus-quickstart/getting-started ---- @@ -597,7 +597,7 @@ The location of source cache is `target/{project.name}-{project.version}-native- ==== To load the sources in `gdb`, run: -[source,shell] +[source,bash] ---- directory target/{project.name}-{project.version}-native-image-source-jar ---- @@ -606,13 +606,13 @@ in the `gdb` prompt. Or start `gdb` with: -[source,shell] +[source,bash] ---- gdb -ex 'directory target/{project.name}-{project.version}-native-image-source-jar' target/{project.name}-{project.version}-runner ---- e.g., -[source,shell] +[source,bash] ---- gdb -ex 'directory target/getting-started-1.0-SNAPSHOT-native-image-source-jar' target/getting-started-1.0-SNAPSHOT-runner ---- diff --git a/docs/src/main/asciidoc/building-substrate-howto.adoc b/docs/src/main/asciidoc/building-substrate-howto.adoc index b5d0d0d678bc5f..232dd5c8a948e8 100644 --- a/docs/src/main/asciidoc/building-substrate-howto.adoc +++ b/docs/src/main/asciidoc/building-substrate-howto.adoc @@ -22,7 +22,7 @@ auth param. After obtaining the download install it and set `JAVA_HOME` -[source,shell] +[source,bash] ---- wget -O jvmci.tgz http://download.oracle.com/otn/utilities_drivers/oracle-labs/labsjdk-8u202-jvmci-0.56-darwin-amd64.tar.gz?AuthParam=[GENERATED AUTH TOKEN HERE] tar -xzvf jvmci.tgz -C /opt @@ -39,7 +39,7 @@ the minimum requirements. Now you need to install Graal’s special build tool, `mx`. -[source,shell] +[source,bash] ---- git clone https://github.com/graalvm/mx.git export PATH=`pwd`/mx:$PATH @@ -49,7 +49,7 @@ export PATH=`pwd`/mx:$PATH You can now check-out and build Substrate: -[source,shell] +[source,bash] ---- git clone https://github.com/oracle/graal.git cd graal/substratevm @@ -58,7 +58,7 @@ mx build Once built, you can quickly run the tools in place -[source,shell] +[source,bash] ---- echo "public class HelloWorld { public static void main(String[] args) { System.out.println(\"Hello World\"); } }" > HelloWorld.java javac HelloWorld.java @@ -75,7 +75,7 @@ build options to pick the modules in your distribution. For a simple subset VM with just substrate and its native tools execute the following: -[source,shell] +[source,bash] ---- cd ../vm mx --dy /substratevm,/tools build @@ -84,7 +84,7 @@ the following: For a stock CE build the following will do: -[source,shell] +[source,bash] ---- mx --dy /substratevm,/tools,/sulong,/graal-nodejs build tar -czvf my-custom-graal.tgz -C latest_graalvm . diff --git a/docs/src/main/asciidoc/cache.adoc b/docs/src/main/asciidoc/cache.adoc index aa3b97fdd91d25..7bbae70e16eb5f 100644 --- a/docs/src/main/asciidoc/cache.adoc +++ b/docs/src/main/asciidoc/cache.adoc @@ -42,7 +42,7 @@ The solution is located in the `cache-quickstart` directory. First, we need to create a new Quarkus project using Maven with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -191,7 +191,7 @@ First, run the application using `./mvnw compile quarkus:dev` from the project d Then, call `http://localhost:8080/weather?city=Raleigh` from a browser. After six long seconds, the application will answer something like this: -[source] +[source,json] ---- {"dailyForecasts":["MONDAY will be cloudy in Raleigh","TUESDAY will be chilly in Raleigh","WEDNESDAY will be rainy in Raleigh"],"executionTimeInMs":6001} ---- diff --git a/docs/src/main/asciidoc/cassandra.adoc b/docs/src/main/asciidoc/cassandra.adoc index 48f0d69bed4787..a80ef0ecf52fc7 100644 --- a/docs/src/main/asciidoc/cassandra.adoc +++ b/docs/src/main/asciidoc/cassandra.adoc @@ -343,7 +343,7 @@ following CQL query: `SELECT data_center FROM system.local`. If you want to use Docker to run a Cassandra database, you can use the following command to launch one: -[source,shell] +[source,bash] ---- docker run \ --name local-cassandra-instance \ @@ -363,7 +363,7 @@ like JMX monitoring of the Cassandra instance. Next you need to create the keyspace and table that will be used by your application. If you are using Docker, run the following commands: -[source,shell] +[source,bash] ---- docker exec -it local-cassandra-instance cqlsh -e "CREATE KEYSPACE IF NOT EXISTS k1 WITH replication = {'class':'SimpleStrategy', 'replication_factor':1}" docker exec -it local-cassandra-instance cqlsh -e "CREATE TABLE IF NOT EXISTS k1.fruit(id text, name text, description text, PRIMARY KEY((id), name))" @@ -371,7 +371,7 @@ docker exec -it local-cassandra-instance cqlsh -e "CREATE TABLE IF NOT EXISTS k1 If you're running Cassandra locally you can execute the cqlsh commands directly: -[source,shell] +[source,bash] ---- cqlsh -e "CREATE KEYSPACE IF NOT EXISTS k1 WITH replication = {'class':'SimpleStrategy', 'replication_factor':1} cqlsh -e "CREATE TABLE IF NOT EXISTS k1.fruit(id text, name text, description text, PRIMARY KEY((id), name)) diff --git a/docs/src/main/asciidoc/centralized-log-management.adoc b/docs/src/main/asciidoc/centralized-log-management.adoc index ea235ab3a159cb..f8a98d7b547fdd 100644 --- a/docs/src/main/asciidoc/centralized-log-management.adoc +++ b/docs/src/main/asciidoc/centralized-log-management.adoc @@ -23,7 +23,7 @@ The following examples will all be based on the same example application that yo Create an application with the `quarkus-logging-gelf` extension. You can use the following Maven command to create it: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -136,7 +136,7 @@ You can do it from the Graylog web console (System -> Input -> Select GELF UDP) This curl example will create a new Input of type GELF UDP, it uses the default login from Graylog (admin/admin). -[source,shell] +[source,bash] ---- curl -H "Content-Type: application/json" -H "Authorization: Basic YWRtaW46YWRtaW4=" -H "X-Requested-By: curl" -X POST -v -d \ '{"title":"udp input","configuration":{"recv_buffer_size":262144,"bind_address":"0.0.0.0","port":12201,"decompress_size_limit":8388608},"type":"org.graylog2.inputs.gelf.udp.GELFUDPInput","global":true}' \ @@ -227,7 +227,7 @@ Launch your application, you should see your logs arriving inside the Elastic St First, you need to create a Fluentd image with the needed plugins: elasticsearch and input-gelf. You can use the following Dockerfile that should be created inside a `fluentd` directory. -[source] +[source,dockerfile] ---- FROM fluent/fluentd:v1.3-debian RUN ["gem", "install", "fluent-plugin-elasticsearch", "--version", "3.7.0"] @@ -315,7 +315,7 @@ As opposed to the GELF input, the Syslog input will not render multiline logs in First, you need to create a Fluentd image with the elasticsearch plugin. You can use the following Dockerfile that should be created inside a `fluentd` directory. -[source] +[source,dockerfile] ---- FROM fluent/fluentd:v1.3-debian RUN ["gem", "install", "fluent-plugin-elasticsearch", "--version", "3.7.0"] diff --git a/docs/src/main/asciidoc/cli-tooling.adoc b/docs/src/main/asciidoc/cli-tooling.adoc index a76ad0e8108a4f..86f0f23cd80e5a 100644 --- a/docs/src/main/asciidoc/cli-tooling.adoc +++ b/docs/src/main/asciidoc/cli-tooling.adoc @@ -24,23 +24,23 @@ binary there. Then in your shell profile (for Bash shell edit '~/.bash_profile'), export the 'QUARKUS_HOME' folder and add that to your 'PATH': -[source,shell] +[source,bash] export QUARKUS_HOME=/path/to/quarkus-cli export PATH="$PATH:$QUARKUS_HOME" Reload your terminal or do: -[source,shell] +[source,bash] source ~/.bash_profile Now you can run the Quarkus CLI: -[source,shell] +[source,bash] $ quarkus --help This will display the help information with all the available commands. -[source,shell] +[source,bash] $ quarkus -i This will start the Quarkus CLI in interactive mode. @@ -53,7 +53,7 @@ Download the jar-file here: As with the native CLI we recommend that you copy the binary to a specific folder, eg '~/quarkus'. The jar file requires Java 8 or newer to run. To start the CLI: -[source,shell] +[source,bash] $ java -jar quarkus-cli.jar The jar file CLI accepts all the same options and commands as the native binary. @@ -66,7 +66,7 @@ Note: In the examples below switch out 'quarkus' with 'java -jar quarkus-cli.jar To create a new project we use the create-project command: -[source,shell] +[source,bash] $ quarkus create-project hello-world This will create a folder called 'hello-world' in your current working directory using default @@ -76,25 +76,25 @@ groupId, artifactId and version values To specify the groupId, artifactId and version values, use the '--groupid', '--artifactid' and '--version' options: -[source,shell] +[source,bash] $ quarkus create-project --groupid=com.foo --artifactId=bar --version=1.0 hello-world Use the help option to display all the possible options: -[source,shell] +[source,bash] $ quarkus create-project --help == Dealing with extensions The Quarkus CLI can obtain a list of the available extensions with: -[source,shell] +[source,bash] $ quarkus list-extensions To more easily get an overview and only display the extension names: -[source,shell] +[source,bash] $ quarkus list-extensions -n @@ -103,7 +103,7 @@ $ quarkus list-extensions -n The Quarkus CLI can add Quarkus extensions to your project with the 'add-extension' command: -[source,shell] +[source,bash] $ quarkus add-extension --extension=hibernate-validator /path/to/my/project The argument path either needs to be the base folder for the project or a direct path to the @@ -113,7 +113,7 @@ build file. To start dev mode from the Quarkus CLI do: -[source,shell] +[source,bash] $ quarkus dev /path/to/my/project As with 'add-extension' the argument path needs to be the base folder for the project or a diff --git a/docs/src/main/asciidoc/config.adoc b/docs/src/main/asciidoc/config.adoc index 226a5e27b7acfa..418bf9c23d8e1c 100644 --- a/docs/src/main/asciidoc/config.adoc +++ b/docs/src/main/asciidoc/config.adoc @@ -32,7 +32,7 @@ The solution is located in the `config-quickstart` {quickstarts-tree-url}/config First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -99,7 +99,7 @@ public String hello() { By default, Quarkus reads `application.properties`. Edit the `src/main/resources/application.properties` with the following content: -[source,shell] +[source,bash] ---- # Your configuration properties greeting.message = hello @@ -108,7 +108,7 @@ greeting.name = quarkus Once set, check the application with: -[source,shell] +[source,bash] ---- $ curl http://localhost:8080/greeting hello quarkus! @@ -374,7 +374,7 @@ All the Quarkus configuration properties are link:all-config[documented and sear It is also possible to generate an example `application.properties` with all known configuration properties, to make it easy to see what Quarkus configuration options are available. To do this, run: -[source,shell] +[source,bash] -- ./mvnw quarkus:generate-config -- @@ -395,7 +395,7 @@ when applicable. For example this HTTP port config entry will appear as: Rather than generating an example config file, you can also add these to you actual config file by setting the `-Dfile` parameter: -[source,shell] +[source,bash] -- ./mvnw quarkus:generate-config -Dfile=application.properties -- @@ -409,7 +409,7 @@ Quarkus does much of its configuration and bootstrap at build time. Most properties will then be read and set during the build time step. To change them, make sure to repackage your application. -[source,shell] +[source,bash] -- ./mvnw clean package -- @@ -586,7 +586,7 @@ corresponding system property, or setting the corresponding environment variable ==== Miscellaneous The default Quarkus application runtime profile is set to the profile used to build the application. For example: -[source,shell] +[source,bash] ---- ./mvnw package -Pnative -Dquarkus.profile=prod-aws ./target/my-app-1.0-runner // <1> diff --git a/docs/src/main/asciidoc/consul-config.adoc b/docs/src/main/asciidoc/consul-config.adoc index 09525166fd1fdd..6f84de72399fba 100644 --- a/docs/src/main/asciidoc/consul-config.adoc +++ b/docs/src/main/asciidoc/consul-config.adoc @@ -35,7 +35,7 @@ This Key-Value store is what the `quarkus-consul-config` extension interacts wit There are various ways to start Consul that vary in complexity, but for the purposes of this guide, we elect to start a single Consul server with no persistence via Docker, like so: -[source] +[source,bash] ---- docker run --rm --name consul -p 8500:8500 -p 8501:8501 consul:1.7 agent -dev -ui -client=0.0.0.0 -bind=0.0.0.0 --https-port=8501 ---- @@ -46,7 +46,7 @@ Please consult the https://www.consul.io/docs/install[documentation] to learn mo First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/container-image.adoc b/docs/src/main/asciidoc/container-image.adoc index f4239f570723b7..7f6cd9e77a7839 100644 --- a/docs/src/main/asciidoc/container-image.adoc +++ b/docs/src/main/asciidoc/container-image.adoc @@ -25,7 +25,7 @@ when all that is needed is the ability to push to a container image registry. To use this feature, add the following extension to your project: -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="container-image-jib" ---- @@ -48,7 +48,7 @@ The extension `quarkus-container-image-docker` is using the Docker binary and th To use this feature, add the following extension to your project. -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="container-image-docker" ---- @@ -75,7 +75,7 @@ The creation of such objects is being taken care of by the Quarkus Kubernetes ex To build a container image for your project, `quarkus.container-image.build=true` needs to be set using any of the ways that Quarkus supports. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package -Dquarkus.container-image.build=true ---- @@ -84,7 +84,7 @@ To build a container image for your project, `quarkus.container-image.build=true To push a container image for your project, `quarkus.container-image.push=true` needs to be set using any of the ways that Quarkus supports. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package -Dquarkus.container-image.push=true ---- @@ -97,7 +97,7 @@ It does not make sense to use multiple extension as part of the same build. When For example, if both `container-image-docker` and `container-image-s2i` are present and the user needs to use `container-image-docker`: -[source] +[source,properties] ---- quarkus.container-image.builder=docker ---- @@ -119,7 +119,7 @@ For example, https://gitlab.com/[GitLab] provides such a registry and in the pro makes available the `CI_REGISTRY_IMAGE` environment variable (see GitLab's https://docs.gitlab.com/ee/ci/variables/[documentation]) for more information), which can be used in Quarkus like so: -[source] +[source,properties] ---- quarkus.container-image.image=${CI_REGISTRY_IMAGE} ---- diff --git a/docs/src/main/asciidoc/datasource.adoc b/docs/src/main/asciidoc/datasource.adoc index f2dcf2484ca80a..aa6a7e17f155d5 100644 --- a/docs/src/main/asciidoc/datasource.adoc +++ b/docs/src/main/asciidoc/datasource.adoc @@ -135,7 +135,7 @@ First, you will need to add the `quarkus-agroal` dependency to your project. You can add it using a simple Maven command: -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="agroal" ---- @@ -172,7 +172,7 @@ As usual, you can install the extension using `add-extension`. To install the PostgreSQL driver dependency for instance, run the following command: -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="jdbc-postgresql" ---- @@ -472,7 +472,7 @@ while the database will run in the JVM as usual. Connect to it using: -[source] +[source,properties] ---- quarkus.datasource.db-kind=h2 quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test diff --git a/docs/src/main/asciidoc/deploying-to-azure-cloud.adoc b/docs/src/main/asciidoc/deploying-to-azure-cloud.adoc index e05a006e995d6e..ab11f4f6c53959 100644 --- a/docs/src/main/asciidoc/deploying-to-azure-cloud.adoc +++ b/docs/src/main/asciidoc/deploying-to-azure-cloud.adoc @@ -43,14 +43,14 @@ CMD ["./application", "-Dquarkus.http.host=0.0.0.0", "-Dquarkus.http.port=80"] Now you can rebuild the docker image: -[source,shell] +[source,bash] ---- $ docker build -f src/main/docker/Dockerfile.native -t quarkus-quickstart/getting-started . ---- To test, run it by exposing port 80 into port 8080 in your host: -[source,shell] +[source,bash] ---- $ docker run -i --rm -p 8080:80 quarkus-quickstart/getting-started ---- @@ -65,7 +65,7 @@ Visit the https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli- Once installed, ensure you are authenticated: -[source,shell] +[source,bash] ---- $ az login ---- @@ -76,21 +76,21 @@ It is possible to deploy images hosted on Docker Hub, but this location by defau First, create an Azure Resource Group: -[source,shell] +[source,bash] ---- $ az group create --name --location eastus ---- Then you can create the ACR: -[source,shell] +[source,bash] ---- $ az acr create --resource-group --name --sku Basic --admin-enabled true ---- Finally, authenticate your local Docker installation with this container registry by running: -[source,shell] +[source,bash] ---- $ az acr login --name ---- @@ -101,14 +101,14 @@ If you've followed the build native image guide, you should have a local contain To upload this image to your ACR, you must tag and push the image under the ACR login server. To find the login server of the Azure Container Registry, run this command: -[source,shell] +[source,bash] ---- $ az acr show -n --query loginServer ---- To upload, now do: -[source,shell] +[source,bash] ---- $ docker tag quarkus-quickstart/getting-started /quarkus-quickstart/getting-started $ docker push /quarkus-quickstart/getting-started @@ -116,7 +116,7 @@ $ docker push /quarkus-quickstart/getting-started At this point, you should have your Quarkus container image on your Azure Container Registry. To verify, run the following command: -[source,shell] +[source,bash] ---- $ az acr repository list -n ---- @@ -129,14 +129,14 @@ There are different approaches for using ACI. Check the documentation for detail First step is to find the username and password for the admin, so that ACI can authenticate into ACR and pull the Docker image: -[source,shell] +[source,bash] ---- $ az acr credential show --name ---- Now create the Docker instance on ACI pointing to your image on ACR: -[source,shell] +[source,bash] ---- $ az container create \ --name quarkus-hello \ diff --git a/docs/src/main/asciidoc/deploying-to-kubernetes.adoc b/docs/src/main/asciidoc/deploying-to-kubernetes.adoc index 9f02650bf0ed2d..03dba98adf65bb 100644 --- a/docs/src/main/asciidoc/deploying-to-kubernetes.adoc +++ b/docs/src/main/asciidoc/deploying-to-kubernetes.adoc @@ -142,7 +142,7 @@ The full source of the `kubernetes.json` file looks something like this: The generated manifest can be applied to the cluster from the project root using `kubectl`: -[source] +[source,bash] ---- kubectl apply -f target/kubernetes/kubernetes.json ---- @@ -152,7 +152,7 @@ The name of the image is controlled by the Jib extension and can be customized u For example with a configuration like: -[source] +[source,properties] ---- quarkus.container-image.group=quarkus #optional, default to the system user name quarkus.container-image.name=demo-app #optional, defaults to the application name @@ -165,7 +165,7 @@ The image that will be used in the generated manifests will be `quarkus/demo-app The Docker registry can be specified with the following property: -[source] +[source,properties] ---- quarkus.container-image.registry=my.docker-registry.net ---- @@ -181,7 +181,7 @@ The generated manifests use the Kubernetes link:https://kubernetes.io/docs/conce These labels can be customized using `quarkus.kubernetes.name`, `quarkus.kubernetes.version` and `quarkus.kubernetes.part-of`. For example by adding the following configuration to your `application.properties`: -[source] +[source,properties] ---- quarkus.kubernetes.part-of=todo-app quarkus.kubernetes.name=todo-rest @@ -193,7 +193,7 @@ quarkus.kubernetes.version=1.0-rc.1 As is described in detail in the <<#openshift, OpenShift>> section, customizing OpenShift (or Knative) properties is done in the same way, but replacing `kubernetes` with `openshift` (or `knative`). The previous example for OpenShift would look like this: -[source] +[source,properties] ---- quarkus.openshift.part-of=todo-app quarkus.openshift.name=todo-rest @@ -216,7 +216,7 @@ The labels in generated resources will look like: To add additional custom labels, for example `foo=bar` just apply the following configuration: -[source] +[source,properties] ---- quarkus.kubernetes.labels.foo=bar ---- @@ -239,7 +239,7 @@ Out of the box, the generated resources will be annotated with version control r Custom annotations can be added in a way similar to labels.For example to add the annotation `foo=bar` and `app.quarkus/id=42` just apply the following configuration: -[source] +[source,properties] ---- quarkus.kubernetes.annotations.foo=bar quarkus.kubernetes.annotations."app.quarkus/id"=42 @@ -360,7 +360,7 @@ This would generate the following in the `env` section of your container: It's also possible to use the value from another field to add a new environment variable by specifying the path of the field to be used as a source, as follows: -[source] +[source,properties] ---- quarkus.kubernetes.env.fields.foo=metadata.name ---- @@ -370,7 +370,7 @@ quarkus.kubernetes.env.fields.foo=metadata.name As is described in detail in the <<#openshift, OpenShift>> section, customizing OpenShift properties is done in the same way, but replacing `kubernetes` with `openshift`. The previous example for OpenShift would look like this: -[source] +[source,properties] ---- quarkus.openshift.env.fields.foo=metadata.name ---- @@ -410,7 +410,7 @@ only generate an environment variable `MY_ENV_VAR=newValue` and issue a warning. The Kubernetes extension allows the user to configure both volumes and mounts for the application. Any volume can be mounted with a simple configuration: -[source] +[source,properties] ---- quarkus.kubernetes.mounts.my-volume.path=/where/to/mount ---- @@ -420,14 +420,14 @@ The volumes themselves can be configured as shown in the sections below. ===== Secret volumes -[source] +[source,properties] ---- quarkus.kubernetes.secret-volumes.my-volume.secret-name=my-secret ---- ===== ConfigMap volumes -[source] +[source,properties] ---- quarkus.kubernetes.config-map-volumes.my-volume.config-map-name=my-secret ---- @@ -436,7 +436,7 @@ quarkus.kubernetes.config-map-volumes.my-volume.config-map-name=my-secret To change the number of replicas from 1 to 3: -[source] +[source,properties] ---- quarkus.kubernetes.replicas=3 ---- @@ -459,7 +459,7 @@ More information about the health extension can be found in the relevant link:mi === Customizing the readiness probe: To set the initial delay of the probe to 20 seconds and the period to 45: -[source] +[source,properties] ---- quarkus.kubernetes.readiness-probe.initial-delay=20s quarkus.kubernetes.readiness-probe.period=45s @@ -468,7 +468,7 @@ quarkus.kubernetes.readiness-probe.period=45s === Add hostAliases To add entries to a Pod's `/etc/hosts` file (more information can be found in https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/[Kubernetes documentation]), just apply the following configuration: -[source] +[source,properties] ---- quarkus.kubernetes.hostaliases."10.0.0.0".hostnames=foo.com,bar.org ---- @@ -523,7 +523,7 @@ This extension assumes a couple things: * Users won't be using an image registry and will instead make their container image accessible to the Kubernetes cluster by building it directly into Minikube's Docker daemon. To use Minikube's Docker daemon you must first execute: + -[source] +[source,bash] ---- eval $(minikube -p minikube docker-env) ---- @@ -531,7 +531,7 @@ eval $(minikube -p minikube docker-env) * Applications deployed to Kubernetes won't be accessed via a Kubernetes `Ingress`, but rather as a `NodePort` `Service`. The advantage of doing this is that the URL of an application can be retrieved trivially by executing: + -[source] +[source,bash] ---- minikube service list ---- @@ -593,7 +593,7 @@ The table below describe all the available configuration options. Properties that use non-standard types, can be referenced by expanding the property. For example to define a `kubernetes-readiness-probe` which is of type `Probe`: -[source] +[source,properties] ---- quarkus.kubernetes.readiness-probe.initial-delay=20s quarkus.kubernetes.readiness-probe.period=45s @@ -733,7 +733,7 @@ Allowed values: `cluster-ip`, `node-port`, `load-balancer`, `external-name` One way to deploy an application to OpenShift is to use s2i (source to image) to create an image stream from the source and then deploy the image stream: -[source] +[source,bash] ---- ./mvnw quarkus:remove-extension -Dextensions="kubernetes, jib" ./mvnw quarkus:add-extension -Dextensions="openshift" @@ -753,14 +753,14 @@ A description of OpenShift resources and customisable properties is given below To enable the generation of OpenShift resources, you need to include OpenShift in the target platforms: -[source] +[source,properties] ---- quarkus.kubernetes.deployment-target=openshift ---- If you need to generate resources for both platforms (vanilla Kubernetes and OpenShift), then you need to include both (comma separated). -[source] +[source,properties] ---- quarkus.kubernetes.deployment-target=kubernetes,openshift ---- @@ -770,14 +770,14 @@ Following the execution of `./mvnw package -Dquarkus.container-image.build=true These manifests can be deployed as is to a running cluster, using `kubectl`: -[source] +[source,bash] ---- kubectl apply -f target/kubernetes/openshift.json ---- OpenShift users might want to use `oc` instead of `kubectl`: -[source] +[source,bash] ---- oc apply -f target/kubernetes/openshift.json ---- @@ -828,7 +828,7 @@ The OpenShift resources can be customized in a similar approach with Kubernetes. To enable the generation of Knative resources, you need to include Knative in the target platforms: -[source] +[source,properties] ---- quarkus.kubernetes.deployment-target=knative ---- @@ -877,7 +877,7 @@ The full source of the `knative.json` file looks something like this: The generated manifest can be deployed as is to a running cluster, using `kubectl`: -[source] +[source,bash] ---- kubectl apply -f target/kubernetes/knative.json ---- @@ -949,7 +949,7 @@ Properties referring to config group arrays (e.g. `kubernetes.labels[0]`, `kuber The code below demonstrates the change in `labels` config: -[source] +[source,properties] ---- # Old labels config: kubernetes.labels[0].name=foo @@ -961,7 +961,7 @@ quarkus.kubernetes.labels.foo=bar The code below demonstrates the change in `env-vars` config: -[source] +[source,properties] ---- # Old env-vars config: kubernetes.env-vars[0].name=foo @@ -981,7 +981,7 @@ See <<#env-vars>> and more specifically <> for more details. To trigger building and deploying a container image you need to enable the `quarkus.kubernetes.deploy` flag (the flag is disabled by default - furthermore it has no effect during test runs or dev mode). This can be easily done with the command line: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package -Dquarkus.kubernetes.deploy=true ---- diff --git a/docs/src/main/asciidoc/deploying-to-openshift.adoc b/docs/src/main/asciidoc/deploying-to-openshift.adoc index bfd18bbaba4403..bd4f8f0c492206 100644 --- a/docs/src/main/asciidoc/deploying-to-openshift.adoc +++ b/docs/src/main/asciidoc/deploying-to-openshift.adoc @@ -25,7 +25,7 @@ To complete this guide, you need: First, we need a new project that contains the OpenShift extension. This can be done using the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -61,14 +61,14 @@ Furthermore, the items provided by `io.quarkus.deployment.ApplicationConfig` aff If the OpenShift extension was not included during the bootstraping of the project nor was it added subsequently (check pom.xml file for it), then it can be added like this: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw quarkus:add-extension -Dextensions="openshift" ---- Building is handled by the link:container-image#s2i[container-image-s2i] extension. To trigger a build: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package -Dquarkus.container-image.build=true ---- @@ -76,7 +76,7 @@ Building is handled by the link:container-image#s2i[container-image-s2i] extensi The build that will be performed is an s2i binary build. The input of the build is the jar that has been built locally and the output of the build is an ImageStream that is configured to automatically trigger a deployment. To deploy the container image created in the above step to OpenShift, follow these commands: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- oc get is oc new-app --name=greeting /openshift-quickstart:1.0-SNAPSHOT @@ -101,14 +101,14 @@ When a non-s2i container image extension is used, an ImageStream is created that To select which extension will be used for building the image: -[source] +[source,properties] ---- quarkus.container-image.builder=docker ---- or -[source] +[source,properties] ---- quarkus.container-image.builder=jib ---- @@ -117,14 +117,14 @@ quarkus.container-image.builder=jib If the OpenShift extension was not included during the bootstraping of the project nor was it added subsequently (check pom.xml file for it), then it can be added like this: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw quarkus:add-extension -Dextensions="openshift" ---- To trigger a build and deployment in a single step: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package -Dquarkus.kubernetes.deploy=true ---- @@ -135,7 +135,7 @@ In other words, any container image build after the initial deployment will auto To confirm the above command has created an image stream, a service resource and has deployed the application (has a pod running), apply these commands: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- oc get is oc get pods @@ -144,7 +144,7 @@ oc get svc To expose the created service to a route and test it: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- oc expose svc/greeting oc get routes @@ -161,14 +161,14 @@ Some examples are provided in the sections below: To expose a `Route` for the Quarkus application: -[source] +[source,properties] ---- quarkus.openshift.expose=true ---- Tip: You don't necessarily need to add this property in the `application.properties`. You can pass it as a command line argument: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package -Dquarkus.openshift.expose=true ---- @@ -179,7 +179,7 @@ The same applies to all properties listed below. To add a label in the generated resources: -[source] +[source,properties] ---- quarkus.openshift.labels.foo=bar ---- @@ -188,7 +188,7 @@ quarkus.openshift.labels.foo=bar To add an annotation in the generated resources: -[source] +[source,properties] ---- quarkus.openshift.annotations.foo=bar ---- @@ -197,7 +197,7 @@ quarkus.openshift.annotations.foo=bar To add an annotation in the generated resources: -[source] +[source,properties] ---- quarkus.openshift.env-vars.my-env-var.value=foobar ---- @@ -212,7 +212,7 @@ That is because for environment variables there are additional options rather th To add all key value pairs of a `Secret` as environment variables: -[source] +[source,properties] ---- quarkus.openshift.env-vars.my-env-var.secret=my-secret ---- @@ -221,7 +221,7 @@ quarkus.openshift.env-vars.my-env-var.secret=my-secret To add all key value pairs of a `ConfigMap` as environment variables: -[source] +[source,properties] ---- quarkus.openshift.env-vars.my-env-var.configmap=my-secret ---- @@ -233,7 +233,7 @@ The OpenShift extension allows the user to configure both volumes and mounts for Any volume can be mounted with a simple configuration: -[source] +[source,properties] ---- quarkus.openshift.mounts.my-volume.path=/where/to/mount ---- @@ -244,14 +244,14 @@ The volumes themselves can be configured as shown in the sections below: ===== Secret volumes -[source] +[source,properties] ---- quarkus.openshift.secret-volumes.my-volume.secret-name=my-secret ---- ===== ConfigMap volumes -[source] +[source,properties] ---- quarkus.openshift.config-map-volumes.my-volume.config-map-name=my-secret ---- @@ -262,7 +262,7 @@ OpenShift also provides the ability to use Knative via the link:https://www.open The first order of business is to instruct Quarkus to generate Knative resources by setting: -[source] +[source,properties] ---- quarkus.kubernetes.deployment-target=knative ---- @@ -270,7 +270,7 @@ quarkus.kubernetes.deployment-target=knative In order to leverage OpenShift S2I to build the container image on the cluster and use the resulting container image for the Knative application, we need to set a couple of configuration properties: -[source] +[source,properties] ---- # set the Kubernetes namespace which will be used to run the application quarkus.container-image.group=geoand diff --git a/docs/src/main/asciidoc/elasticsearch.adoc b/docs/src/main/asciidoc/elasticsearch.adoc index 4d64598c1e6e5c..7aa0f1e5b55148 100644 --- a/docs/src/main/asciidoc/elasticsearch.adoc +++ b/docs/src/main/asciidoc/elasticsearch.adoc @@ -49,7 +49,7 @@ The solution for the high level client is located in the `elasticsearch-rest-hig First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -268,7 +268,7 @@ if you have a local running instance on this port, there is nothing more to do b If you want to use Docker to run an Elasticsearch instance, you can use the following command to launch one: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- docker run --name elasticsearch -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m"\ --rm -p 9200:9200 docker.elastic.co/elasticsearch/elasticsearch-oss:{elasticsearch-version} diff --git a/docs/src/main/asciidoc/funqy-amazon-lambda.adoc b/docs/src/main/asciidoc/funqy-amazon-lambda.adoc index 3641661f9928a5..da40f47ade769f 100644 --- a/docs/src/main/asciidoc/funqy-amazon-lambda.adoc +++ b/docs/src/main/asciidoc/funqy-amazon-lambda.adoc @@ -51,7 +51,7 @@ environments and AWS Lambda is one of them. The Java code is actually the same Only one Funqy function can be exported per Amazon Lambda deployment. If you have multiple functions defined within your project, then you will need to choose the function within your Quarkus `application.properties`: -[source, subs=attributes+] +[source,properties,subs=attributes+] ---- quarkus.funqy.export=greet ---- @@ -70,7 +70,7 @@ at build time. Build the project using maven. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package ---- @@ -84,7 +84,7 @@ a lambda with AWS CLI. Specifically, make sure you have created an `Execution R a `LAMBDA_ROLE_ARN` environment variable in your profile or console window, Alternatively, you can edit the `manage.sh` script that is generated by the build and put the role value directly there: -[source] +[source,bash] ---- LAMBDA_ROLE_ARN="arn:aws:iam::1234567890:role/lambda-role" ---- @@ -113,21 +113,21 @@ and setup the `LAMBDA_ROLE_ARN` environment variable (as described above), pleas A usage statement will be printed to guide you accordingly. To see the `usage` statement, and validate AWS configuration: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh ---- You can `create` your function using the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh create ---- or if you do not have `LAMBDA_ROLE_ARN` already defined in this shell: -[source] +[source,bash] ---- LAMBDA_ROLE_ARN="arn:aws:iam::1234567890:role/lambda-role" sh target/manage.sh create ---- @@ -138,13 +138,13 @@ This special handler is Funqy's integration point with AWS Lambda. If there are any problems creating the function, you must delete it with the `delete` function before re-running the `create` command. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh delete ---- Commands may also be stacked: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh delete create ---- @@ -153,7 +153,7 @@ sh target/manage.sh delete create Use the `invoke` command to invoke your function. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh invoke ---- @@ -163,14 +163,14 @@ in the root directory of the project. The function can also be invoked locally with the SAM CLI like this: -[source] +[source,bash] ---- sam local invoke --template target/sam.jvm.yaml --event payload.json ---- If you are working with your native image build, simply replace the template name with the native version: -[source] +[source,bash] ---- sam local invoke --template target/sam.native.yaml --event payload.json ---- @@ -180,7 +180,7 @@ sam local invoke --template target/sam.native.yaml --event payload.json You can update the Java code as you see fit. Once you've rebuilt, you can redeploy your function by executing the `update` command. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh update ---- @@ -192,7 +192,7 @@ code to a native executable. Just make sure to rebuild your project with the `- For Linux hosts execute: -[source, subs=attributes+] +[source,subs=attributes+] ---- mvn package -Pnative ---- @@ -201,7 +201,7 @@ NOTE: If you are building on a non-Linux system, you will need to also pass in a Lambda requires linux binaries. You can do this by passing this property to your Maven build: `-Dnative-image.docker-build=true`, or for Gradle: `--docker-build=true`. This requires you to have docker installed locally, however. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean install -Pnative -Dnative-image.docker-build=true ---- @@ -213,7 +213,7 @@ Custom (Provided) Runtime. The instructions here are exactly as above with one change: you'll need to add `native` as the first parameter to the `manage.sh` script: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- sh target/manage.sh native create ---- @@ -228,7 +228,7 @@ to create, delete, and update your functions. One thing to note about the create command for native is that the `aws lambda create-function` call must set a specific environment variable: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- --environment 'Variables={DISABLE_SIGNAL_HANDLERS=true}' ---- @@ -279,14 +279,14 @@ A starter template has been generated for both JVM and native execution modes. Run the following SAM CLI command to locally test your function, passing the appropriate SAM `template`. The `event` parameter takes any JSON file, in this case the sample `payload.json`. -[source] +[source,bash] ---- sam local invoke --template target/sam.jvm.yaml --event payload.json ---- The native image can also be locally tested using the `sam.native.yaml` template: -[source] +[source,bash] ---- sam local invoke --template target/sam.native.yaml --event payload.json ---- diff --git a/docs/src/main/asciidoc/funqy-gcp-functions.adoc b/docs/src/main/asciidoc/funqy-gcp-functions.adoc index 2ea9ae8eeb342e..45d8c53c27b15a 100644 --- a/docs/src/main/asciidoc/funqy-gcp-functions.adoc +++ b/docs/src/main/asciidoc/funqy-gcp-functions.adoc @@ -28,14 +28,14 @@ To complete this guide, you need: Login to Google Cloud is necessary for deploying the application and it can be done as follows: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- gcloud auth login ---- At the time of this writing, Cloud Functions are still in beta so make sure to install the `beta` command group. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- gcloud components install beta ---- @@ -51,7 +51,7 @@ The solution is located in the `funqy-google-cloud-functions-quickstart` {quicks Create an application with the `quarkus-funqy-google-cloud-functions` extension. You can use the following Maven command to create it: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -80,7 +80,7 @@ Only one Funqy function can be exported per Google Cloud Functions deployment. annotated with `@Funq` in your project, then there is no worries. If you have multiple functions defined within your project, then you will need to choose the function within your Quarkus `application.properties`: -[source, subs=attributes+] +[source,properties,subs=attributes+] ---- quarkus.funqy.export=greet ---- @@ -91,7 +91,7 @@ Alternatively, you can set the `QUARKUS_FUNQY_EXPORT` environment variable when Build the project using maven. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package ---- @@ -159,9 +159,11 @@ Then you will be able to use `gcloud` to deploy your function to Google Cloud, t [WARNING] ==== The first time you launch the `gcloud beta functions deploy`, you can have the following error message: -``` + +[source] +---- ERROR: (gcloud.beta.functions.deploy) OperationError: code=7, message=Build Failed: Cloud Build has not been used in project before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudbuild.googleapis.com/overview?project= then retry. -``` +---- This means that Cloud Build is not activated yet. To overcome this error, open the URL shown in the error, follow the instructions and then wait a few minutes before retrying the command. ==== @@ -169,7 +171,7 @@ This means that Cloud Build is not activated yet. To overcome this error, open t Use this command to deploy to Google Cloud Functions: -[source] +[source,bash] ---- gcloud beta functions deploy quarkus-example-funky-pubsub \ --entry-point=io.quarkus.funqy.gcp.functions.FunqyBackgroundFunction \ @@ -185,7 +187,7 @@ define that this function will be triggered by all message publication inside th To trigger an event to this function, you can use the `gcloud functions call` command: -[source] +[source,bash] ---- gcloud functions call quarkus-example-funky-pubsub --data '{"data":"Pub/Sub"}' ---- @@ -196,14 +198,14 @@ The `--data '{"data":"Hello, Pub/Sub"}'` option allow to specify the message to Before deploying your function, you need to create a bucket. -[source] +[source,bash] ---- gsutil mb gs://quarkus-hello ---- Then, use this command to deploy to Google Cloud Functions: -[source] +[source,bash] ---- gcloud beta functions deploy quarkus-example-funky-storage \ --entry-point=io.quarkus.funqy.gcp.functions.FunqyBackgroundFunction \ @@ -219,7 +221,7 @@ define that this function will be triggered by all new file inside this bucket. To trigger an event to this function, you can use the `gcloud functions call` command: -[source] +[source,bash] ---- gcloud functions call quarkus-example-funky-storage --data '{"name":"test.txt"}' ---- @@ -234,7 +236,7 @@ The easiest way to locally test your function is using the Cloud Function invoke You can download it via Maven using the following command: -[source] +[source,bash] ---- mvn dependency:copy \ -Dartifact='com.google.cloud.functions.invoker:java-function-invoker:1.0.0-beta1' \ @@ -249,7 +251,7 @@ Then you can use it to launch your function locally, again, the command depends For background functions, you launch the invoker with a target class of `io.quarkus.funqy.gcp.functions.FunqyBackgroundFunction`. -[source] +[source,bash] ---- java -jar java-function-invoker-1.0.0-beta1.jar \ --classpath target/funqy-google-cloud-functions-1.0.0-SNAPSHOT-runner.jar \ @@ -260,7 +262,7 @@ IMPORTANT: The `--classpath` parameter needs to be set to the previously package Then you can call your background function via an HTTP call with a payload containing the event: -[source] +[source,bash] ---- curl localhost:8080 -d '{"data":{"data":"world"}}' ---- @@ -271,7 +273,7 @@ This will call your PubSub background function with a PubSubMessage `{"data":"he For background functions, you launch the invoker with a target class of `io.quarkus.funqy.gcp.functions.FunqyBackgroundFunction`. -[source] +[source,bash] ---- java -jar java-function-invoker-1.0.0-beta1.jar \ --classpath target/funqy-google-cloud-functions-1.0.0-SNAPSHOT-runner.jar \ @@ -282,7 +284,7 @@ IMPORTANT: The `--classpath` parameter needs to be set to the previously package Then you can call your background function via an HTTP call with a payload containing the event: -[source] +[source,bash] ---- curl localhost:8080 -d '{"data":{"name":"text"}}' ---- diff --git a/docs/src/main/asciidoc/funqy-http.adoc b/docs/src/main/asciidoc/funqy-http.adoc index e82ffdd9008f3e..ee3d1bd4b37cb0 100644 --- a/docs/src/main/asciidoc/funqy-http.adoc +++ b/docs/src/main/asciidoc/funqy-http.adoc @@ -53,7 +53,7 @@ To write Funqy HTTP functions, simply include the `quarkus-funqy-http` dependenc == Build Project -[source, shell] +[source,bash] ---- mvn clean quarkus:dev ---- @@ -76,7 +76,7 @@ Invoking the other functions in the quickstart requires an HTTP POST. To execute the `greet` function defined in {quickstarts-tree-url}/funqy-quickstarts/funqy-http-quickstart/src/main/java/org/acme/funqy/GreetingFunction.java[GreetingFunction.java] invoke this curl script. -[source, shell] +[source,bash] ---- curl "http://localhost:8080/greet" \ -X POST \ @@ -88,7 +88,7 @@ Primitive types can also be passed as input using the standard JSON mapping for To execute the `toLowerCase` function defined in {quickstarts-tree-url}/funqy-quickstarts/funqy-http-quickstart/src/main/java/org/acme/funqy/PrimitiveFunctions.java[PrimitiveFunctions.java] invoke this curl script: -[source, shell] +[source,bash] ---- curl "http://localhost:8080/toLowerCase" \ -X POST \ @@ -99,7 +99,7 @@ curl "http://localhost:8080/toLowerCase" \ To execute the `double` function defined in {quickstarts-tree-url}/funqy-quickstarts/funqy-http-quickstart/src/main/java/org/acme/funqy/PrimitiveFunctions.java[PrimitiveFunctions.java] invoke this curl script: -[source, shell] +[source,bash] ---- curl "http://localhost:8080/double" \ -X POST \ @@ -125,7 +125,7 @@ public String hello(Map map) { Key values must be a primitive type (except char) or `String`. Values can be primitives (except char), `String`, `OffsetDateTime` or a complex bean style class. For the above example, here's the corresponding curl request: -[source, shell] +[source,bash] ---- curl "http://localhost:8080/a=1&b=2" ---- @@ -159,7 +159,7 @@ Property values can be any primitive type except `char`. It can also be `String` You can invoke on this using an HTTP GET and query parameters: -[source, shell] +[source,bash] ---- curl "http://localhost:8080/greet?first=Bill&last=Burke" ---- @@ -191,7 +191,7 @@ public class MyFunctions { In this case, query parameters for nested values use the `.` notation. For example: -[source, shell] +[source,bash] ---- curl "http://localhost:8080/greet?dad.first=John&dad.last=Smith&mom.first=Martha&mom.last=Smith" ---- @@ -217,7 +217,7 @@ public class MyFunctions { To invoke a GET request, just list the `pets` query parameter multiple times. -[source, shell] +[source,bash] ---- curl "http://localhost:8080/greet?pets=itchy&pets=scratchy" ---- @@ -246,7 +246,7 @@ Each `kids` query parameter must identify the kid they are referencing so that the runtime can figure out which property values go to which members in the list. Here's the curl request: -[source, shell] +[source,bash] ---- curl "http://localhost:8080/greet?kids.1.first=Buffy&kids.2.first=Charlie" ---- @@ -275,7 +275,7 @@ public class MyFunctions { The corresponding call would look like this: -[source, shell] +[source,bash] ---- curl "http://localhost:8080/greet?address.state=MA&address.city=Boston" ---- @@ -298,7 +298,7 @@ public class MyFunctions { } ---- -[source, shell] +[source,bash] ---- curl "http://localhost:8080/greet?addresses.home.state=MA&addresses.home.city=Boston" ---- diff --git a/docs/src/main/asciidoc/funqy-knative-events.adoc b/docs/src/main/asciidoc/funqy-knative-events.adoc index d04fcfdeff2eb8..d4fa2f01042f3b 100644 --- a/docs/src/main/asciidoc/funqy-knative-events.adoc +++ b/docs/src/main/asciidoc/funqy-knative-events.adoc @@ -107,7 +107,7 @@ public class SimpleFunctionChain { The `configChain` function has its Cloud Event mapping changed by configuration within {quickstarts-tree-url}/funqy-quickstarts/funqy-knative-events-quickstart/src/main/resources/application.properties[application.properties]. -[source, subs=attributes+] +[source,properties,subs=attributes+] ---- quarkus.funqy.knative-events.mapping.configChain.trigger=defaultChain.output quarkus.funqy.knative-events.mapping.configChain.response-type=annotated @@ -207,14 +207,14 @@ Funqy also works with Quarkus Dev mode! First build the Java artifacts: -[source, shell] +[source,bash] ---- mvn clean install ---- Next, a docker image is required by Knative, so you'll need to build that next: -[source, shell] +[source,bash] ---- docker build -f src/main/docker/Dockerfile.jvm -t yourAccountName/funqy-knative-events-quickstart . ---- @@ -224,7 +224,7 @@ Dockerfile is a standard Quarkus dockerfile. No special Knative magic. Push your image to docker hub or quay -[source, shell] +[source,bash] ---- docker push yourAccountName/funqy-knative-events-quickstart ---- @@ -263,7 +263,7 @@ don't have to have a deployment per function, the quickstart combines everything Deploy the service yaml. -[source, shell] +[source,bash] ---- kubectl apply -n knativetutorial -f src/main/k8s/funqy-service.yaml ---- @@ -296,7 +296,7 @@ When a Cloud Event is pushed to the Broker, it will trigger the spin up of the s There's a trigger yaml file for each of our 4 Funqy functions. Deploy them all: -[source, shell] +[source,bash] ---- kubectl apply -n knativetutorial -f src/main/k8s/defaultChain-trigger.yaml kubectl apply -n knativetutorial -f src/main/k8s/configChain-trigger.yaml @@ -312,14 +312,14 @@ files so you can see the messages flowing through the Funqy function event chain Make sure you have the `stern` tool installed. See the Knative Tutorial setup for information on that. Run stern to look for logs outputted by our Funqy deployment -[source, shell] +[source,bash] ---- stern funq user-container ---- Open a separate terminal. You'll first need to learn the URL of the broker. Execute this command to find it. -[source, shell] +[source,bash] ---- kubectl get broker default -o jsonpath='{.status.address.url}' ---- @@ -329,14 +329,14 @@ Remember this URL. Next thing we need to do is ssh into our Kubernetes cluster so that we can send a curl request to our broker. -[source, shell] +[source,bash] ---- kubectl -n knativetutorial exec -it curler -- /bin/bash ---- You will now be in a shell within the Kubernetes cluster. Within the shell, execute this curl command -[source, shell] +[source,bash] ---- curl -v "http://default-broker.knativetutorial.svc.cluster.local" \ -X POST \ diff --git a/docs/src/main/asciidoc/gcp-functions-http.adoc b/docs/src/main/asciidoc/gcp-functions-http.adoc index c47d7fe60ffd51..2d0549178fd960 100644 --- a/docs/src/main/asciidoc/gcp-functions-http.adoc +++ b/docs/src/main/asciidoc/gcp-functions-http.adoc @@ -44,7 +44,7 @@ The solution is located in the `google-cloud-functions-http-quickstart` {quickst Create an application with the `quarkus-google-cloud-functions-http` extension. You can use the following Maven command to create it: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -58,14 +58,14 @@ mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ Login to Google Cloud is necessary for deploying the application and it can be done as follows: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- gcloud auth login ---- At the time of this writing, Cloud Functions are still in beta so make sure to install the `beta` command group. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- gcloud components install beta ---- @@ -169,7 +169,7 @@ The result of the previous command is a single JAR file inside the `target/deplo Then you will be able to use `gcloud` to deploy your function to Google Cloud. -[source] +[source,bash] ---- gcloud beta functions deploy quarkus-example-http \ --entry-point=io.quarkus.gcp.functions.http.QuarkusHttpFunction \ @@ -207,7 +207,7 @@ The easiest way to locally test your function is using the Cloud Function invoke You can download it via Maven using the following command: -[source] +[source,bash] ---- mvn dependency:copy \ -Dartifact='com.google.cloud.functions.invoker:java-function-invoker:1.0.0-beta1' \ @@ -218,7 +218,7 @@ Before using the invoker, you first need to build your function via `mvn package Then you can use it to launch your function locally. -[source] +[source,bash] ---- java -jar java-function-invoker-1.0.0-beta1.jar \ --classpath target/deployment/google-cloud-functions-http-1.0.0-SNAPSHOT-runner.jar \ diff --git a/docs/src/main/asciidoc/gcp-functions.adoc b/docs/src/main/asciidoc/gcp-functions.adoc index 437c67ee8f7e36..4b4f4c8e77b9f6 100644 --- a/docs/src/main/asciidoc/gcp-functions.adoc +++ b/docs/src/main/asciidoc/gcp-functions.adoc @@ -42,7 +42,7 @@ The solution is located in the `google-cloud-functions-quickstart` {quickstarts- Create an application with the `quarkus-google-cloud-functions` extension. You can use the following Maven command to create it: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -63,14 +63,14 @@ Now, let's remove what's not needed inside the generated application: Login to Google Cloud is necessary for deploying the application and it can be done as follows: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- gcloud auth login ---- At the time of this writing, Cloud Functions are still in beta so make sure to install the `beta` command group. -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- gcloud components install beta ---- @@ -91,7 +91,7 @@ project and use configuration or an environment variable to pick the function yo To configure the name of the function, you can use the following configuration property: -[source, subs=attributes+] +[source,properties,subs=attributes+] ---- quarkus.google-cloud-functions.function=test ---- @@ -239,7 +239,7 @@ This means that Cloud Build is not activated yet. To overcome this error, open t This is an example command to deploy your `HttpFunction` to Google Cloud: -[source] +[source,bash] ---- gcloud beta functions deploy quarkus-example-http \ --entry-point=io.quarkus.gcp.functions.QuarkusHttpFunction \ @@ -257,7 +257,7 @@ This command will give you as output a `httpsTrigger.url` that points to your fu Before deploying your function, you need to create a bucket. -[source] +[source,bash] ---- gsutil mb gs://quarkus-hello ---- @@ -265,7 +265,7 @@ gsutil mb gs://quarkus-hello This is an example command to deploy your `BackgroundFunction` to Google Cloud, as the function is triggered by a Storage event, it needs to use `--trigger-event google.storage.object.finalize` and the `--trigger-resource` parameter with the name of a previously created bucket: -[source] +[source,bash] ---- gcloud beta functions deploy quarkus-example-storage \ --entry-point=io.quarkus.gcp.functions.QuarkusBackgroundFunction \ @@ -280,7 +280,7 @@ The entry point must always be set to `io.quarkus.gcp.functions.QuarkusBackgroun To trigger the event, you can send a file to the GCS `quarkus-hello` bucket or you can use gcloud to simulate one: -[source] +[source,bash] ---- gcloud functions call quarkus-example-storage --data '{"name":"test.txt"}' ---- @@ -292,7 +292,7 @@ NOTE: `--data` contains the GCS event, it is a JSON document with the name of th This is an example command to deploy your `RawBackgroundFunction` to Google Cloud, as the function is triggered by a PubSub event, it needs to use `--trigger-event google.pubsub.topic.publish` and the `--trigger-resource` parameter with the name of a previously created topic: -[source] +[source,bash] ---- gcloud beta functions deploy quarkus-example-pubsub \ --entry-point=io.quarkus.gcp.functions.QuarkusBackgroundFunction \ @@ -306,7 +306,7 @@ The entry point must always be set to `io.quarkus.gcp.functions.QuarkusBackgroun To trigger the event, you can send a file to the `hello_topic` topic of you can use gcloud to simulate one: -[source] +[source,bash] ---- gcloud functions call quarkus-example-pubsub --data '{"data":{"greeting":"world"}}' ---- @@ -317,7 +317,7 @@ The easiest way to locally test your function is using the Cloud Function invoke You can download it via Maven using the following command: -[source] +[source,bash] ---- mvn dependency:copy \ -Dartifact='com.google.cloud.functions.invoker:java-function-invoker:1.0.0-beta1' \ @@ -330,7 +330,7 @@ Before using the invoker, you first need to build your function via `mvn package To test an `HttpFunction`, you can use this command to launch your function locally. -[source] +[source,bash] ---- java -jar java-function-invoker-1.0.0-beta1.jar \ --classpath target/google-cloud-functions-1.0.0-SNAPSHOT-runner.jar \ @@ -345,7 +345,7 @@ Your endpoints will be available on http://localhost:8080. For background functions, you launch the invoker with a target class of `io.quarkus.gcp.functions.BackgroundFunction`. -[source] +[source,bash] ---- java -jar java-function-invoker-1.0.0-beta1.jar \ --classpath target/google-cloud-functions-1.0.0-SNAPSHOT-runner.jar \ @@ -356,7 +356,7 @@ IMPORTANT: The `--classpath` parameter needs to be set to the previously package Then you can call your background function via an HTTP call with a payload containing the event: -[source] +[source,bash] ---- curl localhost:8080 -d '{"data":{"name":"hello.txt"}}' ---- @@ -367,7 +367,7 @@ This will call your Storage background function with an event `{"name":"hello.tx For background functions, you launch the invoker with a target class of `io.quarkus.gcp.functions.BackgroundFunction`. -[source] +[source,bash] ---- java -jar java-function-invoker-1.0.0-beta1.jar \ --classpath target/google-cloud-functions-1.0.0-SNAPSHOT-runner.jar \ @@ -378,7 +378,7 @@ IMPORTANT: The `--classpath` parameter needs to be set to the previously package Then you can call your background function via an HTTP call with a payload containing the event: -[source] +[source,bash] ---- curl localhost:8080 -d '{"data":{"greeting":"world"}}' ---- diff --git a/docs/src/main/asciidoc/getting-started-reactive.adoc b/docs/src/main/asciidoc/getting-started-reactive.adoc index fa5c3500fe7d13..487f21f15c6c15 100644 --- a/docs/src/main/asciidoc/getting-started-reactive.adoc +++ b/docs/src/main/asciidoc/getting-started-reactive.adoc @@ -34,7 +34,7 @@ However, you can go right to the completed example. Download an {quickstarts-archive-url}[archive] or clone the git repository: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- git clone {quickstarts-clone-url} ---- @@ -164,7 +164,7 @@ The easiest way to create a new Quarkus project is to open a terminal and run th For Linux and macOS users -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -179,14 +179,14 @@ For Windows users - If using cmd, (don't use forward slash `\`) -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create -DprojectGroupId=org.acme -DprojectArtifactId=getting-started-reactive -DclassName="org.acme.quickstart.ReactiveGreetingResource" -Dpath="/hello" -Dextensions="resteasy-mutiny,resteasy-jsonb" ---- - If using Powershell, wrap `-D` parameters in double quotes -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create "-DprojectGroupId=org.acme" "-DprojectArtifactId=getting-started-reactive" "-DclassName=org.acme.quickstart.ReactiveGreetingResource" "-Dpath=/hello" "-Dextensions=resteasy-mutiny,resteasy-jsonb" ---- @@ -294,7 +294,7 @@ While, in this example, the resulting item is emitted immediately, you can imagi NOTE: In order to get Mutiny working properly with JAX-RS resources, make sure the Mutiny support for RESTEasy extension (`io.quarkus:quarkus-resteasy-mutiny`) is present, otherwise add the extension by executing the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:add-extensions \ -Dextensions="io.quarkus:quarkus-resteasy-mutiny" @@ -312,7 +312,7 @@ Or add `quarkus-resteasy-mutiny` into your dependencies manually. Now, start the application using: -[source, shell] +[source,bash] ---- ./mvnw quarkus:dev ---- @@ -353,7 +353,7 @@ This endpoint streams the items to the client as a JSON Array. The name and number of messages are parameterized using path parameters. So calling the endpoint produces something like: -[source, shell] +[source,bash] ---- $ curl http://localhost:8080/hello/greeting/3/neo ["hello neo - 0","hello neo - 1","hello neo - 2"] @@ -377,7 +377,7 @@ As the `@Produces` annotation defines `SERVER_SENT_EVENTS`, JAX-RS needs it to k You can see the result using: -[source, shell] +[source,bash] ---- $ curl -N http://localhost:8080/hello/stream/5/neo data: hello neo - 0 @@ -400,7 +400,7 @@ In this section, we are going to see how you can use the Reactive PostgreSQL dri Create a new project using: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -413,7 +413,7 @@ cd getting-started-reactive-crud This application is interacting with a PostgreSQL database, so you need one: -[source, shell] +[source,bash] ---- docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 \ --name postgres-quarkus-reactive -e POSTGRES_USER=quarkus_test \ @@ -613,7 +613,7 @@ Also, you can use Vert.x clients directly. First of all, make sure the `quarkus-vertx` extension is present. If not, activate the extension by executing the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:add-extensions \ -Dextensions=vertx diff --git a/docs/src/main/asciidoc/getting-started.adoc b/docs/src/main/asciidoc/getting-started.adoc index 95f41d366d5943..61b9f25f1a245e 100644 --- a/docs/src/main/asciidoc/getting-started.adoc +++ b/docs/src/main/asciidoc/getting-started.adoc @@ -62,7 +62,7 @@ However, you can go right to the completed example. Download an {quickstarts-archive-url}[archive] or clone the git repository: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- git clone {quickstarts-clone-url} ---- @@ -75,7 +75,7 @@ The easiest way to create a new Quarkus project is to open a terminal and run th For Linux & MacOS users -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -89,14 +89,14 @@ For Windows users - If using cmd , (don't use forward slash `\`) -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create -DprojectGroupId=org.acme -DprojectArtifactId=getting-started -DclassName="org.acme.getting.started.GreetingResource" -Dpath="/hello" ---- - If using Powershell , wrap `-D` parameters in double quotes -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create "-DprojectGroupId=org.acme" "-DprojectArtifactId=getting-started" "-DclassName=org.acme.getting.started.GreetingResource" "-Dpath=/hello" ---- @@ -194,7 +194,7 @@ of the resource is created and not one per request. You can configure this using Now we are ready to run our application. Use: `./mvnw compile quarkus:dev`: -[source,shell] +[source,bash] ---- $ ./mvnw compile quarkus:dev [INFO] --------------------< org.acme:getting-started >--------------------- @@ -219,10 +219,11 @@ Listening for transport dt_socket at address: 5005 Once started, you can request the provided endpoint: -``` +[source,bash] +---- $ curl -w "\n" http://localhost:8080/hello hello -``` +---- Hit `CTRL+C` to stop the application, or keep it running and enjoy the blazing fast hot-reload. @@ -298,7 +299,7 @@ public class GreetingResource { If you stopped the application, restart the application with `./mvnw compile quarkus:dev`. Then check that the endpoint returns `hello quarkus` as expected: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- $ curl -w "\n" http://localhost:8080/hello/greeting/quarkus hello quarkus @@ -406,7 +407,7 @@ These tests use http://rest-assured.io/[RestAssured], but feel free to use your You can run these using Maven: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw test ---- diff --git a/docs/src/main/asciidoc/gradle-tooling.adoc b/docs/src/main/asciidoc/gradle-tooling.adoc index da246adcf72398..ae692a26d52d56 100644 --- a/docs/src/main/asciidoc/gradle-tooling.adoc +++ b/docs/src/main/asciidoc/gradle-tooling.adoc @@ -17,7 +17,7 @@ This is just a caution, and we recommend if you like Gradle you try it out and g The easiest way to scaffold a Gradle project, is currently to use the Quarkus Maven plugin like so: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=my-groupId \ @@ -120,14 +120,14 @@ It is not possible to use a custom test configuration profile in native mode for From inside a Quarkus project, you can obtain a list of the available extensions with: -[source,shell] +[source,bash] ---- ./gradlew listExtensions ---- You can enable an extension using: -[source,shell] +[source,bash] ---- ./gradlew addExtension --extensions="hibernate-validator" ---- @@ -139,7 +139,7 @@ But you can pass a partial name and Quarkus will do its best to find the right e For example, `agroal`, `Agroal` or `agro` will expand to `io.quarkus:quarkus-agroal`. If no extension is found or if more than one extensions match, you will see a red check mark ❌ in the command result. -[source,shell] +[source,bash] ---- ./gradlew addExtension --extensions="jdbc,agroal,non-exist-ent" [...] @@ -155,7 +155,7 @@ If no extension is found or if more than one extensions match, you will see a re You can install all extensions which match a globbing pattern: -[source,shell] +[source,bash] ---- ./gradlew addExtension --extensions="hibernate*" ---- @@ -165,7 +165,7 @@ You can install all extensions which match a globbing pattern: Quarkus comes with a built-in development mode. Run your application with: -[source,shell] +[source,bash] ---- ./gradlew quarkusDev ---- @@ -208,7 +208,7 @@ WARNING: Do not use this in production. This should only be used in a developmen To do this you must have the `quarkus-undertow-websockets` extension installed: -[source,shell] +[source,bash] ---- ./gradlew addExtension --extensions="undertow-websockets" ---- @@ -223,7 +223,7 @@ password must be set on both the local and remote processes, while the url only Start Quarkus in dev mode on the remote host. Now you need to connect your local agent to the remote host: -[source,shell] +[source,bash] ---- ./gradlew quarkusRemoteDev -Dquarkus.live-reload.url=http://my-remote-host:8080 ---- @@ -331,7 +331,7 @@ quarkusBuild { The native executable will be specific to your operating system. To create an executable that will run in a container, use the following: -[source,shell] +[source,bash] ---- ./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true ---- @@ -355,7 +355,7 @@ Be aware that a given Quarkus version might not be compatible with all the image Run the native tests using: -[source,shell] +[source,bash] ---- ./gradlew testNative ---- @@ -366,14 +366,14 @@ This task depends on `quarkusBuild`, so it will generate the native image before Quarkus Gradle plugin supports the generation of Uber-Jars by specifying an `--uber-jar` argument as follows: -[source,shell] +[source,bash] ---- ./gradlew quarkusBuild --uber-jar ---- When building an Uber-Jar you can specify entries that you want to exclude from the generated jar by using the `--ignored-entry` argument: -[source,shell] +[source,bash] ---- ./gradlew quarkusBuild --uber-jar --ignored-entry=META-INF/file1.txt ---- diff --git a/docs/src/main/asciidoc/grpc-service-implementation.adoc b/docs/src/main/asciidoc/grpc-service-implementation.adoc index 952220e610844d..47f24db9d69480 100644 --- a/docs/src/main/asciidoc/grpc-service-implementation.adoc +++ b/docs/src/main/asciidoc/grpc-service-implementation.adoc @@ -194,7 +194,7 @@ include::{generated-dir}/config/quarkus-grpc-config-group-config-grpc-server-con To enable TLS, use the following configuration: -[source] +[source,properties] ---- quarkus.grpc.server.ssl.certificate=src/main/resources/tls/server.pem quarkus.grpc.server.ssl.key=src/main/resources/tls/server.key @@ -206,7 +206,7 @@ NOTE: When SSL/TLS is configured, `plain-text` is automatically disabled. To use TLS with mutual authentication, use the following configuration: -[source] +[source,properties] ---- quarkus.grpc.server.ssl.certificate=src/main/resources/tls/server.pem quarkus.grpc.server.ssl.key=src/main/resources/tls/server.key diff --git a/docs/src/main/asciidoc/hibernate-orm.adoc b/docs/src/main/asciidoc/hibernate-orm.adoc index e553282b9cd324..b97409970db6a4 100644 --- a/docs/src/main/asciidoc/hibernate-orm.adoc +++ b/docs/src/main/asciidoc/hibernate-orm.adoc @@ -169,7 +169,7 @@ Make up your mind on which approach you want to use. ==== Want to start a PostgreSQL server on the side with Docker? -[source,shell] +[source,bash] ---- docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 \ --name postgres-quarkus-hibernate -e POSTGRES_USER=hibernate \ @@ -465,7 +465,7 @@ You can define different https://quarkus.io/guides/config#configuration-profiles to select different behaviors depending on your environment. This is great because you can define different combinations of Hibernate ORM properties matching the development style you currently need. -[source] +[source,properties] .application.properties ---- %dev.quarkus.hibernate-orm.database.generation = drop-and-create @@ -500,7 +500,7 @@ but we wanted you to avoid overriding your database by accident in prod :) Speaking of, make sure to not drop your database schema in production! Add the following in your properties file. -[source] +[source,properties] .application.properties ---- %prod.quarkus.hibernate-orm.database.generation = none diff --git a/docs/src/main/asciidoc/hibernate-search-elasticsearch.adoc b/docs/src/main/asciidoc/hibernate-search-elasticsearch.adoc index fbe231ff8cf711..66cf12c9de3783 100644 --- a/docs/src/main/asciidoc/hibernate-search-elasticsearch.adoc +++ b/docs/src/main/asciidoc/hibernate-search-elasticsearch.adoc @@ -55,7 +55,7 @@ The provided solution contains a few additional elements such as tests and testi First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -616,12 +616,12 @@ We need a PostgreSQL instance and an Elasticsearch cluster. Let's use Docker to start one of each: -[source, shell,subs=attributes+] +[source,bash,subs=attributes+] ---- docker run -it --rm=true --name elasticsearch_quarkus_test -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch-oss:{elasticsearch-version} ---- -[source, shell] +[source,bash] ---- docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name postgresql_quarkus_test -e POSTGRES_USER=quarkus_test -e POSTGRES_PASSWORD=quarkus_test -e POSTGRES_DB=quarkus_test -p 5432:5432 postgres:11.3 ---- diff --git a/docs/src/main/asciidoc/http-reference.adoc b/docs/src/main/asciidoc/http-reference.adoc index f01ae61f1e31eb..43f4f499c48ec4 100644 --- a/docs/src/main/asciidoc/http-reference.adoc +++ b/docs/src/main/asciidoc/http-reference.adoc @@ -102,7 +102,7 @@ As with the certificate/key file combination, Quarkus will first try to resolve Add the following property to your `application.properties`: -[source,shell] +[source,bash] ---- quarkus.http.ssl.certificate.key-store-file=/path/to/keystore ---- diff --git a/docs/src/main/asciidoc/jms.adoc b/docs/src/main/asciidoc/jms.adoc index 8b5b8806c90681..b266d29ee91add 100644 --- a/docs/src/main/asciidoc/jms.adoc +++ b/docs/src/main/asciidoc/jms.adoc @@ -58,7 +58,7 @@ or download an https://github.com/amqphub/quarkus-qpid-jms-quickstart/archive/ma First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -68,7 +68,7 @@ cd jms-quickstart ---- This command generates a Maven project, with its pom.xml importing the quarkus-qpid-jms extension: -[source] +[source,xml] ---- org.amqphub.quarkus @@ -82,7 +82,7 @@ This command generates a Maven project, with its pom.xml importing the quarkus-q Then, we need an AMQP broker. In this case we will use an ActiveMQ Artemis server. You can follow the instructions from the https://activemq.apache.org/components/artemis/[Apache Artemis web site] or start a broker via docker: -[source] +[source,bash] ---- docker run -it --rm -p 8161:8161 -p 61616:61616 -p 5672:5672 -e ARTEMIS_USERNAME=quarkus -e ARTEMIS_PASSWORD=quarkus vromero/activemq-artemis:2.11.0-alpine ---- @@ -287,7 +287,7 @@ injecting the ConnectionFactory. This is done in the `src/main/resources/application.properties` file. -[source] +[source,properties] ---- # Configures the Qpid JMS properties. quarkus.qpid-jms.url=amqp://localhost:5672 @@ -303,7 +303,7 @@ More detail about the configuration are available in the https://github.com/amqp If you followed the instructions, you should have the Artemis server running. Then, you just need to run the application using: -[source, shell] +[source,bash] ---- ./mvnw compile quarkus:dev ---- @@ -314,20 +314,20 @@ Open `http://localhost:8080/prices.html` in your browser. You can build the native executable with: -[source, shell] +[source,bash] ---- ./mvnw package -Pnative ---- Or, if you don't have GraalVM installed, you can instead use Docker to build the native executable using: -[source, shell] +[source,bash] ---- ./mvnw package -Pnative -Dquarkus.native.container-build=true ---- and then run with: -[source, shell] +[source,bash] ---- ./target/jms-quickstart-1.0-SNAPSHOT-runner ---- @@ -359,7 +359,7 @@ The Artemis JMS solution is located in the `jms-quickstart` {quickstarts-tree-ur Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -369,7 +369,7 @@ cd jms-quickstart ---- This creates a Maven project, with its pom.xml importing the quarkus-artemis-jms extension: -[source] +[source,xml] ---- io.quarkus @@ -386,7 +386,7 @@ configuration below instead. We need to configure the Artemis connection properties. This is done in the `src/main/resources/application.properties` file. -[source] +[source,properties] ---- # Configures the Artemis properties. quarkus.artemis.url=tcp://localhost:61616 diff --git a/docs/src/main/asciidoc/kafka-streams.adoc b/docs/src/main/asciidoc/kafka-streams.adoc index d9db3ef7751cef..476c190e49050d 100644 --- a/docs/src/main/asciidoc/kafka-streams.adoc +++ b/docs/src/main/asciidoc/kafka-streams.adoc @@ -32,14 +32,14 @@ Using the dev mode, you'll instantly see messages on the output topic(s) as prod For the best development experience, we recommend applying the following configuration settings to your Kafka broker: -[source, subs=attributes+] +[source,subs=attributes+] ---- group.min.session.timeout.ms=250 ---- Also specify the following settings in your Quarkus `application.properties`: -[source, subs=attributes+] +[source,properties,subs=attributes+] ---- kafka-streams.consumer.session.timeout.ms=250 kafka-streams.consumer.heartbeat.interval.ms=200 @@ -82,7 +82,7 @@ The solution is located in the `kafka-streams-quickstart` {quickstarts-tree-url} First, we need a new project with the temperature value producer. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -213,7 +213,7 @@ The two methods each return a _reactive stream_ whose items are sent to the stre The two channels are mapped to Kafka topics using the Quarkus configuration file `application.properties`. For that, add the following to the file `producer/src/main/resources/application.properties`: -[source] +[source,properties] ---- # Configure the Kafka broker location kafka.bootstrap.servers=localhost:9092 @@ -236,7 +236,7 @@ With the producer application in place, it's time to implement the actual aggreg which will run the Kafka Streams pipeline. Create another project like so: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -475,7 +475,7 @@ Changing their values requires a rebuild of the application. We now can build the `producer` and `aggregator` applications: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package -f producer/pom.xml ./mvnw clean package -f aggregator/pom.xml @@ -559,14 +559,14 @@ You should see log statements from the `producer` application about messages bei Now run an instance of the _debezium/tooling_ image, attaching to the same network all the other containers run in. This image provides several useful tools such as _kafkacat_ and _httpie_: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- docker run --tty --rm -i --network ks debezium/tooling:1.1 ---- Within the tooling container, run _kafkacat_ to examine the results of the streaming pipeline: -[source, subs=attributes+] +[source,subs=attributes+] ---- kafkacat -b kafka:9092 -C -o beginning -q -t temperatures-aggregated @@ -763,7 +763,7 @@ public class WeatherStationEndpoint { With this code in place, it's time to rebuild the application and the `aggregator` service in Docker Compose: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package -f aggregator/pom.xml docker-compose stop aggregator @@ -1013,7 +1013,7 @@ public class WeatherStationEndpoint { Now stop the `aggregator` service again and rebuild it. Then let's spin up three instances of it: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- ./mvnw clean package -f aggregator/pom.xml docker-compose stop aggregator @@ -1070,7 +1070,8 @@ http 2af13fe516a9:8080/weather-stations/data/1 If that node holds the data for key "1", you'll get a response like this: -``` +[source] +---- HTTP/1.1 200 OK Connection: keep-alive Content-Length: 74 @@ -1085,23 +1086,25 @@ Date: Tue, 11 Jun 2019 19:16:31 GMT "stationId": 1, "stationName": "Hamburg" } -``` +---- Otherwise, the service will send a redirect: -``` +[source] +---- HTTP/1.1 303 See Other Connection: keep-alive Content-Length: 0 Date: Tue, 18 Jun 2019 20:01:03 GMT Location: http://1eb39af8d587:8080/weather-stations/data/1 -``` +---- You can also have _httpie_ automatically follow the redirect by passing the `--follow option`: -```bash +[source,bash] +---- http --follow 2af13fe516a9:8080/weather-stations/data/1 -``` +---- == Running Natively @@ -1111,7 +1114,7 @@ natively via GraalVM without further configuration. To run both the `producer` and `aggregator` applications in native mode, the Maven builds can be executed using the `native` profile: -[source, shell] +[source,bash] ---- ./mvnw clean package -f producer/pom.xml -Pnative -Dnative-image.container-runtime=docker ./mvnw clean package -f aggregator/pom.xml -Pnative -Dnative-image.container-runtime=docker @@ -1119,7 +1122,7 @@ the Maven builds can be executed using the `native` profile: Now create an environment variable named `QUARKUS_MODE` and with value set to "native": -[source, shell] +[source,bash] ---- export QUARKUS_MODE=native ---- @@ -1128,7 +1131,7 @@ This is used by the Docker Compose file to use the correct `Dockerfile` when bui The Kafka Streams application can work with less than 50 MB RSS in native mode. To do so, add the `Xmx` option to the program invocation in `aggregator/src/main/docker/Dockerfile.native`: -[source, shell] +[source,dockerfile] ---- CMD ["./application", "-Dquarkus.http.host=0.0.0.0", "-Xmx32m"] ---- @@ -1190,7 +1193,9 @@ Obviously you can create your liveness and readiness probes based on the respect === Liveness health check Here is an example of the liveness check: -``` + +[source] +---- curl -i http://aggregator:8080/health/live HTTP/1.1 503 Service Unavailable @@ -1209,13 +1214,15 @@ content-length: 225 } ] } -``` +---- The `state` is coming from the `KafkaStreams.State` enum. === Readiness health check Here is an example of the readiness check: -``` + +[source] +---- curl -i http://aggregator:8080/health/ready HTTP/1.1 503 Service Unavailable @@ -1234,8 +1241,7 @@ content-length: 265 } ] } - -``` +---- == Going Further diff --git a/docs/src/main/asciidoc/kafka.adoc b/docs/src/main/asciidoc/kafka.adoc index a246a193715c65..c1bc6eae64613d 100644 --- a/docs/src/main/asciidoc/kafka.adoc +++ b/docs/src/main/asciidoc/kafka.adoc @@ -43,7 +43,7 @@ The solution is located in the `kafka-quickstart` {quickstarts-tree-url}/kafka-q First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -249,7 +249,7 @@ The `channel-name` segment must match the value set in the `@Incoming` and `@Out * `generated-price` -> sink in which we write the prices * `prices` -> source in which we read the prices -[source] +[source,properties] ---- # Configure the SmallRye Kafka connector kafka.bootstrap.servers=localhost:9092 @@ -313,7 +313,7 @@ Nothing spectacular here. On each received price, it updates the page. If you followed the instructions, you should have Kafka running. Then, you just need to run the application using: -[source, shell] +[source,bash] ---- ./mvnw quarkus:dev ---- @@ -326,7 +326,7 @@ NOTE: If you started the Kafka broker with docker compose, stop it using `CTRL+C You can build the native executable with: -[source, shell] +[source,bash] ---- ./mvnw package -Pnative ---- diff --git a/docs/src/main/asciidoc/kogito.adoc b/docs/src/main/asciidoc/kogito.adoc index 483f8b89af4a77..d4fc60b4cf7d94 100644 --- a/docs/src/main/asciidoc/kogito.adoc +++ b/docs/src/main/asciidoc/kogito.adoc @@ -80,7 +80,7 @@ The solution is located in the `kogito-quickstart` {quickstarts-tree-url}/kogito First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/kotlin.adoc b/docs/src/main/asciidoc/kotlin.adoc index db2a51bc5b9e93..2ac4c76d62b809 100644 --- a/docs/src/main/asciidoc/kotlin.adoc +++ b/docs/src/main/asciidoc/kotlin.adoc @@ -29,7 +29,7 @@ NB: For Gradle project setup please see below, and for further reference consult First, we need a new Kotlin project. This can be done using the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/kubernetes-client.adoc b/docs/src/main/asciidoc/kubernetes-client.adoc index a8cd7fd9a33897..547a64ad48ac7d 100644 --- a/docs/src/main/asciidoc/kubernetes-client.adoc +++ b/docs/src/main/asciidoc/kubernetes-client.adoc @@ -21,7 +21,7 @@ Being able to write such operators in Java with the very low footprint that nati Once you have your Quarkus project configured you can add the `kubernetes-client` extension to your project by running the following command in your project base directory. -[source] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="kubernetes-client" ---- @@ -41,7 +41,7 @@ This will add the following to your `pom.xml`: Quarkus configures a Bean of type `KubernetesClient` which can be injected into application code using the well known CDI methods. This client can be configured using various properties as can be seen in the following example: -[source] +[source,properties] ---- quarkus.kubernetes-client.trust-certs=false quarkus.kubernetes-client.namespace=default diff --git a/docs/src/main/asciidoc/kubernetes-config.adoc b/docs/src/main/asciidoc/kubernetes-config.adoc index 823faaf8419a0e..ccce6af004bd21 100644 --- a/docs/src/main/asciidoc/kubernetes-config.adoc +++ b/docs/src/main/asciidoc/kubernetes-config.adoc @@ -16,7 +16,7 @@ Quarkus includes the `kubernetes-config` extension which allows developers to us Once you have your Quarkus project configured you can add the `kubernetes-config` extension by running the following command in your project base directory. -[source] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="kubernetes-config" ---- diff --git a/docs/src/main/asciidoc/lifecycle.adoc b/docs/src/main/asciidoc/lifecycle.adoc index 9244a450c10e8f..ab7cd9a9e10a92 100644 --- a/docs/src/main/asciidoc/lifecycle.adoc +++ b/docs/src/main/asciidoc/lifecycle.adoc @@ -37,7 +37,7 @@ The solution is located in the `lifecycle-quickstart` {quickstarts-tree-url}/lif First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/mailer.adoc b/docs/src/main/asciidoc/mailer.adoc index 10a134dbd1fc0a..22f6e96336b51b 100644 --- a/docs/src/main/asciidoc/mailer.adoc +++ b/docs/src/main/asciidoc/mailer.adoc @@ -29,7 +29,7 @@ It covers simple emails, attachments, inlined attachments, the reactive and impe Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -40,7 +40,7 @@ cd sending-email-quickstart If you already have an existing project, add the `mailer` extension: -[source] +[source,bash] ---- ./mvnw quarkus:add-extensions -Dextensions="mailer" ---- @@ -62,7 +62,7 @@ Note that the password can also be configured using system properties and enviro Here is an example using _sendgrid_: -[source] +[source,properties] ---- quarkus.mailer.from=test@quarkus.io quarkus.mailer.host=smtp.sendgrid.net @@ -79,14 +79,16 @@ It is recommended to encrypt any sensitive data, such as the `quarkus.mailer.pas One approach is to save the value into a secure store like HashiCorp Vault, and refer to it from the configuration. Assuming for instance that Vault contains key `mail-password` at path `myapps/myapp/myconfig`, then the mailer extension can be simply configured as: -``` + +[source,properties] +---- ... # path within the kv secret engine where is located the application sensitive configuration quarkus.vault.secret-config-kv-path=myapps/myapp/myconfig ... quarkus.mailer.password=${mail-password} -``` +---- Please note that the password value is evaluated only once, at startup time. If `mail-password` was changed in Vault, the only way to get the new value would be to restart the application. ==== @@ -340,7 +342,7 @@ When done, you can configure your Quarkus application by adding the following pr With TLS: -[source] +[source,properties] ---- quarkus.mailer.auth-methods=DIGEST-MD5 CRAM-SHA256 CRAM-SHA1 CRAM-MD5 PLAIN LOGIN quarkus.mailer.from=YOUREMAIL@gmail.com @@ -353,7 +355,7 @@ quarkus.mailer.password=YOURGENERATEDAPPLICATIONPASSWORD Or with SSL: -[source] +[source,properties] ---- quarkus.mailer.auth-methods=DIGEST-MD5 CRAM-SHA256 CRAM-SHA1 CRAM-MD5 PLAIN LOGIN quarkus.mailer.from=YOUREMAIL@gmail.com diff --git a/docs/src/main/asciidoc/maven-tooling.adoc b/docs/src/main/asciidoc/maven-tooling.adoc index 71ce3848d08db0..d1717f1b2cc384 100644 --- a/docs/src/main/asciidoc/maven-tooling.adoc +++ b/docs/src/main/asciidoc/maven-tooling.adoc @@ -12,7 +12,7 @@ include::./attributes.adoc[] With Maven, you can scaffold a new project with: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=my-groupId \ @@ -85,14 +85,14 @@ Instructions to build the image and run the container are written in those Docke From inside a Quarkus project, you can obtain a list of the available extensions with: -[source,shell] +[source,bash] ---- ./mvnw quarkus:list-extensions ---- You can enable an extension using: -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="hibernate-validator" ---- @@ -104,7 +104,7 @@ But you can pass a partial name and Quarkus will do its best to find the right e For example, `agroal`, `Agroal` or `agro` will expand to `io.quarkus:quarkus-agroal`. If no extension is found or if more than one extensions match, you will see a red check mark ❌ in the command result. -[source,shell] +[source,bash] ---- $ ./mvnw quarkus:add-extensions -Dextensions=jdbc,agroal,non-exist-ent [...] @@ -120,7 +120,7 @@ $ ./mvnw quarkus:add-extensions -Dextensions=jdbc,agroal,non-exist-ent You can install all extensions which match a globbing pattern : -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="hibernate-*" ---- @@ -130,7 +130,7 @@ You can install all extensions which match a globbing pattern : Quarkus comes with a built-in development mode. Run your application with: -[source,shell] +[source,bash] ---- ./mvnw compile quarkus:dev ---- @@ -184,7 +184,7 @@ jar, do not attempt to run normal devmode. Now you need to connect your local agent to the remote host, using the `remote-dev` command: -[source,shell] +[source,bash] ---- ./mvnw quarkus:remote-dev -Dquarkus.live-reload.url=http://my-remote-host:8080 ---- @@ -318,7 +318,7 @@ To be able to use it, the following plugin configuration has to be added to the Now you should be able to execute `./mvnw quarkus-bootstrap:build-tree` on your project and see something like: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- [INFO] --- quarkus-bootstrap-maven-plugin:{quarkus-version}:build-tree (default-cli) @ getting-started --- [INFO] org.acme:getting-started:jar:1.0-SNAPSHOT @@ -343,7 +343,7 @@ A native executable will be present in `target/`. To run Integration Tests on the native executable, make sure to have the proper Maven plugin configured (see <>) and launch the `verify` goal. -[source,shell] +[source,bash] ---- ./mvnw verify -Pnative ... @@ -379,7 +379,7 @@ Executing [/Users/starksm/Dev/JBoss/Quarkus/starksm64-quarkus-quickstarts/gettin The native executable will be specific to your operating system. To create an executable that will run in a container, use the following: -[source,shell] +[source,bash] ---- ./mvnw package -Dnative -Dquarkus.native.container-build=true ---- diff --git a/docs/src/main/asciidoc/micrometer.adoc b/docs/src/main/asciidoc/micrometer.adoc index 94edcdb870eb6d..ffa7cc31bf54b8 100644 --- a/docs/src/main/asciidoc/micrometer.adoc +++ b/docs/src/main/asciidoc/micrometer.adoc @@ -43,7 +43,7 @@ The solution is located in the `micrometer-quickstart` {quickstarts-tree-url}/mi First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -171,7 +171,7 @@ To run the microservice in dev mode, use `./mvnw clean compile quarkus:dev` First, ask the endpoint whether some numbers are prime numbers. -[source,shell] +[source,bash] ---- curl localhost:8080/350 ---- @@ -180,7 +180,7 @@ The application will respond that 350 is not a prime number because it can be di Now for some large prime number so that the test takes a bit more time: -[source,shell] +[source,bash] ---- curl localhost:8080/629521085409773 ---- @@ -199,7 +199,7 @@ spent determining whether or not a number is prime. The Micrometer extension enables additional system, jvm, and http metrics. A subset of the collected metrics are shown below. -[source,shell] +[source,bash] ---- # HELP http_server_requests_seconds # TYPE http_server_requests_seconds summary diff --git a/docs/src/main/asciidoc/microprofile-fault-tolerance.adoc b/docs/src/main/asciidoc/microprofile-fault-tolerance.adoc index 3b5b0f7bee3a9a..59a314e8aca832 100644 --- a/docs/src/main/asciidoc/microprofile-fault-tolerance.adoc +++ b/docs/src/main/asciidoc/microprofile-fault-tolerance.adoc @@ -44,7 +44,7 @@ The solution is located in the `microprofile-fault-tolerance-quickstart` {quicks First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -201,7 +201,7 @@ in the `CoffeeResource#coffees()` endpoint method in about 50 % of requests. Why not check that our application works? Run the Quarkus development server with: -[source,shell] +[source,bash] ---- ./mvnw compile quarkus:dev ---- @@ -486,7 +486,7 @@ All that is needed to enable the fault tolerance features in Quarkus is: * adding the `smallrye-fault-tolerance` Quarkus extension to your project using the `quarkus-maven-plugin`: + -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="smallrye-fault-tolerance" ---- diff --git a/docs/src/main/asciidoc/microprofile-graphql.adoc b/docs/src/main/asciidoc/microprofile-graphql.adoc index 37d35ebd957072..d974fd38c02df6 100644 --- a/docs/src/main/asciidoc/microprofile-graphql.adoc +++ b/docs/src/main/asciidoc/microprofile-graphql.adoc @@ -65,7 +65,7 @@ The solution is located in the `microprofile-graphql-quickstart` {quickstarts-tr First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -360,7 +360,7 @@ Launch the quarkus app: The full schema of the GraphQL API can be retrieved by calling the following: -[source] +[source,bash] ---- curl http://localhost:8080/graphql/schema.graphql ---- diff --git a/docs/src/main/asciidoc/microprofile-health.adoc b/docs/src/main/asciidoc/microprofile-health.adoc index ac181ae4001367..c4b8366f5578ea 100644 --- a/docs/src/main/asciidoc/microprofile-health.adoc +++ b/docs/src/main/asciidoc/microprofile-health.adoc @@ -45,7 +45,7 @@ The solution is located in the `microprofile-health-quickstart` First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/microprofile-metrics.adoc b/docs/src/main/asciidoc/microprofile-metrics.adoc index 080a1491bc0ed5..289dfad06b29d9 100644 --- a/docs/src/main/asciidoc/microprofile-metrics.adoc +++ b/docs/src/main/asciidoc/microprofile-metrics.adoc @@ -51,7 +51,7 @@ The solution is located in the `microprofile-metrics-quickstart` {quickstarts-tr First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -158,7 +158,7 @@ To run the microservice in dev mode, use `./mvnw clean compile quarkus:dev` === Generate some values for the metrics First, ask the endpoint whether some numbers are prime numbers. -[source,shell] +[source,bash] ---- curl localhost:8080/350 ---- @@ -167,7 +167,7 @@ The application will respond that 350 is not a prime number because it can be di Now for some large prime number so that the test takes a bit more time: -[source,shell] +[source,bash] ---- curl localhost:8080/629521085409773 ---- diff --git a/docs/src/main/asciidoc/mongodb-panache.adoc b/docs/src/main/asciidoc/mongodb-panache.adoc index f8a1a82cb0b044..a5ff90492fe161 100644 --- a/docs/src/main/asciidoc/mongodb-panache.adoc +++ b/docs/src/main/asciidoc/mongodb-panache.adoc @@ -63,7 +63,7 @@ The solution is located in the `mongodb-panache-quickstart` {quickstarts-tree-ur First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/mongodb.adoc b/docs/src/main/asciidoc/mongodb.adoc index f0d30c7f1c88f2..5ed6eaab97f411 100644 --- a/docs/src/main/asciidoc/mongodb.adoc +++ b/docs/src/main/asciidoc/mongodb.adoc @@ -41,7 +41,7 @@ The solution is located in the `mongodb-quickstart` {quickstarts-tree-url}/mongo First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -293,7 +293,7 @@ The old `io.quarkus.mongodb.runtime.MongoClientName` has been deprecated. It sti As by default, `MongoClient` is configured to access a local MongoDB database on port 27017 (the default MongoDB port), if you have a local running database on this port, there is nothing more to do before being able to test it! If you want to use Docker to run a MongoDB database, you can use the following command to launch one: -[source,shell] +[source,bash] ---- docker run -ti --rm -p 27017:27017 mongo:4.0 ---- diff --git a/docs/src/main/asciidoc/native-and-ssl.adoc b/docs/src/main/asciidoc/native-and-ssl.adoc index 27110e224a2988..d4be51b1bb83e6 100644 --- a/docs/src/main/asciidoc/native-and-ssl.adoc +++ b/docs/src/main/asciidoc/native-and-ssl.adoc @@ -32,34 +32,44 @@ The project is located in the `rest-client-quickstart` {quickstarts-tree-url}/re == Looks like it works out of the box?!? If you open the application's configuration file (`src/main/resources/application.properties`), you can see the following line: -``` + +[source,properties] +---- org.acme.restclient.CountriesService/mp-rest/url=https://restcountries.eu/rest -``` +---- which configures our REST client to connect to an SSL REST service. Now let's build the application as a native executable and run the tests: -``` + +[source,bash] +---- ./mvnw clean install -Pnative -``` +---- And we obtain the following result: -``` + +[source] +---- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ -``` +---- So, yes, it appears it works out of the box and this guide is pretty useless. It's not. The magic happens when building the native executable: -``` + +[source] +---- [INFO] [io.quarkus.creator.phase.nativeimage.NativeImagePhase] /opt/graalvm/bin/native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dcom.sun.xml.internal.bind.v2.bytecode.ClassTailor.noOptimize=true -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar rest-client-1.0-SNAPSHOT-runner.jar -J-Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -H:+PrintAnalysisCallTree -H:EnableURLProtocols=http,https --enable-all-security-services -H:-SpawnIsolates -H:+JNI --no-server -H:-UseServiceLoaderFeature -H:+StackTrace -``` +---- The important elements are these 3 options: -``` + +[source,bash] +---- -H:EnableURLProtocols=http,https --enable-all-security-services -H:+JNI -``` +---- They enable the native SSL support for your native executable. @@ -87,10 +97,12 @@ As SSL is de facto the standard nowadays, we decided to enable its support autom As long as you have one of those extensions in your project, the SSL support will be enabled by default. Now, let's just check the size of our native executable as it will be useful later: -``` + +[source,bash] +---- $ ls -lh target/rest-client-quickstart-1.0-SNAPSHOT-runner -rwxrwxr-x. 1 gandrian gandrian 46M Jun 11 13:01 target/rest-client-quickstart-1.0-SNAPSHOT-runner -``` +---- == Let's disable SSL and see how it goes @@ -101,50 +113,66 @@ So if you are sure you don't need it, you can disable it entirely. First, let's disable it without changing the REST service URL and see how it goes. Open `src/main/resources/application.properties` and add the following line: -``` + +[source,properties] +---- quarkus.ssl.native=false -``` +---- And let's try to build again: -``` + +[source,bash] +---- ./mvnw clean install -Pnative -``` +---- The native executable tests will fail with the following error: -``` + +[source] +---- Exception handling request to /country/name/greece: com.oracle.svm.core.jdk.UnsupportedFeatureError: Accessing an URL protocol that was not enabled. The URL protocol https is supported but not enabled by default. It must be enabled by adding the --enable-url-protocols=https option to the native-image command. -``` +---- This error is the one you obtain when trying to use SSL while it was not explicitly enabled in your native executable. Now, let's change the REST service URL to **not** use SSL in `src/main/resources/application.properties`: -``` + +[source,properties] +---- org.acme.restclient.CountriesService/mp-rest/url=http://restcountries.eu/rest -``` +---- And build again: -``` + +[source,bash] +---- ./mvnw clean install -Pnative -``` +---- If you check carefully the native executable build options, you can see that the SSL related options are gone: -``` + +[source] +---- [INFO] [io.quarkus.creator.phase.nativeimage.NativeImagePhase] /opt/graalvm/bin/native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dcom.sun.xml.internal.bind.v2.bytecode.ClassTailor.noOptimize=true -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -jar rest-client-1.0-SNAPSHOT-runner.jar -J-Djava.util.concurrent.ForkJoinPool.common.parallelism=1 -H:+PrintAnalysisCallTree -H:EnableURLProtocols=http -H:-SpawnIsolates -H:+JNI --no-server -H:-UseServiceLoaderFeature -H:+StackTrace -``` +---- And we end up with: -``` + +[source] +---- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ -``` +---- You remember we checked the size of the native executable with SSL enabled? Let's check again with SSL support entirely disabled: -``` + +[source,bash] +---- $ ls -lh target/rest-client-quickstart-1.0-SNAPSHOT-runner -rwxrwxr-x. 1 gandrian gandrian 35M Jun 11 13:06 target/rest-client-quickstart-1.0-SNAPSHOT-runner -``` +---- Yes, it is now **35 MB** whereas it used to be **46 MB**. SSL comes with a 11 MB overhead in native executable size. @@ -153,14 +181,18 @@ And there's more to it. == Let's start again with a clean slate Let's revert the changes we made to the configuration file and go back to SSL with the following command: -``` + +[source,bash] +---- git checkout -- src/main/resources/application.properties -``` +---- And let's build the native executable again: -``` + +[source,bash] +---- ./mvnw clean install -Pnative -``` +---- [#the-truststore-path] == The TrustStore path @@ -180,9 +212,10 @@ As a consequence, system properties such as `javax.net.ssl.trustStore` do not ha run time, so when the defaults need to be changed, these system properties must be provided at image build time. The easiest way to do so is by setting `quarkus.native.additional-build-args`. For example: -``` +[source,bash] +---- quarkus.native.additional-build-args=-J-Djavax.net.ssl.trustStore=/tmp/mycerts,-J-Djavax.net.ssl.trustStorePassword=changeit -``` +---- will ensure that the certificates of `/tmp/mycerts` are baked into the native binary and used *in addition* to the default cacerts. diff --git a/docs/src/main/asciidoc/neo4j.adoc b/docs/src/main/asciidoc/neo4j.adoc index c0a44da78b054b..23fff2d6d90318 100644 --- a/docs/src/main/asciidoc/neo4j.adoc +++ b/docs/src/main/asciidoc/neo4j.adoc @@ -99,7 +99,7 @@ To complete this guide, you need: The easiest way to start a Neo4j instance is a locally installed Docker environment. -[source,shell,subs="verbatim,attributes"] +[source,bash,subs="verbatim,attributes"] ---- docker run --publish=7474:7474 --publish=7687:7687 -e 'NEO4J_AUTH=neo4j/secret' neo4j:{neo4j_version} ---- @@ -122,7 +122,7 @@ It contains a very simple UI to use the JAX-RS resources created here, too. First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -145,7 +145,7 @@ The Neo4j extension has been added already to your `pom.xml`. In addition, we added `resteasy-jsonb`, which allows us to expose `Fruit` instances over HTTP in the JSON format via JAX-RS resources. If you have an already created project, the `neo4j` extension can be added to an existing Quarkus project with the `add-extension` command: -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="neo4j" ---- @@ -164,7 +164,7 @@ Otherwise, you can manually add this to the dependencies section of your `pom.xm The Neo4j driver can be configured with standard Quarkus properties: -[source] +[source,properties] .src/main/resources/application.properties ---- quarkus.neo4j.uri = bolt://localhost:7687 @@ -243,14 +243,14 @@ public CompletionStage get() { Now start Quarkus in `dev` mode with: -[source, shell] +[source,bash] ---- ./mvnw compile quarkus:dev ---- and retrieve the endpoint like this -[source, shell] +[source,bash] ---- curl localhost:8080/fruits ---- @@ -287,7 +287,7 @@ The node is returned, a `Fruit` entity created and then mapped to a `201` create A curl request against this path may look like this: -[source, shell] +[source,bash] ---- curl -v -X "POST" "http://localhost:8080/fruits" \ -H 'Content-Type: application/json; charset=utf-8' \ @@ -336,7 +336,7 @@ public CompletionStage getSingle(@PathParam("id") Long id) { A request may look like this: -[source, shell] +[source,bash] ---- curl localhost:8080/fruits/42 ---- @@ -370,7 +370,7 @@ public CompletionStage delete(@PathParam("id") Long id) { A request may look like this -[source, shell] +[source,bash] ---- curl -X DELETE localhost:8080/fruits/42 ---- diff --git a/docs/src/main/asciidoc/openapi-swaggerui.adoc b/docs/src/main/asciidoc/openapi-swaggerui.adoc index e3e36261a7cfc1..d02cdd2ae80978 100644 --- a/docs/src/main/asciidoc/openapi-swaggerui.adoc +++ b/docs/src/main/asciidoc/openapi-swaggerui.adoc @@ -37,7 +37,7 @@ The solution is located in the `openapi-swaggerui-quickstart` {quickstarts-tree- First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -178,7 +178,7 @@ specification in order to generate your API https://github.com/OAI/OpenAPI-Speci You just need to add the `openapi` extension to your Quarkus application: -[source, shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="quarkus-smallrye-openapi" ---- @@ -195,14 +195,14 @@ This will add the following to your `pom.xml`: Now, we are ready to run our application: -[source, shell] +[source,bash] ---- ./mvnw compile quarkus:dev ---- Once your application is started, you can make a request to the default `/openapi` endpoint: -[source, shell] +[source,bash] ---- $ curl http://localhost:8080/openapi openapi: 3.0.3 @@ -328,7 +328,7 @@ An OpenAPI document that conforms to the OpenAPI Specification is itself a vali To see this in action, we'll put OpenAPI documentation under `META-INF/openapi.yaml` for our `/fruits` endpoints. Quarkus also supports alternative <> if you prefer. -[source, shell] +[source,bash] ---- openapi: 3.0.1 info: @@ -477,7 +477,7 @@ The value `/` is not allowed as it blocks the application from serving anything Now, we are ready to run our application: -[source, shell] +[source,bash] ---- ./mvnw compile quarkus:dev ---- diff --git a/docs/src/main/asciidoc/opentracing.adoc b/docs/src/main/asciidoc/opentracing.adoc index 85e6e59065cf2e..a189f89d78f779 100644 --- a/docs/src/main/asciidoc/opentracing.adoc +++ b/docs/src/main/asciidoc/opentracing.adoc @@ -39,7 +39,7 @@ The solution is located in the `opentracing-quickstart` {quickstarts-tree-url}/o First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -108,7 +108,7 @@ There are two ways to configure the Jaeger tracer within the application. The first approach is by providing the properties within the `src/main/resources/application.properties` file: -[source,shell] +[source,bash] ---- quarkus.jaeger.service-name=myservice // <1> quarkus.jaeger.sampler-type=const // <2> @@ -148,15 +148,18 @@ or if configuring the tracer via environment variables: Once both the application and tracing system are started, you can make a request to the provided endpoint: -``` +[source,bash] +---- $ curl http://localhost:8080/hello hello -``` +---- When the first request has been submitted, the Jaeger tracer within the app will be initialized: -``` + +[source] +---- 2019-10-16 09:35:23,464 INFO [io.jae.Configuration] (executor-thread-1) Initialized tracer=JaegerTracer(version=Java-0.34.0, serviceName=myservice, reporter=RemoteReporter(sender=UdpSender(), closeEnqueueTimeout=1000), sampler=ConstSampler(decision=true, tags={sampler.type=const, sampler.param=true}), tags={hostname=localhost.localdomain, jaeger.version=Java-0.34.0, ip=127.0.0.1}, zipkinSharedRpcSpan=false, expandExceptionLogs=false, useTraceId128Bit=false) 13:20:11 INFO traceId=1336b2b0a76a96a3, parentId=0, spanId=1336b2b0a76a96a3, sampled=true [or.ac.qu.TracedResource] (executor-thread-63) hello -``` +---- Then visit the http://localhost:16686[Jaeger UI] to see the tracing information. diff --git a/docs/src/main/asciidoc/optaplanner.adoc b/docs/src/main/asciidoc/optaplanner.adoc index f0ab9ad61ae20b..f786d9105a8432 100644 --- a/docs/src/main/asciidoc/optaplanner.adoc +++ b/docs/src/main/asciidoc/optaplanner.adoc @@ -668,7 +668,7 @@ quarkus.optaplanner.solver.termination.spent-limit=5s First start the application: -[source,shell] +[source,bash] ---- $ ./mvnw compile quarkus:dev ---- @@ -679,7 +679,7 @@ Now that the application is running, you can test the REST service. You can use any REST client you wish. The following example uses the Linux command `curl` to send a POST request: -[source,shell] +[source,bash] ---- $ curl -i -X POST http://localhost:8080/timeTable/solve -H "Content-Type:application/json" -d '{"timeslotList":[{"dayOfWeek":"MONDAY","startTime":"08:30:00","endTime":"09:30:00"},{"dayOfWeek":"MONDAY","startTime":"09:30:00","endTime":"10:30:00"}],"roomList":[{"name":"Room A"},{"name":"Room B"}],"lessonList":[{"id":1,"subject":"Math","teacher":"A. Turing","studentGroup":"9th grade"},{"id":2,"subject":"Chemistry","teacher":"M. Curie","studentGroup":"9th grade"},{"id":3,"subject":"French","teacher":"M. Curie","studentGroup":"10th grade"},{"id":4,"subject":"History","teacher":"I. Jones","studentGroup":"10th grade"}]}' ---- diff --git a/docs/src/main/asciidoc/performance-measure.adoc b/docs/src/main/asciidoc/performance-measure.adoc index 9596e85d01b4be..58df0b2081f9ad 100644 --- a/docs/src/main/asciidoc/performance-measure.adoc +++ b/docs/src/main/asciidoc/performance-measure.adoc @@ -59,7 +59,7 @@ Linux:: The linux https://linux.die.net/man/1/pmap[pmap] and https://linux.die.net/man/1/ps[ps] tools provide a report on the native memory map for a process -[source,shell] +[source,bash] -- $ ps -o pid,rss,command -p @@ -67,7 +67,7 @@ Linux:: 11229 12628 ./target/getting-started-1.0-SNAPSHOT-runner -- -[source,shell] +[source,bash] -- $ pmap -x @@ -100,7 +100,7 @@ The Total RSS (kB) line reports the total native memory the process is using. macOS:: On macOS, you can use `ps x -o pid,rss,command -p ` which list the RSS for a given process in KB (1024 bytes). -[source,shell] +[source,bash] -- $ ps x -o pid,rss,command -p 57160 @@ -144,14 +144,14 @@ public class GreetingEndpoint { We start looping in a shell, sending requests to the rest endpoint of the sample application we are testing. -[source, shell] +[source,bash] -- $ while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/api/greeting)" != "200" ]]; do sleep .00001; done -- In a separate terminal, we start the timing application that we are testing, printing the time the application starts -[source, shell] +[source,bash] -- $ date +"%T.%3N" && ./target/quarkus-timing-runner diff --git a/docs/src/main/asciidoc/quartz.adoc b/docs/src/main/asciidoc/quartz.adoc index e83e5b02c468db..60283348e441ec 100644 --- a/docs/src/main/asciidoc/quartz.adoc +++ b/docs/src/main/asciidoc/quartz.adoc @@ -42,7 +42,7 @@ The solution is located in the `quartz-quickstart` {quickstarts-tree-url}/quartz First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -205,7 +205,7 @@ NOTE: By default, the scheduler is not started unless a `@Scheduled` business me == Updating the application configuration file Edit the `application.properties` file and add the below configuration: -[source,shell] +[source,bash] ---- # Quartz configuration quarkus.quartz.clustered=true <1> @@ -377,7 +377,7 @@ networks: In a separate terminal, run the below command: -[source,shell] +[source,bash] ---- docker-compose up postgres <1> ---- @@ -396,7 +396,7 @@ You can also generate the native executable with `./mvnw clean package -Pnative` The application can be packaged using `./mvnw clean package`. Once the build is successful, run the below command: -[source,shell] +[source,bash] ---- docker-compose up --scale tasks=2 --scale nginx=1 <1> ---- diff --git a/docs/src/main/asciidoc/qute.adoc b/docs/src/main/asciidoc/qute.adoc index cb5896c49324fb..aa0e60af6c0637 100644 --- a/docs/src/main/asciidoc/qute.adoc +++ b/docs/src/main/asciidoc/qute.adoc @@ -75,7 +75,7 @@ public class HelloResource { If your application is running, you can request the endpoint: -[source, shell] +[source,bash] ---- $ curl -w "\n" http://localhost:8080/hello?name=Martin Hello Martin! diff --git a/docs/src/main/asciidoc/reactive-event-bus.adoc b/docs/src/main/asciidoc/reactive-event-bus.adoc index 7314910589ebf1..0da13cc6b74fdc 100644 --- a/docs/src/main/asciidoc/reactive-event-bus.adoc +++ b/docs/src/main/asciidoc/reactive-event-bus.adoc @@ -25,7 +25,7 @@ However, it is limited to single-event behavior (no stream) and to local message This mechanism uses the Vert.x EventBus, so you need to enable the `vertx` extension to use this feature. If you are creating a new project, set the `extensions` parameter are follows: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -38,7 +38,7 @@ cd vertx-quickstart If you have an already created project, the `vertx` extension can be added to an existing Quarkus project with the `add-extension` command: -[source] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="vertx,resteasy-mutiny" ---- @@ -263,7 +263,7 @@ This message is consumed by another bean and the response is sent using the _rep First create a new project using: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -353,14 +353,14 @@ To better understand, let's detail how the HTTP request/response has been handle This application can be packaged using: -[source,shell] +[source,bash] ---- ./mvnw clean package ---- You can also compile it as a native executable with: -[source, shell] +[source,bash] ---- ./mvnw clean package -Pnative ---- diff --git a/docs/src/main/asciidoc/reactive-sql-clients.adoc b/docs/src/main/asciidoc/reactive-sql-clients.adoc index e06d2bc3590fed..00e7abd2277517 100644 --- a/docs/src/main/asciidoc/reactive-sql-clients.adoc +++ b/docs/src/main/asciidoc/reactive-sql-clients.adoc @@ -49,7 +49,7 @@ public class Fruit { ==== Do you need a ready-to-use PostgreSQL server to try out the examples? -[source,shell] +[source,bash] ---- docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name quarkus_test -e POSTGRES_USER=quarkus_test -e POSTGRES_PASSWORD=quarkus_test -e POSTGRES_DB=quarkus_test -p 5432:5432 postgres:10.5 ---- @@ -62,7 +62,7 @@ docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name qua First, make sure your project has the `quarkus-reactive-pg-client` extension enabled. If you are creating a new project, set the `extensions` parameter as follows: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -73,7 +73,7 @@ cd reactive-pg-client-quickstart If you have an already created project, the `reactive-pg-client` extension can be added to an existing Quarkus project with the `add-extension` command: -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="reactive-pg-client" ---- @@ -92,7 +92,7 @@ Otherwise, you can manually add this to the dependencies section of your `pom.xm Reactive REST endpoints in your application that return Uni or Multi need `Mutiny support for RESTEasy` extension (`io.quarkus:quarkus-resteasy-mutiny`) to work properly: -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="resteasy-mutiny" ---- @@ -108,7 +108,7 @@ If you're not familiar with Mutiny reactive types, read the link:getting-started We will expose `Fruit` instances over HTTP in the JSON format. Consequently, you also need to add the `quarkus-resteasy-jsonb` extension: -[source,shell] +[source,bash] ---- ./mvnw quarkus:add-extension -Dextensions="resteasy-jsonb" ---- @@ -129,7 +129,7 @@ Of course, this is only a requirement for this guide, not any application using The Reactive PostgreSQL Client can be configured with standard Quarkus datasource properties and a reactive URL: -[source] +[source,properties] .src/main/resources/application.properties ---- quarkus.datasource.db-kind=postgresql @@ -267,14 +267,14 @@ public Multi get() { Now start Quarkus in `dev` mode with: -[source, shell] +[source,bash] ---- ./mvnw compile quarkus:dev ---- Lastly, open your browser and navigate to http://localhost:8080/fruits, you should see: -[source, shell] +[source,bash] ---- [{"id":3,"name":"Apple"},{"id":1,"name":"Orange"},{"id":2,"name":"Pear"}] ---- diff --git a/docs/src/main/asciidoc/redis.adoc b/docs/src/main/asciidoc/redis.adoc index 207b6a04fe2d80..7349bbe55761d4 100644 --- a/docs/src/main/asciidoc/redis.adoc +++ b/docs/src/main/asciidoc/redis.adoc @@ -43,7 +43,7 @@ The solution is located in the `redis-quickstart` {quickstarts-tree-url}/redis-q First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -89,7 +89,7 @@ docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name red Once we have the Redis server running, we need to configure the Redis connection properties. This is done in the `application.properties` configuration file. Edit it to the following content: -[source] +[source,properties] ---- quarkus.redis.hosts=redis://localhost:6379 <1> ---- @@ -390,7 +390,7 @@ public class IncrementResourceTest { If you followed the instructions, you should have the Redis server running. Then, you just need to run the application using: -[source, shell] +[source,bash] ---- ./mvnw quarkus:dev ---- @@ -405,7 +405,7 @@ a key. === Creating a new increment -[source, shell] +[source,bash] ---- curl -X POST -H "Content-Type: application/json" -d '{"key":"first","value":10}' http://localhost:8080/increments <1> ---- @@ -426,7 +426,7 @@ Running the above command should return the result below: To see the list of current increments keys, run the following command: -[source, shell] +[source,bash] ---- curl http://localhost:8080/increments ---- @@ -437,7 +437,7 @@ The above command should return `["first"]` indicating that we have only one in To retrieve an increment using its key, we will have to run the below command: -[source, shell] +[source,bash] ---- curl http://localhost:8080/increments/first <1> ---- @@ -456,7 +456,7 @@ curl http://localhost:8080/increments/first <1> To increment a value, run the following command: -[source, shell] +[source,bash] ---- curl -X PUT -H "Content-Type: application/json" -d '27' http://localhost:8080/increments/first <1> ---- @@ -479,7 +479,7 @@ Now, running the command `curl http://localhost:8080/increments/first` should re Use the command below, to delete an increment given its key. -[source, shell] +[source,bash] ---- curl -X DELETE http://localhost:8080/increments/first <1> ---- @@ -494,7 +494,7 @@ You can run the application as a conventional jar file. First, we will need to package it: -[source, shell] +[source,bash] ---- ./mvnw package ---- @@ -503,7 +503,7 @@ NOTE: This command will start a Redis instance to execute the tests. Thus your R Then run it: -[source, shell] +[source,bash] ---- java -jar ./target/redis-quickstart-1.0-SNAPSHOT-runner.jar ---- @@ -519,14 +519,14 @@ Compiling a native executable takes a bit longer, as GraalVM performs additional steps to remove unnecessary codepaths. Use the `native` profile to compile a native executable: -[source, shell] +[source,bash] ---- ./mvnw package -Pnative ---- Once the build is finished, you can run the executable with: -[source, shell] +[source,bash] ---- ./target/redis-quickstart-1.0-SNAPSHOT-runner ---- diff --git a/docs/src/main/asciidoc/rest-client-multipart.adoc b/docs/src/main/asciidoc/rest-client-multipart.adoc index 1d12856d9db352..2cc4996d0f9d96 100644 --- a/docs/src/main/asciidoc/rest-client-multipart.adoc +++ b/docs/src/main/asciidoc/rest-client-multipart.adoc @@ -35,7 +35,7 @@ The solution is located in the `rest-client-multipart-quickstart` {quickstarts-t First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -147,7 +147,7 @@ It will allow to narrow down the number of JAX-RS providers (which can be seen a In order to determine the base URL to which REST calls will be made, the REST Client uses configuration from `application.properties`. The name of the property needs to follow a certain convention which is best displayed in the following code: -[source,shell] +[source,bash] ---- # Your configuration properties org.acme.rest.client.multipart.MultipartService/mp-rest/url=http://localhost:8080/ @@ -265,7 +265,7 @@ The code above uses link:http://rest-assured.io/[REST Assured] to assert that th Because the test runs in a different port, we also need to include an `application.properties` in our `src/test/resources` with the following content: -[source,shell] +[source,bash] ---- # Your configuration properties org.acme.rest.client.multipart.MultipartService/mp-rest/url=http://localhost:8081/ @@ -278,7 +278,7 @@ org.acme.rest.client.multipart.MultipartService/mp-rest/url=http://localhost:808 You should see an output similar to: -[source,shell] +[source,bash] ---- --89d288bd-960f-460c-b266-64c5b4d170fa Content-Disposition: form-data; name="fileName" diff --git a/docs/src/main/asciidoc/rest-client.adoc b/docs/src/main/asciidoc/rest-client.adoc index fe59c8e1ad48bf..9880b9144045d0 100644 --- a/docs/src/main/asciidoc/rest-client.adoc +++ b/docs/src/main/asciidoc/rest-client.adoc @@ -34,7 +34,7 @@ The solution is located in the `rest-client-quickstart` {quickstarts-tree-url}/r First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -153,7 +153,7 @@ It will allow to narrow down the number of JAX-RS providers (which can be seen a In order to determine the base URL to which REST calls will be made, the REST Client uses configuration from `application.properties`. The name of the property needs to follow a certain convention which is best displayed in the following code: -[source,shell] +[source,bash] ---- # Your configuration properties org.acme.rest.client.CountriesService/mp-rest/url=https://restcountries.eu/rest # // <1> diff --git a/docs/src/main/asciidoc/rest-json.adoc b/docs/src/main/asciidoc/rest-json.adoc index badce09a318576..8fa93cd6d291c9 100644 --- a/docs/src/main/asciidoc/rest-json.adoc +++ b/docs/src/main/asciidoc/rest-json.adoc @@ -41,7 +41,7 @@ The solution is located in the `rest-json-quickstart` {quickstarts-tree-url}/res First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -65,7 +65,7 @@ and in particular adds the following dependency: Quarkus also supports https://github.com/FasterXML/jackson[Jackson] so, if you prefer Jackson over JSON-B, you can create a project relying on the RESTEasy Jackson extension instead: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -489,7 +489,7 @@ public class LoggingFilter implements ContainerRequestFilter { Now, whenever a REST method is invoked, the request will be logged into the console: -[source,shell] +[source,bash] ---- 2019-06-05 12:44:26,526 INFO [org.acm.res.jso.LoggingFilter] (executor-thread-1) Request GET /legumes from IP 127.0.0.1 2019-06-05 12:49:19,623 INFO [org.acm.res.jso.LoggingFilter] (executor-thread-1) Request GET /fruits from IP 0:0:0:0:0:0:0:1 diff --git a/docs/src/main/asciidoc/scheduler.adoc b/docs/src/main/asciidoc/scheduler.adoc index 9fab6275c102ff..b903b8c411ac8d 100644 --- a/docs/src/main/asciidoc/scheduler.adoc +++ b/docs/src/main/asciidoc/scheduler.adoc @@ -41,7 +41,7 @@ The solution is located in the `scheduler-quickstart` {quickstarts-tree-url}/sch First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -134,7 +134,7 @@ it should be invoked as soon as possible. The invocation of the scheduled method == Updating the application configuration file Edit the `application.properties` file and add the `cron.expr` configuration: -[source,shell] +[source,bash] ---- # By default, the syntax used for cron expressions is based on Quartz - http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html # You can change the syntax using the following property: diff --git a/docs/src/main/asciidoc/scripting.adoc b/docs/src/main/asciidoc/scripting.adoc index f6e8eb8da4a6a7..bb9d4399a71753 100644 --- a/docs/src/main/asciidoc/scripting.adoc +++ b/docs/src/main/asciidoc/scripting.adoc @@ -86,7 +86,7 @@ image::getting-started-architecture.png[alt=Architecture] First, we need a Java file. jbang lets you create an initial version using: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- jbang init scripting/quarkusapp.java cd scripting @@ -118,14 +118,14 @@ Is illustrating how you add dependencies to this script. This is a feature of `j Go ahead and update this line to include the `quarkus-resteasy` dependency like so: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- //DEPS io.quarkus:quarkus-resteasy:{quarkus-version} ---- Now, run `jbang quarkusapp.java` and you will see `jbang` resolving this dependency and building the jar with help from Quarkus' jbang integration. -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- $ jbang quarkusapp.java @@ -196,7 +196,7 @@ Now when you run the application you will see Quarkus start up. Use: `jbang quarkusapp.java`: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- $ jbang quarkusapp.java @@ -217,7 +217,7 @@ __ ____ __ _____ ___ __ ____ ______ Once started, you can request the provided endpoint: -[source,shell] +[source,bash] ---- $ curl -w "\n" http://localhost:8080/hello hello @@ -325,7 +325,7 @@ public class quarkusapp { Now when you run `jbang quarkusapp.java` you can check what the new end point returns: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- $ curl -w "\n" http://localhost:8080/hello/greeting/quarkus hello null @@ -337,14 +337,14 @@ The reason is that JAX-RS `@PathParam` relies on the `-parameters` compiler flag We fix that by adding the following comment instruction to the file: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- //JAVAC_OPTIONS -parameters ---- Now when you run with `jbang quarkusapp.java` the end point should return what you expect: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- $ curl -w "\n" http://localhost:8080/hello/greeting/quarkus hello quarkus @@ -394,7 +394,7 @@ Now during build the `quarkus.swagger-ui.always-include` will be generated into If you have the `native-image` binary installed and `GRAALVM_HOME` set, you can get the native executable built and run using `jbang --native quarkusapp.java`: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- $ jbang --native quarkusapp @@ -424,7 +424,7 @@ __ ____ __ _____ ___ __ ____ ______ This native build will take some time on first run but any subsequent runs (without changing `quarkusapp.java`) will be close to instant thanks to jbang cache: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- $ jbang --native quarkusapp.java __ ____ __ _____ ___ __ ____ ______ diff --git a/docs/src/main/asciidoc/security-jdbc.adoc b/docs/src/main/asciidoc/security-jdbc.adoc index 666f92c5298030..b3253eb15d5a4a 100644 --- a/docs/src/main/asciidoc/security-jdbc.adoc +++ b/docs/src/main/asciidoc/security-jdbc.adoc @@ -44,7 +44,7 @@ The solution is located in the `security-jdbc-quickstart` {quickstarts-tree-url} First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -218,7 +218,7 @@ In the `principal-query` configuration all the `index` properties start at 1 (ra The application is now protected and the identities are provided by our database. The very first thing to check is to ensure the anonymous access works. -[source,shell] +[source,bash] ---- $ curl -i -X GET http://localhost:8080/api/public HTTP/1.1 200 OK @@ -230,7 +230,7 @@ public% Now, let's try a to hit a protected resource anonymously. -[source,shell] +[source,bash] ---- $ curl -i -X GET http://localhost:8080/api/admin HTTP/1.1 401 Unauthorized @@ -242,7 +242,7 @@ Not authorized% So far so good, now let's try with an allowed user. -[source,shell] +[source,bash] ---- $ curl -i -X GET -u admin:admin http://localhost:8080/api/admin HTTP/1.1 200 OK @@ -255,7 +255,7 @@ By providing the `admin:admin` credentials, the extension authenticated the user The `admin` user is authorized to access to the protected resources. The user `admin` should be forbidden to access a resource protected with `@RolesAllowed("user")` because it doesn't have this role. -[source,shell] +[source,bash] ---- $ curl -i -X GET -u admin:admin http://localhost:8080/api/users/me HTTP/1.1 403 Forbidden @@ -266,7 +266,7 @@ Forbidden% ---- Finally, using the user `user` works and the security context contains the principal details (username for instance). -[source,shell] +[source,bash] ---- curl -i -X GET -u user:user http://localhost:8080/api/users/me HTTP/1.1 200 OK diff --git a/docs/src/main/asciidoc/security-jpa.adoc b/docs/src/main/asciidoc/security-jpa.adoc index ed3a7f40cc96fe..77f00ba579fffa 100644 --- a/docs/src/main/asciidoc/security-jpa.adoc +++ b/docs/src/main/asciidoc/security-jpa.adoc @@ -45,7 +45,7 @@ The solution is located in the `security-jpa-quickstart` {quickstarts-tree-url}/ First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -268,7 +268,7 @@ In the following tests we use the basic authentication mechanism, you can enable The application is now protected and the identities are provided by our database. The very first thing to check is to ensure the anonymous access works. -[source,shell] +[source,bash] ---- $ curl -i -X GET http://localhost:8080/api/public HTTP/1.1 200 OK @@ -280,7 +280,7 @@ public% Now, let's try a to hit a protected resource anonymously. -[source,shell] +[source,bash] ---- $ curl -i -X GET http://localhost:8080/api/admin HTTP/1.1 401 Unauthorized @@ -292,7 +292,7 @@ Not authorized% So far so good, now let's try with an allowed user. -[source,shell] +[source,bash] ---- $ curl -i -X GET -u admin:admin http://localhost:8080/api/admin HTTP/1.1 200 OK @@ -305,7 +305,7 @@ By providing the `admin:admin` credentials, the extension authenticated the user The `admin` user is authorized to access to the protected resources. The user `admin` should be forbidden to access a resource protected with `@RolesAllowed("user")` because it doesn't have this role. -[source,shell] +[source,bash] ---- $ curl -i -X GET -u admin:admin http://localhost:8080/api/users/me HTTP/1.1 403 Forbidden @@ -316,7 +316,7 @@ Forbidden% ---- Finally, using the user `user` works and the security context contains the principal details (username for instance). -[source,shell] +[source,bash] ---- curl -i -X GET -u user:user http://localhost:8080/api/users/me HTTP/1.1 200 OK diff --git a/docs/src/main/asciidoc/security-jwt.adoc b/docs/src/main/asciidoc/security-jwt.adoc index 06eabaa6b3b041..528d26a3bfdf0f 100644 --- a/docs/src/main/asciidoc/security-jwt.adoc +++ b/docs/src/main/asciidoc/security-jwt.adoc @@ -27,7 +27,7 @@ The solution is located in the `security-jwt-quickstart` {quickstarts-tree-url}/ First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -156,7 +156,7 @@ will produce undesirable behavior since JWT claims are naturally request scoped. Now we are ready to run our application. Use: -[source,shell] +[source,bash] ---- ./mvnw compile quarkus:dev ---- @@ -164,7 +164,7 @@ Now we are ready to run our application. Use: and you should see output similar to: .quarkus:dev Output -[source,shell] +[source,bash] ---- $ ./mvnw compile quarkus:dev [INFO] Scanning for projects... @@ -182,7 +182,7 @@ Listening for transport dt_socket at address: 5005 Now that the REST endpoint is running, we can access it using a command line tool like curl: .curl command for /secured/permit-all -[source,shell] +[source,bash] ---- $ curl http://127.0.0.1:8080/secured/permit-all; echo hello + anonymous, isHttps: false, authScheme: null, hasJWT: false @@ -272,7 +272,7 @@ they have either a "User" or "Admin" role assigned. After you make this addition to your `TokenSecuredResource`, rerun the `./mvnw compile quarkus:dev` command, and then try `curl -v http://127.0.0.1:8080/secured/roles-allowed; echo` to attempt to access the new endpoint. Your output should be: .curl command for /secured/roles-allowed -[source,shell] +[source,bash] ---- $ curl -v http://127.0.0.1:8080/secured/roles-allowed; echo * Trying 127.0.0.1... @@ -416,7 +416,7 @@ Now we can generate a JWT to use with `TokenSecuredResource` endpoint. To do thi .Command to Generate JWT .Sample JWT Generation Output -[source,shell] +[source,bash] ---- $ mvn exec:java -Dexec.mainClass=org.acme.security.jwt.GenerateToken -Dexec.classpathScope=test -Dsmallrye.jwt.sign.key-location=privateKey.pem @@ -429,13 +429,13 @@ First part - JWT headers, second part - JWT claims, third part - JWT signature. == Finally, Secured Access to /secured/roles-allowed Now let's use this to make a secured request to the /secured/roles-allowed endpoint. Make sure you have the Quarkus server running using the `./mvnw compile quarkus:dev` command, and then run the following command, making sure to use your version of the generated JWT from the previous step: -[source,shell] +[source,bash] ---- curl -H "Authorization: Bearer eyJraWQiOiJcL3ByaXZhdGVLZXkucGVtIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJqZG9lLXVzaW5nLWp3dC1yYmFjIiwiYXVkIjoidXNpbmctand0LXJiYWMiLCJ1cG4iOiJqZG9lQHF1YXJrdXMuaW8iLCJiaXJ0aGRhdGUiOiIyMDAxLTA3LTEzIiwiYXV0aF90aW1lIjoxNTUxNjUyMDkxLCJpc3MiOiJodHRwczpcL1wvcXVhcmt1cy5pb1wvdXNpbmctand0LXJiYWMiLCJyb2xlTWFwcGluZ3MiOnsiZ3JvdXAyIjoiR3JvdXAyTWFwcGVkUm9sZSIsImdyb3VwMSI6Ikdyb3VwMU1hcHBlZFJvbGUifSwiZ3JvdXBzIjpbIkVjaG9lciIsIlRlc3RlciIsIlN1YnNjcmliZXIiLCJncm91cDIiXSwicHJlZmVycmVkX3VzZXJuYW1lIjoiamRvZSIsImV4cCI6MTU1MTY1MjM5MSwiaWF0IjoxNTUxNjUyMDkxLCJqdGkiOiJhLTEyMyJ9.aPA4Rlc4kw7n_OZZRRk25xZydJy_J_3BRR8ryYLyHTO1o68_aNWWQCgpnAuOW64svPhPnLYYnQzK-l2vHX34B64JySyBD4y_vRObGmdwH_SEufBAWZV7mkG3Y4mTKT3_4EWNu4VH92IhdnkGI4GJB6yHAEzlQI6EdSOa4Nq8Gp4uPGqHsUZTJrA3uIW0TbNshFBm47-oVM3ZUrBz57JKtr0e9jv0HjPQWyvbzx1HuxZd6eA8ow8xzvooKXFxoSFCMnxotd3wagvYQ9ysBa89bgzL-lhjWtusuMFDUVYwFqADE7oOSOD4Vtclgq8svznBQ-YpfTHfb9QEcofMlpyjNA" http://127.0.0.1:8080/secured/roles-allowed; echo ---- .curl Command for /secured/roles-allowed With JWT -[source,shell] +[source,bash] ---- $ curl -H "Authorization: Bearer eyJraWQ..." http://127.0.0.1:8080/secured/roles-allowed; echo hello + jdoe@quarkus.io, isHttps: false, authScheme: MP-JWT, hasJWT: true, birthdate: 2001-07-13 @@ -542,12 +542,12 @@ public class TokenSecuredResource { Now generate the token again and run: -[source,shell] +[source,bash] ---- curl -H "Authorization: Bearer eyJraWQiOiJcL3ByaXZhdGVLZXkucGVtIiwidHlwIjoiSldUIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJqZG9lLXVzaW5nLWp3dC1yYmFjIiwiYXVkIjoidXNpbmctand0LXJiYWMiLCJ1cG4iOiJqZG9lQHF1YXJrdXMuaW8iLCJiaXJ0aGRhdGUiOiIyMDAxLTA3LTEzIiwiYXV0aF90aW1lIjoxNTUxNjUyMDkxLCJpc3MiOiJodHRwczpcL1wvcXVhcmt1cy5pb1wvdXNpbmctand0LXJiYWMiLCJyb2xlTWFwcGluZ3MiOnsiZ3JvdXAyIjoiR3JvdXAyTWFwcGVkUm9sZSIsImdyb3VwMSI6Ikdyb3VwMU1hcHBlZFJvbGUifSwiZ3JvdXBzIjpbIkVjaG9lciIsIlRlc3RlciIsIlN1YnNjcmliZXIiLCJncm91cDIiXSwicHJlZmVycmVkX3VzZXJuYW1lIjoiamRvZSIsImV4cCI6MTU1MTY1MjM5MSwiaWF0IjoxNTUxNjUyMDkxLCJqdGkiOiJhLTEyMyJ9.aPA4Rlc4kw7n_OZZRRk25xZydJy_J_3BRR8ryYLyHTO1o68_aNWWQCgpnAuOW64svPhPnLYYnQzK-l2vHX34B64JySyBD4y_vRObGmdwH_SEufBAWZV7mkG3Y4mTKT3_4EWNu4VH92IhdnkGI4GJB6yHAEzlQI6EdSOa4Nq8Gp4uPGqHsUZTJrA3uIW0TbNshFBm47-oVM3ZUrBz57JKtr0e9jv0HjPQWyvbzx1HuxZd6eA8ow8xzvooKXFxoSFCMnxotd3wagvYQ9ysBa89bgzL-lhjWtusuMFDUVYwFqADE7oOSOD4Vtclgq8svznBQ-YpfTHfb9QEcofMlpyjNA" http://127.0.0.1:8080/secured/roles-allowed-admin; echo ---- -[source,shell] +[source,bash] ---- $ curl -H "Authorization: Bearer eyJraWQ..." http://127.0.0.1:8080/secured/roles-allowed-admin; echo hello + jdoe@quarkus.io, isHttps: false, authScheme: MP-JWT, hasJWT: true, birthdate: 2001-07-13 @@ -556,7 +556,7 @@ hello + jdoe@quarkus.io, isHttps: false, authScheme: MP-JWT, hasJWT: true, birth === Package and run the application As usual, the application can be packaged using `./mvnw clean package` and executed using the `-runner.jar` file: .Runner jar Example -[source,shell] +[source,bash] ---- Scotts-iMacPro:security-jwt-quickstart starksm$ ./mvnw clean package [INFO] Scanning for projects... @@ -570,7 +570,7 @@ Scotts-iMacPro:security-jwt-quickstart starksm$ java -jar target/security-jwt-qu You can also generate the native executable with `./mvnw clean package -Pnative`. .Native Executable Example -[source,shell] +[source,bash] ---- Scotts-iMacPro:security-jwt-quickstart starksm$ ./mvnw clean package -Pnative [INFO] Scanning for projects... @@ -667,7 +667,9 @@ SmallRye JWT provides more properties which can be used to customize the token p == Create JsonWebToken with JWTParser If the JWT token can not be injected, for example, if it is embedded in the service request payload or the service endpoint acquires it out of band, then one can use `JWTParser`: -``` + +[source,java] +---- import org.eclipse.microprofile.jwt.JsonWebToken; import io.smallrye.jwt.auth.principal.JWTParser; ... @@ -677,11 +679,12 @@ String token = getTokenFromOidcServer(); // Parse and verify the token JsonWebToken jwt = parser.parse(token); -``` +---- You can also use it to customize the way the token is verified or decrypted. For example, one can supply a local `SecretKey`: -``` +[source,java] +---- import javax.crypto.SecretKey; import javax.ws.rs.GET; import javax.ws.rs.core.NewCookie; @@ -692,12 +695,12 @@ import io.smallrye.jwt.build.Jwt; @Path("/secured") public class SecuredResource { - @Inject JWTParser parser; - private String secret = "AyM1SysPpbyDfgZld3umj1qzKObwVMko"; + @Inject JWTParser parser; + private String secret = "AyM1SysPpbyDfgZld3umj1qzKObwVMko"; - @GET - @Produces("text/plain") - public Response getUserName(@CookieParam("jwt") String jwtCookie) { + @GET + @Produces("text/plain") + public Response getUserName(@CookieParam("jwt") String jwtCookie) { Response response = null; if (jwtCookie == null) { // Create a JWT token signed using the 'HS256' algorithm @@ -705,14 +708,15 @@ public class SecuredResource { // or create a JWT token encrypted using the 'A256KW' algorithm // Jwt.upn("alice").encryptWithSecret(secret); return Response.ok("Alice").cookie(new NewCookie("jwt", newJwtCookie)).build(); - else { + } else { // All mp.jwt and smallrye.jwt properties are still effective, only the verification key is customized. JsonWebToken jwt = parser.verify(jwtCookie, secret); // or jwt = parser.decrypt(jwtCookie, secret); return Response.ok(jwt.getName()).build(); } + } } -``` +---- == Token Decryption @@ -875,7 +879,9 @@ String jwt = Jwt.claims("/tokenClaims.json").innerSign().encrypt(); === Fast JWT Generation If `smallrye.jwt.sign.key-location` or/and `smallrye.jwt.encrypt.key-location` properties are set then one can secure the existing claims (resources, maps, JsonObjects) with a single call: -``` + +[source,java] +---- // More compact than Jwt.claims("/claims.json").sign(); Jwt.sign("/claims.json"); @@ -884,7 +890,7 @@ Jwt.encrypt("/claims.json"); // More compact than Jwt.claims("/claims.json").innerSign().encrypt(); Jwt.signAndEncrypt("/claims.json"); -``` +---- As mentioned above, `iat`, `exp`, `jti` and `iss` claims will be added if needed. === SmallRye JWT Builder configuration diff --git a/docs/src/main/asciidoc/security-ldap.adoc b/docs/src/main/asciidoc/security-ldap.adoc index 950eed01112381..5820da9911dd38 100644 --- a/docs/src/main/asciidoc/security-ldap.adoc +++ b/docs/src/main/asciidoc/security-ldap.adoc @@ -44,7 +44,7 @@ The solution is located in the `security-ldap-quickstart` {quickstarts-tree-url} First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -178,7 +178,7 @@ The `elytron-security-ldap` extension requires a dir-context and an identity-map The application is now protected and the identities are provided by our LDAP server. The very first thing to check is to ensure the anonymous access works. -[source,shell] +[source,bash] ---- $ curl -i -X GET http://localhost:8080/api/public HTTP/1.1 200 OK @@ -190,7 +190,7 @@ public% Now, let's try a to hit a protected resource anonymously. -[source,shell] +[source,bash] ---- $ curl -i -X GET http://localhost:8080/api/admin HTTP/1.1 401 Unauthorized @@ -202,7 +202,7 @@ Not authorized% So far so good, now let's try with an allowed user. -[source,shell] +[source,bash] ---- $ curl -i -X GET -u adminUser:adminUserPassword http://localhost:8080/api/admin HTTP/1.1 200 OK @@ -215,7 +215,7 @@ By providing the `adminUser:adminUserPassword` credentials, the extension authen The `adminUser` user is authorized to access to the protected resources. The user `adminUser` should be forbidden to access a resource protected with `@RolesAllowed("standardRole")` because it doesn't have this role. -[source,shell] +[source,bash] ---- $ curl -i -X GET -u adminUser:adminUserPassword http://localhost:8080/api/users/me HTTP/1.1 403 Forbidden @@ -226,7 +226,7 @@ Forbidden% ---- Finally, using the user `standardUser` works and the security context contains the principal details (username for instance). -[source,shell] +[source,bash] ---- curl -i -X GET -u standardUser:standardUserPassword http://localhost:8080/api/users/me HTTP/1.1 200 OK diff --git a/docs/src/main/asciidoc/security-oauth2.adoc b/docs/src/main/asciidoc/security-oauth2.adoc index abc74d71ab5511..5a5b540f4b7a23 100644 --- a/docs/src/main/asciidoc/security-oauth2.adoc +++ b/docs/src/main/asciidoc/security-oauth2.adoc @@ -35,7 +35,7 @@ It contains a very simple UI to use the JAX-RS resources created here, too. First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -128,7 +128,7 @@ public class TokenSecuredResource { Now we are ready to run our application. Use: -[source,shell] +[source,bash] ---- ./mvnw compile quarkus:dev ---- @@ -136,7 +136,7 @@ Now we are ready to run our application. Use: and you should see output similar to: .quarkus:dev Output -[source,shell] +[source,bash] ---- $ ./mvnw clean compile quarkus:dev [INFO] Scanning for projects... @@ -157,7 +157,7 @@ Listening for transport dt_socket at address: 5005 Now that the REST endpoint is running, we can access it using a command line tool like curl: .curl command for /secured/permit-all -[source,shell] +[source,bash] ---- $ curl http://127.0.0.1:8080/secured/permit-all; echo hello + anonymous, isSecure: false, authScheme: null @@ -220,7 +220,7 @@ public class TokenSecuredResource { After you make this addition to your `TokenSecuredResource`, try `curl -v http://127.0.0.1:8080/secured/roles-allowed; echo` to attempt to access the new endpoint. Your output should be: .curl command for /secured/roles-allowed -[source,shell] +[source,bash] ---- $ curl -v http://127.0.0.1:8080/secured/roles-allowed; echo * Trying 127.0.0.1... @@ -270,7 +270,7 @@ You need to obtain the token from a standard OAuth2 authentication server (https You can find below a curl example of such call for a `client_credential` flow: -[source,shell] +[source,bash] ---- curl -X POST "http://oauth-server/token?grant_type=client_credentials" \ -H "Accept: application/json" -H "Authorization: Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=" @@ -288,7 +288,7 @@ It should respond something like that... Now let's use this to make a secured request to the `/secured/roles-allowed` endpoint .curl Command for /secured/roles-allowed With a token -[source,shell] +[source,bash] ---- $ curl -H "Authorization: Bearer 60acf56d-9daf-49ba-b3be-7a423d9c7288" http://127.0.0.1:8080/secured/roles-allowed; echo hello + client_id isSecure: false, authScheme: OAuth2 @@ -309,7 +309,7 @@ You can customize the name of the claim to use for the roles with the `quarkus.o As usual, the application can be packaged using `./mvnw clean package` and executed using the `-runner.jar` file: .Runner jar Example -[source,shell] +[source,bash] ---- $ ./mvnw clean package [INFO] Scanning for projects... @@ -321,7 +321,7 @@ $ java -jar target/security-oauth2-quickstart-runner.jar You can also generate the native executable with `./mvnw clean package -Pnative`. .Native Executable Example -[source,shell] +[source,bash] ---- $ ./mvnw clean package -Pnative [INFO] Scanning for projects... diff --git a/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc b/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc index dd27562ea5b636..b54a4b7e98b50d 100644 --- a/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc +++ b/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc @@ -48,7 +48,7 @@ The solution is located in the `security-openid-connect-multi-tenancy` {quicksta First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/security-openid-connect-web-authentication.adoc b/docs/src/main/asciidoc/security-openid-connect-web-authentication.adoc index d6c2323e4d9981..632cb4429f3905 100644 --- a/docs/src/main/asciidoc/security-openid-connect-web-authentication.adoc +++ b/docs/src/main/asciidoc/security-openid-connect-web-authentication.adoc @@ -48,7 +48,7 @@ The solution is located in the `security-openid-connect-web-authentication-quick First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/security-openid-connect.adoc b/docs/src/main/asciidoc/security-openid-connect.adoc index cd537d991a998b..7063263a4baa0f 100644 --- a/docs/src/main/asciidoc/security-openid-connect.adoc +++ b/docs/src/main/asciidoc/security-openid-connect.adoc @@ -57,7 +57,7 @@ The solution is located in the `security-openid-connect-quickstart` {quickstarts First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/spring-boot-properties.adoc b/docs/src/main/asciidoc/spring-boot-properties.adoc index 2e224ab68450e2..aa91323a08e341 100644 --- a/docs/src/main/asciidoc/spring-boot-properties.adoc +++ b/docs/src/main/asciidoc/spring-boot-properties.adoc @@ -35,7 +35,7 @@ The solution is located in the `spring-boot-properties-quickstart` {quickstarts- First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -112,7 +112,7 @@ Here `text` field is public, but it could also be a private field with getter an Because `text` does not have a default value it is considered required and unless it is defined in a configuration file (`application.properties` by default) your application will fail to start. Define this property in your `src/main/resources/application.properties` file: -[source,shell] +[source,bash] ---- # Your configuration properties greeting.text = hello @@ -350,7 +350,7 @@ This is especially useful when then number of properties grows. Because of the additional class, our property names have changed. Let's update the properties file and the `GreetingResource` class. -[source,shell] +[source,bash] ---- # Your configuration properties greeting.message.text = hello diff --git a/docs/src/main/asciidoc/spring-cache.adoc b/docs/src/main/asciidoc/spring-cache.adoc index 52b4d157481ab0..3c72130e83df6c 100644 --- a/docs/src/main/asciidoc/spring-cache.adoc +++ b/docs/src/main/asciidoc/spring-cache.adoc @@ -29,7 +29,7 @@ To complete this guide, you need: First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/spring-cloud-config-client.adoc b/docs/src/main/asciidoc/spring-cloud-config-client.adoc index 1a27ea32046b84..bceda8a2dcc73b 100644 --- a/docs/src/main/asciidoc/spring-cloud-config-client.adoc +++ b/docs/src/main/asciidoc/spring-cloud-config-client.adoc @@ -35,7 +35,7 @@ The end result of that process is a running Config Server that will provide the First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/spring-data-jpa.adoc b/docs/src/main/asciidoc/spring-data-jpa.adoc index b76080a9117325..0b46131028b9ed 100644 --- a/docs/src/main/asciidoc/spring-data-jpa.adoc +++ b/docs/src/main/asciidoc/spring-data-jpa.adoc @@ -35,7 +35,7 @@ The solution is located in the `spring-data-jpa-quickstart` {quickstarts-tree-ur First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -144,9 +144,10 @@ This configuration assumes that PostgreSQL will be running locally. A very easy way to accomplish that is by using the following Docker command: -``` +[source,bash] +---- docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name quarkus_test -e POSTGRES_USER=quarkus_test -e POSTGRES_PASSWORD=quarkus_test -e POSTGRES_DB=quarkus_test -p 5432:5432 postgres:11.5 -``` +---- If you plan on using a different setup, please change your `application.properties` accordingly. diff --git a/docs/src/main/asciidoc/spring-di.adoc b/docs/src/main/asciidoc/spring-di.adoc index 03335f70a9e096..d626934568dc43 100644 --- a/docs/src/main/asciidoc/spring-di.adoc +++ b/docs/src/main/asciidoc/spring-di.adoc @@ -37,7 +37,7 @@ The solution is located in the `spring-di-quickstart` {quickstarts-tree-url}/spr First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/spring-scheduled.adoc b/docs/src/main/asciidoc/spring-scheduled.adoc index f8255d9560d2af..656a3599eedc81 100644 --- a/docs/src/main/asciidoc/spring-scheduled.adoc +++ b/docs/src/main/asciidoc/spring-scheduled.adoc @@ -38,7 +38,7 @@ The solution is located in the `spring-scheduled-quickstart` {quickstarts-tree-u First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ @@ -126,7 +126,7 @@ public class CounterBean { == Updating the application configuration file Edit the `application.properties` file and add the `cron.expr` and the `fixedRate.expr` configuration: -[source,shell] +[source,bash] ---- # The syntax used by Spring for cron expressions is the same as which is used by regular Quarkus scheduler. cron.expr=*/5 * * * * ? diff --git a/docs/src/main/asciidoc/spring-security.adoc b/docs/src/main/asciidoc/spring-security.adoc index 9a533d1bc6a443..61f18952684ffe 100644 --- a/docs/src/main/asciidoc/spring-security.adoc +++ b/docs/src/main/asciidoc/spring-security.adoc @@ -38,7 +38,7 @@ The solution is located in the `spring-security-quickstart` {quickstarts-tree-ur First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/spring-web.adoc b/docs/src/main/asciidoc/spring-web.adoc index c0933cb00c49fa..4ae2a01b6439ea 100644 --- a/docs/src/main/asciidoc/spring-web.adoc +++ b/docs/src/main/asciidoc/spring-web.adoc @@ -37,7 +37,7 @@ The solution is located in the `spring-web-quickstart` {quickstarts-tree-url}/sp First, we need a new project. Create a new project with the following command: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/tests-with-coverage.adoc b/docs/src/main/asciidoc/tests-with-coverage.adoc index 221e4e35f9673b..d7c456b9459c1e 100644 --- a/docs/src/main/asciidoc/tests-with-coverage.adoc +++ b/docs/src/main/asciidoc/tests-with-coverage.adoc @@ -53,7 +53,7 @@ The solution is located in the `tests-with-coverage-quickstart` {quickstarts-tre Let's start from an empty application created with the Quarkus Maven plugin: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:create \ -DprojectGroupId=org.acme \ @@ -356,7 +356,7 @@ Given the content of `GreetingResourceTest`, `GreetingResource` should have been During the report generation, you may have noticed a warning: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- [WARNING] Classes in bundle '***' do no match with execution data. For report generation the same class files must be used as at runtime. [WARNING] Execution data for class org/acme/testcoverage/GreetingResource does not match. @@ -411,7 +411,7 @@ public class GreetingResource { Some might say that this approach is preferable since the field can be *final* like this. Anyway, in some cases you might need an explicit constructor. And, in that case, the coverage is not reported properly by JaCoCo. This is because Quarkus generates a constructor without any parameter and does some bycode manipulations in order to add it to the class. That is what happened here, just before the execution of the integration tests: -[source,shell,subs=attributes+] +[source,bash,subs=attributes+] ---- [INFO] --- quarkus-maven-plugin:0.16.0:build (default) @ getting-started-testing --- [INFO] [io.quarkus.deployment.QuarkusAugmentor] Beginning quarkus augmentation diff --git a/docs/src/main/asciidoc/tika.adoc b/docs/src/main/asciidoc/tika.adoc index b6c7f529e71ea3..d2cd00ef7967f3 100644 --- a/docs/src/main/asciidoc/tika.adoc +++ b/docs/src/main/asciidoc/tika.adoc @@ -66,7 +66,7 @@ The provided solution contains a few additional elements such as tests and testi First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme.example \ @@ -178,7 +178,7 @@ As you can see the JAX-RS resource method was renamed to `extractText`, `@GET` a Now we are ready to run our application. Use: -[source,shell] +[source,bash] ---- ./mvnw compile quarkus:dev ---- @@ -186,7 +186,7 @@ Now we are ready to run our application. Use: and you should see output similar to: .quarkus:dev Output -[source,shell] +[source,bash] ---- $ ./mvnw clean compile quarkus:dev [INFO] Scanning for projects... @@ -207,7 +207,7 @@ Listening for transport dt_socket at address: 5005 Now that the REST endpoint is running, we can get it to parse PDF and OpenDocument documents using a command line tool like curl: -[source,shell] +[source,bash] ---- $ curl -X POST -H "Content-type: application/pdf" --data-binary @target/classes/quarkus.pdf http://localhost:8080/parse/text Hello Quarkus @@ -215,7 +215,7 @@ Hello Quarkus and -[source,shell] +[source,bash] ---- $ curl -X POST -H "Content-type: Content-type: application/vnd.oasis.opendocument.text" --data-binary @target/classes/quarkus.odt http://localhost:8080/parse/text Hello Quarkus diff --git a/docs/src/main/asciidoc/validation.adoc b/docs/src/main/asciidoc/validation.adoc index d654feb0152fb5..2f84a9e82904f2 100644 --- a/docs/src/main/asciidoc/validation.adoc +++ b/docs/src/main/asciidoc/validation.adoc @@ -42,7 +42,7 @@ The solution is located in the `validation-quickstart` {quickstarts-tree-url}/va First, we need a new project. Create a new project with the following command: -[source, subs=attributes+] +[source,bash,subs=attributes+] ---- mvn io.quarkus:quarkus-maven-plugin:{quarkus-version}:create \ -DprojectGroupId=org.acme \ diff --git a/docs/src/main/asciidoc/vault-auth.adoc b/docs/src/main/asciidoc/vault-auth.adoc index 5bb3c5ca12fa98..122b700b27d1bc 100644 --- a/docs/src/main/asciidoc/vault-auth.adoc +++ b/docs/src/main/asciidoc/vault-auth.adoc @@ -51,14 +51,14 @@ To complete this guide, you need: We assume there is a Vault container and a PostgreSQL container running from the {base-guide}, and the root token is known. First, create a new shell, `docker exec` into the container and set the root token: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- docker exec -it dev-vault sh / # export VAULT_TOKEN={root-token} ---- Create a token for the `vault-quickstart-policy` policy: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- / # vault token create -policy=vault-quickstart-policy Key Value @@ -79,14 +79,14 @@ quarkus.vault.authentication.client-token={client-token} ---- Compile and start the application: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- ./mvnw clean install java -jar target/vault-quickstart-1.0-SNAPSHOT-runner.jar ---- Finally test the application endpoint: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- curl http://localhost:8080/hello/private-key ---- @@ -111,7 +111,7 @@ If the _Wrapping Token_ gets stolen and unwrapped, we will notice immediately be will get an error saying that the token is invalid. With that in mind, let’s create a new token and wrap it inside a _Wrapping Token_ with a TTL of 1 minute: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- / # vault token create -wrap-ttl=60s -policy=vault-quickstart-policy Key Value @@ -133,7 +133,7 @@ quarkus.vault.authentication.client-token-wrapping-token={client-token-wrapping- Compile and run the application *without the tests*, you should be able now to curl the private key `{private-key}` as before. Stop the application, and execute tests with `./mvnw test`. They should fail with the following error: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- ERROR: Failed to start application io.quarkus.vault.VaultException: wrapping token is not valid or does not exist; this means that the token has already expired (if so you can increase the TTL on the wrapping token) or has been consumed by somebody else (potentially indicating that the wrapping token has been stolen) @@ -143,7 +143,7 @@ io.quarkus.vault.VaultException: wrapping token is not valid or does not exist; Normally the `userpass` auth method should already be enabled from the {base-guide}. If not, execute the following commands now: -[source, shell] +[source,bash] ---- vault auth enable userpass vault write auth/userpass/users/bob password=sinclair policies=vault-quickstart-policy @@ -157,7 +157,7 @@ quarkus.vault.authentication.userpass.password=sinclair ---- Test the application endpoint after compiling and starting the application again: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- curl http://localhost:8080/hello/private-key ---- @@ -180,7 +180,7 @@ _Approle_ is an authentication method suited for technical workflows. It relies To set up _Approle_ you need to enable the `approle` auth method, create an app role, and generate a role id and secret id: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- / # vault auth enable approle / # vault write auth/approle/role/myapprole policies=vault-quickstart-policy @@ -210,7 +210,7 @@ After compiling and running the application you should be able to curl it on the === Approle using Response Wrapping Similarly to direct client token authentication, it is possible to wrap the `secret-id`: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- / # vault write -wrap-ttl=60s -f auth/approle/role/myapprole/secret-id Key Value @@ -271,7 +271,7 @@ And apply it: `kubectl apply -f vault-auth-k8s.yml`. Once the objects are created, we need to capture the JWT token of this service account, and grab the public certificate of the cluster: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- secret_name=$(kubectl get sa vault-auth-sa -o json | jq -r '.secrets[0].name') token=$(kubectl get secret $secret_name -o json | jq -r '.data.token' | base64 --decode) @@ -283,7 +283,7 @@ kubectl get secret $secret_name -o json | jq -r '.data."ca.crt"' | base64 -D > / The next step requires to exec interactively with the root token into the Vault container to configure the Kubernetes auth method: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- docker exec -it dev-vault sh export VAULT_TOKEN={root-token} @@ -292,7 +292,7 @@ export VAULT_TOKEN={root-token} Once inside the pod, set the token variable to the value that was just printed in the console before, and recreate `ca.crt` with the same content as `/tmp/ca.crt` outside the container. Finally use `kubectl config view` to assess the url of your Kubernetes cluster: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- token=... => set the value printed in the console just before vi ca.crt => copy/paste /tmp/ca.crt from outside the container @@ -300,7 +300,7 @@ kubernetes_host => url from the kubectl config view (e.g. https://kubernetes.doc ---- Now we have all the information we need to configure Vault: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- vault auth enable kubernetes @@ -338,7 +338,7 @@ quarkus.log.category."io.quarkus.vault".level=DEBUG ---- Now build the application: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- ./mvnw package -DskipTests docker build -f src/main/docker/Dockerfile.jvm -t quarkus/vault-quickstart-jvm . @@ -400,7 +400,7 @@ And apply it: `kubectl apply -f vault-quickstart-k8s.yml`. This will deploy the application, and make it available on port `30400` of the Kubernetes host. You can check that the application has started from the logs: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- kubectl get pods pod=$(kubectl get pod -l app=vaultapp -o json | jq -r '.items[0].metadata.name') @@ -408,7 +408,7 @@ kubectl logs $pod ---- You should see: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- exec java -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/app.jar __ ____ __ _____ ___ __ ____ ______ @@ -428,13 +428,13 @@ __ ____ __ _____ ___ __ ____ ______ ---- Notice in particular the following log line: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- authenticate with jwt at: /var/run/secrets/kubernetes.io/serviceaccount/token => *** ---- Finally curl the `private-key` endpoint to make sure you can retrieve your secret: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- curl http://localhost:30400/hello/private-key ---- diff --git a/docs/src/main/asciidoc/vault-datasource.adoc b/docs/src/main/asciidoc/vault-datasource.adoc index bd7f5ef894d68f..af1ee4617c07b0 100644 --- a/docs/src/main/asciidoc/vault-datasource.adoc +++ b/docs/src/main/asciidoc/vault-datasource.adoc @@ -109,7 +109,7 @@ public int geGiftCount() { Start a PostgreSQL database: -[source, shell] +[source,bash] ---- docker run --ulimit memlock=-1:-1 -it --rm=true --memory-swappiness=0 --name postgres-quarkus-hibernate -e POSTGRES_USER=sarah -e POSTGRES_PASSWORD=connor -e POSTGRES_DB=mydatabase -p 5432:5432 postgres:10.5 ---- @@ -122,7 +122,7 @@ The simplest approach is to write the database password in the KV secret engine fetched from the Vault MicroProfile Config Source. Open a new shell, `docker exec` in the Vault container and set the root token: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- docker exec -it dev-vault sh export VAULT_TOKEN={root-token} @@ -130,7 +130,7 @@ export VAULT_TOKEN={root-token} Add a `dbpassword` property in the `config` path of the KV secret engine, beside the original `a-private-key` property: -[source, shell] +[source,bash] ---- vault kv put secret/myapps/vault-quickstart/config a-private-key=123456 dbpassword=connor ---- @@ -149,7 +149,7 @@ quarkus.hibernate-orm.database.generation=drop-and-create ---- Compile and start the application: -[source, shell] +[source,bash] ---- ./mvnw package java -jar target/vault-quickstart-1.0-SNAPSHOT-runner.jar @@ -157,14 +157,14 @@ java -jar target/vault-quickstart-1.0-SNAPSHOT-runner.jar Test it with the `gift-count` endpoint: -[source, shell] +[source,bash] ---- curl http://localhost:8080/hello/gift-count ---- You should see: -[source, shell] +[source,bash] ---- 0 ---- @@ -187,7 +187,7 @@ we make sure we have a fresh value every time. Create a new path (different than the `config` path) in Vault where the database password will be added: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- vault kv put secret/myapps/vault-quickstart/db password=connor ---- @@ -234,7 +234,7 @@ of databases are supported, such as https://www.vaultproject.io/docs/secrets/dat First we need to enable the `database` secret engine, configure the `postgresql-database-plugin` and create the database role `mydbrole` (replace `10.0.0.3` by the actual host that is running the PostgreSQL container; for simplicity we disabled _TLS_ between Vault and the PostgreSQL database): -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- vault secrets enable database @@ -266,7 +266,7 @@ to create users. ==== Then we need to give a read capability to the Quarkus application on path `database/creds/mydbrole`. -[source, shell] +[source,bash] ---- cat < vault:v1:fN4P7WNjIegpb3lD/pSuhXvyONhGrI21gcKNcedk+5jpjguOw6JkqXYXlkY= ---- And decrypt back this cipher text: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- curl -X POST --data 'vault:v1:fN4P7WNjIegpb3lD/pSuhXvyONhGrI21gcKNcedk+5jpjguOw6JkqXYXlkY=' --header "Content-Type: text/plain" http://localhost:8080/transit/decrypt # ==> some secret data @@ -238,14 +238,14 @@ public Response verify(VerifyRequest request) { ---- And start signing some data: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- curl -X POST --data 'some secret data' --header "Content-Type: text/plain" http://localhost:8080/transit/sign # ==> vault:v1:MEUCIQDl+nE4y4E878bkugGG6FG1/RsttaQnoWfZHppeuk4TnQIgTGWTtMhVPCzN8VH/EEr2qp5h34lI1bnEP6L1F+QQoPI= ---- And finally, let's make sure the signature is matching our input data: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- curl -v -X POST --data '{"input":"some secret data","signature":"vault:v1:MEUCIQDl+nE4y4E878bkugGG6FG1/RsttaQnoWfZHppeuk4TnQIgTGWTtMhVPCzN8VH/EEr2qp5h34lI1bnEP6L1F+QQoPI="}' --header "Content-Type: application/json" http://localhost:8080/transit/verify # ==> ... < HTTP/1.1 202 Accepted diff --git a/docs/src/main/asciidoc/vault.adoc b/docs/src/main/asciidoc/vault.adoc index ef2863bc1da077..d0bff7226f7309 100644 --- a/docs/src/main/asciidoc/vault.adoc +++ b/docs/src/main/asciidoc/vault.adoc @@ -47,20 +47,20 @@ To complete this guide, you need: Let's start Vault in development mode: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- docker run --rm --cap-add=IPC_LOCK -e VAULT_ADDR=http://localhost:8200 -p 8200:8200 -d --name=dev-vault vault:{vault-version} ---- You can check that vault is running with: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- docker logs dev-vault ---- You should see: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- ==> Vault server configuration: @@ -115,21 +115,21 @@ to access a secret stored in the _kv secret engine_. First open a shell inside the vault container: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- docker exec -it dev-vault sh ---- Set the `VAULT_TOKEN` with the value that was printed in the logs: -[source, shell, subs=attributes+] +[source,bash, subs=attributes+] ---- export VAULT_TOKEN={root-token} ---- You can check Vault's status using the CLI command `vault status`: -[source, shell] +[source,bash] ---- Key Value --- ----- @@ -146,7 +146,7 @@ HA Enabled false Now let's add a secret configuration for our application: -[source, shell] +[source,bash] ---- vault kv put secret/myapps/vault-quickstart/config a-private-key=123456 ---- @@ -155,7 +155,7 @@ We have defined a path `secret/myapps/vault-quickstart` in Vault that we need to Create a policy that gives read access to `secret/myapps/vault-quickstart` and subpaths: -[source, shell] +[source,bash] ---- cat <--initialize-at-run-time=com.example.SomeClass\,org.acme.SomeOtherClass ----