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

Add --storage-id flag to Repo Create CLI #8557

Merged
merged 19 commits into from
Feb 10, 2025
Merged
4 changes: 2 additions & 2 deletions cmd/lakectl/cmd/repo_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (

// repoCreateCmd represents the create repo command
var repoCreateCmd = &cobra.Command{
Use: "create <repository URI> <storage namespace> [--storage-id <storage id>]",
Use: "create <repository URI> <storage namespace>",
Short: "Create a new repository",
Example: "lakectl repo create " + myRepoExample + " " + myBucketExample,
Args: cobra.ExactArgs(repoCreateCmdArgs),
Expand Down Expand Up @@ -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", "", "")
Copy link
Member

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)


repoCmd.AddCommand(repoCreateCmd)
}
4 changes: 2 additions & 2 deletions cmd/lakectl/cmd/repo_create_bare.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// repoCreateBareCmd represents the create repo command
var repoCreateBareCmd = &cobra.Command{
Use: "create-bare <repository URI> <storage namespace> [--storage-id <storage id>]",
Use: "create-bare <repository URI> <storage namespace>",
Short: "Create a new repository with no initial branch or commit",
Example: "lakectl create-bare " + myRepoExample + " " + myBucketExample,
Hidden: true,
Expand Down Expand Up @@ -49,7 +49,7 @@ var repoCreateBareCmd = &cobra.Command{
//nolint:gochecknoinits
func init() {
repoCreateBareCmd.Flags().StringP("default-branch", "d", DefaultBranch, "the default branch name of this repository (will not be created)")
repoCreateBareCmd.Flags().String("storage-id", "", "the storage of this repository")
repoCreateBareCmd.Flags().String("storage-id", "", "")

repoCmd.AddCommand(repoCreateBareCmd)
}
8 changes: 4 additions & 4 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -2610,7 +2610,7 @@ Manage and explore repos
Create a new repository

```
lakectl repo create <repository URI> <storage namespace> [--storage-id <storage id>] [flags]
lakectl repo create <repository URI> <storage namespace> [flags]
```

#### Examples
Expand All @@ -2626,7 +2626,7 @@ lakectl repo create lakefs://my-repo s3://my-bucket
```
-d, --default-branch string the default branch of this repository (default "main")
-h, --help help for create
--storage-id string the storage of this repository
--storage-id string
```


Expand Down Expand Up @@ -2709,7 +2709,7 @@ lakeFS plumbing command. Don't use unless you're _really_ sure you know what you
Create a new repository with no initial branch or commit

```
lakectl repo create-bare <repository URI> <storage namespace> [--storage-id <storage id>] [flags]
lakectl repo create-bare <repository URI> <storage namespace> [flags]
```

#### Examples
Expand All @@ -2725,7 +2725,7 @@ lakectl create-bare lakefs://my-repo s3://my-bucket
```
-d, --default-branch string the default branch name of this repository (will not be created) (default "main")
-h, --help help for create-bare
--storage-id string the storage of this repository
--storage-id string
```


Expand Down
10 changes: 10 additions & 0 deletions esti/lakectl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ func TestLakectlBasicRepoActions(t *testing.T) {
newStorage := storage + "/new-storage/"
RunCmdAndVerifyFailureWithFile(t, Lakectl()+" repo create lakefs://"+repoName+" "+newStorage, false, "lakectl_repo_create_not_unique", vars)

// Validate the --storage-id flag (currently only allowed to be empty)
repoNameSID := generateUniqueRepositoryName()
storageSID := generateUniqueStorageNamespace(repoNameSID)
vars = map[string]string{
"REPO": repoNameSID,
"STORAGE": storageSID,
"BRANCH": mainBranch,
}
RunCmdAndVerifySuccessWithFile(t, Lakectl()+" repo create lakefs://"+repoNameSID+" "+storageSID+" --storage-id \"\"", false, "lakectl_repo_create", vars)

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 it would be better to separate this into a different test.
Also, missing the failure scenario when running it with storage_id != ""

// Fails due to the usage of repos for isolation - esti creates repos in parallel and
// the output of 'repo list' command cannot be well-defined
// RunCmdAndVerifySuccessWithFile(t, Lakectl()+" repo list", false, "lakectl_repo_list_1", vars)
Expand Down
Loading