Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ override.tf.json
# Ignore CLI configuration files
.terraformrc
terraform.rc
/go.work
/go.work.sum
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ linters-settings:
- github.com/hashicorp/go-msgpack:
recommendations:
- github.com/hashicorp/consul-net-rpc/go-msgpack
- github.com/golang/protobuf:
recommendations:
- google.golang.org/protobuf

depguard:
list-type: denylist
Expand All @@ -101,7 +104,9 @@ linters-settings:
# Default: []
packages-with-error-message:
- net/rpc: "only use forked copy in github.com/hashicorp/consul-net-rpc/net/rpc"
- github.com/golang/protobuf: "only use google.golang.org/protobuf"

run:
timeout: 10m
concurrency: 4
skip-dirs-use-default: false
61 changes: 34 additions & 27 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

SHELL = bash

GO_MODULES := $(shell find . -name go.mod -exec dirname {} \; | grep -v "proto-gen-rpc-glue/e2e" | sort)

###
# These version variables can either be a valid string for "go install <module>@<version>"
# or the string @DEV to imply use what is currently installed locally.
Expand Down Expand Up @@ -249,19 +251,13 @@ cov: other-consul dev-build

test: other-consul dev-build lint test-internal

go-mod-tidy:
@echo "--> Running go mod tidy"
@cd sdk && go mod tidy
@cd api && go mod tidy
@go mod tidy
@cd test/integration/consul-container && go mod tidy
@cd test/integration/connect/envoy/test-sds-server && go mod tidy
@cd proto-public && go mod tidy
@cd internal/tools/proto-gen-rpc-glue && go mod tidy
@cd internal/tools/proto-gen-rpc-glue/e2e && go mod tidy
@cd internal/tools/proto-gen-rpc-glue/e2e/consul && go mod tidy
@cd internal/tools/protoc-gen-consul-rate-limit && go mod tidy
.PHONY: go-mod-tidy
go-mod-tidy: $(foreach mod,$(GO_MODULES),go-mod-tidy/$(mod))

.PHONY: mod-tidy/%
go-mod-tidy/%:
@echo "--> Running go mod tidy ($*)"
@cd $* && go mod tidy

test-internal:
@echo "--> Running go test"
Expand Down Expand Up @@ -292,6 +288,12 @@ test-internal:
@grep '^FAIL' test.log || true
@if [ "$$(cat exit-code)" == "0" ] ; then echo "PASS" ; exit 0 ; else exit 1 ; fi

test-all: other-consul dev-build lint $(foreach mod,$(GO_MODULES),test-module/$(mod))

test-module/%:
@echo "--> Running go test ($*)"
cd $* && go test $(GOTEST_FLAGS) -tags '$(GOTAGS)' ./...

test-race:
$(MAKE) GOTEST_FLAGS=-race

Expand Down Expand Up @@ -328,21 +330,26 @@ other-consul:
echo "Found other running consul agents. This may affect your tests." ; \
exit 1 ; \
fi

lint: -lint-main lint-container-test-deps

.PHONY: -lint-main
-lint-main: lint-tools
@echo "--> Running golangci-lint"
@golangci-lint run --build-tags '$(GOTAGS)' && \
(cd api && golangci-lint run --build-tags '$(GOTAGS)') && \
(cd sdk && golangci-lint run --build-tags '$(GOTAGS)')
@echo "--> Running golangci-lint (container tests)"
@cd test/integration/consul-container && golangci-lint run --build-tags '$(GOTAGS)'
@echo "--> Running lint-consul-retry"
@lint-consul-retry
@echo "--> Running enumcover"
@enumcover ./...

.PHONY: fmt
fmt: $(foreach mod,$(GO_MODULES),fmt/$(mod))

.PHONY: fmt/%
fmt/%:
@echo "--> Running go fmt ($*)"
@cd $* && go fmt ./...

.PHONY: lint
lint: $(foreach mod,$(GO_MODULES),lint/$(mod)) lint-container-test-deps

.PHONY: lint/%
lint/%:
@echo "--> Running golangci-lint ($*)"
@cd $* && GOWORK=off golangci-lint run --build-tags '$(GOTAGS)'
@echo "--> Running lint-consul-retry ($*)"
@cd $* && GOWORK=off lint-consul-retry
@echo "--> Running enumcover ($*)"
@cd $* && GOWORK=off enumcover ./...

