inputs: add an id property
Add an `id` property that, like `Stage.id`, can be used to uniquely identify an input based on its name and options. Two stages with the same name and options will have the same `id`.
This commit is contained in:
parent
9f4861e58f
commit
684c408914
1 changed files with 8 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ osbuild is the path. The input options are just passed to the
|
|||
"""
|
||||
|
||||
|
||||
import hashlib
|
||||
import importlib
|
||||
import json
|
||||
import os
|
||||
|
|
@ -36,6 +37,13 @@ class Input:
|
|||
def __init__(self, info: ModuleInfo, options: Dict):
|
||||
self.info = info
|
||||
self.options = options or {}
|
||||
self.id = self.calc_id()
|
||||
|
||||
def calc_id(self):
|
||||
m = hashlib.sha256()
|
||||
m.update(json.dumps(self.name, sort_keys=True).encode())
|
||||
m.update(json.dumps(self.options, sort_keys=True).encode())
|
||||
return m.hexdigest()
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue