added skip vetify of server cert
This commit is contained in:
+15
-13
@@ -41,6 +41,7 @@ func (util *FileUtil) CreateFileCmds() *cobra.Command {
|
||||
subCmd.PersistentFlags().StringVarP(&util.commonFileParams.Username, "user", "u", "", "Username")
|
||||
subCmd.PersistentFlags().StringVarP(&util.commonFileParams.Password, "pass", "p", "", "Password")
|
||||
subCmd.PersistentFlags().Uint64VarP(&util.commonFileParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||
subCmd.PersistentFlags().BoolVarP(&util.commonFileParams.SkipTLSVerify, "skipVerify", "S", true, "Skip server certificate verify")
|
||||
subCmd.MarkPersistentFlagRequired("host")
|
||||
subCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||
|
||||
@@ -181,9 +182,10 @@ type FileUtil struct {
|
||||
}
|
||||
|
||||
type CommonFileParams struct {
|
||||
Username string
|
||||
Password string
|
||||
Timeout uint64
|
||||
Username string
|
||||
Password string
|
||||
Timeout uint64
|
||||
SkipTLSVerify bool
|
||||
}
|
||||
|
||||
// FileInfo
|
||||
@@ -209,7 +211,7 @@ func (util *FileUtil) fileInfo(common *CommonFileParams, params *FileInfoParams)
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
exists, opres, err := client.NewClient().FileInfo(ctx, params.Filepath)
|
||||
exists, opres, err := client.NewClient(common.SkipTLSVerify).FileInfo(ctx, params.Filepath)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -244,7 +246,7 @@ func (util *FileUtil) putFile(common *CommonFileParams, params *PutFileParams) (
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
err = client.NewClient().PutFile(ctx, params.Source, params.Dest)
|
||||
err = client.NewClient(common.SkipTLSVerify).PutFile(ctx, params.Source, params.Dest)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -275,7 +277,7 @@ func (util *FileUtil) getFile(common *CommonFileParams, params *GetFileParams) (
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
_, err = client.NewClient().GetFile(ctx, params.Dest, params.Source)
|
||||
_, err = client.NewClient(common.SkipTLSVerify).GetFile(ctx, params.Dest, params.Source)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -303,7 +305,7 @@ func (util *FileUtil) deleteFile(common *CommonFileParams, params *DeleteFilePar
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
err = client.NewClient().DeleteFile(ctx, params.Filepath)
|
||||
err = client.NewClient(common.SkipTLSVerify).DeleteFile(ctx, params.Filepath)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -349,7 +351,7 @@ func (util *FileUtil) listFiles(common *CommonFileParams, params *ListFilesParam
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
files, err := client.NewClient().ListFiles(ctx, params.Filepath, pathUsage)
|
||||
files, err := client.NewClient(common.SkipTLSVerify).ListFiles(ctx, params.Filepath, pathUsage)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -413,7 +415,7 @@ func (util *FileUtil) importFiles(common *CommonFileParams, params *ImportFilesP
|
||||
putErrors = append(putErrors, err)
|
||||
return nil
|
||||
}
|
||||
err = client.NewClient().PutFile(ctx, walkPath, dest)
|
||||
err = client.NewClient(common.SkipTLSVerify).PutFile(ctx, walkPath, dest)
|
||||
if err != nil {
|
||||
putErrors = append(putErrors, err)
|
||||
fmt.Printf("- %s: error: %v \n", walkPath, err)
|
||||
@@ -475,7 +477,7 @@ func (util *FileUtil) exportFiles(common *CommonFileParams, params *ExportFilesP
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
files, err := client.NewClient().ListFiles(ctx, params.Filepath, pathUsage)
|
||||
files, err := client.NewClient(common.SkipTLSVerify).ListFiles(ctx, params.Filepath, pathUsage)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -494,7 +496,7 @@ func (util *FileUtil) exportFiles(common *CommonFileParams, params *ExportFilesP
|
||||
destpath := filepath.Join(params.Dest, file.Collection, file.Name)
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
_, err = client.NewClient().GetFile(ctx, srcpath, destpath)
|
||||
_, err = client.NewClient(common.SkipTLSVerify).GetFile(ctx, srcpath, destpath)
|
||||
if err != nil {
|
||||
fmt.Printf("- %s: error %v\n", srcpath, err)
|
||||
//return res, err
|
||||
@@ -564,7 +566,7 @@ func (util *FileUtil) listCollections(common *CommonFileParams, params *ListColl
|
||||
}
|
||||
timeout := time.Duration(common.Timeout) * time.Second
|
||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||
collecions, err := client.NewClient().ListCollections(ctx, params.Path, pathUsage)
|
||||
collecions, err := client.NewClient(common.SkipTLSVerify).ListCollections(ctx, params.Path, pathUsage)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
@@ -610,7 +612,7 @@ func (util *FileUtil) deleteCollection(common *CommonFileParams, params *DeleteC
|
||||
default:
|
||||
pathUsage = terms.AsFinePath
|
||||
}
|
||||
files, err := client.NewClient().DeleteCollection(ctx, params.Path, pathUsage, params.DryRun)
|
||||
files, err := client.NewClient(common.SkipTLSVerify).DeleteCollection(ctx, params.Path, pathUsage, params.DryRun)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user