Rename the testdata package to testcerts.

`godep save` somehow fails if there is a testdata go package. See
https://github.com/kubernetes/kubernetes/pull/54892#issuecomment-345035489
This commit is contained in:
Chao Xu 2017-11-17 13:24:48 -08:00
parent 6193360eb5
commit 2052a7e2a3
10 changed files with 25 additions and 24 deletions

View File

@ -544,6 +544,7 @@ staging/src/k8s.io/apiserver/pkg/admission/plugin/initialization
staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle staging/src/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/config
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/mutating staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/mutating
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/testcerts
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating
staging/src/k8s.io/apiserver/pkg/apis/apiserver staging/src/k8s.io/apiserver/pkg/apis/apiserver
staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1alpha1 staging/src/k8s.io/apiserver/pkg/apis/apiserver/v1alpha1

View File

@ -84,7 +84,7 @@ filegroup(
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/namespace:all-srcs", "//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/namespace:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/request:all-srcs", "//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/request:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/rules:all-srcs", "//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/rules:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/testdata:all-srcs", "//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/testcerts:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating:all-srcs", "//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/validating:all-srcs",
"//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/versioned:all-srcs", "//staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/versioned:all-srcs",
], ],

View File

@ -49,7 +49,7 @@ go_test(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library", "//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
"//vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/config:go_default_library", "//vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/config:go_default_library",
"//vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/testdata:go_default_library", "//vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/testcerts:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authentication/user:go_default_library", "//vendor/k8s.io/apiserver/pkg/authentication/user:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library", "//vendor/k8s.io/client-go/rest:go_default_library",
], ],

View File

