From 6af0e6406f70814d42d5e6173ced112b6696af2b Mon Sep 17 00:00:00 2001 From: Joshua Casey Date: Wed, 8 Mar 2023 22:32:03 -0600 Subject: [PATCH] Remove old buildtags --- hack/check-copyright-year.sh | 2 +- internal/crypto/ptls/old.go | 15 --------------- internal/testutil/tempdir.go | 17 ++++++++++++----- internal/testutil/tempdir_go1.14.go | 25 ------------------------- test/testlib/iplookup.go | 19 ++++++++++++++----- test/testlib/iplookup_go1.14.go | 29 ----------------------------- 6 files changed, 27 insertions(+), 80 deletions(-) delete mode 100644 internal/crypto/ptls/old.go delete mode 100644 internal/testutil/tempdir_go1.14.go delete mode 100644 test/testlib/iplookup_go1.14.go diff --git a/hack/check-copyright-year.sh b/hack/check-copyright-year.sh index 0870da68..4341f19c 100755 --- a/hack/check-copyright-year.sh +++ b/hack/check-copyright-year.sh @@ -24,6 +24,6 @@ if [[ "${#missing_copyright_files[@]}" -gt "0" ]]; then for f in "${missing_copyright_files[@]}"; do echo " $f" done - echo "Try using hack/update-copyright-year.sh to update the copyright automatically in staged files." + echo "Try using ./hack/update-copyright-year.sh to update the copyright automatically in staged files." exit 1 fi diff --git a/internal/crypto/ptls/old.go b/internal/crypto/ptls/old.go deleted file mode 100644 index a8987673..00000000 --- a/internal/crypto/ptls/old.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2021 the Pinniped contributors. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -//go:build !go1.17 -// +build !go1.17 - -package ptls - -func init() { - // cause compile time failure if an older version of Go is used - `Pinniped's TLS configuration makes assumptions about how the Go standard library implementation of TLS works. -It particular, we rely on the server controlling cipher suite selection. For these assumptions to hold, Pinniped -must be compiled with Go 1.17+. If you are seeing this error message, your attempt to compile Pinniped with an -older Go compiler was explicitly failed to prevent an unsafe configuration.` -} diff --git a/internal/testutil/tempdir.go b/internal/testutil/tempdir.go index 81c2759e..14a60d37 100644 --- a/internal/testutil/tempdir.go +++ b/internal/testutil/tempdir.go @@ -1,15 +1,22 @@ -// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -//go:build !go1.14 -// +build !go1.14 - package testutil import ( + "io/ioutil" //nolint:staticcheck // ioutil is deprecated, but this file is for go1.14 + "os" "testing" + + "github.com/stretchr/testify/require" ) func TempDir(t *testing.T) string { - return t.TempDir() + t.Helper() + dir, err := ioutil.TempDir("", "test-*") + require.NoError(t, err) + t.Cleanup(func() { + require.NoError(t, os.RemoveAll(dir)) + }) + return dir } diff --git a/internal/testutil/tempdir_go1.14.go b/internal/testutil/tempdir_go1.14.go deleted file mode 100644 index 7f3f1bcc..00000000 --- a/internal/testutil/tempdir_go1.14.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -//go:build go1.14 -// +build go1.14 - -package testutil - -import ( - "io/ioutil" //nolint:staticcheck // ioutil is deprecated, but this file is for go1.14 - "os" - "testing" - - "github.com/stretchr/testify/require" -) - -func TempDir(t *testing.T) string { - t.Helper() - dir, err := ioutil.TempDir("", "test-*") - require.NoError(t, err) - t.Cleanup(func() { - require.NoError(t, os.RemoveAll(dir)) - }) - return dir -} diff --git a/test/testlib/iplookup.go b/test/testlib/iplookup.go index 1a6d5553..2a492ebb 100644 --- a/test/testlib/iplookup.go +++ b/test/testlib/iplookup.go @@ -1,9 +1,6 @@ -// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved. +// Copyright 2020-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -//go:build !go1.14 -// +build !go1.14 - package testlib import ( @@ -13,5 +10,17 @@ import ( // LookupIP looks up the IP address of the provided hostname, preferring IPv4. func LookupIP(ctx context.Context, hostname string) ([]net.IP, error) { - return net.DefaultResolver.LookupIP(ctx, "ip4", hostname) + ips, err := net.DefaultResolver.LookupIPAddr(ctx, hostname) + if err != nil { + return nil, err + } + + // Filter out to only IPv4 addresses + var results []net.IP + for _, ip := range ips { + if ip.IP.To4() != nil { + results = append(results, ip.IP) + } + } + return results, nil } diff --git a/test/testlib/iplookup_go1.14.go b/test/testlib/iplookup_go1.14.go deleted file mode 100644 index 42f18e89..00000000 --- a/test/testlib/iplookup_go1.14.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -//go:build go1.14 -// +build go1.14 - -package testlib - -import ( - "context" - "net" -) - -// LookupIP looks up the IP address of the provided hostname, preferring IPv4. -func LookupIP(ctx context.Context, hostname string) ([]net.IP, error) { - ips, err := net.DefaultResolver.LookupIPAddr(ctx, hostname) - if err != nil { - return nil, err - } - - // Filter out to only IPv4 addresses - var results []net.IP - for _, ip := range ips { - if ip.IP.To4() != nil { - results = append(results, ip.IP) - } - } - return results, nil -}