Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Delete yum artifacts regex #72
base: master
Are you sure you want to change the base?
Delete yum artifacts regex #72
Changes from 2 commits
6ac9c06
0cca23d
a67c777
6f19be9
26e45ce
6569a9c
d8913b6
cb9d3a5
4087402
b987072
d7e6ebf
806cfa0
acf6586
32e59be
0ccbed4
2a70340
1c9fabe
0b1d9da
b9fe5cc
0506853
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I believe there's a
.json
method in the requests' response that would be preferable to callingjson.loads
directly.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.
I think that ScriptCollection.run() is already doing .json() on the HTTP response from the Nexus. However I think that the response.result field is interpreted as a string and does not handle the case whether that string is another JSON... hence the json.loads()...
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.
Wouldn't these
del_assets*
subcommands be better under the existing root command (delete|del
)?You could add flags for the user to specify whether the
<repository_path>
contains a regex or a wildcard (glob?)I'll have a better look at the problem this weekend so I have a better informed suggestion.
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.
Regarding the 2 points:
subcommand vs root command: honestly as user of nexus3-cli I found very confusing having both subcommands AND root commands: I didn't pay much attention initially at the repository/script/etc subcommands documented at the end of the "--help" section and it took me a while to discover how many possibilities nexus3-cli provides beside the root commands... all in all they look at bit "hidden".
So IMHO I would completely remove root commands and leave only subcommands: all the list/upload/download/delete root commands IMHO should be under an "assets" subcommand.
Then in this scenario these del_assets_* commands added by this PR could be merged with the "nexus3 assets delete" command perhaps.
regarding having a single command instead of del_assets_regex/del_assets_wildcard: I think you're right, having a flag would make it possible to unify them.
Should the default be to interpret the parameter appearing after the <repo_name> as a wildcard or as a regex? Since wildcards are easier to use I would opt for the former.
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.
As changing the CLI would be a breaking change, I’d favour a bit more research/discussion before acting on it. Perhaps build the docopt in a separate branch so we can see how it looks.
Thanks again for your contribution.
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.
Ok sure - I understand that grouping root commands all together would be a breaking change... better not to mix with this MR. So, for now, should I keep the del_assets command under the "repository" subcommand? Or do you prefer to have a new subcommand or a root-level command for that?
I have to say that after some more attempts to use the new "del_assets_wildcard" command I discovered that the OrientDB used by Nexus3 is handling wildcards in a weird (at least to me) way: i.e. the wildcard symbol % matches only string prefixes or postfixes. E.g. if I have an asset named "folder1/myasset-1.2.3.rpm" and I provide as wildcard "folder1/%1.2.3%" the Groovy script will report 0 matches. If I provide "%1.2.3%", the asset will be matched.
All this to say: maybe allowing the user to use wildcards instead of regex is not that useful finally...
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.
Yes please. I'd prefer to keep it consistent with the subcommand pattern. I'll take your feedback onboard and think of a way to better expose the subcommands to first-time users.
I think that's still useful - if we can clearly communicate how the wildcard handling works (or link to a place that does it). One thing that I didn't consider is what happens when a file you want to delete has a wildcard character in it. I guess the user would need to escape it by default, unless we only enable these options through flags; e.g.:
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.
Hi @thiagofigueiro ,
just to be sure I understand: from reading the example docs you put in point #2 I assume that the answer w.r.t. point #1 is "having these del_assets_wildcard and del_assets_regex merged with the root-level 'del' command" right?
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.
Hi @thiagofigueiro ,
I was going to implement the change but I realized now that regarding point 1
Would that be something like:
nexus3 del --regex myrepoName/^[a-z]*myregex.*
?
Or can we modify the "delete|del" command to separate the reponame from the asset name:
nexus3 del --regex myrepoName ^[a-z]*myregex.*
?
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.
--regex
and--wildcard
would be toggle flags to thedel
command.There's existing code that can receive this
and split it using something like this.
It's a part of the code that is older and somewhat messy but it does the job. Assuming this is the docopt line:
Then you could do something like this:
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.
Hi @thiagofigueiro ,
I'm trying to do the change but I admit I'm facing several issues as I don't know the code so well.
For example: the "nexus3 (delete|del) <repository_path>" command is not using the "api/repository/*" code, while my PR has added all the code to perform delete operations in the API first.
Should I change the "delete|del" command to go through the API?
In practice such existing "delete|del" command can be implemented as a special case of the wildcard code where simply no wildcards are provided...
PS: I pushed a preliminary (untested) version where I tried to merge my delete command with previous one... if you can have a look and tell me what you think before I do the testing that would be appreciated, thanks!