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

Set tokens as json strings in io_config.yaml #5061

Open
g-gilchrist opened this issue May 11, 2024 · 2 comments
Open

Set tokens as json strings in io_config.yaml #5061

g-gilchrist opened this issue May 11, 2024 · 2 comments

Comments

@g-gilchrist
Copy link

g-gilchrist commented May 11, 2024

Is your feature request related to a problem? Please describe.
Currently to pass a token that is not a file into io_config, for instance GOOGLE_SERVICE_ACC_KEY,
you must create all the keys value pairs under GOOGLE_SERVICE_ACC_KEY from inside the token.
Due to the current logic the key must be manipulated externally, it would be more beneficial for
automated key rotation, to pass in the key as a JSON string and have the backend convert the
JSON to a dictionary. This would couple well with AWS Secrets Manager's functionality for
automated key rotation which you already have functionality for.

Describe the solution you'd like
I think for someone who knows the code base it would be a relatively simple modification or addition
to take the JSON string and convert it into a dictionary for connecting to GCP for Buckets or BigQuery.

Describe alternatives you've considered
you could try json.loads on the JSON string to convert to a dictionary, or parse it.

@g-gilchrist
Copy link
Author

I'm not super familiar with this codebase, but I believe if you look in config.py you can modify the last function to read:

    def __traverse_verbose_config(self, key: Union[ConfigKey, str]) -> Any:
        """
        Traverses a configuration file in verbose format to fetch the
        value if exists; else returns None.
        """
        keys = self.KEY_MAP.get(key)
        if keys is None:
            return None
            
        # this adds the additional functionality
        if isinstance(keys,str):
            keys = json.loads(keys)
            
        branch = self.config
        for key in keys:
            if branch is None:
                return None
            branch = branch.get(key)
        return branch

@g-gilchrist
Copy link
Author

I have not tested the code above and could certainly be wrong

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

No branches or pull requests

1 participant