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

Feat(plugins): Add AVD String Formatter for later use in custom descriptions #4432

Conversation

ClausHolbechArista
Copy link
Contributor

Change Summary

Feat(plugins): Add AVD String Formatter for later use in custom descriptions

Proposed changes

  • New string formatter, reusing parts of Python string.Formatter class.
  • Support for upper
  • Support for optional fields
  • Support for prefix / suffix - useful with optional fields
  • Protection against accessing internal objects.
  • Easily extensible to add IP addressing or other things.

How to test

Added pytest

Checklist

User Checklist

  • N/A

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)

Copy link

github-actions bot commented Sep 5, 2024

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-4432
# Activate the virtual environment
source test-avd-pr-4432/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/ClausHolbechArista/avd.git@feat/plugins/format-strings#subdirectory=python-avd" --force
# Point Ansible collections path to the Python virtual environment
export ANSIBLE_COLLECTIONS_PATH=$VIRTUAL_ENV/ansible_collections
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/ClausHolbechArista/avd.git#/ansible_collections/arista/avd/,feat/plugins/format-strings --force
# Optional: Install AVD examples
cd test-avd-pr-4432
ansible-playbook arista.avd.install_examples

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.

nice PR!

python-avd/pyavd/_utils/format_string.py Outdated Show resolved Hide resolved
python-avd/pyavd/_utils/format_string.py Outdated Show resolved Hide resolved
python-avd/pyavd/_utils/format_string.py Outdated Show resolved Hide resolved
@ClausHolbechArista ClausHolbechArista requested a review from a team September 11, 2024 05:19
@gmuloc gmuloc added the one approval This PR has one approval and is only missing one more. label Sep 11, 2024
Copy link

@ClausHolbechArista ClausHolbechArista merged commit 626cdd1 into aristanetworks:devel Sep 11, 2024
40 checks passed
@ClausHolbechArista ClausHolbechArista deleted the feat/plugins/format-strings branch September 27, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
one approval This PR has one approval and is only missing one more. rn: Feat(plugins)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants