mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 22:51:23 -07:00
Use itertools instead of set for tags, as the data may not hash well
The tags field may contain bad data before it is post_validated, however some methods assumed it would be a simple list or string. Using itertools gets us around the problem of the data potentially not being hashable Fixes #9380
This commit is contained in:
parent
af49944ab2
commit
0eb1c880dd
2 changed files with 9 additions and 2 deletions
|
@ -19,6 +19,7 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import itertools
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
@ -232,6 +233,10 @@ class Base:
|
||||||
new_me._loader = self._loader
|
new_me._loader = self._loader
|
||||||
new_me._variable_manager = self._variable_manager
|
new_me._variable_manager = self._variable_manager
|
||||||
|
|
||||||
|
# if the ds value was set on the object, copy it to the new copy too
|
||||||
|
if hasattr(self, '_ds'):
|
||||||
|
new_me._ds = self._ds
|
||||||
|
|
||||||
return new_me
|
return new_me
|
||||||
|
|
||||||
def post_validate(self, templar):
|
def post_validate(self, templar):
|
||||||
|
@ -340,7 +345,8 @@ class Base:
|
||||||
if not isinstance(new_value, list):
|
if not isinstance(new_value, list):
|
||||||
new_value = [ new_value ]
|
new_value = [ new_value ]
|
||||||
|
|
||||||
return list(set(value + new_value))
|
#return list(set(value + new_value))
|
||||||
|
return [i for i,_ in itertools.groupby(value + new_value)]
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return self.serialize()
|
return self.serialize()
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import itertools
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
|
@ -67,7 +68,7 @@ class Taggable:
|
||||||
else:
|
else:
|
||||||
tags = set([tags])
|
tags = set([tags])
|
||||||
else:
|
else:
|
||||||
tags = set(tags)
|
tags = [i for i,_ in itertools.groupby(tags)]
|
||||||
else:
|
else:
|
||||||
# this makes intersection work for untagged
|
# this makes intersection work for untagged
|
||||||
tags = self.__class__.untagged
|
tags = self.__class__.untagged
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue