Skip to content

Commit

Permalink
Add initialize_new_version function to Repository model
Browse files Browse the repository at this point in the history
  • Loading branch information
quba42 authored and dkliban committed Nov 23, 2021
1 parent b4eb856 commit 5cbcbb0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/plugin_api/9579.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added ``initialize_new_version`` function to ``Repository`` model.
21 changes: 21 additions & 0 deletions pulpcore/app/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@ def new_version(self, base_version=None):

return version

def initialize_new_version(self, new_version):
"""
Initialize the new RepositoryVersion with plugin-provided code.
This method should be overridden by plugin writers for an opportunity for plugin input. This
method is intended to be called with the incomplete
:class:`pulpcore.app.models.RepositoryVersion` to validate or modify the content.
This method does not adjust the value of complete, or save the `RepositoryVersion` itself.
Its intent is to allow the plugin writer an opportunity for plugin input before any other
actions performed on the new `RepositoryVersion`.
Args:
new_version (pulpcore.app.models.RepositoryVersion): The incomplete RepositoryVersion to
finalize.
"""
pass

def finalize_new_version(self, new_version):
"""
Finalize the incomplete RepositoryVersion with plugin-provided code.
Expand Down Expand Up @@ -957,6 +976,8 @@ def __enter__(self):
Returns:
RepositoryVersion: self
"""
repository = self.repository.cast()
repository.initialize_new_version(self)
return self

def __exit__(self, exc_type, exc_value, traceback):
Expand Down

0 comments on commit 5cbcbb0

Please sign in to comment.