This way, for downgrades to whatever versions
this lands in onward, having added new parameters to
UpgradeState shouldn't break anything. Can't do much
about downgrades to older versions from this one
but this should help in the future.
Signed-off-by: Adam King <adking@redhat.com>
@classmethod
def from_json(cls, data: dict) -> Optional['UpgradeState']:
+ valid_params = UpgradeState.__init__.__code__.co_varnames
if data:
- c = {k: v for k, v in data.items()}
+ c = {k: v for k, v in data.items() if k in valid_params}
if 'repo_digest' in c:
c['target_digests'] = [c.pop('repo_digest')]
return cls(**c)