Galaxy server clean-up script along with some changes to galaxykit to support it#95
Galaxy server clean-up script along with some changes to galaxykit to support it#95ironfroggy wants to merge 2 commits intomainfrom
Conversation
…the cleanup script.
| include_response = kwargs.pop("include_response", False) | ||
|
|
||
| if include_response and not parse_json: | ||
| raise ValueError("GalaxyClient._http() called with include_response=True only valid when parse_json=True!") |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| raise ValueError("GalaxyClient._http() called with include_response=True only valid when parse_json=True!") | |
| raise ValueError( | |
| "GalaxyClient._http() called with include_response=True only valid when parse_json=True!" | |
| ) |
| def get_collection_list(client): | ||
| url = "_ui/v1/collection-versions/?limit=999999" | ||
| return client.get(url) | ||
| def get_collection_list(client, repo="published", limit=None, offset=None, keywords=None): |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| def get_collection_list(client, repo="published", limit=None, offset=None, keywords=None): | |
| def get_collection_list( | |
| client, repo="published", limit=None, offset=None, keywords=None | |
| ): |
|
|
||
| def delete_collection( | ||
| client, namespace, collection, version=None, repository="published" | ||
| client, namespace, collection, version=None, repositories=("published",), dependents=False |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| client, namespace, collection, version=None, repositories=("published",), dependents=False | |
| client, | |
| namespace, | |
| collection, | |
| version=None, | |
| repositories=("published",), | |
| dependents=False, |
| resp = client.delete(delete_url) | ||
| except GalaxyClientError as e: | ||
| if e.response.status_code == 404: | ||
| logger.debug(f"Ignoring (maybe) already deleted {coll_name}", file=sys.stderr) |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| logger.debug(f"Ignoring (maybe) already deleted {coll_name}", file=sys.stderr) | |
| logger.debug( | |
| f"Ignoring (maybe) already deleted {coll_name}", file=sys.stderr | |
| ) |
| combined = { | ||
| "original": None, | ||
| "dependents": [] | ||
| } |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| combined = { | |
| "original": None, | |
| "dependents": [] | |
| } | |
| combined = {"original": None, "dependents": []} |
| for dep in resp["dependent_collection_versions"]: | ||
| dep_coll, dep_ver = dep.split(" ") | ||
| dep_ns, dep_name = dep_coll.split(".") | ||
| dep_resp = delete_collection(client, dep_ns, dep_name, dep_ver, repositories, dependents=True) |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| dep_resp = delete_collection(client, dep_ns, dep_name, dep_ver, repositories, dependents=True) | |
| dep_resp = delete_collection( | |
| client, | |
| dep_ns, | |
| dep_name, | |
| dep_ver, | |
| repositories, | |
| dependents=True, | |
| ) |
| final_resp["responses"].append({ | ||
| "collection": coll_name, | ||
| "response": resp, | ||
| }) |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| final_resp["responses"].append({ | |
| "collection": coll_name, | |
| "response": resp, | |
| }) | |
| final_resp["responses"].append( | |
| { | |
| "collection": coll_name, | |
| "response": resp, | |
| } | |
| ) |
| def parse_args(parser, args): | ||
| for arg in args: | ||
| parser.add_argument(arg, **(args[arg])) | ||
| flag_args=[] |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| flag_args=[] | |
| flag_args = [] |
| flag_args.append("--" + args[arg].pop("long").strip("-")) | ||
| if not flag_args: | ||
| flag_args.append(arg) | ||
|
|
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| args.version, | ||
| args.repository or "published", | ||
| args.repository.split(","), | ||
| args.dependents |
There was a problem hiding this comment.
[black] reported by reviewdog 🐶
| args.dependents | |
| args.dependents, |
9a13c57 to
56d8d73
Compare
|
This is causing a lot of failures in UI tests (https://github.com/ansible/ansible-hub-ui/actions/runs/5617442384/job/15221548810?pr=4013#step:30:464) but looks like the primary cause is the change to
Which makes Is that an intentional change? (Also, if the goal is to update the API endpoint, shouldn't this be using |
Changes to galaxykit include:
repository: Can specify multiple repositories to list from. Default:"published"offset: How many collections to skip, to allow paging.keywords: Filter results with a keyword search.include_response. Causes to return both the parsed JSON and the originalHttpResponseobject.get()can take a keyword argument"params"to pass querystring parameters easily.delete_collection()has many changes to support the cleanup script:repositoriesparameter instead of arepositoryparameter.dependenciesparameter to recursively delete dependencies of the collection before deleting the collection itself.Finally, of course, added the actual clean up script in
scripts/galaxy-cleaner.sh.