feat(operations.pkg): migrate FreeBSD pkg to PackageInfo (phase 2 of #1725)#1823
Open
wowi42 wants to merge 3 commits into
Open
feat(operations.pkg): migrate FreeBSD pkg to PackageInfo (phase 2 of #1725)#1823wowi42 wants to merge 3 commits into
wowi42 wants to merge 3 commits into
Conversation
Collaborator
…ness - Remove PackageInfo.to_json now that pyinfra-testing serializes dataclasses - Extend pyinfra_cli json_encode with enum/dataclass support - Normalize dict-shaped PkgPackages values in pkg operations - Update pkg operation fixtures from packageinfo tags to plain dicts - Update tests
8787b2e to
65c4f3e
Compare
…t in pkg ops Replace the private _package_info_from_value helper with a public PackageInfo.from_dict classmethod so the conversion lives next to the model and can be reused by later package-manager migrations.
11bda27 to
dc70763
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 of the staged rollout tracked in #1725.
Summary
Migrates the
pkg(FreeBSD) manager to the unified package model. Per the rollout direction, the manager exposes a single fact:PkgPackagesnow returnslist[PackageInfo]directly. There are noPkgUpgradeablePackages/PkgLockedPackagessub-facts.PkgPackagesreturnslist[PackageInfo]sorted by name, gathered by one compound command:(pkg query '%n %v %k' && echo __pyinfra_pkg_remote__ && (pkg version -vRL= || true)) || pkg_info || true. On FreeBSD,pkg queryprovides name/version/locked in one pass andpkg version -vRL=(after the marker line) provides available upgrades, so entries carryHELDandUPGRADEABLEstatuses. On other BSDs thepkg_infofallback runs and every entry isINSTALLED. The marker presence tellsprocess()which format to parse, so the two formats never mix.build_package_map()now returns the samelist[PackageInfo]shape (name lives on each entry, so a name-keyed dict only duplicated it). Phase 1 merged after the v3.9.2 release, so this signature change is not in any released version.PackageInfogainsto_json()sojson_encodecan serialize fact output (CLIfactcommand and the test harness).ensure_packages()additionally acceptslist[PackageInfo], normalizing to a name-keyed dict internally. Existing dict-shaped callers are unchanged.pkg.update(force=False)(non-idempotent catalog refresh) andpkg.upgrade()(noops when nothing is upgradeable).pkg.packagesgainslatest; packages locked withpkg lockalways noop, even withlatest=True.parse_valueintests/util.pybuildsPackageInfofrom a{"packageinfo": {...}}tagged dict (same spirit as the existingset:/datetime:conventions). Later phases reuse this hook.Test plan
pkg_infofallback; empty output.pkg.update(plain/force),pkg.upgrade(noop/upgrades),pkg.packageswithlatest(upgrade, up-to-date noop, held noop).pkg.packagesfixtures updated to the list shape; behaviour unchanged.tests/test_facts_packages.pyupdated for the list return plus ato_json()round-trip test;tests/test_operations_utils.pygains alist[PackageInfo]case.Requirements
3.xat this time)scripts/dev-test.sh)scripts/dev-lint.sh)