Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor(plugins): Move jinja filter code for arista.avd.is_in_filter to PyAVD #4133

Merged
merged 2 commits into from
Jun 19, 2024

Conversation

Vibhu-gslab
Copy link
Contributor

Change Summary

Move jinja filter code for arista.avd.is_in_filter to PyAVD

Related Issue(s)

Fixes #4132

Component(s) name

arista.avd.is_in_filter

Proposed changes

Moving the code and unit tests for arista.avd.is_in_filter filter to PyAVD

How to test

CI should catch things.

Checklist

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

@Vibhu-gslab Vibhu-gslab self-assigned this Jun 19, 2024
@github-actions github-actions bot added filter: is_in_filter issue related to is_in_filter plugin type: Python filters labels Jun 19, 2024
Copy link

Review docs on Read the Docs

To test this pull request:

# Create virtual environment for this testing below the current directory
python -m venv test-avd-pr-4133
# Activate the virtual environment
source test-avd-pr-4133/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/Vibhu-gslab/avd.git@is_in_filter#subdirectory=python-avd" --force
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/Vibhu-gslab/avd.git#/ansible_collections/arista/avd/,is_in_filter --force
# Optional: Install AVD examples
cd test-avd-pr-4133
ansible-playbook arista.avd.install_examples

@Vibhu-gslab Vibhu-gslab marked this pull request as ready for review June 19, 2024 14:06
@Vibhu-gslab Vibhu-gslab requested review from a team as code owners June 19, 2024 14:06
Copy link
Member

@carlbuchmann carlbuchmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ClausHolbechArista ClausHolbechArista merged commit 35ef6cd into aristanetworks:devel Jun 19, 2024
40 checks passed
(HOSTNAME_VALID, None, True), # default filter
(HOSTNAME_VALID, HOSTNAME_FILTER_VALID, True), # valid hostname
(HOSTNAME_INVALID, HOSTNAME_FILTER_VALID, False), # invalid hostname
# TODO: Check if this is a valid testcase. Add a type check?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be working like this for the last example. Can you please log an issue to revisit the behavior of this filter after migration as changing this now would be a breaking change probably (here we end up looping over every character in the string and checking if any character is in the hostname, which is not the spirit of the filter, or at least should not be given like this as an input)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some historic behavior here, where the device-filters in the cvp-related roles accepted a string or a list.

Copy link
Contributor

@gmuloc gmuloc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the move. Some of the filter behavior is dubious but that's not the purpose of this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor(plugins): Move jinja filter code for arista.avd.is_in_filter to PyAVDFeature request Title
4 participants