-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Shortcircuit commands with version or help flags #7683
Merged
Merged
Conversation
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
Signed-off-by: Derek Nola <[email protected]>
Signed-off-by: Derek Nola <[email protected]>
briandowns
approved these changes
Jun 7, 2023
brandond
approved these changes
Jun 7, 2023
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #7683 +/- ##
==========================================
+ Coverage 47.55% 51.91% +4.35%
==========================================
Files 141 141
Lines 14347 14358 +11
==========================================
+ Hits 6823 7454 +631
+ Misses 6442 5728 -714
- Partials 1082 1176 +94
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
dereknola
added a commit
to dereknola/k3s
that referenced
this pull request
Jun 8, 2023
* Shortcircuit search with help and version flag Signed-off-by: Derek Nola <[email protected]> * Keep functions seperate Signed-off-by: Derek Nola <[email protected]> --------- Signed-off-by: Derek Nola <[email protected]>
dereknola
added a commit
to dereknola/k3s
that referenced
this pull request
Jun 8, 2023
* Shortcircuit search with help and version flag Signed-off-by: Derek Nola <[email protected]> * Keep functions seperate Signed-off-by: Derek Nola <[email protected]> --------- Signed-off-by: Derek Nola <[email protected]>
dereknola
added a commit
that referenced
this pull request
Jun 8, 2023
* Bump docker go.mod (#7681) * Shortcircuit commands with version or help flags (#7683) * Fix for longhorn integration test * Add Rotation certification Check (#7097) * Add Certification Test to Validate Cluster * Fix to stop/start for k3s certificate rotation * E2E: Use sudo for all RunCmdOnNode * Remove unnecessary daemonset addition/deletion Signed-off-by: Derek Nola <[email protected]> Signed-off-by: est-suse <[email protected]> Signed-off-by: Brad Davidson <[email protected]> Co-authored-by: Esteban Esquivel Alvarado <[email protected]> Co-authored-by: est-suse <[email protected]> Co-authored-by: Brad Davidson <[email protected]>
dereknola
added a commit
that referenced
this pull request
Jun 9, 2023
* Shortcircuit search with help and version flag Signed-off-by: Derek Nola <[email protected]> * Keep functions seperate Signed-off-by: Derek Nola <[email protected]> --------- Signed-off-by: Derek Nola <[email protected]>
dereknola
added a commit
to dereknola/k3s
that referenced
this pull request
Jun 9, 2023
* Shortcircuit search with help and version flag Signed-off-by: Derek Nola <[email protected]> * Keep functions seperate Signed-off-by: Derek Nola <[email protected]> --------- Signed-off-by: Derek Nola <[email protected]>
dereknola
added a commit
that referenced
this pull request
Jun 10, 2023
* Shortcircuit search with help and version flag Signed-off-by: Derek Nola <[email protected]> * Keep functions seperate Signed-off-by: Derek Nola <[email protected]> --------- Signed-off-by: Derek Nola <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposed Changes
Before attempting to open config files, we check if the arguments provided contain a
--version, -v, --help, -h
flag. If so, we shortcircuit the search. As-h
and-v
flags always override the given command anyway, this enables users who do not have permission to access/etc/rancher/k3s/config.yaml
or other root guarded files to still run these basic commands.Types of Changes
Verification
touch /etc/rancher/k3s/config.yaml
sudo chmod 700 /etc/rancher/k3s/config.yaml
k3s --help
,k3s --version
,k3s -h
,k3s server -h
. Note that these commands now complete successfully.Testing
Linked Issues
#4321
User-Facing Change
Further Comments
This change is injected into
FindString
because this function is called when attemtping to finddata-dir
orprefer-bundled-bin
arguments before running a command.FindString
in turn attempts to open the default config file (/etc/rancher/k3s/config.yaml
), and if permission is not given on that file, the whole process will fail.