-
Notifications
You must be signed in to change notification settings - Fork 15
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
Galaxy server clean-up script along with some changes to galaxykit to support it #95
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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 | |
): |
@@ -201,19 +216,75 @@ def move_or_copy_collection( | |||
|
|||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[black] reported by reviewdog 🐶
final_resp["responses"].append({ | |
"collection": coll_name, | |
"response": resp, | |
}) | |
final_resp["responses"].append( | |
{ | |
"collection": coll_name, | |
"response": resp, | |
} | |
) |
@@ -489,7 +526,15 @@ def report_error(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[black] reported by reviewdog 🐶
args.namespace, | ||
args.collection, | ||
args.version, | ||
args.repository or "published", | ||
args.repository.split(","), | ||
args.dependents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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 originalHttpResponse
object.get()
can take a keyword argument"params"
to pass querystring parameters easily.delete_collection()
has many changes to support the cleanup script:repositories
parameter instead of arepository
parameter.dependencies
parameter 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
.