Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/v2/google.golang.org/g…
Browse files Browse the repository at this point in the history
…rpc-1.62.1
  • Loading branch information
azdagron authored Apr 1, 2024
2 parents 3f1a16d + 3495fea commit be62906
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request: {}
workflow_dispatch: {}
env:
GO_VERSION: 1.19
GO_VERSION: 1.21
jobs:
lint-linux:
runs-on: ubuntu-latest
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ ifeq ($(arch1),x86_64)
arch2=amd64
else ifeq ($(arch1),aarch64)
arch2=arm64
else ifeq ($(arch1),arm64)
arch2=arm64
else
$(error unsupported ARCH: $(arch1))
endif
Expand Down Expand Up @@ -70,7 +72,7 @@ protoc_gen_go_grpc_base_dir := $(build_dir)/protoc-gen-go-grpc
protoc_gen_go_grpc_dir := $(protoc_gen_go_grpc_base_dir)/$(protoc_gen_go_grpc_version)-go$(go_version)
protoc_gen_go_grpc_bin := $(protoc_gen_go_grpc_dir)/protoc-gen-go-grpc

golangci_lint_version = v1.50.1
golangci_lint_version = v1.57.2
golangci_lint_dir = $(build_dir)/golangci_lint/$(golangci_lint_version)
golangci_lint_bin = $(golangci_lint_dir)/golangci-lint

Expand All @@ -81,7 +83,7 @@ apiprotos := \
# Toolchain
#############################################################################

go_version_full := 1.19.12
go_version_full := 1.21.8
go_version := $(go_version_full:.0=)
go_dir := $(build_dir)/go/$(go_version)

Expand Down
25 changes: 14 additions & 11 deletions v2/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,9 @@ run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 10m

# include examples
skip-dirs-use-default: false

skip-dirs:
- testdata$
- test/mock

skip-files:
- ".*\\.pb\\.go"

linters:
enable:
- bodyclose
- depguard
- goimports
- revive
- gosec
Expand All @@ -28,6 +17,16 @@ linters:
- gocritic

issues:
# include examples
exclude-dirs-use-default: false

exclude-dirs:
- testdata$
- test/mock

exclude-files:
- ".*\\.pb\\.go"

exclude-rules:
# exclude some lints from examples test files
- path: examples_test.go
Expand All @@ -40,3 +39,7 @@ linters-settings:
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.0
revive:
rules:
- name: unused-parameter
disabled: true # It's useful to name parameters in library code for better readability
2 changes: 1 addition & 1 deletion v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/Microsoft/go-winio v0.6.1
github.com/go-jose/go-jose/v3 v3.0.1
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/zeebo/errs v1.3.0
google.golang.org/grpc v1.62.1
google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20
Expand Down
4 changes: 2 additions & 2 deletions v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/zeebo/errs v1.3.0 h1:hmiaKqgYZzcVgRL1Vkc1Mn2914BbzB0IBxs+ebeutGs=
github.com/zeebo/errs v1.3.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
2 changes: 1 addition & 1 deletion v2/internal/test/fakeworkloadapi/workload_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func New(tb testing.TB) *WorkloadAPI {
x509BundlesChans: make(map[chan *workload.X509BundlesResponse]struct{}),
}

listener, err := newListener()
listener, err := newListener(tb)
require.NoError(tb, err)

server := grpc.NewServer()
Expand Down
3 changes: 2 additions & 1 deletion v2/internal/test/fakeworkloadapi/workload_api_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ package fakeworkloadapi
import (
"fmt"
"net"
"testing"
)

func newListener() (net.Listener, error) {
func newListener(_ testing.TB) (net.Listener, error) {
return net.Listen("tcp", "localhost:0")
}

Expand Down
27 changes: 20 additions & 7 deletions v2/internal/test/fakeworkloadapi/workload_api_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@
package fakeworkloadapi

import (
"crypto/rand"
"fmt"
"math/rand"
"math"
"math/big"
"net"
"strings"
"testing"
"time"

"github.com/Microsoft/go-winio"
"github.com/spiffe/go-spiffe/v2/proto/spiffe/workload"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
)

var maxUint64 = maxBigUint64()

func NewWithNamedPipeListener(tb testing.TB) *WorkloadAPI {
w := &WorkloadAPI{
x509Chans: make(map[chan *workload.X509SVIDResponse]struct{}),
jwtBundlesChans: make(map[chan *workload.JWTBundlesResponse]struct{}),
}

listener, err := winio.ListenPipe(fmt.Sprintf(`\\.\pipe\go-spiffe-test-pipe-%x`, rand.Uint64()), nil) //nolint: gosec // not use for crypto
listener, err := winio.ListenPipe(fmt.Sprintf(`\\.\pipe\go-spiffe-test-pipe-%x`, randUint64(tb)), nil)
require.NoError(tb, err)

server := grpc.NewServer()
Expand All @@ -45,12 +48,22 @@ func GetPipeName(s string) string {
return strings.TrimPrefix(s, `\\.\pipe`)
}

func init() {
rand.Seed(time.Now().UnixNano())
func maxBigUint64() *big.Int {
n := big.NewInt(0)
return n.SetUint64(math.MaxUint64)
}

func randUint64(t testing.TB) uint64 {
n, err := rand.Int(rand.Reader, maxUint64)
if err != nil {
t.Fail()
}

return n.Uint64()
}

func newListener() (net.Listener, error) {
return winio.ListenPipe(fmt.Sprintf(`\\.\pipe\go-spiffe-test-pipe-%x`, rand.Uint64()), nil) //nolint: gosec // not used for crypto
func newListener(tb testing.TB) (net.Listener, error) {
return winio.ListenPipe(fmt.Sprintf(`\\.\pipe\go-spiffe-test-pipe-%x`, randUint64(tb)), nil)
}

func getTargetName(addr net.Addr) string {
Expand Down

0 comments on commit be62906

Please sign in to comment.