inputs: make inputs aware of their names

The name of the input here refers to its id within the manifest. This
is unique per stage and thus identifies a input for a given stage.
This commit is contained in:
Christian Kellner 2021-06-01 11:35:43 +02:00 committed by Tom Gundersen
parent 8c1a0a2eeb
commit ef5e9364bb
2 changed files with 8 additions and 2 deletions

View file

@ -33,7 +33,8 @@ class Input:
A single input with its corresponding options.
"""
def __init__(self, info, origin: str, options: Dict):
def __init__(self, name, info, origin: str, options: Dict):
self.name = name
self.info = info
self.origin = origin
self.refs = {}
@ -45,6 +46,11 @@ class Input:
self.id = self.calc_id()
def calc_id(self):
# NB: The input `name` is not included here on purpose since it
# is either prescribed by the stage itself and thus not actual
# parameter or arbitrary and chosen by the manifest generator
# and thus can be changed without affecting the contents
m = hashlib.sha256()
m.update(json.dumps(self.info.name, sort_keys=True).encode())
m.update(json.dumps(self.origin, sort_keys=True).encode())

View file

@ -60,7 +60,7 @@ class Stage:
return m.hexdigest()
def add_input(self, name, info, origin, options=None):
ip = Input(info, origin, options or {})
ip = Input(name, info, origin, options or {})
self.inputs[name] = ip
return ip