Ensure we're using proper types for validation_name and _id
In some case we might get string instead of list - instead of failing, just do a simple convertion and go on. We also support both notation, either playbook name (foo.yaml) and validation name (foo) in the search of valid content. Co-Authored-By: Gael Chamoulaud (Strider) <gchamoul@redhat.com> Change-Id: I8d0288dae3cab131a8bc65e3d0b986dc6b9aec67 Closes-Bug: #1901676
This commit is contained in:
parent
0c7eda82d3
commit
6d0d1ce06d
|
@ -91,12 +91,15 @@ def get_validations_playbook(path, validation_id=None, groups=None):
|
|||
"""
|
||||
if isinstance(groups, six.string_types):
|
||||
groups = [groups]
|
||||
if isinstance(validation_id, six.string_types):
|
||||
validation_id = [validation_id]
|
||||
pl = []
|
||||
for f in os.listdir(path):
|
||||
pl_path = join(path, f)
|
||||
if os.path.isfile(pl_path):
|
||||
if validation_id:
|
||||
if os.path.splitext(f)[0] in validation_id:
|
||||
if os.path.splitext(f)[0] in validation_id or \
|
||||
os.path.basename(f) in validation_id:
|
||||
pl.append(pl_path)
|
||||
if groups:
|
||||
val = Validation(pl_path)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import logging
|
||||
import os
|
||||
import json
|
||||
import six
|
||||
import yaml
|
||||
|
||||
from validations_libs.ansible import Ansible as v_ansible
|
||||
|
@ -85,6 +86,9 @@ class ValidationActions(object):
|
|||
except Exception as e:
|
||||
raise(e)
|
||||
elif validation_name:
|
||||
if isinstance(validation_name, six.string_types):
|
||||
validation_name = [validation_name]
|
||||
|
||||
playbooks = v_utils.get_validations_playbook(validations_dir,
|
||||
validation_name,
|
||||
group)
|
||||
|
|
Loading…
Reference in New Issue