mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-01-08 15:21:55 +00:00
Merge branch 'main' into dynamic_clients
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
// Copyright 2020-2021 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package testlib
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
@@ -154,7 +153,7 @@ func runKubectlGetNamespaces(t *testing.T, kubeConfigYAML string) (string, error
|
||||
|
||||
f := writeStringToTempFile(t, "pinniped-generated-kubeconfig-*", kubeConfigYAML)
|
||||
|
||||
//nolint: gosec // It's okay that we are passing f.Name() to an exec command here. It was created above.
|
||||
//nolint:gosec // It's okay that we are passing f.Name() to an exec command here. It was created above.
|
||||
output, err := exec.Command(
|
||||
"kubectl", "get", "namespace", "--kubeconfig", f.Name(),
|
||||
).CombinedOutput()
|
||||
@@ -164,7 +163,7 @@ func runKubectlGetNamespaces(t *testing.T, kubeConfigYAML string) (string, error
|
||||
|
||||
func writeStringToTempFile(t *testing.T, filename string, kubeConfigYAML string) *os.File {
|
||||
t.Helper()
|
||||
f, err := ioutil.TempFile("", filename)
|
||||
f, err := os.CreateTemp("", filename)
|
||||
require.NoError(t, err)
|
||||
deferMe := func() {
|
||||
err := os.Remove(f.Name())
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2020-2021 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package testlib
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -17,7 +16,7 @@ import (
|
||||
"go.pinniped.dev/internal/testutil"
|
||||
)
|
||||
|
||||
//nolint: gochecknoglobals
|
||||
//nolint:gochecknoglobals
|
||||
var pinnipedCLIBinaryCache struct {
|
||||
buf []byte
|
||||
mutex sync.Mutex
|
||||
@@ -38,7 +37,7 @@ func PinnipedCLIPath(t *testing.T) string {
|
||||
path := filepath.Join(testutil.TempDir(t), "pinniped")
|
||||
if pinnipedCLIBinaryCache.buf != nil {
|
||||
t.Log("using previously built pinniped CLI binary")
|
||||
require.NoError(t, ioutil.WriteFile(path, pinnipedCLIBinaryCache.buf, 0500))
|
||||
require.NoError(t, os.WriteFile(path, pinnipedCLIBinaryCache.buf, 0500))
|
||||
return path
|
||||
}
|
||||
|
||||
@@ -49,7 +48,7 @@ func PinnipedCLIPath(t *testing.T) string {
|
||||
t.Logf("built CLI binary in %s", time.Since(start).Round(time.Millisecond))
|
||||
|
||||
// Fill our cache so we don't have to do this again.
|
||||
pinnipedCLIBinaryCache.buf, err = ioutil.ReadFile(path)
|
||||
pinnipedCLIBinaryCache.buf, err = os.ReadFile(path)
|
||||
require.NoError(t, err, string(output))
|
||||
|
||||
return path
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -57,7 +56,7 @@ func NewClientsetForKubeConfig(t *testing.T, kubeConfig string) kubernetes.Inter
|
||||
}
|
||||
|
||||
func NewRestConfigFromKubeconfig(t *testing.T, kubeConfig string) *rest.Config {
|
||||
kubeConfigFile, err := ioutil.TempFile("", "pinniped-cli-test-*")
|
||||
kubeConfigFile, err := os.CreateTemp("", "pinniped-cli-test-*")
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
require.NoError(t, os.Remove(kubeConfigFile.Name()))
|
||||
|
||||
@@ -5,7 +5,6 @@ package testlib
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -118,7 +117,7 @@ func (e *TestEnv) ProxyEnv() []string {
|
||||
|
||||
// memoizedTestEnvsByTest maps *testing.T pointers to *TestEnv. It exists so that we don't do all the
|
||||
// environment parsing N times per test and so that any implicit assertions happen only once.
|
||||
var memoizedTestEnvsByTest sync.Map //nolint: gochecknoglobals
|
||||
var memoizedTestEnvsByTest sync.Map //nolint:gochecknoglobals
|
||||
|
||||
// IntegrationEnv gets the integration test environment from OS environment variables. This
|
||||
// method also implies SkipUnlessIntegration().
|
||||
@@ -137,7 +136,7 @@ func IntegrationEnv(t *testing.T) *TestEnv {
|
||||
"must specify either PINNIPED_TEST_CLUSTER_CAPABILITY_YAML or PINNIPED_TEST_CLUSTER_CAPABILITY_FILE env var for integration tests",
|
||||
)
|
||||
if capabilitiesDescriptionYAML == "" {
|
||||
bytes, err := ioutil.ReadFile(capabilitiesDescriptionFile)
|
||||
bytes, err := os.ReadFile(capabilitiesDescriptionFile)
|
||||
capabilitiesDescriptionYAML = string(bytes)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2020 the Pinniped contributors. All Rights Reserved.
|
||||
// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
//go:build !go1.14
|
||||
// +build !go1.14
|
||||
|
||||
package testlib
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2020-2022 the Pinniped contributors. All Rights Reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
//nolint:goimports // not an import
|
||||
//go:build go1.14
|
||||
// +build go1.14
|
||||
|
||||
package testlib
|
||||
|
||||
Reference in New Issue
Block a user