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

Breaking Change: Update commit ref to commit URI for lakectl tag create command #3017

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions cmd/lakectl/cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,26 @@ var tagListCmd = &cobra.Command{
}

var tagCreateCmd = &cobra.Command{
Use: "create <tag uri> <commit ref>",
Use: "create <tag uri> <commit uri>",
Short: "Create a new tag in a repository",
Example: "lakectl tag create lakefs://example-repo/example-tag 2397cc9a9d04c20a4e5739b42c1dd3d8ba655c0b3a3b974850895a13d8bf9917",
Example: "lakectl tag create lakefs://example-repo/example-tag lakefs://example-repo/2397cc9a9d04c20a4e5739b42c1dd3d8ba655c0b3a3b974850895a13d8bf9917",
Args: cobra.ExactArgs(tagCreateRequiredArgs),
Run: func(cmd *cobra.Command, args []string) {
tagURI := MustParseRefURI("tag", args[0])
tagURI := MustParseRefURI("tag uri", args[0])
commitURI := MustParseRefURI("commit uri", args[1])
Fmt("Tag ref: %s\n", tagURI.String())

client := getClient()
commitRef := args[1]
ctx := cmd.Context()
force, _ := cmd.Flags().GetBool("force")

if tagURI.Repository != commitURI.Repository {
Die("both references must belong to the same repository", 1)
}

if force {
// checking validity of the commitRef before deleting the old one
res, err := client.GetCommitWithResponse(ctx, tagURI.Repository, commitRef)
res, err := client.GetCommitWithResponse(ctx, tagURI.Repository, commitURI.Ref)
DieOnErrorOrUnexpectedStatusCode(res, err, http.StatusOK)

resp, err := client.DeleteTagWithResponse(ctx, tagURI.Repository, tagURI.Ref)
Expand All @@ -88,7 +93,7 @@ var tagCreateCmd = &cobra.Command{

resp, err := client.CreateTagWithResponse(ctx, tagURI.Repository, api.CreateTagJSONRequestBody{
Id: tagURI.Ref,
Ref: commitRef,
Ref: commitURI.Ref,
})
DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusCreated)

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -2558,14 +2558,14 @@ Create delete and list tags within a lakeFS repository
Create a new tag in a repository

```
lakectl tag create <tag uri> <commit ref> [flags]
lakectl tag create <tag uri> <commit uri> [flags]
```

#### Examples
{:.no_toc}

```
lakectl tag create lakefs://example-repo/example-tag 2397cc9a9d04c20a4e5739b42c1dd3d8ba655c0b3a3b974850895a13d8bf9917
lakectl tag create lakefs://example-repo/example-tag lakefs://example-repo/2397cc9a9d04c20a4e5739b42c1dd3d8ba655c0b3a3b974850895a13d8bf9917
```

#### Options
Expand Down