Merge pull request #117430 from charles-chenzz/refactoring_util_pkgs
remove Mkdirtemp func to reduce util pkg for testing Kubernetes-commit: 0a37874037538896cdedbc058d7346f00cce5ae8
This commit is contained in:
commit
91bae23f02
16
go.mod
16
go.mod
|
|
@ -30,10 +30,10 @@ require (
|
|||
github.com/stretchr/testify v1.8.2
|
||||
golang.org/x/sys v0.7.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/api v0.0.0-20230501174425-14796d1f9020
|
||||
k8s.io/apimachinery v0.0.0-20230501213034-4749b4e24f66
|
||||
k8s.io/cli-runtime v0.0.0-20230501230530-d44b4d77176d
|
||||
k8s.io/client-go v0.0.0-20230501214135-10f4062eb6e8
|
||||
k8s.io/api v0.0.0-20230502053112-cdff1d4efea5
|
||||
k8s.io/apimachinery v0.0.0-20230502013411-c11b0f21a18f
|
||||
k8s.io/cli-runtime v0.0.0-20230502101629-cfdf645e83d6
|
||||
k8s.io/client-go v0.0.0-20230502053453-71d8553562d8
|
||||
k8s.io/component-base v0.0.0-20230501221019-ba15531b8233
|
||||
k8s.io/component-helpers v0.0.0-20230501221513-9f84e26d89c3
|
||||
k8s.io/klog/v2 v2.90.1
|
||||
|
|
@ -94,10 +94,10 @@ require (
|
|||
)
|
||||
|
||||
replace (
|
||||
k8s.io/api => k8s.io/api v0.0.0-20230501174425-14796d1f9020
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230501213034-4749b4e24f66
|
||||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20230501230530-d44b4d77176d
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20230501214135-10f4062eb6e8
|
||||
k8s.io/api => k8s.io/api v0.0.0-20230502053112-cdff1d4efea5
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230502013411-c11b0f21a18f
|
||||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20230502101629-cfdf645e83d6
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20230502053453-71d8553562d8
|
||||
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20230501212622-ce065752af56
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20230501221019-ba15531b8233
|
||||
k8s.io/component-helpers => k8s.io/component-helpers v0.0.0-20230501221513-9f84e26d89c3
|
||||
|
|
|
|||
16
go.sum
16
go.sum
|
|
@ -540,14 +540,14 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
|||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/api v0.0.0-20230501174425-14796d1f9020 h1:S9xIIE+YN8m+OzIH+081ybssE8ez+7WUqGhLXiJPJiY=
|
||||
k8s.io/api v0.0.0-20230501174425-14796d1f9020/go.mod h1:Q3mFvxQWcKDcMww6VOwmdhvjHt4L2TegJLa6Q12hjGg=
|
||||
k8s.io/apimachinery v0.0.0-20230501213034-4749b4e24f66 h1:5+1+biEctM8zPpQ0xzjsc3WK5Q0qcSfdnfl53nrEJHk=
|
||||
k8s.io/apimachinery v0.0.0-20230501213034-4749b4e24f66/go.mod h1:D/d0HgOLmg6/40zRBT8Tzb0OSoysLc8CBtPty5QmjEM=
|
||||
k8s.io/cli-runtime v0.0.0-20230501230530-d44b4d77176d h1:9vhlG82Aeifx+6a7YO2h/+gQVo85rs5yerJ+7reXGqc=
|
||||
k8s.io/cli-runtime v0.0.0-20230501230530-d44b4d77176d/go.mod h1:uHl4W1oDbzdLx6fXJigQfIPSohmT7MQp0c81xP7eukQ=
|
||||
k8s.io/client-go v0.0.0-20230501214135-10f4062eb6e8 h1:2rKlbILUO+3snuM9kNYIG9chih66YT74KvKO7SjMhx8=
|
||||
k8s.io/client-go v0.0.0-20230501214135-10f4062eb6e8/go.mod h1:pjUllY1G+kLwpVTuoAchVkLA2fBz8UEoJ8jh0iEECPE=
|
||||
k8s.io/api v0.0.0-20230502053112-cdff1d4efea5 h1:AAFiq+OLQqeMCf6esHsifDHaYsFfvBJhTg6jd27vevM=
|
||||
k8s.io/api v0.0.0-20230502053112-cdff1d4efea5/go.mod h1:nfd0ttnXD79Rj548Bl1hfHBh9J38Is9kBvnnhBtdHQc=
|
||||
k8s.io/apimachinery v0.0.0-20230502013411-c11b0f21a18f h1:mO0WE9xlbKiSIYzK7L9SIOkq9s9tLZDZIrLLzXQt3kU=
|
||||
k8s.io/apimachinery v0.0.0-20230502013411-c11b0f21a18f/go.mod h1:D/d0HgOLmg6/40zRBT8Tzb0OSoysLc8CBtPty5QmjEM=
|
||||
k8s.io/cli-runtime v0.0.0-20230502101629-cfdf645e83d6 h1:/1uydnUimg+XoIS4sYunxGBByjH+hqSwwWuvcAprnp8=
|
||||
k8s.io/cli-runtime v0.0.0-20230502101629-cfdf645e83d6/go.mod h1:0X0OV6tEvdvjAmqaEaNd/QP17o8BMPdoUcvr61MQIW8=
|
||||
k8s.io/client-go v0.0.0-20230502053453-71d8553562d8 h1:MXl4uJ7P80vDEGjE8kNECfhf1uIf/5TJvMfud3PsTtk=
|
||||
k8s.io/client-go v0.0.0-20230502053453-71d8553562d8/go.mod h1:iX6WIf4qsVuylZlg/hn2PXJw2Iq0M4hV9pSgr9zGHSU=
|
||||
k8s.io/component-base v0.0.0-20230501221019-ba15531b8233 h1:9hrVHZ7vsrJlVv3fp5p7nXg7J1e+Hq/EgFLrjM9odl0=
|
||||
k8s.io/component-base v0.0.0-20230501221019-ba15531b8233/go.mod h1:NGCxB/ykdnVkrGmvZWQ5h4JMSIXyB3G3SzAbpuCbask=
|
||||
k8s.io/component-helpers v0.0.0-20230501221513-9f84e26d89c3 h1:Wm412iO0IS93oX2w+63RnKE1CmhjE3cnymdI7BOfFUg=
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||
package create
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
|
@ -25,7 +24,6 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
utiltesting "k8s.io/client-go/util/testing"
|
||||
)
|
||||
|
||||
var rsaCertPEM = `-----BEGIN CERTIFICATE-----
|
||||
|
|
@ -84,17 +82,14 @@ rLTt0TTazzwBCgCD0Jkoqg==
|
|||
|
||||
func TestCreateSecretTLS(t *testing.T) {
|
||||
|
||||
validCertTmpDir := utiltesting.MkTmpdirOrDie("tls-valid-cert-test")
|
||||
validCertTmpDir := t.TempDir()
|
||||
validKeyPath, validCertPath := writeKeyPair(validCertTmpDir, rsaKeyPEM, rsaCertPEM, t)
|
||||
defer tearDown(validCertTmpDir)
|
||||
|
||||
invalidCertTmpDir := utiltesting.MkTmpdirOrDie("tls-invalid-cert-test")
|
||||
invalidCertTmpDir := t.TempDir()
|
||||
invalidKeyPath, invalidCertPath := writeKeyPair(invalidCertTmpDir, "test", "test", t)
|
||||
defer tearDown(invalidCertTmpDir)
|
||||
|
||||
mismatchCertTmpDir := utiltesting.MkTmpdirOrDie("tls-mismatch-test")
|
||||
mismatchCertTmpDir := t.TempDir()
|
||||
mismatchKeyPath, mismatchCertPath := writeKeyPair(mismatchCertTmpDir, rsaKeyPEM, mismatchRSAKeyPEM, t)
|
||||
defer tearDown(mismatchCertTmpDir)
|
||||
|
||||
tests := map[string]struct {
|
||||
tlsSecretName string
|
||||
|
|
@ -189,13 +184,6 @@ func TestCreateSecretTLS(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func tearDown(tmpDir string) {
|
||||
err := os.RemoveAll(tmpDir)
|
||||
if err != nil {
|
||||
fmt.Printf("Error in cleaning up test: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func write(path, contents string, t *testing.T) {
|
||||
f, err := os.Create(path)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue