Skip to content

Commit 28d8cc3

Browse files
committed
fix non-constant format string
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent cbfe869 commit 28d8cc3

15 files changed

Lines changed: 50 additions & 49 deletions

File tree

ca/server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (s *Server) GetUnlockKey(_ context.Context, _ *api.GetUnlockKeyRequest) (*a
147147
// NodeCertificateStatus returns the current issuance status of an issuance request identified by the nodeID
148148
func (s *Server) NodeCertificateStatus(ctx context.Context, request *api.NodeCertificateStatusRequest) (*api.NodeCertificateStatusResponse, error) {
149149
if request.NodeID == "" {
150-
return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
150+
return nil, status.Error(codes.InvalidArgument, codes.InvalidArgument.String())
151151
}
152152

153153
serverCtx, err := s.isRunningLocked()
@@ -178,7 +178,7 @@ func (s *Server) NodeCertificateStatus(ctx context.Context, request *api.NodeCer
178178

179179
// This node ID doesn't exist
180180
if node == nil {
181-
return nil, status.Errorf(codes.NotFound, codes.NotFound.String())
181+
return nil, status.Error(codes.NotFound, codes.NotFound.String())
182182
}
183183

184184
log.G(ctx).WithFields(log.Fields{
@@ -234,7 +234,7 @@ func (s *Server) NodeCertificateStatus(ctx context.Context, request *api.NodeCer
234234
func (s *Server) IssueNodeCertificate(ctx context.Context, request *api.IssueNodeCertificateRequest) (*api.IssueNodeCertificateResponse, error) {
235235
// First, let's see if the remote node is presenting a non-empty CSR
236236
if len(request.CSR) == 0 {
237-
return nil, status.Errorf(codes.InvalidArgument, codes.InvalidArgument.String())
237+
return nil, status.Error(codes.InvalidArgument, codes.InvalidArgument.String())
238238
}
239239

240240
if err := s.isReadyLocked(); err != nil {

manager/controlapi/ca_rotation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func validateCAConfig(ctx context.Context, securityConfig *ca.SecurityConfig, cl
241241
if cluster.RootCA.LastForcedRotation != newConfig.ForceRotate {
242242
newRootCA, err := ca.CreateRootCA(ca.DefaultRootCN)
243243
if err != nil {
244-
return nil, status.Errorf(codes.Internal, err.Error())
244+
return nil, status.Error(codes.Internal, err.Error())
245245
}
246246
return newRootRotationObject(ctx, securityConfig, &cluster.RootCA, newRootCA, oldCertExtCAs, newConfig.ForceRotate)
247247
}
@@ -265,7 +265,7 @@ func validateCAConfig(ctx context.Context, securityConfig *ca.SecurityConfig, cl
265265
}
266266
newRootCA, err := ca.NewRootCA(newConfig.SigningCACert, signingCert, newConfig.SigningCAKey, ca.DefaultNodeCertExpiration, nil)
267267
if err != nil {
268-
return nil, status.Errorf(codes.InvalidArgument, err.Error())
268+
return nil, status.Error(codes.InvalidArgument, err.Error())
269269
}
270270

271271
if len(newRootCA.Pool.Subjects()) != 1 {

manager/controlapi/cluster.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ var (
3232

3333
func validateClusterSpec(spec *api.ClusterSpec) error {
3434
if spec == nil {
35-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
35+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
3636
}
3737

3838
// Validate that expiry time being provided is valid, and over our minimum
3939
if spec.CAConfig.NodeCertExpiry != nil {
4040
expiry, err := gogotypes.DurationFromProto(spec.CAConfig.NodeCertExpiry)
4141
if err != nil {
42-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
42+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
4343
}
4444
if expiry < ca.MinNodeCertExpiration {
4545
return status.Errorf(codes.InvalidArgument, "minimum certificate expiry time is: %s", ca.MinNodeCertExpiration)
@@ -60,7 +60,7 @@ func validateClusterSpec(spec *api.ClusterSpec) error {
6060
if spec.Dispatcher.HeartbeatPeriod != nil {
6161
heartbeatPeriod, err := gogotypes.DurationFromProto(spec.Dispatcher.HeartbeatPeriod)
6262
if err != nil {
63-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
63+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
6464
}
6565
if heartbeatPeriod < 0 {
6666
return status.Errorf(codes.InvalidArgument, "heartbeat time period cannot be a negative duration")
@@ -79,7 +79,7 @@ func validateClusterSpec(spec *api.ClusterSpec) error {
7979
// - Returns `NotFound` if the Cluster is not found.
8080
func (s *Server) GetCluster(_ context.Context, request *api.GetClusterRequest) (*api.GetClusterResponse, error) {
8181
if request.ClusterID == "" {
82-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
82+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
8383
}
8484

8585
var cluster *api.Cluster
@@ -105,7 +105,7 @@ func (s *Server) GetCluster(_ context.Context, request *api.GetClusterRequest) (
105105
// - Returns an error if the update fails.
106106
func (s *Server) UpdateCluster(ctx context.Context, request *api.UpdateClusterRequest) (*api.UpdateClusterResponse, error) {
107107
if request.ClusterID == "" || request.ClusterVersion == nil {
108-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
108+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
109109
}
110110
if err := validateClusterSpec(request.Spec); err != nil {
111111
return nil, err

manager/controlapi/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (s *Server) GetConfig(_ context.Context, request *api.GetConfigRequest) (*a
5252
// - Returns an error if the update fails.
5353
func (s *Server) UpdateConfig(ctx context.Context, request *api.UpdateConfigRequest) (*api.UpdateConfigResponse, error) {
5454
if request.ConfigID == "" || request.ConfigVersion == nil {
55-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
55+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
5656
}
5757

5858
var config *api.Config
@@ -234,7 +234,7 @@ func (s *Server) RemoveConfig(ctx context.Context, request *api.RemoveConfigRequ
234234

235235
func validateConfigSpec(spec *api.ConfigSpec) error {
236236
if spec == nil {
237-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
237+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
238238
}
239239
if err := validateConfigOrSecretAnnotations(spec.Annotations); err != nil {
240240
return err

manager/controlapi/network.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (s *Server) validateIPAM(ipam *api.IPAMOptions) error {
7070

7171
func (s *Server) validateNetworkSpec(spec *api.NetworkSpec) error {
7272
if spec == nil {
73-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
73+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
7474
}
7575

7676
if spec.Attachable && spec.Ingress {
@@ -138,7 +138,7 @@ func (s *Server) CreateNetwork(_ context.Context, request *api.CreateNetworkRequ
138138
// - Returns `NotFound` if the Network is not found.
139139
func (s *Server) GetNetwork(ctx context.Context, request *api.GetNetworkRequest) (*api.GetNetworkResponse, error) {
140140
if request.NetworkID == "" {
141-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
141+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
142142
}
143143

144144
var n *api.Network
@@ -162,7 +162,7 @@ func (s *Server) GetNetwork(ctx context.Context, request *api.GetNetworkRequest)
162162
// - Returns an error if the deletion fails.
163163
func (s *Server) RemoveNetwork(_ context.Context, request *api.RemoveNetworkRequest) (*api.RemoveNetworkResponse, error) {
164164
if request.NetworkID == "" {
165-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
165+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
166166
}
167167

168168
var (

manager/controlapi/node.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
func validateNodeSpec(spec *api.NodeSpec) error {
1717
if spec == nil {
18-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
18+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
1919
}
2020
return nil
2121
}
@@ -25,7 +25,7 @@ func validateNodeSpec(spec *api.NodeSpec) error {
2525
// - Returns `NotFound` if the Node is not found.
2626
func (s *Server) GetNode(_ context.Context, request *api.GetNodeRequest) (*api.GetNodeResponse, error) {
2727
if request.NodeID == "" {
28-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
28+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
2929
}
3030

3131
var node *api.Node
@@ -202,7 +202,7 @@ func (s *Server) ListNodes(_ context.Context, request *api.ListNodesRequest) (*a
202202
// - Returns an error if the update fails.
203203
func (s *Server) UpdateNode(_ context.Context, request *api.UpdateNodeRequest) (*api.UpdateNodeResponse, error) {
204204
if request.NodeID == "" || request.NodeVersion == nil {
205-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
205+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
206206
}
207207
if err := validateNodeSpec(request.Spec); err != nil {
208208
return nil, err
@@ -293,7 +293,7 @@ func orphanNodeTasks(tx store.Tx, nodeID string) error {
293293
// - Returns an error if the delete fails.
294294
func (s *Server) RemoveNode(_ context.Context, request *api.RemoveNodeRequest) (*api.RemoveNodeResponse, error) {
295295
if request.NodeID == "" {
296-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
296+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
297297
}
298298

299299
err := s.store.Update(func(tx store.Tx) error {

manager/controlapi/secret.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (s *Server) GetSecret(_ context.Context, request *api.GetSecretRequest) (*a
5151
// - Returns an error if the update fails.
5252
func (s *Server) UpdateSecret(ctx context.Context, request *api.UpdateSecretRequest) (*api.UpdateSecretResponse, error) {
5353
if request.SecretID == "" || request.SecretVersion == nil {
54-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
54+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
5555
}
5656
var secret *api.Secret
5757
err := s.store.Update(func(tx store.Tx) error {
@@ -242,7 +242,7 @@ func (s *Server) RemoveSecret(ctx context.Context, request *api.RemoveSecretRequ
242242

243243
func validateSecretSpec(spec *api.SecretSpec) error {
244244
if spec == nil {
245-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
245+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
246246
}
247247
if err := validateConfigOrSecretAnnotations(spec.Annotations); err != nil {
248248
return err
@@ -256,7 +256,7 @@ func validateSecretSpec(spec *api.SecretSpec) error {
256256
return nil
257257
}
258258
if err := validation.ValidateSecretPayload(spec.Data); err != nil {
259-
return status.Errorf(codes.InvalidArgument, "%s", err.Error())
259+
return status.Error(codes.InvalidArgument, err.Error())
260260
}
261261
return nil
262262
}

manager/controlapi/service.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func validateContainerSpec(taskSpec api.TaskSpec) error {
147147
LogDriver: taskSpec.LogDriver,
148148
})
149149
if err != nil {
150-
return status.Errorf(codes.InvalidArgument, err.Error())
150+
return status.Error(codes.InvalidArgument, err.Error())
151151
}
152152

153153
if err := validateImage(container.Image); err != nil {
@@ -526,7 +526,7 @@ func validateJob(spec *api.ServiceSpec) error {
526526

527527
func validateServiceSpec(spec *api.ServiceSpec) error {
528528
if spec == nil {
529-
return status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
529+
return status.Error(codes.InvalidArgument, errInvalidArgument.Error())
530530
}
531531
if err := validateAnnotations(spec.Annotations); err != nil {
532532
return err
@@ -789,7 +789,7 @@ func (s *Server) CreateService(_ context.Context, request *api.CreateServiceRequ
789789
// - Returns `NotFound` if the Service is not found.
790790
func (s *Server) GetService(_ context.Context, request *api.GetServiceRequest) (*api.GetServiceResponse, error) {
791791
if request.ServiceID == "" {
792-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
792+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
793793
}
794794

795795
var service *api.Service
@@ -816,7 +816,7 @@ func (s *Server) GetService(_ context.Context, request *api.GetServiceRequest) (
816816
// - Returns an error if the update fails.
817817
func (s *Server) UpdateService(_ context.Context, request *api.UpdateServiceRequest) (*api.UpdateServiceResponse, error) {
818818
if request.ServiceID == "" || request.ServiceVersion == nil {
819-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
819+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
820820
}
821821
if err := validateServiceSpec(request.Spec); err != nil {
822822
return nil, err
@@ -853,7 +853,7 @@ func (s *Server) UpdateService(_ context.Context, request *api.UpdateServiceRequ
853853
if (len(request.Spec.Networks) != 0 || len(service.Spec.Networks) != 0) &&
854854
!reflect.DeepEqual(request.Spec.Networks, service.Spec.Networks) &&
855855
reflect.DeepEqual(request.Spec.Task.Networks, service.Spec.Task.Networks) {
856-
return status.Errorf(codes.Unimplemented, errNetworkUpdateNotSupported.Error())
856+
return status.Error(codes.Unimplemented, errNetworkUpdateNotSupported.Error())
857857
}
858858

859859
// Check to see if all the secrets being added exist as objects
@@ -872,11 +872,11 @@ func (s *Server) UpdateService(_ context.Context, request *api.UpdateServiceRequ
872872
// with service mode change (comparing current config with previous config).
873873
// proper way to change service mode is to delete and re-add.
874874
if reflect.TypeOf(service.Spec.Mode) != reflect.TypeOf(request.Spec.Mode) {
875-
return status.Errorf(codes.Unimplemented, errModeChangeNotAllowed.Error())
875+
return status.Error(codes.Unimplemented, errModeChangeNotAllowed.Error())
876876
}
877877

878878
if service.Spec.Annotations.Name != request.Spec.Annotations.Name {
879-
return status.Errorf(codes.Unimplemented, errRenameNotSupported.Error())
879+
return status.Error(codes.Unimplemented, errRenameNotSupported.Error())
880880
}
881881

882882
service.Meta.Version = *request.ServiceVersion
@@ -942,7 +942,7 @@ func (s *Server) UpdateService(_ context.Context, request *api.UpdateServiceRequ
942942
// - Returns an error if the deletion fails.
943943
func (s *Server) RemoveService(_ context.Context, request *api.RemoveServiceRequest) (*api.RemoveServiceResponse, error) {
944944
if request.ServiceID == "" {
945-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
945+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
946946
}
947947

948948
err := s.store.Update(func(tx store.Tx) error {
@@ -1000,7 +1000,7 @@ func (s *Server) ListServices(_ context.Context, request *api.ListServicesReques
10001000
if err != nil {
10011001
switch err {
10021002
case store.ErrInvalidFindBy:
1003-
return nil, status.Errorf(codes.InvalidArgument, err.Error())
1003+
return nil, status.Error(codes.InvalidArgument, err.Error())
10041004
default:
10051005
return nil, err
10061006
}

manager/controlapi/task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
// - Returns `NotFound` if the Task is not found.
1717
func (s *Server) GetTask(_ context.Context, request *api.GetTaskRequest) (*api.GetTaskResponse, error) {
1818
if request.TaskID == "" {
19-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
19+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
2020
}
2121

2222
var task *api.Task
@@ -37,7 +37,7 @@ func (s *Server) GetTask(_ context.Context, request *api.GetTaskRequest) (*api.G
3737
// - Returns an error if the deletion fails.
3838
func (s *Server) RemoveTask(_ context.Context, request *api.RemoveTaskRequest) (*api.RemoveTaskResponse, error) {
3939
if request.TaskID == "" {
40-
return nil, status.Errorf(codes.InvalidArgument, errInvalidArgument.Error())
40+
return nil, status.Error(codes.InvalidArgument, errInvalidArgument.Error())
4141
}
4242

4343
err := s.store.Update(func(tx store.Tx) error {

manager/dispatcher/nodes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (rn *registeredNode) checkSessionID(sessionID string) error {
3535
// changed. If it has, we will the stream and make the node
3636
// re-register.
3737
if sessionID == "" || rn.SessionID != sessionID {
38-
return status.Errorf(codes.InvalidArgument, ErrSessionInvalid.Error())
38+
return status.Error(codes.InvalidArgument, ErrSessionInvalid.Error())
3939
}
4040

4141
return nil
@@ -135,7 +135,7 @@ func (s *nodeStore) Get(id string) (*registeredNode, error) {
135135
rn, ok := s.nodes[id]
136136
s.mu.RUnlock()
137137
if !ok {
138-
return nil, status.Errorf(codes.NotFound, ErrNodeNotRegistered.Error())
138+
return nil, status.Error(codes.NotFound, ErrNodeNotRegistered.Error())
139139
}
140140
return rn, nil
141141
}
@@ -145,7 +145,7 @@ func (s *nodeStore) GetWithSession(id, sid string) (*registeredNode, error) {
145145
rn, ok := s.nodes[id]
146146
s.mu.RUnlock()
147147
if !ok {
148-
return nil, status.Errorf(codes.NotFound, ErrNodeNotRegistered.Error())
148+
return nil, status.Error(codes.NotFound, ErrNodeNotRegistered.Error())
149149
}
150150
return rn, rn.checkSessionID(sid)
151151
}

0 commit comments

Comments
 (0)