Skip to content

Commit

Permalink
chore: run gofumpt (#5222)
Browse files Browse the repository at this point in the history
* chore: run gofumpt

Signed-off-by: zirain <zirain2009@gmail.com>
  • Loading branch information
zirain authored Feb 7, 2025
1 parent bc190aa commit 74acfb9
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 35 deletions.
16 changes: 6 additions & 10 deletions examples/envoy-als/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@ import (
"google.golang.org/grpc"
)

var (
LogCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "log_count",
Help: "The total number of logs received.",
}, []string{"api_version"})
)
var LogCount = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "log_count",
Help: "The total number of logs received.",
}, []string{"api_version"})

func init() {
// Register the summary and the histogram with Prometheus's default registry.
prometheus.MustRegister(LogCount)
}

type ALSServer struct {
}
type ALSServer struct{}

func (a *ALSServer) StreamAccessLogs(logStream alsv2.AccessLogService_StreamAccessLogsServer) error {
log.Println("Streaming als v2 logs")
Expand All @@ -50,8 +47,7 @@ func (a *ALSServer) StreamAccessLogs(logStream alsv2.AccessLogService_StreamAcce
}
}

type ALSServerV3 struct {
}
type ALSServerV3 struct{}

func (a *ALSServerV3) StreamAccessLogs(logStream alsv3.AccessLogService_StreamAccessLogsServer) error {
log.Println("Streaming als v3 logs")
Expand Down
3 changes: 2 additions & 1 deletion examples/grpc-ext-auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func NewAuthServer(users Users) envoy_service_auth_v3.AuthorizationServer {
// attributes associated with the incoming request.
func (s *authServer) Check(
_ context.Context,
req *envoy_service_auth_v3.CheckRequest) (*envoy_service_auth_v3.CheckResponse, error) {
req *envoy_service_auth_v3.CheckRequest,
) (*envoy_service_auth_v3.CheckResponse, error) {
authorization := req.Attributes.Request.Http.Headers["authorization"]
log.Println(authorization)

Expand Down
2 changes: 1 addition & 1 deletion examples/grpc-ext-proc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func main() {
log.Fatalf("failed to listen: %v", err)
}

err = os.Chmod(udsAddr, 0700)
err = os.Chmod(udsAddr, 0o700)
if err != nil {
log.Fatalf("failed to set permissions: %v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion test/resilience/resilience_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (
"flag"
"io/fs"
"os"
"testing"

"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/gateway-api/conformance/utils/flags"
"testing"

"github.com/envoyproxy/gateway/test/resilience/suite"
"github.com/envoyproxy/gateway/test/resilience/tests"
Expand Down
4 changes: 1 addition & 3 deletions test/resilience/suite/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ package suite

import "flag"

var (
ReportSaveDir = flag.String("report-save-dir", "benchmark_report", "The dir where to save the benchmark test report.")
)
var ReportSaveDir = flag.String("report-save-dir", "benchmark_report", "The dir where to save the benchmark test report.")
19 changes: 8 additions & 11 deletions test/resilience/suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ package suite

import (
"context"
"github.com/envoyproxy/gateway/test/utils/kubernetes"
"io/fs"
"sigs.k8s.io/gateway-api/conformance/utils/roundtripper"
"testing"
"time"

opt "github.com/envoyproxy/gateway/internal/cmd/options"
kube "github.com/envoyproxy/gateway/internal/kubernetes"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/gateway-api/conformance/utils/config"
"sigs.k8s.io/gateway-api/conformance/utils/roundtripper"

opt "github.com/envoyproxy/gateway/internal/cmd/options"
kube "github.com/envoyproxy/gateway/internal/kubernetes"
"github.com/envoyproxy/gateway/test/utils/kubernetes"
)

const (
Expand Down Expand Up @@ -50,9 +51,7 @@ type ResilienceTestSuite struct {
}

func NewResilienceTestSuite(client client.Client, reportDir string, manifestFS []fs.FS, gcn string) (*ResilienceTestSuite, error) {
var (
timeoutConfig = config.TimeoutConfig{}
)
timeoutConfig := config.TimeoutConfig{}

// Reset some timeout config for the benchmark test.
config.SetupTimeoutConfig(&timeoutConfig)
Expand Down Expand Up @@ -84,8 +83,7 @@ func (rts *ResilienceTestSuite) WithResCleanUp(ctx context.Context, t *testing.T
res, err := f()
t.Cleanup(func() {
t.Logf("Start to cleanup resilsence test resources")
if deleteErr := rts.Client.Delete(ctx, res); deleteErr != nil {
}
_ = rts.Client.Delete(ctx, res)

t.Logf("Clean up complete!")
})
Expand All @@ -107,8 +105,7 @@ func (rts *ResilienceTestSuite) Run(t *testing.T, tests []ResilienceTest) {
func (rts *ResilienceTestSuite) RegisterCleanup(t *testing.T, ctx context.Context, object client.Object) {
t.Cleanup(func() {
t.Logf("Start to cleanup resilsence test resources")
if deleteErr := rts.Client.Delete(ctx, object); deleteErr != nil {
}
_ = rts.Client.Delete(ctx, object)

t.Logf("Clean up complete!")
})
Expand Down
10 changes: 6 additions & 4 deletions test/resilience/tests/envoygateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ package tests

import (
"context"
"github.com/envoyproxy/gateway/test/resilience/suite"
"testing"
"time"

"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/gateway-api/conformance/utils/http"
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
"sigs.k8s.io/gateway-api/conformance/utils/tlog"
"testing"
"time"

"github.com/envoyproxy/gateway/test/resilience/suite"
)

const (
Expand Down Expand Up @@ -47,7 +49,7 @@ var EGResilience = suite.ResilienceTest{
}
ap.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, "testdata/base.yaml", true)

//this test will fail until https://github.com/envoyproxy/gateway/pull/4767/files is merged
// this test will fail until https://github.com/envoyproxy/gateway/pull/4767/files is merged
t.Run("Secondary EnvoyGateway instances can serve an up to date xDS", func(t *testing.T) {
ctx := context.Background()
t.Log("Scaling down the deployment to 0 replicas")
Expand Down
8 changes: 5 additions & 3 deletions test/resilience/tests/envoyproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ package tests

import (
"context"
"github.com/envoyproxy/gateway/test/resilience/suite"
"testing"
"time"

"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/gateway-api/conformance/utils/http"
"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
"sigs.k8s.io/gateway-api/conformance/utils/tlog"
"testing"
"time"

"github.com/envoyproxy/gateway/test/resilience/suite"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion tools/make/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
##@ Lint

GITHUB_ACTION ?=
LINT_BUILD_TAGS ?= e2e,celvalidation,conformance,experimental,benchmark
LINT_BUILD_TAGS ?= e2e,celvalidation,conformance,experimental,benchmark,resilience

.PHONY: lint
lint: ## Run all linter of code sources, including golint, yamllint, whitenoise lint and codespell.
Expand Down

0 comments on commit 74acfb9

Please sign in to comment.