-
Notifications
You must be signed in to change notification settings - Fork 6
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
Allow to track removed collections in collection-meta.yaml #173
Changes from 2 commits
fadd8d1
d4ee468
48aaf8e
4759371
6ab4204
f177fae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- "Allow information on removed collections in collection metadata schema (https://github.com/ansible-community/antsibull-core/pull/173)." |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,10 @@ class RemovalInformation(p.BaseModel): | |
|
||
model_config = p.ConfigDict(arbitrary_types_allowed=True) | ||
|
||
# The Ansible major version from which the collection will be removed. | ||
major_version: t.Union[int, t.Literal["TBD"]] | ||
|
||
# The reason because of which the collection will be removed. | ||
reason: t.Literal[ | ||
"deprecated", | ||
"considered-unmaintained", | ||
|
@@ -60,9 +63,19 @@ class RemovalInformation(p.BaseModel): | |
"other", | ||
] | ||
reason_text: t.Optional[str] = None | ||
|
||
# The Ansible version in which the announcement was made. This is needed | ||
# for changelog generation. | ||
announce_version: t.Optional[PydanticPypiVersion] = None | ||
|
||
# In case reason=renamed, the new name of the collection. | ||
new_name: t.Optional[str] = None | ||
|
||
# The link to the discussion of the removal. | ||
discussion: t.Optional[p.HttpUrl] = None | ||
|
||
# In case reason=renamed, the major Ansible release in which the collection's | ||
# contents have been replaced by deprecated redirects. | ||
redirect_replacement_major_version: t.Optional[int] = None | ||
|
||
@p.model_validator(mode="after") # pyre-ignore[56] | ||
|
@@ -112,28 +125,76 @@ def _check_reason_is_not_renamed(self) -> Self: | |
return self | ||
|
||
|
||
class CollectionMetadata(p.BaseModel): | ||
class RemovedRemovalInformation(RemovalInformation): | ||
""" | ||
Stores metadata on when and why a collection was removed. | ||
""" | ||
|
||
major_version: int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth adding a comment that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be no longer necessary due to 4759371. |
||
|
||
|
||
class BaseCollectionMetadata(p.BaseModel): | ||
""" | ||
Stores metadata about one collection. | ||
""" | ||
|
||
# If the collection does not use changelogs/changelog.yaml, it can provide | ||
# an URL where the collection's changelog can be found. | ||
felixfontein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
changelog_url: t.Optional[str] = p.Field(alias="changelog-url", default=None) | ||
|
||
# In case the collection is not located in the root of its repository, the | ||
# subdirectory in which the collection appears. | ||
collection_directory: t.Optional[str] = p.Field( | ||
alias="collection-directory", default=None | ||
) | ||
|
||
# The collection's repository. | ||
repository: t.Optional[str] = None | ||
|
||
# A regular expression to match the collection's version from a tag in the repository. | ||
tag_version_regex: t.Optional[str] = None | ||
|
||
# A list of maintainers. These should be usernames for the repository's | ||
# hosting environment. | ||
maintainers: list[str] = [] | ||
|
||
|
||
class CollectionMetadata(BaseCollectionMetadata): | ||
""" | ||
Stores metadata about one collection. | ||
""" | ||
|
||
# Optional information that the collection will be removed from | ||
# a future Ansible release. | ||
removal: t.Optional[RemovalInformation] = None | ||
|
||
|
||
class RemovedCollectionMetadata(BaseCollectionMetadata): | ||
""" | ||
Stores metadata about a removed collection. | ||
""" | ||
|
||
model_config = p.ConfigDict(arbitrary_types_allowed=True) | ||
|
||
# Information why the collection has been removed | ||
removal: RemovedRemovalInformation | ||
|
||
# The exact version from which the collection has been removed. | ||
# This is needed for changelog generation. | ||
removed_version: PydanticPypiVersion | ||
|
||
|
||
class CollectionsMetadata(p.BaseModel): | ||
""" | ||
Stores metadata about a set of collections. | ||
""" | ||
|
||
# Metadata on the collections included in Ansible. | ||
collections: dict[str, CollectionMetadata] | ||
|
||
# Metadata on the collections removed from this major version of Ansible. | ||
removed_collections: dict[str, RemovedCollectionMetadata] = {} | ||
|
||
@staticmethod | ||
def load_from(deps_dir: StrPath | None) -> CollectionsMetadata: | ||
if deps_dir is None: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,22 @@ | |
reason_text: The collection wasn't cow friendly, so the Steering Committee decided to kick it out. | ||
discussion: https://forum.ansible.com/... | ||
announce_version: 9.3.0 | ||
removed_collections: | ||
bad.baz2: | ||
repository: https://github.com/ansible-collections/collection_template | ||
removed_version: 10.2.1 | ||
removal: | ||
major_version: 9 | ||
reason: renamed | ||
new_name: bad.bar2 | ||
announce_version: 9.3.0 | ||
redirect_replacement_major_version: 7 | ||
bad.baz1: | ||
removed_version: 9.1.0 | ||
removal: | ||
major_version: 8 | ||
reason: deprecated | ||
announce_version: 7.1.0 | ||
""", | ||
[ | ||
"foo.bar", | ||
|
@@ -153,6 +169,7 @@ | |
], | ||
[ | ||
"The collection list must be sorted; 'baz.bam' must come before foo.bar", | ||
"The removed collection list must be sorted; 'bad.baz1' must come before bad.baz2", | ||
"collections -> bad.bar1 -> removal -> announce_version: Major version of 10.1.0 must not be larger than the current major version 9", | ||
"collections -> bad.bar1 -> removal -> major_version: Removal major version 7 must be larger than current major version 9", | ||
"collections -> bad.bar1: Collection not in ansible.in", | ||
|
@@ -162,6 +179,10 @@ | |
"collections -> baz.bam: Collection not in ansible.in", | ||
"collections -> foo.bar -> repository: Required field not provided", | ||
"collections: No metadata present for not.there", | ||
"removed_collections -> bad.baz1 -> removal -> major_version: Removal major version 8 must be current major version 9", | ||
"removed_collections -> bad.baz1 -> repository: Required field not provided", | ||
"removed_collections -> bad.baz2 -> removal -> announce_version: Major version of 9.3.0 must be less than the current major version 9", | ||
"removed_collections -> bad.baz2 -> removed_version: Major version of 10.2.1 must be the current major version 9", | ||
], | ||
), | ||
( | ||
|
@@ -271,6 +292,18 @@ | |
removal: | ||
major_version: 11 | ||
reason: foo | ||
removed_collections: | ||
bad.foo1: | ||
repository: https://github.com/ansible-collections/collection_template | ||
removed_version: 1.0.0 | ||
removal: | ||
major_version: TBD | ||
reason: deprecated | ||
bad.foo2: | ||
repository: https://github.com/ansible-collections/collection_template | ||
removal: | ||
major_version: 10 | ||
reason: deprecated | ||
extra_stuff: baz | ||
""", | ||
[], | ||
|
@@ -292,6 +325,8 @@ | |
"collections -> bad.foo8 -> removal: Value error, new_name must not be provided if reason is not 'renamed'", | ||
"collections -> bad.foo9 -> removal: Value error, redirect_replacement_major_version must not be provided if reason is not 'renamed'", | ||
"extra_stuff: Extra inputs are not permitted", | ||
"removed_collections -> bad.foo1 -> removal -> major_version: Input should be a valid integer, unable to parse string as an integer", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could add a pre validator that specifically checks for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be no longer necessary due to 4759371. |
||
"removed_collections -> bad.foo2 -> removed_version: Field required", | ||
], | ||
), | ||
] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
major_version
not be part ofRemovedRemovalInformation
? Havingremoved_collections[NAME].removal.major_version
andremoved_collection[NAME].removed_version
seems duplicative.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea was that one can simply move the metadata entry for the removed collection to the
removed_collections
list with minimal modifications (theremoval_version
entry needs to be added).But since that modification is needed anyway, how about replacing
major_version
with a newversion
entry that replaces theremoval_version
one level up? I originally wanted to use an unmodifiedRemovalInformation
here, that's why I addedremoval_version
one level up, but now that there's a different class it might be easier to do it this way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I figured that as well, but then I wondered if that was worth the potential confusion of having the same information twice.
That sounds reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented that in 4759371.