vmware-archive / repository-editor-for-tuf

Command line tool for editing and maintaining a TUF repository
Apache License 2.0
5 stars 3 forks source link

Edit refactor #52

Closed jku closed 2 years ago

jku commented 2 years ago

Refactor Repository.edit()

Hide the contextmanager complexity from the concrete Repository implementation. Do this by introducing a new class MetadataDescriptor.

Implementations now only need to implement:

This change does not affect the users of Repository.edit(): it functions just like before.

Majority of the code changes are moving methods from GitRepository to GitMetadata.

jku commented 2 years ago

@lukpueh I think this might be a version that we could start looking at as a potential python-tuf repository library starting point. See tufrepo/librepo/repo.py (and then tufrepo/gitrepo.py and tufrepo/cli.py for the CLI-based-on-git-storage application code which I'm not suggesting to add to python-tuf)

I think it makes a decent compromise

jku commented 2 years ago

force pushed: only change is adding a suggested raise NotImplementedError

jku commented 2 years ago

Class and method naming is definitely not very polished... but this is not any kind of public API yet so I'm fine with it: let's re-evaluate once we try to get things into python-tuf.

using MetadataDescriptor.edit() for initialization seems logical as when initializing you are actually editing a role and this saves you some repeating lines, so cool.

It's still Repository.edit() but yes I agree. I originally avoided arguments like init but it turns out adding it actually makes the code simpler in multiple levels.

Merging now to allow new PRs to be made without blocking on this: further comments are welcome but in new issues please.