[#58] Update error strings to be golint compliant

Error strings by convention should not end in punctuation, or contain
uppercase letters.

Relates-To: #58

Change-Id: I027fb21a20f08fdd24cf654f3ae1cbceb3e5a6c6
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
This commit is contained in:
Alexander Hughes 2020-02-28 09:30:26 -05:00
parent 84e677344d
commit f66f94dc80
10 changed files with 32 additions and 52 deletions

View File

@ -69,7 +69,7 @@ func TestGetAuthInfoCmd(t *testing.T) {
Name: "missing", Name: "missing",
CmdLine: fmt.Sprintf("%s", missingAuthInfo), CmdLine: fmt.Sprintf("%s", missingAuthInfo),
Cmd: cmd.NewCmdConfigGetAuthInfo(settings), Cmd: cmd.NewCmdConfigGetAuthInfo(settings),
Error: fmt.Errorf("User %s information was not "+ Error: fmt.Errorf("user %s information was not "+
"found in the configuration.", missingAuthInfo), "found in the configuration.", missingAuthInfo),
}, },
} }

View File

@ -110,7 +110,7 @@ func TestGetClusterCmd(t *testing.T) {
Name: "missing", Name: "missing",
CmdLine: fmt.Sprintf("%s %s", targetFlag, missingCluster), CmdLine: fmt.Sprintf("%s %s", targetFlag, missingCluster),
Cmd: cmd.NewCmdConfigGetCluster(settings), Cmd: cmd.NewCmdConfigGetCluster(settings),
Error: fmt.Errorf("Cluster clusterMissing information was not " + Error: fmt.Errorf("cluster clustermissing information was not " +
"found in the configuration."), "found in the configuration."),
}, },
} }

View File

@ -1,20 +0,0 @@
Error: accepts 1 arg(s), received 0
Usage:
set-context NAME [flags]
Examples:
# Create a completely new e2e context entry
airshipctl config set-context e2e --namespace=kube-system --manifest=manifest --user=auth-info --cluster-type=target
# Update the current-context to e2e
airshipctl config set-context e2e
Flags:
--cluster string sets the cluster for the specified context in the airshipctl config
--cluster-type string sets the cluster-type for the specified context in the airshipctl config
-h, --help help for set-context
--manifest string sets the manifest for the specified context in the airshipctl config
--namespace string sets the namespace for the specified context in the airshipctl config
--user string sets the user for the specified context in the airshipctl config

View File

@ -48,7 +48,7 @@ func TestConfigUseContext(t *testing.T) {
Name: "config-use-context-does-not-exist", Name: "config-use-context-does-not-exist",
CmdLine: "foo", CmdLine: "foo",
Cmd: cmd.NewCmdConfigUseContext(settings), Cmd: cmd.NewCmdConfigUseContext(settings),
Error: errors.New("Missing configuration: Context with name 'foo'"), Error: errors.New("missing configuration: context with name 'foo'"),
}, },
} }

View File

