0

Anyone knows how to replace the character "/" in application.yaml in Quarkus

# REST Client configuration property
org:
  acme:
    restclient:
      CountriesService/mp-rest/url: https://restcountries.eu/rest

When I deploy, this error seems to appear

Error: release insurance-svc failed, and has been uninstalled due to atomic being set: ConfigMap "insurance-svc-dev-config" is invalid: [data[coreClient/mp-rest/url]: Invalid value: "coreClient/mp-rest/url": a valid config key must consist of alphanumeric characters, '-', '_' or '.' (e.g. 'key.name', or 'KEY_NAME', or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+'), data[identityClient/mp-rest/scope]: Invalid value: "identityClient/mp-rest/scope": a valid config key must consist of alphanumeric characters, '-', '_' or '.' (e.g. 'key.name', or 'KEY_NAME', or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+'), data[coreClient/mp-rest/scope]: Invalid value: "coreClient/mp-rest/scope": a valid config key must consist of alphanumeric characters, '-', '_' or '.' (e.g. 'key.name', or 'KEY_NAME', or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+'), data[identityClient/mp-rest/url]: Invalid value: "identityClient/mp-rest/url": a valid config key must consist of alphanumeric characters, '-', '_' or '.' (e.g. 'key.name', or 'KEY_NAME', or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+')

Is there any way to change the way it configs without adding whole baseUri into annotation @RegisterRestClient()?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
hoangkm
  • 11
  • 4
  • Does this answer your question? [YAML: Do I need quotes for strings in YAML?](https://stackoverflow.com/questions/19109912/yaml-do-i-need-quotes-for-strings-in-yaml) – aksappy Sep 01 '21 at 14:51
  • @aksappy it seems the character problem belongs to MP Config in RestClient, still dont know the solution – hoangkm Sep 01 '21 at 15:11

2 Answers2

0

You can use different approach, you can create a custom configuration property to hold the URI. Then create a Factory that reads or has injected this configuration property and is used to instantiate your rest client.

URL apiUrl = new URL("http://localhost:9080/onlineMusicService");
MusicPlaylistService playlistSvc =
    RestClientBuilder.newBuilder()
                     .baseUrl(apiUrl)
                     .register(PlaylistResponseExceptionMapper.class)
                     .build(MusicPlaylistService.class);

List<String> playlistNames = playlistSvc.getPlaylistNames();
for (String name : playlistNames) {
    List<Song> songs = playlistSvc.getPlaylist(name);
    if (hasSongBy(songs, "band name")) {
        coolPlaylists.add(name);
    }
}

You can read that url from the custom configuration property with the name you want.

Javier Toja
  • 1,630
  • 1
  • 14
  • 31
0

I'd recommend watching this pull request: https://github.com/quarkusio/quarkus/pull/17220 Once it is merged and a Quarkus version with it released, you'll be able to use quarkus.rest-client."org.acme.restclient.CountriesService".url=https://restcountries.eu/rest instead - the key does not contain a slash, so it's compatible with Kubernetes

Jan Martiška
  • 1,151
  • 5
  • 7