add detection for duplicate ids in standards

This commit is contained in:
Robert Kaussow 2019-04-12 13:45:35 +02:00
parent 10aaa8e7e3
commit a3b6ef54a3

View File

@ -6,6 +6,7 @@ import sys
from distutils.version import LooseVersion from distutils.version import LooseVersion
import ansible import ansible
import toolz
from ansiblelater import settings from ansiblelater import settings
from ansiblelater import utils from ansiblelater import utils
@ -48,4 +49,11 @@ def get_standards(filepath):
"Please upgrade ansible-later." % "Please upgrade ansible-later." %
(standards.ansible_review_min_version, utils.get_property("__version__"))) (standards.ansible_review_min_version, utils.get_property("__version__")))
normalized_std = (list(toolz.remove(lambda x: x.id == "", standards.standards)))
unique_std = len(list(toolz.unique(normalized_std, key=lambda x: x.id)))
all_std = len(normalized_std)
if not all_std == unique_std:
utils.sysexit_with_message(
"Detect duplicate ID's in standards definition. Please use unique ID's only.")
return standards.standards return standards.standards