Removing unused filters from osa plugins
pip_constraint_update, filtered_list, git_link_parse, git_link_parse_name filters have no reference inside OSA hence removing these filters. Change-Id: Id4bc4ab87ac4b60121290ad6cbbd143962357d39 Closes-Bug: #1826245
This commit is contained in:
parent
ded5a2da89
commit
24fe4789c8
|
@ -32,62 +32,6 @@ will raise an exception if the old variable is used.
|
|||
# "new_var"
|
||||
# => "old value"
|
||||
|
||||
git_link_parse
|
||||
~~~~~~~~~~~~~~
|
||||
This filter will return a dict containing the parts of a given git repo URL.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
{{ 'https://git.openstack.org/openstack/openstack-ansible@master' |
|
||||
git_link_parse }}
|
||||
# =>
|
||||
# {
|
||||
# "url": "https://git.openstack.org/openstack/openstack-ansible",
|
||||
# "plugin_path": null,
|
||||
# "version": "master",
|
||||
# "name": "openstack-ansible",
|
||||
# "original":
|
||||
# "https://git.openstack.org/openstack/openstack-ansible@master"
|
||||
# }
|
||||
|
||||
git_link_parse_name
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
This filter will return the name of a given git repo URL.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
{{ 'https://git.openstack.org/openstack/openstack-ansible@master' |
|
||||
git_link_parse_name }}
|
||||
# => "openstack-ansible"
|
||||
|
||||
filtered_list
|
||||
~~~~~~~~~~~~~
|
||||
This filter takes two lists as inputs. The first list will be returned to the
|
||||
user after removing any duplicates found within the second list.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
{{ ['a', 'b'] | filtered_list(['b', 'c']) }}
|
||||
# => [ "a" ]
|
||||
|
||||
pip_constraint_update
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
This filter will return a merged list from a given list of pip packages and a
|
||||
list of pip package constraints to a apply to that list.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
pip_package_list:
|
||||
- pip==8.1.2
|
||||
- setuptools==25.1.0
|
||||
- wheel==0.29.0
|
||||
pip_package_constraint_list:
|
||||
- babel==2.3.4
|
||||
- pip==8.1.0
|
||||
|
||||
{{ pip_package_list | pip_constraint_update(pip_package_constraint_list) }}
|
||||
# => [ "babel==2.3.4", "pip==8.1.0", "setuptools==25.1.0", "wheel==0.29.0" ]
|
||||
|
||||
splitlines
|
||||
~~~~~~~~~~
|
||||
This filter will return of list from a string with line breaks.
|
||||
|
|
|
@ -162,79 +162,12 @@ def string_2_int(string):
|
|||
return int(hashed_name, 36) % 10240
|
||||
|
||||
|
||||
def pip_constraint_update(list_one, list_two):
|
||||
|
||||
_list_one, _list_two = _lower_set_lists(list_one, list_two)
|
||||
_list_one, _list_two = list(_list_one), list(_list_two)
|
||||
for item2 in _list_two:
|
||||
item2_name, item2_versions, _ = _pip_requirement_split(item2)
|
||||
if item2_versions:
|
||||
for item1 in _list_one:
|
||||
if item2_name == _pip_requirement_split(item1)[0]:
|
||||
item1_index = _list_one.index(item1)
|
||||
_list_one[item1_index] = item2
|
||||
break
|
||||
else:
|
||||
_list_one.append(item2)
|
||||
|
||||
return sorted(_list_one)
|
||||
|
||||
|
||||
def splitlines(string_with_lines):
|
||||
"""Return a ``list`` from a string with lines."""
|
||||
|
||||
return string_with_lines.splitlines()
|
||||
|
||||
|
||||
def filtered_list(list_one, list_two):
|
||||
|
||||
_list_one, _list_two = _lower_set_lists(list_one, list_two)
|
||||
return list(_list_one-_list_two)
|
||||
|
||||
|
||||
def git_link_parse(repo):
|
||||
"""Return a dict containing the parts of a git repository.
|
||||
|
||||
:param repo: git repo string to parse.
|
||||
:type repo: ``str``
|
||||
:returns: ``dict``
|
||||
"""
|
||||
|
||||
if 'git+' in repo:
|
||||
_git_url = repo.split('git+', 1)[-1]
|
||||
else:
|
||||
_git_url = repo
|
||||
|
||||
if '@' in _git_url:
|
||||
url, branch = _git_url.split('@', 1)
|
||||
else:
|
||||
url = _git_url
|
||||
branch = 'master'
|
||||
|
||||
name = os.path.basename(url.rstrip('/'))
|
||||
_branch = branch.split('#')
|
||||
branch = _branch[0]
|
||||
|
||||
plugin_path = None
|
||||
# Determine if the package is a plugin type
|
||||
if len(_branch) > 1 and 'subdirectory=' in _branch[-1]:
|
||||
plugin_path = _branch[-1].split('subdirectory=')[-1].split('&')[0]
|
||||
|
||||
return {
|
||||
'name': name.split('.git')[0].lower(),
|
||||
'version': branch,
|
||||
'plugin_path': plugin_path,
|
||||
'url': url,
|
||||
'original': repo
|
||||
}
|
||||
|
||||
|
||||
def git_link_parse_name(repo):
|
||||
"""Return the name of a git repo."""
|
||||
|
||||
return git_link_parse(repo)['name']
|
||||
|
||||
|
||||
class FilterModule(object):
|
||||
"""Ansible jinja2 filters."""
|
||||
|
||||
|
@ -242,10 +175,6 @@ class FilterModule(object):
|
|||
def filters():
|
||||
return {
|
||||
'string_2_int': string_2_int,
|
||||
'pip_constraint_update': pip_constraint_update,
|
||||
'splitlines': splitlines,
|
||||
'filtered_list': filtered_list,
|
||||
'git_link_parse': git_link_parse,
|
||||
'git_link_parse_name': git_link_parse_name,
|
||||
'deprecated': _deprecated
|
||||
}
|
||||
|
|
|
@ -39,13 +39,6 @@
|
|||
- pip==8.1.0
|
||||
- setuptools==25.1.0
|
||||
- wheel==0.29.0
|
||||
- name: Set pip package filter facts
|
||||
set_fact:
|
||||
pip_package_list_constraint_filtered: "{{ pip_package_list_1 | pip_constraint_update(pip_package_list_2) }}"
|
||||
- name: Validate pip requirement filters
|
||||
assert:
|
||||
that:
|
||||
- "pip_package_list_constraint_filtered == pip_package_list_merged"
|
||||
|
||||
- name: Set splitlines string facts
|
||||
set_fact:
|
||||
|
@ -76,15 +69,6 @@
|
|||
plugin_path: null
|
||||
url: "https://git.openstack.org/openstack/nova"
|
||||
original: "git+https://git.openstack.org/openstack/nova@2bc8128d7793cc72ca2e146de3a092e1fef5033b#egg=nova&gitname=nova"
|
||||
- name: Set git link parse filter facts
|
||||
set_fact:
|
||||
git_repo_link_parse_filtered: "{{ git_repo | git_link_parse }}"
|
||||
git_repo_link_parse_name_filtered: "{{ git_repo | git_link_parse_name }}"
|
||||
- name: Validate git link parse filters
|
||||
assert:
|
||||
that:
|
||||
- "git_repo_link_parse_filtered == git_repo_link_parts"
|
||||
- "git_repo_link_parse_name_filtered == git_repo_name"
|
||||
|
||||
- name: Set deprecation variable facts
|
||||
set_fact:
|
||||
|
|
Loading…
Reference in New Issue