Skip to content

Commit 0cc706d

Browse files
committed
Make golangcilint happy
Signed-off-by: Jonathan West <[email protected]>
1 parent 447c175 commit 0cc706d

File tree

19 files changed

+50
-36
lines changed

19 files changed

+50
-36
lines changed

appstudio-controller/controllers/webhooks/environment_webhook.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package webhooks
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
2223
"net/url"
2324

@@ -108,7 +109,7 @@ func validateEnvironment(r *appstudiov1alpha1.Environment) error {
108109

109110
if r.Spec.UnstableConfigurationFields != nil && r.Spec.UnstableConfigurationFields.KubernetesClusterCredentials.APIURL != "" {
110111
if _, err := url.ParseRequestURI(r.Spec.UnstableConfigurationFields.KubernetesClusterCredentials.APIURL); err != nil {
111-
return fmt.Errorf(err.Error() + appstudiov1alpha1.InvalidAPIURL)
112+
return errors.New(err.Error() + appstudiov1alpha1.InvalidAPIURL)
112113
}
113114
}
114115

backend-shared/apis/managed-gitops/v1alpha1/gitopsdeployment_webhook.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
"errors"
2021
"fmt"
2122

2223
logutil "github.com/redhat-appstudio/managed-gitops/backend-shared/util/log"
@@ -100,7 +101,7 @@ func (r *GitOpsDeployment) validateGitOpsDeployment() error {
100101

101102
// Check whether Type is manual or automated
102103
if !(r.Spec.Type == GitOpsDeploymentSpecType_Automated || r.Spec.Type == GitOpsDeploymentSpecType_Manual) {
103-
return fmt.Errorf(error_invalid_spec_type)
104+
return errors.New(error_invalid_spec_type)
104105
}
105106

106107
// Check whether sync options are valid
@@ -109,14 +110,14 @@ func (r *GitOpsDeployment) validateGitOpsDeployment() error {
109110

110111
if !(syncOptionString == SyncOptions_CreateNamespace_true ||
111112
syncOptionString == SyncOptions_CreateNamespace_false) {
112-
return fmt.Errorf(error_invalid_sync_option)
113+
return errors.New(error_invalid_sync_option)
113114
}
114115

115116
}
116117
}
117118

118119
if r.Spec.Destination.Environment == "" && r.Spec.Destination.Namespace != "" {
119-
return fmt.Errorf(error_nonempty_namespace_empty_environment)
120+
return errors.New(error_nonempty_namespace_empty_environment)
120121
}
121122

122123
return nil

backend-shared/apis/managed-gitops/v1alpha1/gitopsdeploymentmanagedenvironment_webhook.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"net/url"
2223

@@ -99,11 +100,11 @@ func (r *GitOpsDeploymentManagedEnvironment) ValidateGitOpsDeploymentManagedEnv(
99100
if r.Spec.APIURL != "" {
100101
apiURL, err := url.ParseRequestURI(r.Spec.APIURL)
101102
if err != nil {
102-
return fmt.Errorf(err.Error())
103+
return errors.New(err.Error())
103104
}
104105

105106
if apiURL.Scheme != "https" {
106-
return fmt.Errorf(error_invalid_cluster_api_url)
107+
return errors.New(error_invalid_cluster_api_url)
107108
}
108109
}
109110

backend-shared/apis/managed-gitops/v1alpha1/gitopsdeploymentrepositorycredential_webhook.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"net/url"
2223

@@ -98,11 +99,11 @@ func (r *GitOpsDeploymentRepositoryCredential) ValidateGitOpsDeploymentRepoCred(
9899
if r.Spec.Repository != "" {
99100
apiURL, err := url.ParseRequestURI(r.Spec.Repository)
100101
if err != nil {
101-
return fmt.Errorf(err.Error())
102+
return err
102103
}
103104

104105
if !(apiURL.Scheme == "https" || apiURL.Scheme == "ssh") {
105-
return fmt.Errorf(error_invalid_repository)
106+
return errors.New(error_invalid_repository)
106107
}
107108
}
108109

backend-shared/apis/managed-gitops/v1alpha1/gitopsdeploymentsyncrun_webhook.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
"errors"
2021
"fmt"
2122

2223
logutil "github.com/redhat-appstudio/managed-gitops/backend-shared/util/log"
@@ -66,7 +67,7 @@ func (r *GitOpsDeploymentSyncRun) ValidateCreate() error {
6667
log.V(logutil.LogLevel_Debug).Info("validate create")
6768

6869
if r.Name == invalid_name {
69-
err := fmt.Errorf(error_invalid_name)
70+
err := errors.New(error_invalid_name)
7071
log.Info("webhook rejected invalid create", "error", fmt.Sprintf("%v", err))
7172
return err
7273
}

backend-shared/util/operations/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package operations
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"time"
78

@@ -114,7 +115,7 @@ func createOperationInternal(ctx context.Context, waitForOperation bool, dbOpera
114115

115116
if operationNamespace != gitopsEngineInstance.Namespace_name {
116117
mismatchedNamespace := "OperationNS: " + operationNamespace + " " + "GitopsEngineInstanceNS: " + gitopsEngineInstance.Namespace_name
117-
return nil, nil, fmt.Errorf("namespace mismatched in given OperationCR and existing GitopsEngineInstance " + mismatchedNamespace)
118+
return nil, nil, errors.New("namespace mismatched in given OperationCR and existing GitopsEngineInstance " + mismatchedNamespace)
118119
}
119120

120121
var dbOperationList []db.Operation

backend-shared/util/test_task_retry_loop_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package util
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"math/rand"
78
"sync"
@@ -241,7 +242,7 @@ func (event *mockTestTaskEvent) PerformTask(taskContext context.Context) (bool,
241242

242243
if event.shouldReturnError {
243244
wg.Done()
244-
return false, fmt.Errorf(event.errorReturned)
245+
return false, errors.New(event.errorReturned)
245246
}
246247

247248
time.Sleep(1 * time.Millisecond)

backend-shared/util/util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package util
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"math/rand"
78
"os"
@@ -108,7 +109,7 @@ outer:
108109
// We only return if the context was cancelled.
109110
select {
110111
case <-ctx.Done():
111-
err = fmt.Errorf(taskDescription + ": context cancelled")
112+
err = errors.New(taskDescription + ": context cancelled")
112113
break outer
113114
default:
114115
}

backend/condition/conditions_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var _ = Describe("ConditionManager", func() {
4141
obj = getFirst(sut)
4242

4343
Expect((sut)).To(HaveLen(1))
44-
Expect(obj.LastProbeTime).NotTo(Equal(probe))
44+
Expect(obj.LastProbeTime).NotTo(Equal(*probe))
4545
Expect(obj.LastTransitionTime).To(Equal(transition))
4646
Expect(obj.Message).To(Equal(message))
4747
Expect(obj.Reason).To(Equal(reason))
@@ -71,7 +71,7 @@ var _ = Describe("ConditionManager", func() {
7171
Expect(obj.Reason).To(Equal(gitopsv1alpha1.GitOpsDeploymentReasonType("DummyResolved")))
7272
Expect(obj.Status).To(Equal(status))
7373
Expect(obj.LastProbeTime).NotTo(Equal(now))
74-
Expect(obj.LastTransitionTime).NotTo(Equal(now))
74+
Expect(*obj.LastTransitionTime).NotTo(Equal(now))
7575
})
7676
})
7777

backend/eventloop/application_event_loop/application_event_runner_deployments.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package application_event_loop
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"reflect"
89
"strings"
@@ -115,12 +116,12 @@ func (a *applicationEventLoopRunner_Action) applicationEventRunner_handleDeploym
115116
if gitopsDeployment.Spec.Source.Path == "" {
116117
userError := managedgitopsv1alpha1.GitOpsDeploymentUserError_PathIsRequired
117118
return signalledShutdown_false, nil, nil, deploymentModifiedResult_Failed,
118-
gitopserrors.NewUserDevError(userError, fmt.Errorf(userError))
119+
gitopserrors.NewUserDevError(userError, errors.New(userError))
119120

120121
} else if gitopsDeployment.Spec.Source.Path == "/" {
121122
userError := managedgitopsv1alpha1.GitOpsDeploymentUserError_InvalidPathSlash
122123
return signalledShutdown_false, nil, nil, deploymentModifiedResult_Failed,
123-
gitopserrors.NewUserDevError(userError, fmt.Errorf(userError))
124+
gitopserrors.NewUserDevError(userError, errors.New(userError))
124125

125126
}
126127
}

0 commit comments

Comments
 (0)