Giter Site home page Giter Site logo

quarkus-vault-rest-client's Introduction

Reproducer for missing config when using Hashicorp Vault

When using the extension some config keys needs to be present in application.properties in order for the config to be visible when running the application.

For instance with the following in application.properties:

%dev.quarkus.smallrye-graphql-client.star-wars-typesafe.url=https://development.star.wars

The application will crash on startup when deployed with a Vault with

quarkus.smallrye-graphql-client.star-wars-typesafe.url=https://production.star.wars

These problems is leftovers not fixed in quarkusio/quarkus#21336.

Follow the steps for initializing the local Vault container.

docker run --rm --cap-add=IPC_LOCK -e VAULT_ADDR=http://localhost:8200 -p 8200:8200 --name=dev-vault vault:1.6.0 (Terminal A)
docker exec -it dev-vault sh (in new terminal B)
export VAULT_ADDR='http://0.0.0.0:8200'
export VAULT_TOKEN=$Root Token FROM terminal A (in terminal B)

vault kv put secret/myapps/vault-quickstart/config a-private-key=123456 (in terminal B)
cat <<EOF | vault policy write vault-quickstart-policy -
 path "secret/data/myapps/vault-quickstart/*" {
    capabilities = ["read"]
}
EOF

vault auth enable userpass
vault write auth/userpass/users/bob password=sinclair policies=vault-quickstart-policy

Login to http://localhost:8200 with $Root Token FROM terminal A and add secrets in myapps/vault-quickstart/

{
  "a-private-key": "123456",
  "newconfig": "newconfig",
  "quarkus.micrometer.export.influx.api-version": "V2",
  "quarkus.micrometer.export.influx.org": "org",
  "quarkus.micrometer.export.influx.token": "atoken",
  "quarkus.micrometer.export.influx.bucket": "abucket",
  "quarkus.micrometer.export.influx.uri": "https://localhost/metrics",
  "quarkus.rest-client.country-api.url": "https://restcountries.com/",
  "quarkus.smallrye-graphql-client.star-wars-typesafe.url": "https://swapi-graphql.netlify.app/.netlify/functions/index",
  "quarkus.log.category.\"org.acme.rest.client.CountriesResource\".level": "DEBUG",
  "eventing.config": "the config"
}

Start the app with mvn quarkus:dev.

Tests and expectations

On startup the following should be printed. (And print errors)

Using InfluxDB API version V2 to write metrics
curl http://localhost:8080/country/name/norway

should print json.

curl http://localhost:8080/starward

should print json, not fail with

2022-08-18 10:53:18,778 ERROR [org.jbo.res.rea.com.cor.AbstractResteasyReactiveContext] (executor-thread-0) Request failed: java.lang.RuntimeException: URL not configured for client. Please define the property quarkus.smallrye-graphql-client.star-wars-typesafe.url or pass it to your client builder dynamically
        at io.quarkus.smallrye.graphql.client.runtime.QuarkifiedErrorMessageProvider.urlMissingErrorForNamedClient(QuarkifiedErrorMessageProvider.java:14)
        at io.smallrye.graphql.client.vertx.typesafe.VertxTypesafeGraphQLClientBuilder.build(VertxTypesafeGraphQLClientBuilder.java:124)
        at io.quarkus.smallrye.graphql.client.runtime.SmallRyeGraphQLClientRecorder.lambda$typesafeClientSupplier$0(SmallRyeGraphQLClientRecorder.java:20)
        at org.acme.graphql.client.StarWarsClientApi_eafe9a3b2d3e2a2588a03c49fa86dfd0a5185761_Synthetic_Bean.create(Unknown Source)
curl 'http://localhost:8080/graphql' \
  -H 'Accept: application/json' \
  --data-raw '{"query":"query {\n  something {\n    value\n  }\n}","variables":null}'

should print json and print in console

2022-08-18 12:44:01,405 INFO  [org.acm.gra.Service] (vert.x-eventloop-thread-0) value the config

Workaround

Adding the following dummy config to application.properties

quarkus.micrometer.export.influx.api-version=
quarkus.micrometer.export.influx.org=
quarkus.micrometer.export.influx.bucket=
quarkus.micrometer.export.influx.uri=
quarkus.smallrye-graphql-client.star-wars-typesafe.url=
quarkus.log.category."org.acme.rest.client.CountriesResource".level=INFO

quarkus-vault-rest-client's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.