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

command buckets converted to the cobra style #859

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tommyshem
Copy link

issue #472 Migrate all commands to cobra style commands

converted buckets command to cobra style

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tommyshem
Once this PR has been reviewed and has the lgtm label, please assign serathius for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link

Hi @tommyshem. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ivanvc
Copy link
Member

ivanvc commented Nov 11, 2024

Hi @tommyshem, thanks for your pull request. Could you please sign your commit? So the developer certificate of origin (DCO) check passes, i.e:

git rebase HEAD~1 --signoff
git push --force

Thanks!

Ref: https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#commit-your-change

/ok-to-test

@ahrtr
Copy link
Member

ahrtr commented Nov 11, 2024

Thanks for raising the PR. It doesn't break the user experience, so I agree to get this PR included in 1.4.

Please resolve the test failure in case TestBucketsCommand_Run.

Copy link
Author

Choose a reason for hiding this comment

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

changed the output so it could be tested in the future

Copy link
Author

Choose a reason for hiding this comment

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

removed the tests and put them in the buckets test file

@ahrtr
Copy link
Member

ahrtr commented Nov 12, 2024

Copy link
Author

Choose a reason for hiding this comment

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

not sure how to delete this as upload by mistake

Copy link
Member

Choose a reason for hiding this comment

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

I think running git rm cmd/bbolt/bbolt.exe should work, as the file is not ignored. If it doesn't work, you can try adding -f, i.e., git rm -f cmd/bbolt/bbolt.exe.

You'll then need to do a commit.

@tommyshem
Copy link
Author

Should be finished now for review.
But some how I upload the bbolt.exe in the pull request and I don't know how to remove it.

Comment on lines 18 to 20
fmt.Fprintln(cmd.OutOrStdout(), "bbolt Version: ", version.Version)
fmt.Fprintln(cmd.OutOrStdout(), "Go Version: ", runtime.Version())
fmt.Fprintln(cmd.OutOrStdout(), "Go OS/Arch: ", runtime.GOOS, "/", runtime.GOARCH)
Copy link
Member

Choose a reason for hiding this comment

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

One PR only does one thing. Please don't make unrelated change.

@tommyshem
Copy link
Author

Removed the bolt.exe file and the command_version.go file.
So it should be just the buckets command change now hopefully.

Comment on lines +11 to +13
// newBucketsCommand creates a new command that prints a list of buckets in the given Bolt database.
//
// The path to a Bolt database must be specified as an argument.
Copy link
Member

Choose a reason for hiding this comment

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

It's unnecessary comment to me. The command is self-explanation.

Suggested change
// newBucketsCommand creates a new command that prints a list of buckets in the given Bolt database.
//
// The path to a Bolt database must be specified as an argument.

Comment on lines +17 to +22
Short: "Print a list of buckets",
Long: "Print a list of buckets in the given Bolt database\nThe path to a Bolt database must be specified as an argument",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return printBucketsList(cmd, args[0])
},
Copy link
Member

Choose a reason for hiding this comment

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

Please try to keep consistent with other commands implementation.

Suggested change
Short: "Print a list of buckets",
Long: "Print a list of buckets in the given Bolt database\nThe path to a Bolt database must be specified as an argument",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return printBucketsList(cmd, args[0])
},
Short: "print a list of buckets",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
return bucketsFunc(args[0])
},

// Verify if the specified database file exists.
} else if _, err := os.Stat(path); os.IsNotExist(err) {
return ErrFileNotFound
}
Copy link
Member

Choose a reason for hiding this comment

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

Please use checkSourceDBPath. See example below,

if _, err := checkSourceDBPath(srcDBPath); err != nil {

}

// executeCommand runs the given command and returns the output and error.
func executeCommand(rootCmd *cobra.Command, args ...string) (*cobra.Command, string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we just remove this function and get the implementation inlined in the test?

If you want to make it as a generic test utility function (i.e. included in utils_test.go), let's do it in a followup PR and we can discuss it separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants