Browse Source

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
changes/66/759866/5
Cédric Jeanneret 3 months ago
parent
commit
6d0d1ce06d
2 changed files with 8 additions and 1 deletions
  1. +4
    -1
      validations_libs/utils.py
  2. +4
    -0
      validations_libs/validation_actions.py

+ 4
- 1
validations_libs/utils.py View File

@ -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)


+ 4
- 0
validations_libs/validation_actions.py View File

@ -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…
Cancel
Save