Enable prettier via pre-commit (#188)

pull/194/head
Bradley A. Thornton 2022-05-26 07:02:52 -07:00 committed by GitHub
parent 6e25216d7a
commit 4fe771a95c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 55932 additions and 55925 deletions

View File

@ -9,11 +9,38 @@ repos:
- id: no-commit-to-branch
args: [--branch, main]
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.6.2"
hooks:
- id: prettier
# Original hook implementation is flaky due to *several* bugs described
# in https://github.com/prettier/prettier/issues/12364
# a) CI=1 needed to avoid incomplete output
# b) two executions are needed because --list-different works correctly
# only when run with --check as with --write the output will also
# include other entries and logging level cannot be used to keep only
# modified files listed (any file is listed using the log level, regardless if
# is modified or not).
# c) We avoid letting pre-commit pass each filename in order to avoid
# running multiple instances in parallel. This also ensures that running
# prettier from the command line behaves identically with the pre-commit
# one. No real performance downsides.
# d) exit with the return code from list-different (0=none, 1=some)
# rather than the write (0=successfully rewrote files). pre-commit.ci
entry: env CI=1 bash -c "prettier --list-different . || ec=$? && prettier --loglevel=error --write . && exit $ec"
pass_filenames: false
args: []
additional_dependencies:
- prettier
- prettier-plugin-toml
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: [-l, "79"]
- repo: https://github.com/ansible-network/collection_prep
rev: 1.0.0
hooks:

17
.prettierignore Normal file
View File

@ -0,0 +1,17 @@
# Stuff we don't want priettier to ever to look into
.*/
coverage/
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# A linked collection directory created by pytest-ansible-units
collections/
README.md

View File

@ -19,16 +19,16 @@ releases:
modules:
- description: Parse cli output or text using a variety of parsers
name: cli_parse
namespace: ''
namespace: ""
- description: Find the difference between currently set facts
name: fact_diff
namespace: ''
namespace: ""
- description: Update currently set facts
name: update_fact
namespace: ''
namespace: ""
- description: Validate data with provided criteria
name: validate
namespace: ''
namespace: ""
plugins:
lookup:
- description: Retrieve the value in a variable using a path
@ -43,14 +43,14 @@ releases:
- description: Validate data with provided criteria
name: validate
namespace: null
release_date: '2020-12-08'
release_date: "2020-12-08"
1.0.1:
changes:
minor_changes:
- Move CHANGELOG.rst file under changelogs folder as required
fragments:
- fix_changelog_file_location.yaml
release_date: '2020-12-08'
release_date: "2020-12-08"
2.0.0:
changes:
breaking_changes:
@ -66,7 +66,7 @@ releases:
- 32_doc_updates.yaml
- sub_plugins_dir_change.yaml
- upcap_ansible.yaml
release_date: '2021-01-29'
release_date: "2021-01-29"
2.0.1:
changes:
bugfixes:
@ -75,7 +75,7 @@ releases:
fragments:
- ansible-doc.yaml
- cli_parse_fix.yaml
release_date: '2021-02-25'
release_date: "2021-02-25"
2.0.2:
changes:
bugfixes:
@ -84,7 +84,7 @@ releases:
fragments:
- cli_parse_errors_return.yaml
- jsonschema_data_validation_fix.yaml
release_date: '2021-03-29'
release_date: "2021-03-29"
2.1.0:
changes:
bugfixes:
@ -96,7 +96,7 @@ releases:
- add-xmltojson-and-jsontoxml-filter.yaml
- add_missing_test_requirements.yml
- fix_tests.yaml
release_date: '2021-04-27'
release_date: "2021-04-27"
2.2.0:
changes:
minor_changes:
@ -118,7 +118,7 @@ releases:
- add_netaddr_test_plugins_6.yml
- add_netaddr_test_plugins_7.yml
- add_netaddr_test_plugins_8.yml
release_date: '2021-05-17'
release_date: "2021-05-17"
2.3.0:
changes:
bugfixes:
@ -132,7 +132,7 @@ releases:
- empty_list_mapping.yml
- improve_coverage_for_filter_plugins.yaml
- update_doc_for_usable_range_filter_plugin.yml
release_date: '2021-06-22'
release_date: "2021-06-22"
2.3.1:
changes:
bugfixes:
@ -140,7 +140,7 @@ releases:
- Improve test coverage
fragments:
- 81_add_support_for_format.yaml
release_date: '2021-07-26'
release_date: "2021-07-26"
2.4.0:
changes:
bugfixes:
@ -152,14 +152,14 @@ releases:
- 85_update_validate_plugin.yaml
- 88_compare_resource_list_filter_plugin.yaml
- param_list_compare_docs_added.yaml
release_date: '2021-08-28'
release_date: "2021-08-28"
2.4.1:
changes:
release_summary: Rereleased 2.4.0 with trivial changes.
fragments:
- 2.4.1.yaml
- fix_network_ee.yaml
release_date: '2021-09-24'
release_date: "2021-09-24"
2.4.2:
changes:
release_summary: Rereleased 2.4.1 with valid requirement.txt.
@ -167,22 +167,22 @@ releases:
- 2.4.2.yaml
- add_ignore_2.13.yaml
- bugfix_100.yaml
release_date: '2021-10-07'
release_date: "2021-10-07"
2.4.3:
changes:
release_summary: Rereleased 2.4.2 with fix of network ee tests.
fragments:
- 2.4.3.yaml
- fix_network_ee.yaml
release_date: '2021-12-07'
release_date: "2021-12-07"
2.5.0:
changes:
doc_changes:
- Enhancement in documentation and docstring.
minor_changes:
- '''keep_keys'' filter plugin added.'
- '''remove_keys'' filter plugin added.'
- '''replace_keys'' filter plugin added.'
- "'keep_keys' filter plugin added."
- "'remove_keys' filter plugin added."
- "'replace_keys' filter plugin added."
- Add cli_merge ipaddr filter plugin.
- Add ip4_hex filter plugin.
- Add ipaddr filter plugin.
@ -219,16 +219,16 @@ releases:
- add_slaac_mac_hwaddr_filter.yaml
- docfix_minor_corrections.yaml
- recursive_filter_plugins.yaml
release_date: '2022-01-31'
release_date: "2022-01-31"
2.5.1:
changes:
doc_changes:
- '`in_any_network` - plugin doc fix for redundant line.'
- "`in_any_network` - plugin doc fix for redundant line."
fragments:
- Improve_test_covrage.yaml
- minor_doc_update.yaml
- unit_test_container_venv.yaml
release_date: '2022-03-01'
release_date: "2022-03-01"
2.5.2:
changes:
bugfixes:
@ -237,18 +237,18 @@ releases:
- ipaddr - Fix issue of breaking ipaddr filter with netcommon 2.6.0(https://github.com/ansible-collections/ansible.netcommon/issues/375).
fragments:
- bugfix_ipaddr_filter.yaml
release_date: '2022-03-04'
release_date: "2022-03-04"
2.6.0:
changes:
minor_changes:
- '''consolidate'' filter plugin added.'
- "'consolidate' filter plugin added."
fragments:
- 0-ignore.yml
- consolidate_filter_plugin.yml
- enable_upgrade_black.yml
- pre-commit-enable.yml
- pre-commit-skip.yml
release_date: '2022-04-12'
release_date: "2022-04-12"
2.6.1:
changes:
release_summary: Rereleased 2.6.0 with fixes for internal testing.
@ -258,4 +258,4 @@ releases:
- pylint-black-flake.yml
- sanity_fix.yaml
- test inits.yml
release_date: '2022-04-25'
release_date: "2022-04-25"

View File

@ -0,0 +1,3 @@
---
trivial:
- Enable prettier via pre-commit

View File

@ -1,2 +1,2 @@
---
requires_ansible: '>=2.9.10'
requires_ansible: ">=2.9.10"

View File

@ -45,7 +45,6 @@
vars:
msg: "one of the following is required: command, text"
- name: "{{ parser }} validate argspec"
ansible.utils.cli_parse:
text: ""

View File

@ -18,7 +18,6 @@
- "{{ nxos_ttp_text['parsed'][0][0] | selectattr('interface', 'search', 'mgmt0') | list | length }}"
- "{{ nxos_ttp_text['parsed'] == nxos_ttp_text_parsed }}"
- name: "{{ parser }} Pass text and custom variable"
ansible.utils.cli_parse:
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -3,10 +3,7 @@
ansible.builtin.set_fact:
data_sources:
- data:
[
{ "name": "GigabitEthernet0/1" },
{ "name": "GigabitEthernet0/2" },
]
[{ "name": "GigabitEthernet0/1" }, { "name": "GigabitEthernet0/2" }]
match_key: name
name: acl_interfaces
- data:

View File

@ -59,7 +59,6 @@
ansible.utils.fact_diff:
before: "{{ before|to_nice_yaml }}"
after: "{{ after|to_nice_yaml }}"
# TASK [ansible.utils.fact_diff] **************************************
# --- before
# +++ after
@ -74,7 +73,6 @@
# changed: [localhost]
#### Show the difference between complex object using restconf
# ansible_connection: ansible.netcommon.httpapi
# ansible_httpapi_use_ssl: True

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -6,7 +6,7 @@
plugin:
vars:
skip_lines:
- '+'
- "+"
ignore_errors: true
register: result

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -1,16 +1,16 @@
---
- name: Setup xml and expected json
ansible.builtin.set_fact:
data: "
<netconf-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\"><schemas><schema/></schemas></netconf-state>
"
output: {
"netconf-state": {
data: '
<netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring"><schemas><schema/></schemas></netconf-state>
'
output:
{
"netconf-state":
{
"@xmlns": "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring",
"schemas": {
"schema": null
}
}
"schemas": { "schema": null },
},
}
- debug:
@ -25,7 +25,7 @@
- name: Setup invalid xml as input to ansible.utils.from_xml.
ansible.builtin.set_fact:
data: "<netconf-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">"
data: '<netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">'
- name: validate input xml
ansible.builtin.set_fact:

View File

@ -21,7 +21,6 @@
# ansible_facts:
# value: '0'
#### Working with hostvars
- name: Retrieve a value deep inside all of the host's vars
@ -37,7 +36,6 @@
# as_filter: '0'
# as_lookup: '0'
#### Used alongside ansible.utils.to_paths
- name: Get the paths for the object
@ -53,7 +51,6 @@
vars:
path: "{{ item }}"
value: "{{ vars|ansible.utils.get_path(item) }}"
# TASK [Get the paths for the object] *******************************
# ok: [nxos101] => changed=false
# ansible_facts:
@ -73,7 +70,6 @@
# ok: [nxos101] => (item=a.b.c.e[1]) =>
# msg: The value of path a.b.c.e[1] in vars is False
#### Working with complex structures and transforming results
# - name: Retrieve the current interface config
@ -92,7 +88,6 @@
# - by_name['Ethernet1/2'].description|upper
# - by_name['Ethernet1/3'].description|default('')
# TASK [Get the description of several interfaces] ******************
# ok: [nxos101] => (item=by_name['Ethernet1/1'].description) => changed=false
# msg: Configured by ansible

View File

@ -21,7 +21,6 @@
# ansible_facts:
# value: '0'
#### Working with hostvars
- name: Retrieve a value deep inside all of the host's vars
@ -37,7 +36,6 @@
# as_filter: '0'
# as_lookup: '0'
#### Used alongside ansible.utils.to_paths
- name: Get the paths for the object
@ -53,7 +51,6 @@
vars:
path: "{{ item }}"
value: "{{ lookup('ansible.utils.get_path', hostvars[inventory_hostname], item) }}"
# TASK [Get the paths for the object] *******************************
# ok: [nxos101] => changed=false
# ansible_facts:
@ -73,7 +70,6 @@
# ok: [nxos101] => (item=a.b.c.e[1]) =>
# msg: The value of path a.b.c.e[1] in vars is False
#### Working with complex structures and transforming results
# - name: Retrieve the current interface config
@ -92,7 +88,6 @@
# - by_name['Ethernet1/2'].description|upper
# - by_name['Ethernet1/3'].description|default('')
# TASK [Get the description of several interfaces] ******************
# ok: [nxos101] => (item=by_name['Ethernet1/1'].description) => changed=false
# msg: Configured by ansible

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -23,7 +23,7 @@
expected: "{{ a.b.c.d[0] }}"
- result: "{{ a|ansible.utils.get_path('b.c.d[1]') }}"
expected: "{{ a.b.c.d[1] }}"
- result: "{{ a|ansible.utils.get_path('b[\"c\"]') }}"
- result: '{{ a|ansible.utils.get_path(''b["c"]'') }}'
expected: "{{ a.b.c }}"
- result: "{{ lookup('ansible.utils.get_path', vars, 'a') }}"
expected: "{{ a }}"
@ -37,7 +37,7 @@
expected: "{{ a.b.c.d[0] }}"
- result: "{{ lookup('ansible.utils.get_path', a, 'b.c.d[1]') }}"
expected: "{{ a.b.c.d[1] }}"
- result: "{{ lookup('ansible.utils.get_path', a, 'b[\"c\"]') }}"
- result: '{{ lookup(''ansible.utils.get_path'', a, ''b["c"]'') }}'
expected: "{{ a.b.c }}"
- ansible.builtin.set_fact:

View File

@ -51,7 +51,6 @@
# ok: [sw01] => (item=2) =>
# msg: 3 is > than 1
#### Working with lists of dictionaries
- ansible.builtin.set_fact:
@ -102,7 +101,6 @@
# ok: [nxos101] => (item=3) =>
# msg: The device named fw02.example.corp is a firewall
#### Working with complex structures from resource modules
# - name: Retrieve the current L3 interface configuration
@ -153,7 +151,6 @@
# ok: [nxos101] => (item=[{'interface_idx': '128', 'address_idxs': [0]}, 0]) =>
# msg: mgmt0 has ip 192.168.101.14/24
#### Working with deeply nested data
- ansible.builtin.set_fact:
@ -201,7 +198,6 @@
index: 3
index: 3
- name: Find the description of loopback111, subinterface index 10
debug:
msg: |-

View File

@ -58,7 +58,7 @@
vars:
params:
data: "{{ data }}"
test: '>'
test: ">"
value: 1
# TASK [Find numbers greater than 1, using with] *****************************
@ -67,7 +67,6 @@
# ok: [nxos101] => (item=2) =>
# msg: 3 is > than 1
#### Working with lists of dictionaries
- ansible.builtin.set_fact:
@ -118,7 +117,6 @@
# ok: [nxos101] => (item=3) =>
# msg: The device named fw02.example.corp is a firewall
#### Working with complex structures from resource modules
# - name: Retrieve the current L3 interface configuration
@ -169,7 +167,6 @@
# ok: [nxos101] => (item=[{'interface_idx': '128', 'address_idxs': [0]}, 0]) =>
# msg: mgmt0 has ip 192.168.101.14/24
#### Working with deeply nested data
- ansible.builtin.set_fact:
@ -217,7 +214,6 @@
index: 3
index: 3
- name: Find the description of loopback111, subinterface index 10
debug:
msg: |-

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -57,7 +57,6 @@
- test: "{{ lookup('ansible.utils.index_of', complex.d, 'match', '.*d$') }}"
result: [0, 1]
- ansible.builtin.set_fact:
complex:
a:

View File

@ -7,7 +7,6 @@
assert:
that: "{{ result1 == '1a:2b:3c:4d:5e:6f' }}"
- name: hwaddr filter test2
ansible.builtin.set_fact:
result1: "{{ '1a:2b:3c:4d:5e:6f'|ansible.utils.hwaddr('cisco') }}"

View File

@ -26,7 +26,6 @@
assert:
that: "{{ result2 == ipaddr_result2 }}"
- name: ipaddr filter with public network query
ansible.builtin.set_fact:
result3: "{{ value|ansible.utils.ipaddr('public') }}"

View File

@ -31,7 +31,6 @@
assert:
that: "{{ result1 == '192.168.1.1' }}"
- name: Get the next tenth address in IPv6 with Ipmath filter
ansible.builtin.set_fact:
result1: "{{ '2001::1'|ansible.utils.ipmath('10') }}"

View File

@ -4,7 +4,7 @@
value:
- 192.24.2.1
- ::ffff:192.168.32.0/120
- ''
- ""
- ::ffff:192.24.2.1/128
- 192.168.32.0/24
- fe80::100/10

View File

@ -7,7 +7,6 @@
assert:
that: "{{ result1 == '1a:2b:3c:4d:5e:6f' }}"
- name: macaddr filter test2
ansible.builtin.set_fact:
result1: "{{ '1a:2b:3c:4d:5e:6f'|ansible.utils.macaddr('cisco') }}"

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -15,7 +15,6 @@
assert:
that: "{{ result1 == False }}"
- name: network_in_network filter test3
ansible.builtin.set_fact:
result1: "{{ '192.168.0.0/16'|ansible.utils.network_in_network('192.168.0.0/24') }}"

View File

@ -15,7 +15,6 @@
assert:
that: "{{ result1 == False }}"
- name: network_in_usable filter test3
ansible.builtin.set_fact:
result1: "{{ '192.168.0.0/16'|ansible.utils.network_in_usable('192.168.0.255') }}"

View File

@ -1,6 +1,6 @@
---
address: '192.168.144.5'
subnet: '192.168.0.0/16'
address: "192.168.144.5"
subnet: "192.168.0.0/16"
result1_val:
- "192.24.2.1"
- "192.168.32.0/24"

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -6,42 +6,42 @@
ansible.builtin.set_fact:
network_resources:
modules:
- 'acl_interfaces'
- 'acls'
- 'bgp_address_family'
- 'bgp_global'
- 'interfaces'
- 'l2_interfaces'
- 'l3_interfaces'
- 'lacp'
- 'lacp_interfaces'
- 'lag_interfaces'
- 'lldp_global'
- 'lldp_interfaces'
- 'logging_global'
- 'ospf_interfaces'
- 'ospfv2'
- 'ospfv3'
- 'prefix_lists'
- 'route_maps'
- 'static_routes'
- 'vlans'
- "acl_interfaces"
- "acls"
- "bgp_address_family"
- "bgp_global"
- "interfaces"
- "l2_interfaces"
- "l3_interfaces"
- "lacp"
- "lacp_interfaces"
- "lag_interfaces"
- "lldp_global"
- "lldp_interfaces"
- "logging_global"
- "ospf_interfaces"
- "ospfv2"
- "ospfv3"
- "prefix_lists"
- "route_maps"
- "static_routes"
- "vlans"
- name: Setup target resources with bangs
ansible.builtin.set_fact:
provided_resources:
- '!all'
- '!acl_interfaces'
- 'acls'
- 'bgp_address_family'
- 'bgp_global'
- "!all"
- "!acl_interfaces"
- "acls"
- "bgp_address_family"
- "bgp_global"
- name: Setup target resources with bangs
ansible.builtin.set_fact:
expected_network_resources:
- 'acls'
- 'bgp_address_family'
- 'bgp_global'
- "acls"
- "bgp_address_family"
- "bgp_global"
- name: Get the final list of resources
set_fact:

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -19,7 +19,6 @@
vars:
msg: "'5' is not a valid boolean"
- name: Check argspec validation with lookup
ansible.builtin.set_fact:
_result: "{{ lookup('ansible.utils.to_paths') }}"

View File

@ -26,7 +26,6 @@
- name: Use prepend to add the initial variable name
ansible.builtin.set_fact:
paths: "{{ a|ansible.utils.to_paths(prepend='a') }}"
# TASK [Use prepend to add the initial variable name] **************************
# ok: [nxos101] => changed=false
# ansible_facts:
@ -36,7 +35,6 @@
# a.b.c.e[0]: true
# a.b.c.e[1]: false
#### Using a complex object
# - name: Make an API call

View File

@ -26,7 +26,6 @@
- name: Use prepend to add the initial variable name
ansible.builtin.set_fact:
paths: "{{ lookup('ansible.utils.to_paths', a, prepend='a') }}"
# TASK [Use prepend to add the initial variable name] **************************
# ok: [nxos101] => changed=false
# ansible_facts:
@ -36,7 +35,6 @@
# a.b.c.e[0]: true
# a.b.c.e[1]: false
#### Using a complex object
# - name: Make an API call

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -6,7 +6,7 @@
recurse: false
use_regex: true
patterns:
- '^(?!_|main).+$'
- "^(?!_|main).+$"
delegate_to: localhost
register: found

View File

@ -9,9 +9,7 @@
"$id": "#root/items",
"title": "Items",
"type": "integer",
"examples": [
1
],
"examples": [1],
"default": 0
}
}

View File

@ -79,7 +79,6 @@
ansible.builtin.set_fact:
is_data_valid: "{{ show_interfaces is ansible.utils.validate(criteria=in_rate_check_criteria) }}"
- name: validate data using jsonschema engine (valid data read from file)
ansible.builtin.set_fact:
data_criteria_checks: "{{ data|ansible.utils.validate(in_rate_check_criteria) }}"

View File

@ -23,7 +23,7 @@ show_interfaces:
rate:
in_rate: 0
out_rate: 0
description: '# interface is configures with Ansible'
description: "# interface is configures with Ansible"
duplex_mode: full
enabled: false
line_protocol: up