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

add storage.beforeRepoCreate Plugin Execution Points #402

Open
domruf opened this issue Dec 8, 2021 · 0 comments
Open

add storage.beforeRepoCreate Plugin Execution Points #402

domruf opened this issue Dec 8, 2021 · 0 comments

Comments

@domruf
Copy link

domruf commented Dec 8, 2021

There is already a storage.beforeCreate Plugin Execution Points that lets you implement plugins that react before artifacts are created in a repository. What we need is a plugin that reacts before a repository itself is created.

More concretely we want to restrict the names used for repositories. The idea would be something like this

import org.artifactory.exception.CancelException

storage {
    beforeRepoCreate { item ->
        def pattern = "(([^\\-]+)-)+(alpine|cargo|chef|cocoa|conan|conda|cran|debian|docker|gems|generic|gitlfs|go|helm|ivy|maven|npm|nuget|opkg|php|puppet|pypi|rpm|sbt|vagrant|bower)(-(prod|qa|dev))?-(local|remote)"
        def repoConf = repositories.getRepositoryConfiguration(item.repoPath.repoKey)
        if (!(item.repoPath.repoKey ==~ pattern)){
            def message = "Repo name: " + item.repoPath.repoKey + ". "
            message += "The repository name must end with -<type>-<remote|local> or -<type>-<prod|qa|dev>-<local|remote>"
            def status = 400
            throw new CancelException(message, status) {
                public Throwable fillInStackTrace() {
                    return null;
                }
            }
        }
    }
}
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

No branches or pull requests

1 participant