Skip to content

Conversation

@maisim
Copy link
Contributor

@maisim maisim commented Oct 14, 2025

This pull request refactors and modernizes the APT repository and key management logic in src/pyinfra/facts/apt.py and related files. supporting both legacy and deb822 repository formats, and updating keyring handling to use modern GPG infrastructure.

Follow #1465

  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh)
  • Type checking & code style passes (see scripts/dev-lint.sh)

@maisim
Copy link
Contributor Author

maisim commented Oct 14, 2025

WIP, I messed up the rebase of this branch... I'll continue at the end of the week.

- Add GpgFactBase, GpgKey, GpgKeys, GpgSecretKeys, and GpgKeyrings facts
- Add gpg.key and gpg.dearmor operations for managing GPG keys
- Support for keyserver fetching, local files, URLs, and key removal
- Comprehensive test coverage for all GPG operations and facts
- Add AptRepo and AptSourcesFile dataclasses for type-safe repository handling
- Support both legacy .list and modern .sources deb822 formats
- Maintain backward compatibility with dict-like access patterns
- Add comprehensive parsing for deb822 multi-value fields
- Expand deb822 entries to individual repository configurations
- Add test coverage for deb822 sources and components with numbers
- Update existing tests to handle new file-marker based parsing
- Add GpgFactBase, GpgKey, GpgKeys, GpgSecretKeys, and GpgKeyrings facts
- Add gpg.key and gpg.dearmor operations for managing GPG keys
- Support for keyserver fetching, local files, URLs, and key removal
- Comprehensive test coverage for all GPG operations and facts
- Add AptRepo and AptSourcesFile dataclasses for type-safe repository handling
- Support both legacy .list and modern .sources deb822 formats
- Maintain backward compatibility with dict-like access patterns
- Add comprehensive parsing for deb822 multi-value fields
- Expand deb822 entries to individual repository configurations
- Add test coverage for deb822 sources and components with numbers
- Update existing tests to handle new file-marker based parsing
…mand

- Update AptKeys fact to use GpgKeyrings instead of deprecated apt-key command
- Maintain backward compatibility by flattening keyring data to match old format
- Search APT-specific directories: /etc/apt/trusted.gpg.d, /etc/apt/keyrings, /usr/share/keyrings
- Add comprehensive test coverage for modernized apt.key operations
- Support both legacy and modern APT key management workflows
- Break down complex key() function into smaller, focused helper functions
- Add _install_key_from_src() for file/URL installation
- Add _install_key_from_keyserver() for keyserver installation
- Add _remove_key_from_keyrings() for multi-keyring removal
- Add _remove_key_from_keyring() for single keyring removal
- Add _remove_keyring_file() for complete keyring removal
- Add validation helper functions for parameters
- Improve code readability and maintainability
- Follow Docker operations pattern for function organization
- Maintain 100% backward compatibility with existing API
# Conflicts:
#	src/pyinfra/operations/gpg.py
# Conflicts:
#	src/pyinfra/facts/apt.py
#	src/pyinfra/operations/gpg.py
@maisim maisim force-pushed the pr3-manage-apt-key-removal branch from 2602657 to c9e83ad Compare October 16, 2025 09:05
GPG key IDs contain hexadecimal values that trigger false positives
in typos (e.g., 'BA' in '1E9377A2BA9EF27F' is flagged as misspelled).
These are valid hex values, not typos.
@maisim maisim changed the title Pr3 manage apt key removal Pr3/3 manage apt key removal Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant