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

vdk-core: parse vdk subsections in config.ini #3305

Open
DeltaMichael opened this issue Apr 15, 2024 · 0 comments
Open

vdk-core: parse vdk subsections in config.ini #3305

DeltaMichael opened this issue Apr 15, 2024 · 0 comments
Assignees
Labels

Comments

@DeltaMichael
Copy link
Contributor

DeltaMichael commented Apr 15, 2024

Overview

To support multiple databases of the same type, we should support subsections in the vdk configuration. The following config should be valid. VDK should parse three separate configs and name them using the subsection names.

[vdk]
oracle_connection_string = localhost:1521/FREE

[vdk.my_oracle]
oracle_connection_string = localhost:1521/FREE

[vdk.another_oracle]
oracle_connection_string = another.oracle.bg:1522/NOP

Suggested Implementation

job_config.py

    def get_vdk_options(self) -> Dict[Dict[str, str]]:
        sections = self._config_ini.sections()
        out = {}
        for section in sections:
            if "vdk" in section:
                out[section] = dict(self._config_ini[section])
         return out

    def get_vdk_options_for_section(self, section: str = None) -> Dict[str, str]:
        sections = self._config_ini.sections()
        if section and self._config_ini.has_section(section):
            return dict(self._config_ini[section])
        elif self._config_ini.has_section("vdk"):
            return dict(self._config_ini["vdk"])
        else:
            return {}

And then in the JobConfigIniPlugin class

    @hookimpl(tryfirst=True)
    def vdk_configure(self, config_builder: ConfigurationBuilder) -> None:
            
            for key, value in job_config.get_vdk_options_for_section("vdk").items():
                config_builder.set_value(key, value)

This should work for the current state of config files without any problem and support sections like vdk.something

Acceptance criteria

  1. Do the above implementation or a better alternative
  2. Add tests
@DeltaMichael DeltaMichael added the enhancement New feature or request label Apr 15, 2024
@duyguHsnHsn duyguHsnHsn self-assigned this Apr 17, 2024
duyguHsnHsn added a commit that referenced this issue Apr 17, 2024
Solving: #3305

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
duyguHsnHsn added a commit that referenced this issue Apr 23, 2024
Solving: #3305

The main change is that now we have sections list in Configuration and
ConfigurationBuilder instead of having only key-value lists

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dilyan Marinov <mdilyan@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants