added skip vetify of server cert
This commit is contained in:
+21
-20
@@ -38,10 +38,11 @@ type AccountUtil struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CommonAccountParams struct {
|
type CommonAccountParams struct {
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
Hostname string
|
Hostname string
|
||||||
Timeout uint64
|
Timeout uint64
|
||||||
|
SkipTLSVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (util *AccountUtil) CreateAccountCmds() *cobra.Command {
|
func (util *AccountUtil) CreateAccountCmds() *cobra.Command {
|
||||||
@@ -52,10 +53,11 @@ func (util *AccountUtil) CreateAccountCmds() *cobra.Command {
|
|||||||
}
|
}
|
||||||
const defaultTimeout uint64 = 10
|
const defaultTimeout uint64 = 10
|
||||||
|
|
||||||
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Username, "user", "u", util.commonAccountParams.Username, "Username")
|
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Username, "user", "U", util.commonAccountParams.Username, "Username")
|
||||||
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Password, "pass", "p", util.commonAccountParams.Password, "Password")
|
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Password, "pass", "P", util.commonAccountParams.Password, "Password")
|
||||||
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Hostname, "host", "x", defaultHostname, "Hostname")
|
subCmd.PersistentFlags().StringVarP(&util.commonAccountParams.Hostname, "host", "X", defaultHostname, "Hostname")
|
||||||
subCmd.PersistentFlags().Uint64VarP(&util.commonAccountParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
subCmd.PersistentFlags().Uint64VarP(&util.commonAccountParams.Timeout, "timeout", "T", defaultTimeout, "Operation timeout")
|
||||||
|
subCmd.PersistentFlags().BoolVarP(&util.commonAccountParams.SkipTLSVerify, "skipVerify", "S", true, "Skip server certificate verify")
|
||||||
subCmd.MarkFlagsRequiredTogether("user", "pass")
|
subCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
|
||||||
vi := viper.New()
|
vi := viper.New()
|
||||||
@@ -90,8 +92,8 @@ func (util *AccountUtil) CreateAccountCmds() *cobra.Command {
|
|||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
Run: util.UpdateAccount,
|
Run: util.UpdateAccount,
|
||||||
}
|
}
|
||||||
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.NewUsername, "newname", "N", "", "New username")
|
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.NewUsername, "newname", "u", "", "New username")
|
||||||
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.NewPassword, "newpass", "P", "", "New password")
|
updateAccountCmd.Flags().StringVarP(&util.updateAccountParams.NewPassword, "newpass", "p", "", "New password")
|
||||||
updateAccountCmd.MarkFlagsOneRequired("newname", "newpass")
|
updateAccountCmd.MarkFlagsOneRequired("newname", "newpass")
|
||||||
subCmd.AddCommand(updateAccountCmd)
|
subCmd.AddCommand(updateAccountCmd)
|
||||||
|
|
||||||
@@ -102,7 +104,6 @@ func (util *AccountUtil) CreateAccountCmds() *cobra.Command {
|
|||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
Run: util.DeleteAccount,
|
Run: util.DeleteAccount,
|
||||||
}
|
}
|
||||||
deleteAccountCmd.Flags().StringVarP(&util.updateAccountParams.AccountID, "name", "n", "", "Account ID or username")
|
|
||||||
subCmd.AddCommand(deleteAccountCmd)
|
subCmd.AddCommand(deleteAccountCmd)
|
||||||
|
|
||||||
// ListAccount
|
// ListAccount
|
||||||
@@ -148,7 +149,7 @@ func (util *AccountUtil) createAccount(common *CommonAccountParams, params *Crea
|
|||||||
}
|
}
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||||
accountID, err := client.NewClient().CreateAccount(ctx, hostname, params.NewUsername, params.NewPassword)
|
accountID, err := client.NewClient(common.SkipTLSVerify).CreateAccount(ctx, hostname, params.NewUsername, params.NewPassword)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -162,7 +163,7 @@ func (util *AccountUtil) createAccount(common *CommonAccountParams, params *Crea
|
|||||||
terms.RightReadImages,
|
terms.RightReadImages,
|
||||||
}
|
}
|
||||||
for _, right := range fullRights {
|
for _, right := range fullRights {
|
||||||
id, err := client.NewClient().CreateGrantByAccountID(ctx, hostname, accountID, right, ".*")
|
id, err := client.NewClient(common.SkipTLSVerify).CreateGrantByAccountID(ctx, hostname, accountID, right, ".*")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -202,9 +203,9 @@ func (util *AccountUtil) updateAccount(common *CommonAccountParams, params *Upda
|
|||||||
re := regexp.MustCompile(uuidRegex)
|
re := regexp.MustCompile(uuidRegex)
|
||||||
id := strings.ToLower(params.AccountID)
|
id := strings.ToLower(params.AccountID)
|
||||||
if re.MatchString(id) {
|
if re.MatchString(id) {
|
||||||
err = client.NewClient().UpdateAccountByID(ctx, hostname, id, params.NewUsername, params.NewPassword)
|
err = client.NewClient(common.SkipTLSVerify).UpdateAccountByID(ctx, hostname, id, params.NewUsername, params.NewPassword)
|
||||||
} else {
|
} else {
|
||||||
err = client.NewClient().UpdateAccountByName(ctx, hostname, params.AccountID, params.NewUsername, params.NewPassword)
|
err = client.NewClient(common.SkipTLSVerify).UpdateAccountByName(ctx, hostname, params.AccountID, params.NewUsername, params.NewPassword)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
@@ -243,9 +244,9 @@ func (util *AccountUtil) getAccount(common *CommonAccountParams, params *GetAcco
|
|||||||
re := regexp.MustCompile(uuidRegex)
|
re := regexp.MustCompile(uuidRegex)
|
||||||
id := strings.ToLower(params.AccountID)
|
id := strings.ToLower(params.AccountID)
|
||||||
if re.MatchString(id) {
|
if re.MatchString(id) {
|
||||||
opRes, err = client.NewClient().GetAccountByID(ctx, hostname, id)
|
opRes, err = client.NewClient(common.SkipTLSVerify).GetAccountByID(ctx, hostname, id)
|
||||||
} else {
|
} else {
|
||||||
opRes, err = client.NewClient().GetAccountByName(ctx, hostname, params.AccountID)
|
opRes, err = client.NewClient(common.SkipTLSVerify).GetAccountByName(ctx, hostname, params.AccountID)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
@@ -280,9 +281,9 @@ func (util *AccountUtil) deleteAccount(common *CommonAccountParams, params *Dele
|
|||||||
re := regexp.MustCompile(uuidRegex)
|
re := regexp.MustCompile(uuidRegex)
|
||||||
id := strings.ToLower(params.AccountID)
|
id := strings.ToLower(params.AccountID)
|
||||||
if re.MatchString(id) {
|
if re.MatchString(id) {
|
||||||
err = client.NewClient().DeleteAccountByID(ctx, hostname, id)
|
err = client.NewClient(common.SkipTLSVerify).DeleteAccountByID(ctx, hostname, id)
|
||||||
} else {
|
} else {
|
||||||
err = client.NewClient().DeleteAccountByName(ctx, hostname, params.AccountID)
|
err = client.NewClient(common.SkipTLSVerify).DeleteAccountByName(ctx, hostname, params.AccountID)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
@@ -327,7 +328,7 @@ func (util *AccountUtil) listAccounts(common *CommonAccountParams, params *ListA
|
|||||||
|
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||||
accounts, err := client.NewClient().ListAccounts(ctx, hostname)
|
accounts, err := client.NewClient(common.SkipTLSVerify).ListAccounts(ctx, hostname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
+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.Username, "user", "u", "", "Username")
|
||||||
subCmd.PersistentFlags().StringVarP(&util.commonFileParams.Password, "pass", "p", "", "Password")
|
subCmd.PersistentFlags().StringVarP(&util.commonFileParams.Password, "pass", "p", "", "Password")
|
||||||
subCmd.PersistentFlags().Uint64VarP(&util.commonFileParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
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.MarkPersistentFlagRequired("host")
|
||||||
subCmd.MarkFlagsRequiredTogether("user", "pass")
|
subCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
|
||||||
@@ -181,9 +182,10 @@ type FileUtil struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CommonFileParams struct {
|
type CommonFileParams struct {
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
Timeout uint64
|
Timeout uint64
|
||||||
|
SkipTLSVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileInfo
|
// FileInfo
|
||||||
@@ -209,7 +211,7 @@ func (util *FileUtil) fileInfo(common *CommonFileParams, params *FileInfoParams)
|
|||||||
}
|
}
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
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 {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -244,7 +246,7 @@ func (util *FileUtil) putFile(common *CommonFileParams, params *PutFileParams) (
|
|||||||
}
|
}
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
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 {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -275,7 +277,7 @@ func (util *FileUtil) getFile(common *CommonFileParams, params *GetFileParams) (
|
|||||||
}
|
}
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
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 {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -303,7 +305,7 @@ func (util *FileUtil) deleteFile(common *CommonFileParams, params *DeleteFilePar
|
|||||||
}
|
}
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
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 {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -349,7 +351,7 @@ func (util *FileUtil) listFiles(common *CommonFileParams, params *ListFilesParam
|
|||||||
}
|
}
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
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 {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -413,7 +415,7 @@ func (util *FileUtil) importFiles(common *CommonFileParams, params *ImportFilesP
|
|||||||
putErrors = append(putErrors, err)
|
putErrors = append(putErrors, err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err = client.NewClient().PutFile(ctx, walkPath, dest)
|
err = client.NewClient(common.SkipTLSVerify).PutFile(ctx, walkPath, dest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
putErrors = append(putErrors, err)
|
putErrors = append(putErrors, err)
|
||||||
fmt.Printf("- %s: error: %v \n", walkPath, 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
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
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 {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -494,7 +496,7 @@ func (util *FileUtil) exportFiles(common *CommonFileParams, params *ExportFilesP
|
|||||||
destpath := filepath.Join(params.Dest, file.Collection, file.Name)
|
destpath := filepath.Join(params.Dest, file.Collection, file.Name)
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
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 {
|
if err != nil {
|
||||||
fmt.Printf("- %s: error %v\n", srcpath, err)
|
fmt.Printf("- %s: error %v\n", srcpath, err)
|
||||||
//return res, err
|
//return res, err
|
||||||
@@ -564,7 +566,7 @@ func (util *FileUtil) listCollections(common *CommonFileParams, params *ListColl
|
|||||||
}
|
}
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
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 {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -610,7 +612,7 @@ func (util *FileUtil) deleteCollection(common *CommonFileParams, params *DeleteC
|
|||||||
default:
|
default:
|
||||||
pathUsage = terms.AsFinePath
|
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 {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-11
@@ -33,6 +33,7 @@ func (util *GrantUtil) CreateGrantCmds() *cobra.Command {
|
|||||||
subCmd.PersistentFlags().StringVarP(&util.commonGrantParams.Username, "user", "u", "", "Username")
|
subCmd.PersistentFlags().StringVarP(&util.commonGrantParams.Username, "user", "u", "", "Username")
|
||||||
subCmd.PersistentFlags().StringVarP(&util.commonGrantParams.Password, "pass", "p", "", "Password")
|
subCmd.PersistentFlags().StringVarP(&util.commonGrantParams.Password, "pass", "p", "", "Password")
|
||||||
subCmd.PersistentFlags().Uint64VarP(&util.commonGrantParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
subCmd.PersistentFlags().Uint64VarP(&util.commonGrantParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
|
subCmd.PersistentFlags().BoolVarP(&util.commonGrantParams.SkipTLSVerify, "skipVerify", "S", true, "Skip server certificate verify")
|
||||||
|
|
||||||
vi := viper.New()
|
vi := viper.New()
|
||||||
vi.SetEnvPrefix("mstore")
|
vi.SetEnvPrefix("mstore")
|
||||||
@@ -102,10 +103,11 @@ type GrantUtil struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CommonGrantParams struct {
|
type CommonGrantParams struct {
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
Hostname string
|
Hostname string
|
||||||
Timeout uint64
|
Timeout uint64
|
||||||
|
SkipTLSVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateGrant
|
// CreateGrant
|
||||||
@@ -140,9 +142,9 @@ func (util *GrantUtil) createGrant(common *CommonGrantParams, params *CreateGran
|
|||||||
id := strings.ToLower(params.AccountID)
|
id := strings.ToLower(params.AccountID)
|
||||||
var operRes string
|
var operRes string
|
||||||
if re.MatchString(id) {
|
if re.MatchString(id) {
|
||||||
operRes, err = client.NewClient().CreateGrantByAccountID(ctx, hostname, id, params.Right, params.Pattern)
|
operRes, err = client.NewClient(common.SkipTLSVerify).CreateGrantByAccountID(ctx, hostname, id, params.Right, params.Pattern)
|
||||||
} else {
|
} else {
|
||||||
operRes, err = client.NewClient().CreateGrantByUsername(ctx, hostname, params.AccountID, params.Right, params.Pattern)
|
operRes, err = client.NewClient(common.SkipTLSVerify).CreateGrantByUsername(ctx, hostname, params.AccountID, params.Right, params.Pattern)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
@@ -176,7 +178,7 @@ func (util *GrantUtil) updateGrant(common *CommonGrantParams, params *UpdateGran
|
|||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||||
id := strings.ToLower(params.GrantID)
|
id := strings.ToLower(params.GrantID)
|
||||||
err = client.NewClient().UpdateGrant(ctx, hostname, id, params.Pattern)
|
err = client.NewClient(common.SkipTLSVerify).UpdateGrant(ctx, hostname, id, params.Pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -212,7 +214,7 @@ func (util *GrantUtil) getGrant(common *CommonGrantParams, params *GetGrantParam
|
|||||||
opRes := &descr.Grant{}
|
opRes := &descr.Grant{}
|
||||||
|
|
||||||
id := strings.ToLower(params.GrantID)
|
id := strings.ToLower(params.GrantID)
|
||||||
opRes, err = client.NewClient().GetGrant(ctx, hostname, id)
|
opRes, err = client.NewClient(common.SkipTLSVerify).GetGrant(ctx, hostname, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -243,7 +245,7 @@ func (util *GrantUtil) deleteGrant(common *CommonGrantParams, params *DeleteGran
|
|||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
ctx, _ := context.WithTimeout(context.Background(), timeout)
|
||||||
id := strings.ToLower(params.GrantID)
|
id := strings.ToLower(params.GrantID)
|
||||||
err = client.NewClient().DeleteGrant(ctx, hostname, id)
|
err = client.NewClient(common.SkipTLSVerify).DeleteGrant(ctx, hostname, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -280,9 +282,9 @@ func (util *GrantUtil) listGrants(common *CommonGrantParams, params *ListGrantsP
|
|||||||
re := regexp.MustCompile(uuidRegex)
|
re := regexp.MustCompile(uuidRegex)
|
||||||
id := strings.ToLower(params.AccountID)
|
id := strings.ToLower(params.AccountID)
|
||||||
if re.MatchString(id) {
|
if re.MatchString(id) {
|
||||||
grants, err = client.NewClient().ListGrantsByAccountID(ctx, hostname, id)
|
grants, err = client.NewClient(common.SkipTLSVerify).ListGrantsByAccountID(ctx, hostname, id)
|
||||||
} else {
|
} else {
|
||||||
grants, err = client.NewClient().ListGrantsByUsername(ctx, hostname, params.AccountID)
|
grants, err = client.NewClient(common.SkipTLSVerify).ListGrantsByUsername(ctx, hostname, params.AccountID)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ func (util *ImageUtil) CreateImageCmds() *cobra.Command {
|
|||||||
subCmd.PersistentFlags().StringVarP(&util.commonImageParams.Username, "user", "u", "", "Username")
|
subCmd.PersistentFlags().StringVarP(&util.commonImageParams.Username, "user", "u", "", "Username")
|
||||||
subCmd.PersistentFlags().StringVarP(&util.commonImageParams.Password, "pass", "p", "", "Password")
|
subCmd.PersistentFlags().StringVarP(&util.commonImageParams.Password, "pass", "p", "", "Password")
|
||||||
subCmd.PersistentFlags().Uint64VarP(&util.commonImageParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
subCmd.PersistentFlags().Uint64VarP(&util.commonImageParams.Timeout, "timeout", "t", defaultTimeout, "Operation timeout")
|
||||||
|
subCmd.PersistentFlags().BoolVarP(&util.commonImageParams.SkipTLSVerify, "skipVerify", "S", true, "Skip server certificate verify")
|
||||||
subCmd.MarkFlagsRequiredTogether("user", "pass")
|
subCmd.MarkFlagsRequiredTogether("user", "pass")
|
||||||
|
|
||||||
vi := viper.New()
|
vi := viper.New()
|
||||||
@@ -109,9 +110,10 @@ type ImageUtil struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CommonImageParams struct {
|
type CommonImageParams struct {
|
||||||
Timeout uint64
|
Timeout uint64
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
|
SkipTLSVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// PushImage
|
// PushImage
|
||||||
@@ -135,7 +137,7 @@ func (util *ImageUtil) pushImage(common *CommonImageParams, params *PushImagePar
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
res := &PushImageResult{}
|
res := &PushImageResult{}
|
||||||
|
|
||||||
cli := client.NewClient()
|
cli := client.NewClient(common.SkipTLSVerify)
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
params.Imagepath, err = packUserinfo(params.Imagepath, common.Username, common.Password)
|
params.Imagepath, err = packUserinfo(params.Imagepath, common.Username, common.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -169,7 +171,7 @@ func (util *ImageUtil) imageInfo(common *CommonImageParams, params *ImageInfoPar
|
|||||||
res := &ImageInfoResult{}
|
res := &ImageInfoResult{}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
cli := client.NewClient()
|
cli := client.NewClient(common.SkipTLSVerify)
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
|
|
||||||
params.Imagepath, err = packUserinfo(params.Imagepath, common.Username, common.Password)
|
params.Imagepath, err = packUserinfo(params.Imagepath, common.Username, common.Password)
|
||||||
@@ -209,7 +211,7 @@ func (util *ImageUtil) pullImage(common *CommonImageParams, params *PullImagePar
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
res := &PullImageResult{}
|
res := &PullImageResult{}
|
||||||
|
|
||||||
cli := client.NewClient()
|
cli := client.NewClient(common.SkipTLSVerify)
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
params.Imagepath, err = packUserinfo(params.Imagepath, common.Username, common.Password)
|
params.Imagepath, err = packUserinfo(params.Imagepath, common.Username, common.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -249,7 +251,7 @@ func (util *ImageUtil) deleteImage(common *CommonImageParams, params *DeleteImag
|
|||||||
res := &DeleteImageResult{}
|
res := &DeleteImageResult{}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
cli := client.NewClient()
|
cli := client.NewClient(common.SkipTLSVerify)
|
||||||
timeout := time.Duration(common.Timeout) * time.Second
|
timeout := time.Duration(common.Timeout) * time.Second
|
||||||
|
|
||||||
params.Imagepath, err = packUserinfo(params.Imagepath, common.Username, common.Password)
|
params.Imagepath, err = packUserinfo(params.Imagepath, common.Username, common.Password)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, passwor
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apiuri, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apiuri, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ func (cli *Client) GetAccountByID(ctx context.Context, hosturi, accountID string
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ func (cli *Client) GetAccountByName(ctx context.Context, hosturi, username strin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, accoun
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ func (cli *Client) UpdateAccountByName(ctx context.Context, hosturi, username, n
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ func (cli *Client) DeleteAccountByName(ctx context.Context, hosturi, username st
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,7 @@ func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi, accountID str
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,7 @@ func (cli *Client) ListAccounts(ctx context.Context, hosturi string) ([]descr.Ac
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,12 @@
|
|||||||
*/
|
*/
|
||||||
package client
|
package client
|
||||||
|
|
||||||
type Client struct{}
|
type Client struct {
|
||||||
|
skipTLSVerify bool
|
||||||
func NewClient() *Client {
|
}
|
||||||
return &Client{}
|
|
||||||
|
func NewClient(skipTLSVerify bool) *Client {
|
||||||
|
return &Client{
|
||||||
|
skipTLSVerify: skipTLSVerify,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -45,7 +45,7 @@ func (cli *Client) FileInfo(ctx context.Context, fileuri string) (bool, *descr.F
|
|||||||
basic := auxhttp.EncodeBasicAuth(username, password)
|
basic := auxhttp.EncodeBasicAuth(username, password)
|
||||||
req.Header.Add("Authorization", basic)
|
req.Header.Add("Authorization", basic)
|
||||||
}
|
}
|
||||||
client := makeHTTPClient()
|
client := makeHTTPClient(cli.skipTLSVerify)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return exists, file, err
|
return exists, file, err
|
||||||
@@ -100,7 +100,7 @@ func (cli *Client) PutFile(ctx context.Context, filename, fileuri string) error
|
|||||||
basic := auxhttp.EncodeBasicAuth(username, password)
|
basic := auxhttp.EncodeBasicAuth(username, password)
|
||||||
req.Header.Add("Authorization", basic)
|
req.Header.Add("Authorization", basic)
|
||||||
}
|
}
|
||||||
client := makeHTTPClient()
|
client := makeHTTPClient(cli.skipTLSVerify)
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -135,7 +135,7 @@ func (cli *Client) GetFile(ctx context.Context, fileuri, filename string) (int64
|
|||||||
basic := auxhttp.EncodeBasicAuth(username, password)
|
basic := auxhttp.EncodeBasicAuth(username, password)
|
||||||
req.Header.Add("Authorization", basic)
|
req.Header.Add("Authorization", basic)
|
||||||
}
|
}
|
||||||
client := makeHTTPClient()
|
client := makeHTTPClient(cli.skipTLSVerify)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return size, err
|
return size, err
|
||||||
@@ -195,7 +195,7 @@ func (cli *Client) DeleteFile(ctx context.Context, fileuri string) error {
|
|||||||
basic := auxhttp.EncodeBasicAuth(username, password)
|
basic := auxhttp.EncodeBasicAuth(username, password)
|
||||||
req.Header.Add("Authorization", basic)
|
req.Header.Add("Authorization", basic)
|
||||||
}
|
}
|
||||||
client := makeHTTPClient()
|
client := makeHTTPClient(cli.skipTLSVerify)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -238,7 +238,7 @@ func (cli *Client) ListFiles(ctx context.Context, catalogURI, usePathAs string)
|
|||||||
basic := auxhttp.EncodeBasicAuth(username, password)
|
basic := auxhttp.EncodeBasicAuth(username, password)
|
||||||
req.Header.Add("Authorization", basic)
|
req.Header.Add("Authorization", basic)
|
||||||
}
|
}
|
||||||
client := makeHTTPClient()
|
client := makeHTTPClient(cli.skipTLSVerify)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
@@ -307,7 +307,7 @@ func (cli *Client) ListCollections(ctx context.Context, catalogURI, usePathAs st
|
|||||||
basic := auxhttp.EncodeBasicAuth(username, password)
|
basic := auxhttp.EncodeBasicAuth(username, password)
|
||||||
req.Header.Add("Authorization", basic)
|
req.Header.Add("Authorization", basic)
|
||||||
}
|
}
|
||||||
client := makeHTTPClient()
|
client := makeHTTPClient(cli.skipTLSVerify)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
@@ -378,7 +378,7 @@ func (cli *Client) DeleteCollection(ctx context.Context, catalogURI, usePathAs s
|
|||||||
basic := auxhttp.EncodeBasicAuth(username, password)
|
basic := auxhttp.EncodeBasicAuth(username, password)
|
||||||
req.Header.Add("Authorization", basic)
|
req.Header.Add("Authorization", basic)
|
||||||
}
|
}
|
||||||
client := makeHTTPClient()
|
client := makeHTTPClient(cli.skipTLSVerify)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeHTTPClient() *http.Client {
|
func makeHTTPClient(skipTLSVerify bool) *http.Client {
|
||||||
transport := &http.Transport{
|
transport := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{
|
TLSClientConfig: &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: skipTLSVerify,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
|
|||||||
+7
-7
@@ -36,7 +36,7 @@ func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, a
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apiuri, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apiuri, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apiuri, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apiuri, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ func (cli *Client) GetGrant(ctx context.Context, hosturi, grantID string) (*desc
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ func (cli *Client) UpdateGrant(ctx context.Context, hosturi, grantID, newPattern
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ func (cli *Client) DeleteGrant(ctx context.Context, hosturi, grantID string) err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi, accountID
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ func (cli *Client) ListGrantsByUsername(ctx context.Context, hosturi, username s
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
respBytes, err := doHTTPCall(ctx, cli.skipTLSVerify, apipath, paramsJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func setApiPath(base, apipath string) (string, error) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func doHTTPCall(ctx context.Context, apiuri string, reqBytes []byte) ([]byte, error) {
|
func doHTTPCall(ctx context.Context, skipTLSVerify bool, apiuri string, reqBytes []byte) ([]byte, error) {
|
||||||
var err error
|
var err error
|
||||||
respBytes := make([]byte, 0)
|
respBytes := make([]byte, 0)
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ func doHTTPCall(ctx context.Context, apiuri string, reqBytes []byte) ([]byte, er
|
|||||||
httpReq.Header.Add("Authorization", basicHeader)
|
httpReq.Header.Add("Authorization", basicHeader)
|
||||||
}
|
}
|
||||||
transport := &http.Transport{
|
transport := &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: skipTLSVerify},
|
||||||
}
|
}
|
||||||
httpClient := &http.Client{
|
httpClient := &http.Client{
|
||||||
Transport: transport,
|
Transport: transport,
|
||||||
|
|||||||
+11
-3
@@ -16,11 +16,19 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type roundTripper struct{}
|
type RoundTripper struct {
|
||||||
|
skipTLSVerify bool
|
||||||
|
}
|
||||||
|
|
||||||
func (t *roundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
|
func NewRoundTripper(skipTLSVerify bool) *RoundTripper {
|
||||||
|
return &RoundTripper{
|
||||||
|
skipTLSVerify: skipTLSVerify,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *RoundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||||
tlsConfig := &tls.Config{
|
tlsConfig := &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: t.skipTLSVerify,
|
||||||
}
|
}
|
||||||
httpTransport := &http.Transport{
|
httpTransport := &http.Transport{
|
||||||
TLSClientConfig: tlsConfig,
|
TLSClientConfig: tlsConfig,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func (cli *Client) DeleteImage(ctx context.Context, imagepath string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if username != "" && password != "" {
|
if username != "" && password != "" {
|
||||||
defaultTransport := &roundTripper{}
|
defaultTransport := NewRoundTripper(cli.skipTLSVerify)
|
||||||
scopes := []string{repo.Scope(transport.PullScope)}
|
scopes := []string{repo.Scope(transport.PullScope)}
|
||||||
|
|
||||||
regName := repo.RegistryStr()
|
regName := repo.RegistryStr()
|
||||||
@@ -56,7 +56,7 @@ func (cli *Client) DeleteImage(ctx context.Context, imagepath string) error {
|
|||||||
}
|
}
|
||||||
options = append(options, crane.WithTransport(authTransport))
|
options = append(options, crane.WithTransport(authTransport))
|
||||||
} else {
|
} else {
|
||||||
transport := &roundTripper{}
|
transport := NewRoundTripper(cli.skipTLSVerify)
|
||||||
options = append(options, crane.WithTransport(transport))
|
options = append(options, crane.WithTransport(transport))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func (cli *Client) ImageInfo(ctx context.Context, imagepath string) (*ImageDescr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if username != "" && password != "" {
|
if username != "" && password != "" {
|
||||||
defaultTransport := &roundTripper{}
|
defaultTransport := NewRoundTripper(cli.skipTLSVerify)
|
||||||
scopes := []string{repo.Scope(transport.PullScope)}
|
scopes := []string{repo.Scope(transport.PullScope)}
|
||||||
|
|
||||||
regName := repo.RegistryStr()
|
regName := repo.RegistryStr()
|
||||||
@@ -65,7 +65,7 @@ func (cli *Client) ImageInfo(ctx context.Context, imagepath string) (*ImageDescr
|
|||||||
}
|
}
|
||||||
options = append(options, crane.WithTransport(authTransport))
|
options = append(options, crane.WithTransport(authTransport))
|
||||||
} else {
|
} else {
|
||||||
transport := &roundTripper{}
|
transport := NewRoundTripper(cli.skipTLSVerify)
|
||||||
options = append(options, crane.WithTransport(transport))
|
options = append(options, crane.WithTransport(transport))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ func (cli *Client) ImageInfo(ctx context.Context, imagepath string) (*ImageDescr
|
|||||||
remoteOptions = append(remoteOptions, remote.WithContext(ctx))
|
remoteOptions = append(remoteOptions, remote.WithContext(ctx))
|
||||||
|
|
||||||
if username != "" && password != "" {
|
if username != "" && password != "" {
|
||||||
defaultTransport := &roundTripper{}
|
defaultTransport := NewRoundTripper(cli.skipTLSVerify)
|
||||||
scopes := []string{repo.Scope(transport.PullScope)}
|
scopes := []string{repo.Scope(transport.PullScope)}
|
||||||
|
|
||||||
regName := repo.RegistryStr()
|
regName := repo.RegistryStr()
|
||||||
@@ -110,7 +110,7 @@ func (cli *Client) ImageInfo(ctx context.Context, imagepath string) (*ImageDescr
|
|||||||
}
|
}
|
||||||
remoteOptions = append(remoteOptions, remote.WithTransport(authTransport))
|
remoteOptions = append(remoteOptions, remote.WithTransport(authTransport))
|
||||||
} else {
|
} else {
|
||||||
transport := &roundTripper{}
|
transport := NewRoundTripper(cli.skipTLSVerify)
|
||||||
options = append(options, crane.WithTransport(transport))
|
options = append(options, crane.WithTransport(transport))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func (cli *Client) PullImage(ctx context.Context, imagepath, filepath string) er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defaultTransport := &roundTripper{}
|
defaultTransport := NewRoundTripper(cli.skipTLSVerify)
|
||||||
|
|
||||||
scopes := []string{repo.Scope(transport.PullScope)}
|
scopes := []string{repo.Scope(transport.PullScope)}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ func (cli *Client) PullImage(ctx context.Context, imagepath, filepath string) er
|
|||||||
}
|
}
|
||||||
options = append(options, crane.WithTransport(authTransport))
|
options = append(options, crane.WithTransport(authTransport))
|
||||||
} else {
|
} else {
|
||||||
transport := &roundTripper{}
|
transport := NewRoundTripper(cli.skipTLSVerify)
|
||||||
options = append(options, crane.WithTransport(transport))
|
options = append(options, crane.WithTransport(transport))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (cli *Client) PushImage(ctx context.Context, filepath, imagepath string) er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defaultTransport := &roundTripper{}
|
defaultTransport := NewRoundTripper(cli.skipTLSVerify)
|
||||||
|
|
||||||
scopes := []string{
|
scopes := []string{
|
||||||
repo.Scope(transport.PushScope),
|
repo.Scope(transport.PushScope),
|
||||||
@@ -66,7 +66,7 @@ func (cli *Client) PushImage(ctx context.Context, filepath, imagepath string) er
|
|||||||
}
|
}
|
||||||
options = append(options, crane.WithTransport(authTransport))
|
options = append(options, crane.WithTransport(authTransport))
|
||||||
} else {
|
} else {
|
||||||
defaultTransport := &roundTripper{}
|
defaultTransport := NewRoundTripper(cli.skipTLSVerify)
|
||||||
options = append(options, crane.WithTransport(defaultTransport))
|
options = append(options, crane.WithTransport(defaultTransport))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user