@ -38,7 +38,7 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/admission/plugin/webhook/config" "k8s.io/apiserver/pkg/admission/plugin/webhook/config"
"k8s.io/apiserver/pkg/admission/plugin/webhook/testdata" "k8s.io/apiserver/pkg/admission/plugin/webhook/testcerts"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
) )
@ -97,7 +97,7 @@ func ccfgSVC(urlPath string) registrationv1alpha1.WebhookClientConfig {
Namespace: "default", Namespace: "default",
Path: &urlPath, Path: &urlPath,
}, },
CABundle: testdata.CACert, CABundle: testcerts.CACert,
} }
} }
@ -112,7 +112,7 @@ func (c urlConfigGenerator) ccfgURL(urlPath string) registrationv1alpha1.Webhook
urlString := u2.String() urlString := u2.String()
return registrationv1alpha1.WebhookClientConfig{ return registrationv1alpha1.WebhookClientConfig{
URL: &urlString, URL: &urlString,
CABundle: testdata.CACert, CABundle: testcerts.CACert,
} }
} }
@ -557,12 +557,12 @@ func TestAdmitCachedClient(t *testing.T) {
func newTestServer(t *testing.T) *httptest.Server { func newTestServer(t *testing.T) *httptest.Server {
// Create the test webhook server // Create the test webhook server
sCert, err := tls.X509KeyPair(testdata.ServerCert, testdata.ServerKey) sCert, err := tls.X509KeyPair(testcerts.ServerCert, testcerts.ServerKey)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
rootCAs := x509.NewCertPool() rootCAs := x509.NewCertPool()
rootCAs.AppendCertsFromPEM(testdata.CACert) rootCAs.AppendCertsFromPEM(testcerts.CACert)
testServer := httptest.NewUnstartedServer(http.HandlerFunc(webhookHandler)) testServer := httptest.NewUnstartedServer(http.HandlerFunc(webhookHandler))
testServer.TLS = &tls.Config{ testServer.TLS = &tls.Config{
Certificates: []tls.Certificate{sCert}, Certificates: []tls.Certificate{sCert},
@ -618,9 +618,9 @@ func newFakeAuthenticationInfoResolver(count *int32) *fakeAuthenticationInfoReso
return &fakeAuthenticationInfoResolver{ return &fakeAuthenticationInfoResolver{
restConfig: &rest.Config{ restConfig: &rest.Config{
TLSClientConfig: rest.TLSClientConfig{ TLSClientConfig: rest.TLSClientConfig{
CAData: testdata.CACert, CAData: testcerts.CACert,
CertData: testdata.ClientCert, CertData: testcerts.ClientCert,
KeyData: testdata.ClientKey, KeyData: testcerts.ClientKey,
}, },
}, },
cachedCount: count, cachedCount: count,

View File

@ -6,7 +6,7 @@ go_library(
"certs.go", "certs.go",
"doc.go", "doc.go",
], ],
importpath = "k8s.io/apiserver/pkg/admission/plugin/webhook/testdata", importpath = "k8s.io/apiserver/pkg/admission/plugin/webhook/testcerts",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )

View File

@ -17,7 +17,7 @@ limitations under the License.
// This file was generated using openssl by the gencerts.sh script // This file was generated using openssl by the gencerts.sh script
// and holds raw certificates for the webhook tests. // and holds raw certificates for the webhook tests.
package testdata package testcerts
var CAKey = []byte(`-----BEGIN RSA PRIVATE KEY----- var CAKey = []byte(`-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEArqnW4K+UsmPzbSB7JYhN0HNsJNItjw/87SJxIjGqUttC+2ts MIIEogIBAAKCAQEArqnW4K+UsmPzbSB7JYhN0HNsJNItjw/87SJxIjGqUttC+2ts

View File

@ -14,6 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
// Package testdata contains generated key pairs used by the unit tests of // Package testcerts contains generated key pairs used by the unit tests of
// mutating and validating webhooks. They are for testing only. // mutating and validating webhooks. They are for testing only.
package testdata // import "k8s.io/apiserver/pkg/admission/plugin/webhook/testdata" package testcerts // import "k8s.io/apiserver/pkg/admission/plugin/webhook/testcerts"

View File

@ -95,7 +95,7 @@ EOF
echo "// This file was generated using openssl by the gencerts.sh script" >> $outfile echo "// This file was generated using openssl by the gencerts.sh script" >> $outfile
echo "// and holds raw certificates for the webhook tests." >> $outfile echo "// and holds raw certificates for the webhook tests." >> $outfile
echo "" >> $outfile echo "" >> $outfile
echo "package testdata" >> $outfile echo "package testcerts" >> $outfile
for file in CAKey CACert BadCAKey BadCACert ServerKey ServerCert ClientKey ClientCert; do for file in CAKey CACert BadCAKey BadCACert ServerKey ServerCert ClientKey ClientCert; do
data=$(cat ${file}.pem) data=$(cat ${file}.pem)
echo "" >> $outfile echo "" >> $outfile

View File

@ -47,7 +47,7 @@ go_test(
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library", "//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
"//vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/config:go_default_library", "//vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/config:go_default_library",
"//vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/testdata:go_default_library", "//vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/testcerts:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authentication/user:go_default_library", "//vendor/k8s.io/apiserver/pkg/authentication/user:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library", "//vendor/k8s.io/client-go/rest:go_default_library",
], ],

View File

@ -38,7 +38,7 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/admission" "k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/admission/plugin/webhook/config" "k8s.io/apiserver/pkg/admission/plugin/webhook/config"
"k8s.io/apiserver/pkg/admission/plugin/webhook/testdata" "k8s.io/apiserver/pkg/admission/plugin/webhook/testcerts"
"k8s.io/apiserver/pkg/authentication/user" "k8s.io/apiserver/pkg/authentication/user"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
) )
@ -97,7 +97,7 @@ func ccfgSVC(urlPath string) registrationv1alpha1.WebhookClientConfig {
Namespace: "default", Namespace: "default",
Path: &urlPath, Path: &urlPath,
}, },
CABundle: testdata.CACert, CABundle: testcerts.CACert,
} }
} }
@ -112,7 +112,7 @@ func (c urlConfigGenerator) ccfgURL(urlPath string) registrationv1alpha1.Webhook
urlString := u2.String() urlString := u2.String()
return registrationv1alpha1.WebhookClientConfig{ return registrationv1alpha1.WebhookClientConfig{
URL: &urlString, URL: &urlString,
CABundle: testdata.CACert, CABundle: testcerts.CACert,
} }
} }
@ -579,12 +579,12 @@ func TestAdmitCachedClient(t *testing.T) {
func newTestServer(t *testing.T) *httptest.Server { func newTestServer(t *testing.T) *httptest.Server {
// Create the test webhook server // Create the test webhook server
sCert, err := tls.X509KeyPair(testdata.ServerCert, testdata.ServerKey) sCert, err := tls.X509KeyPair(testcerts.ServerCert, testcerts.ServerKey)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
rootCAs := x509.NewCertPool() rootCAs := x509.NewCertPool()
rootCAs.AppendCertsFromPEM(testdata.CACert) rootCAs.AppendCertsFromPEM(testcerts.CACert)
testServer := httptest.NewUnstartedServer(http.HandlerFunc(webhookHandler)) testServer := httptest.NewUnstartedServer(http.HandlerFunc(webhookHandler))
testServer.TLS = &tls.Config{ testServer.TLS = &tls.Config{
Certificates: []tls.Certificate{sCert}, Certificates: []tls.Certificate{sCert},
@ -643,9 +643,9 @@ func newFakeAuthenticationInfoResolver(count *int32) *fakeAuthenticationInfoReso
return &fakeAuthenticationInfoResolver{ return &fakeAuthenticationInfoResolver{
restConfig: &rest.Config{ restConfig: &rest.Config{
TLSClientConfig: rest.TLSClientConfig{ TLSClientConfig: rest.TLSClientConfig{
CAData: testdata.CACert, CAData: testcerts.CACert,
CertData: testdata.ClientCert, CertData: testcerts.ClientCert,
KeyData: testdata.ClientKey, KeyData: testcerts.ClientKey,
}, },
}, },
cachedCount: count, cachedCount: count,