Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
luismedel committed Dec 13, 2024
1 parent 7ae3375 commit 27fe90b
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/bluish/nodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,6 @@ class VariableExpandError(Exception):
ValueResult = namedtuple("ValueResult", ["value", "contains_secrets"])


def _step_or_job(ctx: Node) -> Node:
if ctx.NODE_TYPE == "step" or ctx.NODE_TYPE == "job":
return ctx
raise ValueError(f"Can't find step or job in context of type: {ctx.NODE_TYPE}")


def _step(ctx: Node) -> Node:
if ctx.NODE_TYPE == "step":
return ctx
Expand Down Expand Up @@ -366,16 +360,14 @@ def prepare_value(value: Any) -> Any:
elif root == "step":
return _try_get_value(_step(ctx), varname, raw)
elif root == "inputs":
node = ctx
if varname in node.inputs:
if varname in node.sensitive_inputs:
return prepare_value(SafeString(node.inputs[varname], "********"))
else:
return prepare_value(node.inputs[varname])
if varname in ctx.inputs:
value = ctx.inputs[varname]
if varname in ctx.sensitive_inputs:
value = prepare_value(SafeString(value, "********"))
return prepare_value(value)
elif root == "outputs":
node = _step_or_job(ctx)
if varname in node.outputs:
return prepare_value(node.outputs[varname])
if varname in ctx.outputs:
return prepare_value(ctx.outputs[varname])

return None

Expand Down Expand Up @@ -424,8 +416,7 @@ def _try_set_value(ctx: "Node", name: str, value: str) -> bool:
step.inputs[varname] = value
return True
elif root == "outputs":
node = _step_or_job(ctx)
node.outputs[varname] = value
ctx.outputs[varname] = value
return True

return False
Expand Down

0 comments on commit 27fe90b

Please sign in to comment.