apiextensions: make integration test server flags available to test code

This commit is contained in:
Dr. Stefan Schimanski 2019-05-24 11:17:04 +02:00
parent 74e62b9a77
commit 0cafec6608

View File

@ -31,7 +31,7 @@ import (
) )
// StartDefaultServer starts a test server. // StartDefaultServer starts a test server.
func StartDefaultServer(t servertesting.Logger) (func(), *rest.Config, *options.CustomResourceDefinitionsServerOptions, error) { func StartDefaultServer(t servertesting.Logger, flags ...string) (func(), *rest.Config, *options.CustomResourceDefinitionsServerOptions, error) {
// create kubeconfig which will not actually be used. But authz/authn needs it to startup. // create kubeconfig which will not actually be used. But authz/authn needs it to startup.
fakeKubeConfig, err := ioutil.TempFile("", "kubeconfig") fakeKubeConfig, err := ioutil.TempFile("", "kubeconfig")
fakeKubeConfig.WriteString(` fakeKubeConfig.WriteString(`
@ -55,15 +55,16 @@ users:
`) `)
fakeKubeConfig.Close() fakeKubeConfig.Close()
s, err := servertesting.StartTestServer(t, nil, []string{ s, err := servertesting.StartTestServer(t, nil, append([]string{
"--etcd-prefix", uuid.New(), "--etcd-prefix", uuid.New(),
"--etcd-servers", strings.Join(IntegrationEtcdServers(), ","), "--etcd-servers", strings.Join(IntegrationEtcdServers(), ","),
"--authentication-skip-lookup", "--authentication-skip-lookup",
"--authentication-kubeconfig", fakeKubeConfig.Name(), "--authentication-kubeconfig", fakeKubeConfig.Name(),
"--authorization-kubeconfig", fakeKubeConfig.Name(), "--authorization-kubeconfig", fakeKubeConfig.Name(),
"--kubeconfig", fakeKubeConfig.Name(), "--kubeconfig", fakeKubeConfig.Name(),
"--disable-admission-plugins", "NamespaceLifecycle,MutatingAdmissionWebhook,ValidatingAdmissionWebhook", "--disable-admission-plugins", "NamespaceLifecycle,MutatingAdmissionWebhook,ValidatingAdmissionWebhook"},
}, nil) flags...,
), nil)
if err != nil { if err != nil {
os.Remove(fakeKubeConfig.Name()) os.Remove(fakeKubeConfig.Name())
return nil, nil, nil, err return nil, nil, nil, err
@ -78,8 +79,8 @@ users:
} }
// StartDefaultServerWithClients starts a test server and returns clients for it. // StartDefaultServerWithClients starts a test server and returns clients for it.
func StartDefaultServerWithClients(t servertesting.Logger) (func(), clientset.Interface, dynamic.Interface, error) { func StartDefaultServerWithClients(t servertesting.Logger, extraFlags ...string) (func(), clientset.Interface, dynamic.Interface, error) {
tearDown, config, _, err := StartDefaultServer(t) tearDown, config, _, err := StartDefaultServer(t, extraFlags...)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }