apiextensions-apiserver: add pkg/cmd/server/testing pkg for integration bootstrapping
In analogy to kube-apiserver. Kubernetes-commit: 42f1e81488d8599c6874e467fe39b91a23654886
This commit is contained in:
parent
0d528b5838
commit
a2bfc0e5f0
|
|
@ -27,7 +27,7 @@ import (
|
||||||
// select the loopback certificate via SNI if TLS is used.
|
// select the loopback certificate via SNI if TLS is used.
|
||||||
const LoopbackClientServerNameOverride = "apiserver-loopback-client"
|
const LoopbackClientServerNameOverride = "apiserver-loopback-client"
|
||||||
|
|
||||||
func (s *SecureServingInfo) NewLoopbackClientConfig(token string, loopbackCert []byte) (*restclient.Config, error) {
|
func (s *SecureServingInfo) NewClientConfig(caCert []byte) (*restclient.Config, error) {
|
||||||
if s == nil || (s.Cert == nil && len(s.SNICerts) == 0) {
|
if s == nil || (s.Cert == nil && len(s.SNICerts) == 0) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
@ -44,16 +44,26 @@ func (s *SecureServingInfo) NewLoopbackClientConfig(token string, loopbackCert [
|
||||||
QPS: 50,
|
QPS: 50,
|
||||||
Burst: 100,
|
Burst: 100,
|
||||||
Host: "https://" + net.JoinHostPort(host, port),
|
Host: "https://" + net.JoinHostPort(host, port),
|
||||||
BearerToken: token,
|
|
||||||
// override the ServerName to select our loopback certificate via SNI. This name is also
|
// override the ServerName to select our loopback certificate via SNI. This name is also
|
||||||
// used by the client to compare the returns server certificate against.
|
// used by the client to compare the returns server certificate against.
|
||||||
TLSClientConfig: restclient.TLSClientConfig{
|
TLSClientConfig: restclient.TLSClientConfig{
|
||||||
ServerName: LoopbackClientServerNameOverride,
|
CAData: caCert,
|
||||||
CAData: loopbackCert,
|
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SecureServingInfo) NewLoopbackClientConfig(token string, loopbackCert []byte) (*restclient.Config, error) {
|
||||||
|
c, err := s.NewClientConfig(loopbackCert)
|
||||||
|
if err != nil || c == nil {
|
||||||
|
return c, err
|
||||||
|
}
|
||||||
|
|
||||||
|
c.BearerToken = token
|
||||||
|
c.TLSClientConfig.ServerName = LoopbackClientServerNameOverride
|
||||||
|
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
|
||||||
// LoopbackHostPort returns the host and port loopback REST clients should use
|
// LoopbackHostPort returns the host and port loopback REST clients should use
|
||||||
// to contact the server.
|
// to contact the server.
|
||||||
func LoopbackHostPort(bindAddress string) (string, string, error) {
|
func LoopbackHostPort(bindAddress string) (string, string, error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue