Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vicentefb committed Sep 19, 2024
1 parent 0e7e5c0 commit c7471aa
Show file tree
Hide file tree
Showing 63 changed files with 449 additions and 446 deletions.
1 change: 0 additions & 1 deletion build/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func main() {
}
if err != nil {
log.Fatalf("error listing builds: %v", err)
break
}
createTime := resp.CreateTime.AsTime()
if createTime.Before(windowStart) {
Expand Down
18 changes: 9 additions & 9 deletions cmd/allocator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ func runHTTP(listenCtx context.Context, workerCtx context.Context, h *serviceHan
if err == http.ErrServerClosed {
logger.WithError(err).Info("HTTP/HTTPS server closed")
os.Exit(0)
} else {
logger.WithError(err).Fatal("Unable to start HTTP/HTTPS listener")
os.Exit(1)
}
logger.WithError(err).Fatal("Unable to start HTTP/HTTPS listener")
os.Exit(1)

}()
}

Expand All @@ -411,10 +411,10 @@ func runGRPC(ctx context.Context, h *serviceHandler, grpcHealth *grpchealth.Serv
if err != nil {
logger.WithError(err).Fatal("allocation service crashed")
os.Exit(1)
} else {
logger.Info("allocation server closed")
os.Exit(0)
}
logger.Info("allocation server closed")
os.Exit(0)

}()
}

Expand Down Expand Up @@ -534,15 +534,15 @@ func (h *serviceHandler) getGRPCServerOptions() []grpc.ServerOption {
return append([]grpc.ServerOption{grpc.Creds(credentials.NewTLS(cfg))}, opts...)
}

func (h *serviceHandler) getTLSCert(ch *tls.ClientHelloInfo) (*tls.Certificate, error) {
func (h *serviceHandler) getTLSCert(_ *tls.ClientHelloInfo) (*tls.Certificate, error) {
h.tlsMutex.RLock()
defer h.tlsMutex.RUnlock()
return h.tlsCert, nil
}

// verifyClientCertificate verifies that the client certificate is accepted
// This method is used as GetConfigForClient is cross lang incompatible.
func (h *serviceHandler) verifyClientCertificate(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
func (h *serviceHandler) verifyClientCertificate(rawCerts [][]byte, _ [][]*x509.Certificate) error {
opts := x509.VerifyOptions{
Roots: h.caCertPool,
CurrentTime: time.Now(),
Expand Down Expand Up @@ -645,7 +645,7 @@ type serviceHandler struct {
}

// Allocate implements the Allocate gRPC method definition
func (h *serviceHandler) Allocate(ctx context.Context, in *pb.AllocationRequest) (*pb.AllocationResponse, error) {
func (h *serviceHandler) Allocate(_ context.Context, in *pb.AllocationRequest) (*pb.AllocationResponse, error) {
logger.WithField("request", in).Infof("allocation request received.")
gsa := converters.ConvertAllocationRequestToGSA(in)
gsa.ApplyDefaults()
Expand Down
8 changes: 4 additions & 4 deletions cmd/allocator/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestAllocateHandler(t *testing.T) {
t.Parallel()

h := serviceHandler{
allocationCallback: func(gsa *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
allocationCallback: func(_ *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
return &allocationv1.GameServerAllocation{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestAllocateHandlerReturnsError(t *testing.T) {
t.Parallel()

h := serviceHandler{
allocationCallback: func(gsa *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
allocationCallback: func(_ *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
return nil, k8serror.NewBadRequest("error")
},
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestHandlingStatus(t *testing.T) {

errorMessage := "GameServerAllocation is invalid"
h := serviceHandler{
allocationCallback: func(gsa *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
allocationCallback: func(_ *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
return &metav1.Status{
Status: metav1.StatusFailure,
Message: errorMessage,
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestBadReturnType(t *testing.T) {
t.Parallel()

h := serviceHandler{
allocationCallback: func(gsa *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
allocationCallback: func(_ *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
return &corev1.Secret{}, nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ping/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func serveHTTP(ctlConf config, h healthcheck.Handler) func() {
// add health check as well
mux.HandleFunc("/live", h.LiveEndpoint)

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
if _, err := w.Write([]byte(ctlConf.HTTPResponse)); err != nil {
w.WriteHeader(http.StatusInternalServerError)
logger.WithError(err).Error("Error responding to http request")
Expand Down
2 changes: 1 addition & 1 deletion cmd/ping/udp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestUDPServerHealth(t *testing.T) {

cancel()

err = wait.PollUntilContextTimeout(context.Background(), time.Second, 5*time.Second, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), time.Second, 5*time.Second, true, func(_ context.Context) (bool, error) {
return u.Health() != nil, nil
})

Expand Down
2 changes: 1 addition & 1 deletion cmd/sdk-server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestHealthCheckWrapper(t *testing.T) {
{"non-empty body", bytes.NewBuffer([]byte(`{}`)), http.StatusOK},
}

testWrapper := healthCheckWrapper(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testWrapper := healthCheckWrapper(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
}))

Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/agones/v1/gameserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ func TestGameServerApplyDefaults(t *testing.T) {
expected expected
}{
"set basic defaults on a very simple gameserver": {
gameServer: defaultGameServerAnd(func(gss *GameServerSpec) {}),
expected: wantDefaultAnd(func(e *expected) {}),
gameServer: defaultGameServerAnd(func(_ *GameServerSpec) {}),
expected: wantDefaultAnd(func(_ *expected) {}),
},
"PlayerTracking=true": {
featureFlags: string(runtime.FeaturePlayerTracking) + "=true",
Expand Down Expand Up @@ -347,7 +347,7 @@ func TestGameServerApplyDefaults(t *testing.T) {
}),
},
"defaults are eviction.safe: Never": {
gameServer: defaultGameServerAnd(func(gss *GameServerSpec) {}),
gameServer: defaultGameServerAnd(func(_ *GameServerSpec) {}),
expected: wantDefaultAnd(func(e *expected) {
e.evictionSafeSpec = EvictionSafeNever
e.evictionSafeStatus = EvictionSafeNever
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/allocation/v1/gameserverallocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func (la *ListAction) ListActions(list string, gs *agonesv1.GameServer) error {
errs = errors.Join(errs, capErr)
}
}
if la.AddValues != nil && len(la.AddValues) > 0 {
if len(la.AddValues) > 0 {
cntErr := gs.AppendListValues(list, la.AddValues)
if cntErr != nil {
errs = errors.Join(errs, cntErr)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudproduct/gke/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ type autopilotPortAllocator struct {
maxPort int32
}

func (*autopilotPortAllocator) Run(_ context.Context) error { return nil }
func (*autopilotPortAllocator) DeAllocate(gs *agonesv1.GameServer) {}
func (*autopilotPortAllocator) Run(_ context.Context) error { return nil }
func (*autopilotPortAllocator) DeAllocate(_ *agonesv1.GameServer) {}

func checkPassthroughPortPolicyForAutopilot(portPolicy agonesv1.PortPolicy) bool {
// Autopilot can have Dynamic or Passthrough
Expand Down
Loading

0 comments on commit c7471aa

Please sign in to comment.