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

Refactoring: interfaces, refresh_settings and services #290

Open
kairoaraujo opened this issue May 11, 2023 · 1 comment
Open

Refactoring: interfaces, refresh_settings and services #290

kairoaraujo opened this issue May 11, 2023 · 1 comment

Comments

@kairoaraujo
Copy link
Member

kairoaraujo commented May 11, 2023

While implementing changes on LocalKeyVault, @MVrachev raised an interesting comment that it greatly improved how our backend services use the configurations.

The first change required is to change ÌKeyVaultandIStorageinrepository_services_tuf_worker.interfaces.py`

IKeyVault should return List["IKeyVault"] what will be List[{NAME}KeyVault] i.e. List[LocalKeyVault]
IStorage should return IStorage what will be in the services '{NAME}Storage i.e. LocalStorage

Where {NAME} will be the defined name for the storage.

On the implementation of the services, we use the class method configure to return our object with all checks and settings done.
In that way, the services I{Service}.__init__() will store the required fields validated and configured.

In the repository_services_tuf_worker.repository.MetadataRepository, we change the refresh_settings to instantiate the objects using the class method configure instead of the class itself

Example:

settings.KEYVAULT = settings.KEYVAULT_BACKEND.configure(settings)

instead

settings.KEYVAULT_BACKEND.configure(settings)
settings.KEYVAULT = settings.KEYVAULT_BACKEND(**keyvault_kwargs)

Original comment:
I think it would be useful to have a similar function as from_dict for the Signed classes in TUF: https://github.com/theupdateframework/python-tuf/blob/eff842201e7bbb3817958dc242f21031766ab2b9/tuf/api/metadata.py#L737
There I imagine you will set up the path by calling _base_64_key, then also we can call _raw_key_parser to parse the key and we can have an init where it will accept a list of LocalKey objects.

This way we would access the online key as many times as we would without doing the parsing again and again in LocalKeyVault.get().

Originally posted by @MVrachev in #283 (comment)

@kairoaraujo kairoaraujo changed the title Refactoring: interfaces, refresh_settings` and services Refactoring: interfaces, refresh_settings and services May 11, 2023
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

2 participants