-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Add/update SMTP auth providers via cli #18197
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
The document differs (
--skip-verify
vs--skip-verify=false
):ps: the document says
--id
instead of the-id
in the example.Since most options are shared/common, maybe we can also group these options:
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.
All bool options uses BoolTFlag which allows using
--option=[true|false]
format and--option
defaults to true. If option is not specified than those option is not changed. See github.com/urfave/cli.Many of BoolFlag options in cli should be migrated to BoolTFlag as there is no way to disable those options. See my remark in #18197 (comment)
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.
So usually just not setting the option is the best way of indicating that the option is meant to be false but if BoolTFlag allows both then that's fine.
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.
Omitting option for false is fine in 'add-smtp'. But in 'update-smtp' that behavior would require specifying all enabled options on every call. With my approach you could just do
gitea admin auth update-smtp --id 1 --active=false
to deactivate provider without changing or specifying other options.At first I replicated
add-oauth
andupdate-oauth
approach but in runUpdateOauth they also ended with "change needed options" instead of "change all on every call". Their approach is fine for string options as you could specify --flag="" but not for bool options. As a example to implementskip-local-2fa
option handling inrunUpdateOauth
we could:which would not allow us to disable option as omitting options would just leave last value.
which would always set option. But omitting option would change it to false which would be contrary to approach for other options.
which would set option to value specified (either true or false) or leave option unchanged if omitted.
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.
ps: I meant that the documents differ foradd
andupdate
.* Foradd
: it says--skip-verify --active
(and, does--skip-verify
work with BoolT correctly? undefined behavior?)* Forupdate
: it says--skip-verify=false
It confuses readers.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.
Hmm ... the cli library does that trick, so
--option
is the same as--option=true
.👍 No question from my side.
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.
Urfave cli library is really poorly documented. It took a while till I stumbled on right option.