@ -59,7 +59,7 @@ func (c *Config) LoadConfig(airshipConfigPath, kubeConfigPath string) error {
// * the file at airshipConfigPath cannot be marshaled into Config // * the file at airshipConfigPath cannot be marshaled into Config
func (c *Config) loadFromAirConfig(airshipConfigPath string) error { func (c *Config) loadFromAirConfig(airshipConfigPath string) error {
if airshipConfigPath == "" { if airshipConfigPath == "" {
return errors.New("Configuration file location was not provided.") return errors.New("configuration file location was not provided")
} }
// Remember where I loaded the Config from // Remember where I loaded the Config from
@ -983,7 +983,7 @@ func ValidClusterType(clusterType string) error {
return nil return nil
} }
} }
return fmt.Errorf("Cluster Type must be one of %v", AllClusterTypes) return fmt.Errorf("cluster type must be one of %v", AllClusterTypes)
} }
/* ______________________________ /* ______________________________

View File

@ -115,7 +115,7 @@ func getDockerContainerMock(mdc mockDockerClient) *DockerContainer {
} }
func TestGetCmd(t *testing.T) { func TestGetCmd(t *testing.T) {
testError := fmt.Errorf("Inspect error") testError := fmt.Errorf("inspect error")
tests := []struct { tests := []struct {
cmd []string cmd []string
mockDockerClient mockDockerClient mockDockerClient mockDockerClient
@ -170,7 +170,7 @@ func TestGetCmd(t *testing.T) {
} }
func TestGetImageId(t *testing.T) { func TestGetImageId(t *testing.T) {
testError := fmt.Errorf("Img List Error") testError := fmt.Errorf("img list error")
tests := []struct { tests := []struct {
url string url string
mockDockerClient mockDockerClient mockDockerClient mockDockerClient
@ -208,7 +208,7 @@ func TestGetImageId(t *testing.T) {
} }
func TestImagePull(t *testing.T) { func TestImagePull(t *testing.T) {
testError := fmt.Errorf("Image Pull Error") testError := fmt.Errorf("image pull rror")
tests := []struct { tests := []struct {
mockDockerClient mockDockerClient mockDockerClient mockDockerClient
expectedErr error expectedErr error
@ -248,10 +248,10 @@ func TestGetId(t *testing.T) {
} }
func TestRunCommand(t *testing.T) { func TestRunCommand(t *testing.T) {
imageListError := fmt.Errorf("Image List Error") imageListError := fmt.Errorf("image list error")
attachError := fmt.Errorf("Attach error") attachError := fmt.Errorf("attach error")
containerStartError := fmt.Errorf("Container Start error") containerStartError := fmt.Errorf("container start error")
containerWaitError := fmt.Errorf("Container Wait Error") containerWaitError := fmt.Errorf("container wait error")
tests := []struct { tests := []struct {
cmd []string cmd []string
containerInput io.Reader containerInput io.Reader
@ -371,7 +371,7 @@ func TestRunCommand(t *testing.T) {
} }
func TestRunCommandOutput(t *testing.T) { func TestRunCommandOutput(t *testing.T) {
testError := fmt.Errorf("Img List Error") testError := fmt.Errorf("img list error")
tests := []struct { tests := []struct {
cmd []string cmd []string
containerInput io.Reader containerInput io.Reader
@ -421,7 +421,7 @@ func TestRunCommandOutput(t *testing.T) {
} }
func TestNewDockerContainer(t *testing.T) { func TestNewDockerContainer(t *testing.T) {
testError := fmt.Errorf("Image Pull Error") testError := fmt.Errorf("image pull error")
type resultStruct struct { type resultStruct struct {
tag string tag string
imageUrl string imageUrl string

View File

@ -180,9 +180,9 @@ func (b *BundleFactory) GetByName(name string) (Document, error) {
// by adding strongly typed errors // by adding strongly typed errors
switch found := len(resSet); { switch found := len(resSet); {
case found == 0: case found == 0:
return &DocumentFactory{}, fmt.Errorf("No documents found with name %s", name) return &DocumentFactory{}, fmt.Errorf("no documents found with name %s", name)
case found > 1: case found > 1:
return &DocumentFactory{}, fmt.Errorf("More than one document found with name %s", name) return &DocumentFactory{}, fmt.Errorf("more than one document found with name %s", name)
default: default:
return NewDocument(resSet[0]) return NewDocument(resSet[0])
} }

View File

@ -26,9 +26,9 @@ const (
) )
var ( var (
ErrNoOpenRepo = errors.New("No open repository is stored") ErrNoOpenRepo = errors.New("no open repository is stored")
ErrRemoteRefNotImplemented = errors.New("RemoteRef is not yet implemented") ErrRemoteRefNotImplemented = errors.New("remoteref is not yet implemented")
ErrCantParseUrl = errors.New("Couldn't get target directory from URL") ErrCantParseUrl = errors.New("could not get target directory from url")
) )
type OptionsBuilder interface { type OptionsBuilder interface {
@ -94,7 +94,7 @@ func (repo *Repository) Update(force bool) error {
} }
err = repo.Driver.Fetch(repo.ToFetchOptions(auth)) err = repo.Driver.Fetch(repo.ToFetchOptions(auth))
if err != nil && err != git.NoErrAlreadyUpToDate { if err != nil && err != git.NoErrAlreadyUpToDate {
return fmt.Errorf("Failed to fetch refs for repository %v: %w", repo.Name, err) return fmt.Errorf("failed to fetch refs for repository %v: %w", repo.Name, err)
} }
return repo.Checkout(force) return repo.Checkout(force)
} }
@ -108,7 +108,7 @@ func (repo *Repository) Checkout(enforce bool) error {
co := repo.ToCheckoutOptions(enforce) co := repo.ToCheckoutOptions(enforce)
tree, err := repo.Driver.Worktree() tree, err := repo.Driver.Worktree()
if err != nil { if err != nil {
return fmt.Errorf("Cloud not get worktree from the repo, %w", err) return fmt.Errorf("could not get worktree from the repo, %w", err)
} }
return tree.Checkout(co) return tree.Checkout(co)
} }
@ -124,7 +124,7 @@ func (repo *Repository) Clone() error {
log.Debugf("Attempting to clone the repository %s", repo.Name) log.Debugf("Attempting to clone the repository %s", repo.Name)
auth, err := repo.ToAuth() auth, err := repo.ToAuth()
if err != nil { if err != nil {
return fmt.Errorf("Failed to build Auth options for repository %v: %w", repo.Name, err) return fmt.Errorf("failed to build auth options for repository %v: %w", repo.Name, err)
} }
return repo.Driver.Clone(repo.ToCloneOptions(auth)) return repo.Driver.Clone(repo.ToCloneOptions(auth))

View File

@ -84,7 +84,7 @@ func TestRedfishRemoteDirectGetSystemNetworkError(t *testing.T) {
defer m.AssertExpectations(t) defer m.AssertExpectations(t)
systemID := computerSystemID systemID := computerSystemID
realErr := fmt.Errorf("Server request timeout") realErr := fmt.Errorf("server request timeout")
httpResp := &http.Response{ httpResp := &http.Response{
StatusCode: 408, StatusCode: 408,
} }
@ -109,7 +109,7 @@ func TestRedfishRemoteDirectInvalidIsoPath(t *testing.T) {
localRDCfg := rDCfg localRDCfg := rDCfg
localRDCfg.IsoPath = "bogus/path/to.iso" localRDCfg.IsoPath = "bogus/path/to.iso"
errStr := "Invalid remote boot path" errStr := "invalid remote boot path"
realErr := fmt.Errorf(errStr) realErr := fmt.Errorf(errStr)
httpResp := &http.Response{ httpResp := &http.Response{
StatusCode: 500, StatusCode: 500,
@ -163,7 +163,7 @@ func TestRedfishRemoteDirectSetSystemBootSourceFailed(t *testing.T) {
m.On("InsertVirtualMedia", context.Background(), "manager-1", "Cd", mock.Anything). m.On("InsertVirtualMedia", context.Background(), "manager-1", "Cd", mock.Anything).
Return(redfishClient.RedfishError{}, nil, nil) Return(redfishClient.RedfishError{}, nil, nil)
realErr := fmt.Errorf("Unauthorized") realErr := fmt.Errorf("unauthorized")
httpResp := &http.Response{ httpResp := &http.Response{
StatusCode: 401, StatusCode: 401,
} }
@ -195,7 +195,7 @@ func TestRedfishRemoteDirectSystemRebootFailed(t *testing.T) {
Times(1). Times(1).
Return(redfishClient.ComputerSystem{}, nil, nil) Return(redfishClient.ComputerSystem{}, nil, nil)
realErr := fmt.Errorf("Unauthorized") realErr := fmt.Errorf("unauthorized")
httpResp := &http.Response{ httpResp := &http.Response{
StatusCode: 401, StatusCode: 401,
} }

View File

@ -22,7 +22,7 @@ func TestRedfishErrorNoError(t *testing.T) {
} }
func TestRedfishErrorNonNilErrorWithoutHttpResp(t *testing.T) { func TestRedfishErrorNonNilErrorWithoutHttpResp(t *testing.T) {
realErr := fmt.Errorf("Sample error") realErr := fmt.Errorf("sample error")
err := ScreenRedfishError(nil, realErr) err := ScreenRedfishError(nil, realErr)
assert.Error(t, err) assert.Error(t, err)
_, ok := err.(*RedfishClientError) _, ok := err.(*RedfishClientError)
@ -30,7 +30,7 @@ func TestRedfishErrorNonNilErrorWithoutHttpResp(t *testing.T) {
} }
func TestRedfishErrorNonNilErrorWithHttpRespError(t *testing.T) { func TestRedfishErrorNonNilErrorWithHttpRespError(t *testing.T) {
realErr := fmt.Errorf("Sample error") realErr := fmt.Errorf("sample error")
httpResp := &http.Response{StatusCode: 408} httpResp := &http.Response{StatusCode: 408}
err := ScreenRedfishError(httpResp, realErr) err := ScreenRedfishError(httpResp, realErr)
@ -46,7 +46,7 @@ func TestRedfishErrorNonNilErrorWithHttpRespError(t *testing.T) {
} }
func TestRedfishErrorNonNilErrorWithHttpRespOK(t *testing.T) { func TestRedfishErrorNonNilErrorWithHttpRespOK(t *testing.T) {
realErr := fmt.Errorf("Sample error") realErr := fmt.Errorf("sample error")
httpResp := &http.Response{StatusCode: 204} httpResp := &http.Response{StatusCode: 204}
err := ScreenRedfishError(httpResp, realErr) err := ScreenRedfishError(httpResp, realErr)
@ -122,7 +122,7 @@ func TestRedfishUtilRebootSystemForceOffError2(t *testing.T) {
defer m.AssertExpectations(t) defer m.AssertExpectations(t)
ctx := context.Background() ctx := context.Background()
realErr := fmt.Errorf("Unauthorized") realErr := fmt.Errorf("unauthorized")
httpResp := &http.Response{ httpResp := &http.Response{
StatusCode: 401, StatusCode: 401,
} }
@ -142,7 +142,7 @@ func TestRedfishUtilRebootSystemForceOffError(t *testing.T) {
defer m.AssertExpectations(t) defer m.AssertExpectations(t)
ctx := context.Background() ctx := context.Background()
realErr := fmt.Errorf("Unauthorized") realErr := fmt.Errorf("unauthorized")
httpResp := &http.Response{ httpResp := &http.Response{
StatusCode: 401, StatusCode: 401,
} }
@ -167,7 +167,7 @@ func TestRedfishUtilRebootSystemTurningOnError(t *testing.T) {
Times(1). Times(1).
Return(redfishClient.RedfishError{}, nil, nil) Return(redfishClient.RedfishError{}, nil, nil)
realErr := fmt.Errorf("Unauthorized") realErr := fmt.Errorf("unauthorized")
httpResp := &http.Response{ httpResp := &http.Response{
StatusCode: 401, StatusCode: 401,
} }