mirror of
https://github.com/famedly/ansible-collection-matrix
synced 2024-12-13 12:42:29 +00:00
fix(matrix-uia-login): pick correct stage when multiple stages are available.
ref: https://gitlab.com/famedly/company/devops/collections/matrix/-/issues/18
This commit is contained in:
parent
4c15534323
commit
14752e23c7
1 changed files with 2 additions and 9 deletions
|
@ -111,15 +111,7 @@ uia_stages = {
|
|||
def pick_flow(flows):
|
||||
supported_stages = uia_stages.keys()
|
||||
# reduces each flow to a boolean telling filter if the flow consists only out of compatible stages
|
||||
compatible_flows = list(
|
||||
filter(
|
||||
lambda flow: reduce(
|
||||
(lambda compatible, stage: compatible and (stage in supported_stages)),
|
||||
flow['stages']
|
||||
),
|
||||
flows
|
||||
)
|
||||
)
|
||||
compatible_flows = [flow for flow in flows if all([stage in supported_stages for stage in flow['stages']])]
|
||||
# the best flow is the one with the fewest stages, key= takes a function telling min() the weight of an entry
|
||||
best = min(compatible_flows, key=(lambda flow: len(flow['stages'])))
|
||||
return best
|
||||
|
@ -160,6 +152,7 @@ async def run_module():
|
|||
log.append("DEBUG: begin UIA for session=" + uia_session)
|
||||
|
||||
# Figure out best compatible UIA login flow
|
||||
log.append("INFO: available flows: " + str(res['flows']))
|
||||
flow_to_attempt = pick_flow(res['flows'])
|
||||
log.append("INFO: picking flow: " + (" -> ".join(flow_to_attempt['stages'])))
|
||||
|
||||
|
|
Loading…
Reference in a new issue