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.
 | 
			
		||||
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) {
 | 
			
		||||
		return nil, nil
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -41,19 +41,29 @@ func (s *SecureServingInfo) NewLoopbackClientConfig(token string, loopbackCert [
 | 
			
		|||
		// Increase QPS limits. The client is currently passed to all admission plugins,
 | 
			
		||||
		// and those can be throttled in case of higher load on apiserver - see #22340 and #22422
 | 
			
		||||
		// for more details. Once #22422 is fixed, we may want to remove it.
 | 
			
		||||
		QPS:         50,
 | 
			
		||||
		Burst:       100,
 | 
			
		||||
		Host:        "https://" + net.JoinHostPort(host, port),
 | 
			
		||||
		BearerToken: token,
 | 
			
		||||
		QPS:   50,
 | 
			
		||||
		Burst: 100,
 | 
			
		||||
		Host:  "https://" + net.JoinHostPort(host, port),
 | 
			
		||||
		// 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.
 | 
			
		||||
		TLSClientConfig: restclient.TLSClientConfig{
 | 
			
		||||
			ServerName: LoopbackClientServerNameOverride,
 | 
			
		||||
			CAData:     loopbackCert,
 | 
			
		||||
			CAData: caCert,
 | 
			
		||||
		},
 | 
			
		||||
	}, 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
 | 
			
		||||
// to contact the server.
 | 
			
		||||
func LoopbackHostPort(bindAddress string) (string, string, error) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue