Skip to content

fix(api): replace deprecated name_regex attribute in delete_in_bulk() #1536

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions gitlab/v4/objects/container_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,28 @@ class ProjectRegistryTagManager(DeleteMixin, RetrieveMixin, RESTManager):
_path = "/projects/%(project_id)s/registry/repositories/%(repository_id)s/tags"

@cli.register_custom_action(
"ProjectRegistryTagManager", optional=("name_regex", "keep_n", "older_than")
"ProjectRegistryTagManager",
("name_regex_delete",),
optional=("keep_n", "name_regex_keep", "older_than"),
)
@exc.on_http_error(exc.GitlabDeleteError)
def delete_in_bulk(self, name_regex=".*", **kwargs):
def delete_in_bulk(self, name_regex_delete, **kwargs):
"""Delete Tag in bulk

Args:
name_regex (string): The regex of the name to delete. To delete all
tags specify .*.
keep_n (integer): The amount of latest tags of given name to keep.
name_regex_keep (string): The regex of the name to keep. This value
overrides any matches from name_regex.
older_than (string): Tags to delete that are older than the given time,
written in human readable form 1h, 1d, 1month.
**kwargs: Extra options to send to the server (e.g. sudo)
name_regex_delete (string): The regex of the name to delete. To delete all
tags specify .*.
keep_n (integer): The amount of latest tags of given name to keep.
name_regex_keep (string): The regex of the name to keep. This value
overrides any matches from name_regex.
older_than (string): Tags to delete that are older than the given time,
written in human readable form 1h, 1d, 1month.
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server cannot perform the request
"""
valid_attrs = ["keep_n", "name_regex_keep", "older_than"]
data = {"name_regex": name_regex}
data = {"name_regex_delete": name_regex_delete}
data.update({k: v for k, v in kwargs.items() if k in valid_attrs})
self.gitlab.http_delete(self.path, query_data=data, **kwargs)