From ef5e9364bbe2f1dcfa49fe84006e1ebfbb464efe Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 1 Jun 2021 11:35:43 +0200 Subject: [PATCH] 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. --- osbuild/inputs.py | 8 +++++++- osbuild/pipeline.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/osbuild/inputs.py b/osbuild/inputs.py index 6dfaec97..f58d6290 100644 --- a/osbuild/inputs.py +++ b/osbuild/inputs.py @@ -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()) diff --git a/osbuild/pipeline.py b/osbuild/pipeline.py index 9fb19bc5..9174a574 100644 --- a/osbuild/pipeline.py +++ b/osbuild/pipeline.py @@ -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