quarkiverse / quarkus-embedded-postgresql

Allowing you to unit test with a PostgreSQL DB without requiring end users to install and set up a database cluster
https://github.com/zonkyio/embedded-postgres
Apache License 2.0
9 stars 13 forks source link

DevUI: Add Card #71

Closed melloware closed 8 months ago

melloware commented 10 months ago

You can assign this to me.

image

melloware commented 10 months ago

@phillip-kruger I am working on this and I want to put the values of this Embedded Postres in the DevServices panel.

I have this code.

    @BuildStep
    void registerDevServices(BuildProducer<DevServicesResultBuildItem> devServices) {
        Map<String, String> devServerConfigMap = new LinkedHashMap<>();
        Config config = ConfigProviderResolver.instance().getConfig();
        for (String propertyName : config.getPropertyNames()) {
            if (propertyName.startsWith("quarkus.datasource.")) {
                devServerConfigMap.put(propertyName, config.getConfigValue(propertyName).getValue());
            }
        }

        DevServicesResultBuildItem.RunningDevService devService = new DevServicesResultBuildItem.RunningDevService(
                FEATURE, null, null, devServerConfigMap);
        devServices.produce(devService.toBuildItem());
    }

But its only producing BuildTime values not the run time values on the ConfigProvider?

image

How can I get the DevServices to show the Run Time configured Datasource values?

phillip-kruger commented 10 months ago

Hi! I am not sure I am following? The properties you see in the dev service screen are the "magic" ones. I.e. the properties set by dev service automatically so that the service run. This is so that the user know what they need to set themself in a prod environment where there is no dev service and they need to provide the service themselves

phillip-kruger commented 10 months ago

Normal config related to an extension can be seen in the config screen when navigation there from the extension card. It will use the filter value in the extension yaml and filter the navigation screen accordingly

melloware commented 10 months ago

Oh I forgot to mention this is an embedded service so its not a REAL Container Dev Service is running embedded DB. So like in Quinoa we do this to put the "fake" DevService in the list for Node.js. I was hoping to do something similar here.

 @BuildStep
    void registerDevServices(BuildProducer<DevServicesResultBuildItem> devServices) {
        Map<String, String> devServerConfigMap = new LinkedHashMap<>();
        Config config = ConfigProviderResolver.instance().getConfig();
        for (String propertyName : config.getPropertyNames()) {
            if (propertyName.startsWith("quarkus.datasource.")) {
                devServerConfigMap.put(propertyName, config.getConfigValue(propertyName).getValue());
            }
        }

        DevServicesResultBuildItem.RunningDevService devService = new DevServicesResultBuildItem.RunningDevService(
                FEATURE, null, null, devServerConfigMap);
        devServices.produce(devService.toBuildItem());
    }
phillip-kruger commented 10 months ago

But are you not just after the filtered configuration feature that already exists?

melloware commented 10 months ago

No at runtime it dynamically assigns to quarkus.datasource.jdbc.url to jdbc:postgresql://localhost:60290/postgres

phillip-kruger commented 10 months ago

But that should show up in the config screen?

melloware commented 10 months ago

It looks like its only has build time properties that are in the application.properties when I ask ConfigProvider.

Sorry yes its on the Config screen because it looks like you using a JsonRpcProvider that has access to runtime values?

melloware commented 10 months ago

I guess the question is how is it possible to have the DevServices info use Runtime values?

phillip-kruger commented 10 months ago

Ok, so let a dev ui question and more a dev service question? I think so, but let me see if I can find an example. Give me a few hours, doing morning school runs etc at the moment

melloware commented 10 months ago

No problem! Yeah I got the DevUI card using a JsonRpcService to get the port and running URL but was wondering how to jam it on DevServices too.

phillip-kruger commented 10 months ago

I don't think this is possible at the moment. The dev services is built time data. We would need to change that to jsonrpc to get run time data. Or maybe a mix / config that allows this.

melloware commented 10 months ago

No worries I think based on the other ticket I am going to end up making this a build time config anyway to refactor for the 3.6.0 issues