Skip to content

Commit

Permalink
chore(*) enable gofmt simplify mode (#2870) (#2872)
Browse files Browse the repository at this point in the history
Signed-off-by: James Peach <james.peach@konghq.com>
(cherry picked from commit 630d76e)

Co-authored-by: James Peach <james.peach@konghq.com>
  • Loading branch information
mergify[bot] and jpeach authored Oct 4, 2021
1 parent 377dee3 commit 67cc633
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 46 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ linters:
- bodyclose
- gci
- gocritic
- gofmt
- gomodguard
- govet
- importas
Expand Down Expand Up @@ -48,6 +49,8 @@ linters-settings:
locale: US
ignore-words:
- cancelled # US English should be "canceled", but this is in the Retry API, so we can't change it.
gofmt:
simplify: true

issues:
fix: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ var _ = Describe("ExternalService Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service2",
},
Expand Down Expand Up @@ -122,14 +122,14 @@ var _ = Describe("ExternalService Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "*",
},
Expand Down Expand Up @@ -179,14 +179,14 @@ var _ = Describe("ExternalService Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service2",
"version": "v1",
Expand Down Expand Up @@ -247,14 +247,14 @@ var _ = Describe("ExternalService Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service2",
},
Expand Down Expand Up @@ -307,14 +307,14 @@ var _ = Describe("ExternalService Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service3",
"version": "v1",
Expand Down
36 changes: 18 additions & 18 deletions pkg/core/managers/apis/ratelimit/ratelimit_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ var _ = Describe("RateLimit Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service2",
"version": "v1",
Expand Down Expand Up @@ -90,14 +90,14 @@ var _ = Describe("RateLimit Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "*",
"version": "v1",
Expand Down Expand Up @@ -145,14 +145,14 @@ var _ = Describe("RateLimit Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service2",
},
Expand Down Expand Up @@ -202,14 +202,14 @@ var _ = Describe("RateLimit Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "*",
},
Expand Down Expand Up @@ -259,14 +259,14 @@ var _ = Describe("RateLimit Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service2",
"version": "v1",
Expand Down Expand Up @@ -312,14 +312,14 @@ var _ = Describe("RateLimit Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service2",
"version": "v1",
Expand Down Expand Up @@ -370,14 +370,14 @@ var _ = Describe("RateLimit Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service2",
},
Expand Down Expand Up @@ -430,14 +430,14 @@ var _ = Describe("RateLimit Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service2",
},
Expand Down Expand Up @@ -498,14 +498,14 @@ var _ = Describe("RateLimit Manager", func() {
ratelimit := core_mesh.RateLimitResource{
Spec: &mesh_proto.RateLimit{
Sources: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "service1",
},
},
},
Destinations: []*mesh_proto.Selector{
&mesh_proto.Selector{
{
Match: map[string]string{
"kuma.io/service": "*",
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/core/permissions/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ var _ = Describe("Match", func() {
},
},
expected: map[mesh_proto.InboundInterface]string{
mesh_proto.InboundInterface{DataplaneAdvertisedIP: "192.168.0.1", DataplaneIP: "192.168.0.1", WorkloadIP: "127.0.0.1", WorkloadPort: 8081, DataplanePort: 8080}: "more-specific-kong-to-web",
mesh_proto.InboundInterface{DataplaneAdvertisedIP: "192.168.0.1", DataplaneIP: "192.168.0.1", WorkloadIP: "127.0.0.1", WorkloadPort: 1234, DataplanePort: 1234}: "metrics",
{DataplaneAdvertisedIP: "192.168.0.1", DataplaneIP: "192.168.0.1", WorkloadIP: "127.0.0.1", WorkloadPort: 8081, DataplanePort: 8080}: "more-specific-kong-to-web",
{DataplaneAdvertisedIP: "192.168.0.1", DataplaneIP: "192.168.0.1", WorkloadIP: "127.0.0.1", WorkloadPort: 1234, DataplanePort: 1234}: "metrics",
},
}),
)
Expand Down
8 changes: 4 additions & 4 deletions pkg/core/xds/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ var _ = Describe("DataplaneMetadataFromXdsMetadata", func() {
Entry("from non-empty node", testCase{
node: &structpb.Struct{
Fields: map[string]*structpb.Value{
"dataplane.admin.port": &structpb.Value{
"dataplane.admin.port": {
Kind: &structpb.Value_StringValue{
StringValue: "1234",
},
},
"dataplane.dns.port": &structpb.Value{
"dataplane.dns.port": {
Kind: &structpb.Value_StringValue{
StringValue: "8000",
},
},
"dataplane.dns.empty.port": &structpb.Value{
"dataplane.dns.empty.port": {
Kind: &structpb.Value_StringValue{
StringValue: "8001",
},
Expand Down Expand Up @@ -75,7 +75,7 @@ var _ = Describe("DataplaneMetadataFromXdsMetadata", func() {

node := &structpb.Struct{
Fields: map[string]*structpb.Value{
"version": &structpb.Value{
"version": {
Kind: &structpb.Value_StructValue{
StructValue: util_proto.MustToStruct(version),
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/runtime/gateway/merge/traffic_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var _ = Describe("TrafficRoute", func() {
Spec: &mesh_proto.TrafficRoute{
Conf: &mesh_proto.TrafficRoute_Conf{
Split: []*mesh_proto.TrafficRoute_Split{
&mesh_proto.TrafficRoute_Split{
{
Weight: util_proto.UInt32(1),
Destination: map[string]string{
mesh_proto.ServiceTag: "bar-service",
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/runtime/gateway/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (d *DataplaneGenerator) generate(
dp.Spec.Networking = &mesh_proto.Dataplane_Networking{
Address: addr.String(),
Inbound: []*mesh_proto.Dataplane_Networking_Inbound{
&mesh_proto.Dataplane_Networking_Inbound{
{
Port: 20011,
ServicePort: 10011,
Tags: map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/xds/v3/callbacks_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var _ = Describe("CallbacksChain", func() {

// then
Expect(calls).To(Equal([]methodCall{
methodCall{"1st", "OnStreamOpen()", []interface{}{ctx, streamID, typ}},
{"1st", "OnStreamOpen()", []interface{}{ctx, streamID, typ}},
}))
// and
Expect(err).To(MatchError("1st: OnStreamOpen()"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@ var _ = Describe("HttpOutboundRouteConfigurer", func() {
},
},
Headers: map[string]*mesh_proto.TrafficRoute_Http_Match_StringMatcher{
"x-custom-header-a": &mesh_proto.TrafficRoute_Http_Match_StringMatcher{
"x-custom-header-a": {
MatcherType: &mesh_proto.TrafficRoute_Http_Match_StringMatcher_Prefix{
Prefix: "prefix",
},
},
"x-custom-header-b": &mesh_proto.TrafficRoute_Http_Match_StringMatcher{
"x-custom-header-b": {
MatcherType: &mesh_proto.TrafficRoute_Http_Match_StringMatcher_Exact{
Exact: "exact",
},
},
"x-custom-header-c": &mesh_proto.TrafficRoute_Http_Match_StringMatcher{
"x-custom-header-c": {
MatcherType: &mesh_proto.TrafficRoute_Http_Match_StringMatcher_Regex{
Regex: "^regex$",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/xds/server/callbacks/dataplane_callbacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var _ = Describe("Dataplane Callbacks", func() {
Id: "default.example",
Metadata: &structpb.Struct{
Fields: map[string]*structpb.Value{
"dataplane.token": &structpb.Value{
"dataplane.token": {
Kind: &structpb.Value_StringValue{
StringValue: "token",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ = Describe("Dataplane Metadata Tracker", func() {
Id: "default.example",
Metadata: &structpb.Struct{
Fields: map[string]*structpb.Value{
"dataplane.token": &structpb.Value{
"dataplane.token": {
Kind: &structpb.Value_StringValue{
StringValue: "token",
},
Expand Down
8 changes: 4 additions & 4 deletions tools/docs/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {
format := GetenvOr("FORMAT", "markdown")

apps := map[string]command{
path.Join(prefix, "kuma-cp"): command{
path.Join(prefix, "kuma-cp"): {
command: kuma_cp.DefaultRootCmd(),
header: &doc.GenManHeader{
Title: "KUMA-CP",
Expand All @@ -75,7 +75,7 @@ func main() {
Manual: version.Product,
},
},
path.Join(prefix, "kuma-dp"): command{
path.Join(prefix, "kuma-dp"): {
command: kuma_dp.DefaultRootCmd(),
header: &doc.GenManHeader{
Title: "KUMA-DP",
Expand All @@ -84,7 +84,7 @@ func main() {
Manual: version.Product,
},
},
path.Join(prefix, "kuma-prometheus-sd"): command{
path.Join(prefix, "kuma-prometheus-sd"): {
command: kuma_prometheus_sd.DefaultRootCmd(),
header: &doc.GenManHeader{
Title: "KUMA-PROMETHEUS-SD",
Expand All @@ -93,7 +93,7 @@ func main() {
Manual: version.Product,
},
},
path.Join(prefix, "kumactl"): command{
path.Join(prefix, "kumactl"): {
command: kumactl.DefaultRootCmd(),
header: &doc.GenManHeader{
Title: "KUMACTL",
Expand Down

0 comments on commit 67cc633

Please sign in to comment.