Skip to content

Commit

Permalink
Changed default value for pre-sign flag for lakectl fs upload and dow…
Browse files Browse the repository at this point in the history
…nload commands
  • Loading branch information
idanovo committed Sep 28, 2023
1 parent 32a23c3 commit 8137ddf
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
11 changes: 6 additions & 5 deletions cmd/lakectl/cmd/fs_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ var fsDownloadCmd = &cobra.Command{
Args: cobra.RangeArgs(fsDownloadCmdMinArgs, fsDownloadCmdMaxArgs),
Run: func(cmd *cobra.Command, args []string) {
remote, dest := getSyncArgs(args, true, false)
client := getClient()
flagSet := cmd.Flags()
parallelism := Must(flagSet.GetInt(localParallelismFlagName))
preSignMode := Must(flagSet.GetBool(localPresignFlagName))
preSignMode := Must(flagSet.GetBool("pre-sign"))
parallelism := Must(flagSet.GetInt("parallelism"))

if parallelism < 1 {
DieFmt("Invalid value for parallel (%d), minimum is 1.\n", parallelism)
DieFmt("Invalid value for parallelism (%d), minimum is 1.\n", parallelism)
}

// optional destination directory
Expand All @@ -37,6 +36,7 @@ var fsDownloadCmd = &cobra.Command{
}

ctx := cmd.Context()
client := getClient()
s := local.NewSyncManager(ctx, client, parallelism, preSignMode)
remotePath := remote.GetPath()

Expand Down Expand Up @@ -112,6 +112,7 @@ var fsDownloadCmd = &cobra.Command{

//nolint:gochecknoinits
func init() {
withSyncFlags(fsDownloadCmd)
fsDownloadCmd.Flags().Bool("pre-sign", false, "Use pre-sign link to access the data")
withParallelismFlag(fsDownloadCmd)
fsCmd.AddCommand(fsDownloadCmd)
}
12 changes: 9 additions & 3 deletions cmd/lakectl/cmd/fs_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ var fsUploadCmd = &cobra.Command{
pathURI := MustParsePathURI("path", args[0])
flagSet := cmd.Flags()
source := Must(flagSet.GetString("source"))
parallelism := Must(flagSet.GetInt(localParallelismFlagName))
preSignMode := Must(flagSet.GetBool(localPresignFlagName))
preSignMode := Must(flagSet.GetBool("pre-sign"))
parallelism := Must(flagSet.GetInt("parallelism"))
contentType := Must(flagSet.GetString("content-type"))
println("preSignMode", preSignMode)

if parallelism < 1 {
DieFmt("Invalid value for parallelism (%d), minimum is 1.\n", parallelism)
}

ctx := cmd.Context()

Expand Down Expand Up @@ -95,7 +100,8 @@ func init() {
fsUploadCmd.Flags().StringP("source", "s", "", "local file to upload, or \"-\" for stdin")
_ = fsUploadCmd.MarkFlagRequired("source")
fsUploadCmd.Flags().StringP("content-type", "", "", "MIME type of contents")
withSyncFlags(fsUploadCmd)
fsUploadCmd.Flags().Bool("pre-sign", false, "Use pre-sign link to access the data")
withParallelismFlag(fsUploadCmd)

fsCmd.AddCommand(fsUploadCmd)
}
4 changes: 2 additions & 2 deletions cmd/lakectl/cmd/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func withPresignFlag(cmd *cobra.Command) {
"Use pre-signed URLs when downloading/uploading data (recommended)")
}

func withSyncFlags(cmd *cobra.Command) {
func withLocalSyncFlags(cmd *cobra.Command) {
withParallelismFlag(cmd)
withPresignFlag(cmd)
}
Expand Down Expand Up @@ -96,7 +96,7 @@ func getLocalSyncFlags(cmd *cobra.Command, client *apigen.ClientWithResponses) s

parallelism := Must(cmd.Flags().GetInt(localParallelismFlagName))
if parallelism < 1 {
DieFmt("Invalid value for parallel (%d), minimum is 1.\n", parallelism)
DieFmt("Invalid value for parallelism (%d), minimum is 1.\n", parallelism)
}
return syncFlags{parallelism: parallelism, presign: presign}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/lakectl/cmd/local_checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ func init() {
localCheckoutCmd.Flags().Bool("all", false, "Checkout given source branch or reference for all linked directories")
localCheckoutCmd.MarkFlagsMutuallyExclusive("ref", "all")
AssignAutoConfirmFlag(localCheckoutCmd.Flags())
withSyncFlags(localCheckoutCmd)
withLocalSyncFlags(localCheckoutCmd)
localCmd.AddCommand(localCheckoutCmd)
}
2 changes: 1 addition & 1 deletion cmd/lakectl/cmd/local_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ var localCloneCmd = &cobra.Command{
//nolint:gochecknoinits
func init() {
withGitIgnoreFlag(localCloneCmd)
withSyncFlags(localCloneCmd)
withLocalSyncFlags(localCloneCmd)
localCmd.AddCommand(localCloneCmd)
}
2 changes: 1 addition & 1 deletion cmd/lakectl/cmd/local_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,6 @@ func init() {
localCommitCmd.Flags().Bool(localCommitAllowEmptyMessage, false, "Allow commit with empty message")
localCommitCmd.MarkFlagsMutuallyExclusive(localCommitMessageFlagName, localCommitAllowEmptyMessage)
localCommitCmd.Flags().StringSlice(metaFlagName, []string{}, "key value pair in the form of key=value")
withSyncFlags(localCommitCmd)
withLocalSyncFlags(localCommitCmd)
localCmd.AddCommand(localCommitCmd)
}
2 changes: 1 addition & 1 deletion cmd/lakectl/cmd/local_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ var localPullCmd = &cobra.Command{
//nolint:gochecknoinits
func init() {
withForceFlag(localPullCmd, "Reset any uncommitted local change")
withSyncFlags(localPullCmd)
withLocalSyncFlags(localPullCmd)
localCmd.AddCommand(localPullCmd)
}
4 changes: 2 additions & 2 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,7 @@ lakectl fs download <path uri> [<destination path>] [flags]
```
-h, --help help for download
-p, --parallelism int Max concurrent operations to perform (default 25)
--pre-sign Use pre-signed URLs when downloading/uploading data (recommended) (default true)
--pre-sign Use pre-sign link to access the data
```


Expand Down Expand Up @@ -2256,7 +2256,7 @@ lakectl fs upload <path uri> [flags]
--content-type string MIME type of contents
-h, --help help for upload
-p, --parallelism int Max concurrent operations to perform (default 25)
--pre-sign Use pre-signed URLs when downloading/uploading data (recommended) (default true)
--pre-sign Use pre-sign link to access the data
-s, --source string local file to upload, or "-" for stdin
```

Expand Down

0 comments on commit 8137ddf

Please sign in to comment.