-
Notifications
You must be signed in to change notification settings - Fork 367
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 --storage-id flag to Repo Create CLI #8557
Conversation
🎊 PR Preview 2049918 has been successfully built and deployed to https://treeverse-lakeFS-preview-pr-8557.surge.sh 🕐 Build time: 0.01s 🤖 By surge-preview |
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.
Thanks!
Some comments regarding documentation +
Please add esti tests
I have some reservations on documenting this parameter ATM.
Also, lets have a discussion on this in a different forum
cmd/lakectl/cmd/repo_create.go
Outdated
@@ -16,7 +16,7 @@ const ( | |||
|
|||
// repoCreateCmd represents the create repo command | |||
var repoCreateCmd = &cobra.Command{ | |||
Use: "create <repository URI> <storage namespace>", | |||
Use: "create <repository URI> <storage namespace> [--storage-id <storage id>]", |
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.
Lets not document this flag ATM and open an issue to discuss that
cmd/lakectl/cmd/repo_create.go
Outdated
@@ -48,6 +52,7 @@ var repoCreateCmd = &cobra.Command{ | |||
//nolint:gochecknoinits | |||
func init() { | |||
repoCreateCmd.Flags().StringP("default-branch", "d", DefaultBranch, "the default branch of this repository") | |||
repoCreateCmd.Flags().String("storage-id", "", "the storage of this repository") |
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.
Suggest we make this a hidden flag for now
cmd/lakectl/cmd/repo_create_bare.go
Outdated
@@ -10,7 +10,7 @@ import ( | |||
|
|||
// repoCreateBareCmd represents the create repo command | |||
var repoCreateBareCmd = &cobra.Command{ | |||
Use: "create-bare <repository URI> <storage namespace>", | |||
Use: "create-bare <repository URI> <storage namespace> [--storage-id <storage id>]", |
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.
Same comments as the "create" command
@N-o-Z regarding esti - Any other esti tests you think should be added? |
We should test 2 things:
|
Add the first, @N-o-Z Can you think of a way to test this, or are you OK with having the Config tests covering this part? |
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.
Looks good.
Still missing a couple of things
cmd/lakectl/cmd/repo_create.go
Outdated
@@ -52,7 +52,7 @@ var repoCreateCmd = &cobra.Command{ | |||
//nolint:gochecknoinits | |||
func init() { | |||
repoCreateCmd.Flags().StringP("default-branch", "d", DefaultBranch, "the default branch of this repository") | |||
repoCreateCmd.Flags().String("storage-id", "", "the storage of this repository") | |||
repoCreateCmd.Flags().String("storage-id", "", "") |
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.
Can you please define the storage-id flag globally (see withNoProgress
as example) and set its property to hidden so it won't show up in the CLI docs (MarkHidden
)
esti/lakectl_test.go
Outdated
"BRANCH": mainBranch, | ||
} | ||
RunCmdAndVerifySuccessWithFile(t, Lakectl()+" repo create lakefs://"+repoNameSID+" "+storageSID+" --storage-id \"\"", false, "lakectl_repo_create", vars) | ||
|
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 it would be better to separate this into a different test.
Also, missing the failure scenario when running it with storage_id != ""
@N-o-Z fixed - |
# Conflicts: # cmd/lakectl/cmd/repo_create.go # docs/reference/cli.md
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.
Looks good- added a few comments
cmd/lakectl/cmd/repo_create.go
Outdated
|
||
defaultBranch, err := cmd.Flags().GetString(defaultBranchFlagName) | ||
if err != nil { | ||
DieErr(err) |
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.
What is the difference between the Must and this error handling? What is the reason for this change?
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 it's some merges mixed up.
Updating.
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.
Following a talk with @N-o-Z -
Changed it to Must
. Same effect, also for optional params.
cmd/lakectl/cmd/repo_create.go
Outdated
DieErr(err) | ||
} | ||
sampleData := Must(cmd.Flags().GetBool(sampleDataFlagName)) | ||
storageID, _ := cmd.Flags().GetString(storageIDFlagName) |
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.
Why ignore the error?
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.
Since it's an optional param.
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.
There are other possible errors than "flag accessed but not defined"
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.
Thanks.
Added error handling for this (obviously, copied from other commands).
@@ -187,6 +188,13 @@ func withRecursiveFlag(cmd *cobra.Command, usage string) { | |||
cmd.Flags().BoolP(recursiveFlagName, recursiveFlagShort, false, usage) | |||
} | |||
|
|||
func withStorageID(cmd *cobra.Command) { |
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.
Clean code- add a one line comment explaining what this does
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.
Isn't clean code about self-explained code?
And again, StorageID
is not very documented in the OSS at the moment,
And this a part of it.
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, hmm I find it takes me a while to read this function and understand what I'm looking at. Maybe a better function name rather than a comment? Maybe it should be addStorageID? withStorageID sounds like it's more of a query checking if the command has this flag than a command that does something
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.
This is the convention for global flags in lakectl...
(See @N-o-Z 's comment on this PR.)
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.
@nadavsteindler thanks.
Addressed - PTAL again.
cmd/lakectl/cmd/repo_create.go
Outdated
DieErr(err) | ||
} | ||
sampleData := Must(cmd.Flags().GetBool(sampleDataFlagName)) | ||
storageID, _ := cmd.Flags().GetString(storageIDFlagName) |
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.
Since it's an optional param.
@@ -187,6 +188,13 @@ func withRecursiveFlag(cmd *cobra.Command, usage string) { | |||
cmd.Flags().BoolP(recursiveFlagName, recursiveFlagShort, false, usage) | |||
} | |||
|
|||
func withStorageID(cmd *cobra.Command) { |
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.
Isn't clean code about self-explained code?
And again, StorageID
is not very documented in the OSS at the moment,
And this a part of it.
cmd/lakectl/cmd/repo_create.go
Outdated
|
||
defaultBranch, err := cmd.Flags().GetString(defaultBranchFlagName) | ||
if err != nil { | ||
DieErr(err) |
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 it's some merges mixed up.
Updating.
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.
Thanks!
Approved with 2 comments that need to be addressed
cmd/lakectl/cmd/repo_create.go
Outdated
|
||
defaultBranch := Must(cmd.Flags().GetString(defaultBranchFlagName)) | ||
sampleData := Must(cmd.Flags().GetBool(sampleDataFlagName)) | ||
storageID, err := cmd.Flags().GetString(storageIDFlagName) |
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.
Should also be under a Must
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.
Isn't the --storage flag optional for the OSS?
cmd/lakectl/cmd/repo_create_bare.go
Outdated
} | ||
|
||
defaultBranch := Must(cmd.Flags().GetString(defaultBranchFlagName)) | ||
storageID, _ := cmd.Flags().GetString(storageIDFlagName) |
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.
Must
Closes #8511.
Change Description
Support creating a repository with storageID in the CLI.