Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide PostgreSQL/Keycloak mapped port information. #1941

Conversation

whitingjr
Copy link
Collaborator

For subsequent container configuration.

Fixes Issue

fixes #1940

Changes proposed

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@johnaohara
Copy link
Member

What is the need to push all the configuration properties into system properties?

it is possible to obtain a programmatic reference to the infra container properties with something like;

import io.hyperfoil.tools.horreum.infra.common.Const;
import io.hyperfoil.tools.horreum.infra.common.HorreumResources;
import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class TestInfraStart {

    @Test
    public void test_start_infra() {

        final Map<String, String> containerArgs = new HashMap<>();
        containerArgs.put(Const.HORREUM_DEV_KEYCLOAK_ENABLED, Boolean.toString(true));
        containerArgs.put(Const.HORREUM_DEV_KEYCLOAK_IMAGE, "quay.io/keycloak/keycloak:23.0.3");
        containerArgs.put(Const.HORREUM_DEV_KEYCLOAK_NETWORK_ALIAS, Const.DEFAULT_KEYCLOAK_NETWORK_ALIAS);
        containerArgs.put(Const.HORREUM_DEV_POSTGRES_ENABLED, Boolean.toString(true));
        containerArgs.put(Const.HORREUM_DEV_POSTGRES_IMAGE, "postgres:16");
        containerArgs.put(Const.HORREUM_DEV_POSTGRES_NETWORK_ALIAS, Const.DEFAULT_POSTGRES_NETWORK_ALIAS);
        containerArgs.put(Const.HORREUM_DEV_KEYCLOAK_DB_USERNAME, Const.DEFAULT_KC_DB_USERNAME);
        containerArgs.put(Const.HORREUM_DEV_KEYCLOAK_DB_PASSWORD, Const.DEFAULT_KC_DB_PASSWORD);
        containerArgs.put(Const.HORREUM_DEV_KEYCLOAK_ADMIN_USERNAME, Const.DEFAULT_KC_ADMIN_USERNAME);
        containerArgs.put(Const.HORREUM_DEV_KEYCLOAK_ADMIN_PASSWORD, Const.DEFAULT_KC_ADMIN_PASSWORD);

        Map<String, String> container_props = HorreumResources.startContainers(Collections.unmodifiableMap(containerArgs));

        System.out.println(Arrays.toString(container_props.entrySet().toArray()) );

        HorreumResources.stopContainers();

    }
}

You can query container_props to get any necessary ephemeral container properties to bootstrap Horreum

@whitingjr whitingjr force-pushed the horreum-add-properties-started-container-info branch from b767a79 to 9c9e238 Compare August 20, 2024 12:31
@whitingjr
Copy link
Collaborator Author

I'll redo this using the map of properties.

@whitingjr
Copy link
Collaborator Author

Actually this information is already contained in keycloak.host and quarkus.datasource.jdbc.url so this pr can be scrapped.

@whitingjr whitingjr closed this Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing mapped port information.
2 participants