.PHONY: lint-container-test-deps
lint-container-test-deps:
Expand Down
2 changes: 1 addition & 1 deletion agent/consul/leader_peering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1921,7 +1921,7 @@ func Test_Leader_PeeringSync_ServerAddressUpdates(t *testing.T) {
require.True(r, found)
// We assert for this error to be set which would indicate that we iterated
// through a bad address.
require.Contains(r, status.LastSendErrorMessage, "transport: Error while dialing dial tcp: address bad: missing port in address")
require.Contains(r, status.LastSendErrorMessage, "transport: Error while dialing: dial tcp: address bad: missing port in address")
require.False(r, status.Connected)
})
})
Expand Down
4 changes: 3 additions & 1 deletion agent/envoyextensions/builtin/ext-authz/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (c extAuthzConfig) isHTTP() bool {
//
// If the extension is configured with the ext_authz service as an upstream there is no need to insert
// a new cluster so this method returns nil.
func (c *extAuthzConfig) toEnvoyCluster(cfg *cmn.RuntimeConfig) (*envoy_cluster_v3.Cluster, error) {
func (c *extAuthzConfig) toEnvoyCluster(_ *cmn.RuntimeConfig) (*envoy_cluster_v3.Cluster, error) {
var target *Target
if c.isHTTP() {
target = c.HttpService.Target
Expand Down Expand Up @@ -678,8 +678,10 @@ type TransportApiVersion string
func (t TransportApiVersion) toEnvoy() envoy_core_v3.ApiVersion {
switch strings.ToLower(string(t)) {
case "v2":
//nolint:staticcheck
return envoy_core_v3.ApiVersion_V2
case "auto":
//nolint:staticcheck
return envoy_core_v3.ApiVersion_AUTO
default:
return envoy_core_v3.ApiVersion_V3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
envoy_http_v3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
envoy_type_v3 "github.com/envoyproxy/go-control-plane/envoy/type/v3"
envoy_resource_v3 "github.com/envoyproxy/go-control-plane/pkg/resource/v3"
"github.com/golang/protobuf/ptypes/wrappers"
"github.com/hashicorp/go-multierror"
"github.com/mitchellh/mapstructure"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/wrapperspb"

"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/envoyextensions/extensioncommon"
Expand Down Expand Up @@ -125,7 +125,7 @@ func (r ratelimit) PatchFilter(p extensioncommon.FilterPayload) (*envoy_listener
tokenBucket := envoy_type_v3.TokenBucket{}

if r.TokensPerFill != nil {
tokenBucket.TokensPerFill = &wrappers.UInt32Value{
tokenBucket.TokensPerFill = &wrapperspb.UInt32Value{
Value: uint32(*r.TokensPerFill),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ type MockPatcher[K proto.Message] struct {
appliedPatches []Patch
}

//nolint:unparam
func (m *MockPatcher[K]) applyPatch(k K, p Patch, _ bool) (result K, e error) {
m.appliedPatches = append(m.appliedPatches, p)
return k, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package propertyoverride

import (
"fmt"
"testing"

envoy_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
envoy_endpoint_v3 "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
envoy_listener_v3 "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
envoy_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
_struct "github.com/golang/protobuf/ptypes/struct"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"
_struct "google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/wrapperspb"
"testing"
)

func TestPatchStruct(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion agent/grpc-internal/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (s *ServerResolverBuilder) Build(target resolver.Target, cc resolver.Client
}

//nolint:staticcheck
serverType, datacenter, err := parseEndpoint(target.Endpoint)
serverType, datacenter, err := parseEndpoint(target.Endpoint())
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion agent/grpc-internal/resolver/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resolver
import (
"fmt"
"net"
"net/url"
"strings"
"testing"

Expand Down Expand Up @@ -40,7 +41,7 @@ func TestServerResolverBuilder(t *testing.T) {
_, err := rs.Build(resolver.Target{
Scheme: "consul",
Authority: rs.Authority(),
Endpoint: endpoint,
URL: url.URL{Opaque: endpoint},
}, cc, resolver.BuildOptions{})
require.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion agent/grpc-middleware/testutil/testservice/simple.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading