Skip to content
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

Format bool arguments in a way it expected by kopia's cmd lib. #1849

Merged
merged 5 commits into from
Jan 9, 2023

Conversation

TimonOmsk
Copy link
Contributor

Change Overview

Kopia uses Kingpin(https://github.com/alecthomas/kingpin) lib for handling cmd args.
This lib does not allow to set bool var in k=v way. Instead it uses k\no-k format.
It means that instead of --ingore-permission-errors=false we should use --no-ignore-permission-errors argument.

From https://github.com/alecthomas/kingpin/blob/master/README.md#boolean-values

Boolean values are uniquely managed by Kingpin. Each boolean flag will have a negative complement: --<name> and --no-<name>.

Pull request type

Please check the type of change your PR introduces:

  • 🐛 Bugfix

Test Plan

  • ⚡ Unit test

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2023

Thanks for submitting this pull request 🎉. The team will review it soon and get back to you.

If you haven't already, please take a moment to review our project contributing guideline and Code of Conduct document.

@infraq infraq added this to In Progress in Kanister Jan 9, 2023
pkg/logsafe/logsafe.go Outdated Show resolved Hide resolved
Copy link
Contributor

@pchistikov pchistikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Kanister automation moved this from In Progress to Reviewer approved Jan 9, 2023
@@ -64,7 +64,7 @@ type SnapshotRestoreCommandArgs struct {
func SnapshotRestore(cmdArgs SnapshotRestoreCommandArgs) []string {
args := commonArgs(cmdArgs.CommandArgs, false)
args = args.AppendLoggable(snapshotSubCommand, restoreSubCommand, cmdArgs.SnapID, cmdArgs.TargetPath)
args = args.AppendLoggableKV(ignorePermissionsError, strconv.FormatBool(cmdArgs.IgnorePermissionErrors))
args = args.AppendLoggableBool(ignorePermissionsError, cmdArgs.IgnorePermissionErrors)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TimonOmsk Wouldn't it be simpler if we do

if cmdArgs.IgnorePermissionErrors {
    args = args.AppendLoggable(ignorePermissionsError)
} else {
    args = args.AppendLoggable(noIgnorePermissionsError)
}

noIgnorePermissionsError is a constant with --no-ignore-permission-errors value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's simpler, but we'd have to introduce 2 arguments for every single argument. I think it's up to you here. If you think it's easier I would do it :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like @pavannd1's proposal. It's simple and straightforward.

@pavannd1 pavannd1 added the kueue label Jan 9, 2023
@mergify mergify bot merged commit 48f08e1 into master Jan 9, 2023
Kanister automation moved this from Reviewer approved to Done Jan 9, 2023
@mergify mergify bot deleted the keu/dgolushko/fix_cmd_bool_vars branch January 9, 2023 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants