Merge "Remove AirshipError"

This commit is contained in:
Zuul 2020-07-08 17:43:06 +00:00 committed by Gerrit Code Review
commit bfa6344335
4 changed files with 15 additions and 28 deletions

View File

@ -60,7 +60,7 @@ func (c *RepoCheckout) Validate() error {
return ErrMutuallyExclusiveCheckout{}
}
if c.RemoteRef != "" {
return fmt.Errorf("Repository checkout by RemoteRef is not yet implemented\n%w", errors.ErrNotImplemented{})
return errors.ErrNotImplemented{What: "repository checkout by RemoteRef"}
}
return nil
}
@ -163,7 +163,7 @@ func (repo *Repository) ToAuth() (transport.AuthMethod, error) {
case HTTPBasic:
return &http.BasicAuth{Username: repo.Auth.Username, Password: repo.Auth.HTTPPassword}, nil
default:
return nil, fmt.Errorf("Error building auth opts, repo\n%s\n: %w", repo.String(), errors.ErrNotImplemented{})
return nil, errors.ErrNotImplemented{What: fmt.Sprintf("authtype %s", repo.Auth.Type)}
}
}

View File

@ -14,23 +14,16 @@
package errors
// AirshipError is the base error type
// used to create extended error types
// in other airshipctl packages.
type AirshipError struct {
Message string
}
import "fmt"
// Error function implements the golang
// error interface
func (ae *AirshipError) Error() string {
return ae.Message
}
// ErrNotImplemented returned for not implemented features
// ErrNotImplemented returned for features not yet implemented
type ErrNotImplemented struct {
What string
}
func (e ErrNotImplemented) Error() string {
return "Not implemented"
if e.What != "" {
return fmt.Sprintf("not implemented: %s", e.What)
}
return "not implemented"
}

View File

@ -16,8 +16,6 @@ package remote
import (
"fmt"
aerror "opendev.org/airship/airshipctl/pkg/errors"
)
// TODO: This need to be refactored to match the error format used elsewhere in airshipctl
@ -25,20 +23,21 @@ import (
// GenericError provides general feedback about an error that occurred in a remote operation
type GenericError struct {
aerror.AirshipError
Message string
}
// NewRemoteDirectErrorf retruns formatted remote direct errors
func NewRemoteDirectErrorf(format string, v ...interface{}) error {
e := &GenericError{}
e.Message = fmt.Sprintf(format, v...)
return e
return &GenericError{Message: fmt.Sprintf(format, v...)}
}
func (e GenericError) Error() string {
return e.Message
}
// ErrUnknownManagementType is an error that indicates the remote type specified in the airshipctl management
// configuration (e.g. redfish, redfish-dell) is not supported.
type ErrUnknownManagementType struct {
aerror.AirshipError
Type string
}
@ -49,7 +48,6 @@ func (e ErrUnknownManagementType) Error() string {
// ErrMissingBootstrapInfoOption is an error that indicates a bootstrap option is missing in the airshipctl
// bootstrapInfo configuration.
type ErrMissingBootstrapInfoOption struct {
aerror.AirshipError
What string
}

View File

@ -16,13 +16,10 @@ package redfish
import (
"fmt"
aerror "opendev.org/airship/airshipctl/pkg/errors"
)
// ErrRedfishClient describes an error encountered by the go-redfish client.
type ErrRedfishClient struct {
aerror.AirshipError
Message string
}
@ -51,7 +48,6 @@ func (e ErrOperationRetriesExceeded) Error() string {
// ErrUnrecognizedRedfishResponse is a debug error that describes unexpected formats in a Redfish error response.
type ErrUnrecognizedRedfishResponse struct {
aerror.AirshipError
Key string
}