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

Provide a mechanism to register callbacks for branch merge approval #189

Open
jeremystretch opened this issue Dec 13, 2024 · 0 comments
Open
Assignees
Labels
complexity: medium Requires a substantial but not unusual amount of effort to implement status: accepted type: feature A new feature or functionality

Comments

@jeremystretch
Copy link
Contributor

jeremystretch commented Dec 13, 2024

Plugin Version

v0.5.2

Proposed functionality

Introduce a mechanism that other plugins can use to prevent the merging of a branch, e.g. to enforce a change policy. This could be a class method on the Branch model used to register callback functions, which return a boolean (pass or fail) and optionally a failure reason. For example:

import datetime
from netbox_branching.models import Branch

def check_if_friday(branch):
    if datetime.date.today().weekday() == 4:
        return False, "No merging on Friday!"

Branch.register_merge_check(check_if_friday)

This will complement (or, potentially, replace) the current ability to manually register such functions via the plugin's configuration:

PLUGINS_CONFIG = {
    'netbox_branching': {
        'merge_validators': ['myplugin.check_if_friday'],
    }
}

Use case

This will enable other plugins to integrate with the branch merging functionality and enforce administrative policy.

External dependencies

N/A

@jeremystretch jeremystretch added type: feature A new feature or functionality status: accepted complexity: medium Requires a substantial but not unusual amount of effort to implement labels Dec 13, 2024
@jeremystretch jeremystretch self-assigned this Dec 13, 2024
jeremystretch added a commit that referenced this issue Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: medium Requires a substantial but not unusual amount of effort to implement status: accepted type: feature A new feature or functionality
Projects
None yet
Development

No branches or pull requests

1 participant