зеркало из https://github.com/docker/hub-tool.git
unexpose errors when possible, add documentation where not
Signed-off-by: Moshe Beladev <moshebe123@gmail.com>
This commit is contained in:
Родитель
760afc1304
Коммит
645ce6c610
|
@ -41,7 +41,7 @@ type rmOptions struct {
|
|||
force bool
|
||||
}
|
||||
|
||||
var ErrCanceled = errors.New("canceled")
|
||||
var errCanceled = errors.New("canceled")
|
||||
|
||||
func newRmCmd(streams command.Streams, hubClient *hub.Client, parent string) *cobra.Command {
|
||||
var opts rmOptions
|
||||
|
@ -55,7 +55,7 @@ func newRmCmd(streams command.Streams, hubClient *hub.Client, parent string) *co
|
|||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
err := runRm(cmd.Context(), streams, hubClient, opts, args[0])
|
||||
if err == nil || err == ErrCanceled {
|
||||
if err == nil || err == errCanceled {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
@ -92,7 +92,7 @@ func runRm(ctx context.Context, streams command.Streams, hubClient *hub.Client,
|
|||
input := ""
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ErrCanceled
|
||||
return errCanceled
|
||||
case input = <-userIn:
|
||||
}
|
||||
if input != namedRef.Name() {
|
||||
|
|
|
@ -41,7 +41,7 @@ type rmOptions struct {
|
|||
force bool
|
||||
}
|
||||
|
||||
var ErrCanceled = errors.New("canceled")
|
||||
var errCanceled = errors.New("canceled")
|
||||
|
||||
func newRmCmd(streams command.Streams, hubClient *hub.Client, parent string) *cobra.Command {
|
||||
var opts rmOptions
|
||||
|
@ -55,7 +55,7 @@ func newRmCmd(streams command.Streams, hubClient *hub.Client, parent string) *co
|
|||
},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
err := runRm(cmd.Context(), streams, hubClient, opts, args[0])
|
||||
if err == nil || err == ErrCanceled {
|
||||
if err == nil || err == errCanceled {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
@ -89,7 +89,7 @@ func runRm(ctx context.Context, streams command.Streams, hubClient *hub.Client,
|
|||
input := ""
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ErrCanceled
|
||||
return errCanceled
|
||||
case input = <-userIn:
|
||||
}
|
||||
if strings.ToLower(input) != "y" {
|
||||
|
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/docker/hub-tool/internal/hub"
|
||||
)
|
||||
|
||||
// ErrCanceled represents a normally canceled operation
|
||||
var ErrCanceled = errors.New("canceled")
|
||||
|
||||
// RunLogin logs the user and asks for the 2FA code if needed
|
||||
|
|
Загрузка…
Ссылка в новой задаче