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

Patterns for PermissionTarget #434

Open
vittoriocanilli opened this issue Nov 1, 2023 · 1 comment
Open

Patterns for PermissionTarget #434

vittoriocanilli opened this issue Nov 1, 2023 · 1 comment
Labels
Help Wanted We will be glad if somebody proposes a solution via PR question

Comments

@vittoriocanilli
Copy link

vittoriocanilli commented Nov 1, 2023

I need to create a permission target with a repository and an include pattern; I have found out that the pattern can not be defined in the PermissionTarget.add_repository() function, but I had to set the pattern in the constructor of the permission target; I found it quite different from the UI experience on Artifactory, but it worked at least till September of this year.

Unfortunately it does not work anymore: when I create a new permission target, it comes out with no pattern at all, either if I pass it to the constructor or not: I mean that even the default ** include pattern is not set, which results to an useless permission target. Here is my code's snippet:

connection = ArtifactorySaaSPath(
    'https://mycompany.jfrog.io' + '/artifactory',
    apikey=`1234567890`
)

perm_target = PermissionTarget(
    connection,
    `my_permission_target`,
    includes_pattern='@mycompany-myproject/**'
)
perm_target.create()

I am using the latest version of the library, which is currently 0.9.1. Thanks in advance!

@allburov allburov added Help Wanted We will be glad if somebody proposes a solution via PR question labels Nov 2, 2023
@vittoriocanilli
Copy link
Author

As workaround I have stopped using the PermissionTarget.add_repository() to add the repository to an existing permission target and instead I set both the repository and the include pattern when I create the permission template:

connection = ArtifactorySaaSPath(
    'https://mycompany.jfrog.io' + '/artifactory',
    apikey=`1234567890`
)

repos_names = 'repo1,repo2,repo3'
repos_list = repos_names.split(',')
repos_obj_list = []

for repo in repos_list:
    repos_obj_list.append(connection.find_repository_local(repo))

perm_target = PermissionTarget(
    connection,
    `my_permission_target`,
    repositories=repos_obj_list,
    includes_pattern='@mycompany-myproject/**'
)
perm_target.create()

It works both with the library's version 0.9.1 and 0.9.2. Nevertheless it is just a workaround and I think that a properly documented solution is still needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted We will be glad if somebody proposes a solution via PR question
Development

No branches or pull requests

2 participants