Update go dependencies
This commit is contained in:
parent
7169f3ba46
commit
ec3da4d2c9
24 changed files with 402 additions and 173 deletions
|
|
@ -1,19 +1,23 @@
|
|||
package internal
|
||||
|
||||
// APIServerDefaultArgs allow tests to run offline, by preventing API server from attempting to
|
||||
// use default route to determine its --advertise-address.
|
||||
var APIServerDefaultArgs = []string{
|
||||
// Allow tests to run offline, by preventing API server from attempting to
|
||||
// use default route to determine its --advertise-address
|
||||
"--advertise-address=127.0.0.1",
|
||||
"--etcd-servers={{ if .EtcdURL }}{{ .EtcdURL.String }}{{ end }}",
|
||||
"--cert-dir={{ .CertDir }}",
|
||||
"--insecure-port={{ if .URL }}{{ .URL.Port }}{{ end }}",
|
||||
"--insecure-bind-address={{ if .URL }}{{ .URL.Hostname }}{{ end }}",
|
||||
"--secure-port={{ if .SecurePort }}{{ .SecurePort }}{{ end }}",
|
||||
"--disable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount,TaintNodesByCondition,Priority,DefaultTolerationSeconds,DefaultStorageClass,StorageObjectInUseProtection,PersistentVolumeClaimResize,ResourceQuota", //nolint
|
||||
// we're keeping this disabled because if enabled, default SA is missing which would force all tests to create one
|
||||
// in normal apiserver operation this SA is created by controller, but that is not run in integration environment
|
||||
"--disable-admission-plugins=ServiceAccount",
|
||||
"--service-cluster-ip-range=10.0.0.0/24",
|
||||
"--allow-privileged=true",
|
||||
}
|
||||
|
||||
// DoAPIServerArgDefaulting will set default values to allow tests to run offline when the args are not informed. Otherwise,
|
||||
// it will return the same []string arg passed as param.
|
||||
func DoAPIServerArgDefaulting(args []string) []string {
|
||||
if len(args) != 0 {
|
||||
return args
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"html/template"
|
||||
)
|
||||
|
||||
// RenderTemplates returns an []string to render the templates
|
||||
func RenderTemplates(argTemplates []string, data interface{}) (args []string, err error) {
|
||||
var t *template.Template
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import (
|
|||
"net/url"
|
||||
)
|
||||
|
||||
// EtcdDefaultArgs allow tests to run offline, by preventing API server from attempting to
|
||||
// use default route to determine its urls.
|
||||
var EtcdDefaultArgs = []string{
|
||||
"--listen-peer-urls=http://localhost:0",
|
||||
"--advertise-client-urls={{ if .URL }}{{ .URL.String }}{{ end }}",
|
||||
|
|
@ -11,6 +13,8 @@ var EtcdDefaultArgs = []string{
|
|||
"--data-dir={{ .DataDir }}",
|
||||
}
|
||||
|
||||
// DoEtcdArgDefaulting will set default values to allow tests to run offline when the args are not informed. Otherwise,
|
||||
// it will return the same []string arg passed as param.
|
||||
func DoEtcdArgDefaulting(args []string) []string {
|
||||
if len(args) != 0 {
|
||||
return args
|
||||
|
|
@ -19,6 +23,7 @@ func DoEtcdArgDefaulting(args []string) []string {
|
|||
return EtcdDefaultArgs
|
||||
}
|
||||
|
||||
// isSecureScheme returns false when the schema is insecure.
|
||||
func isSecureScheme(scheme string) bool {
|
||||
// https://github.com/coreos/etcd/blob/d9deeff49a080a88c982d328ad9d33f26d1ad7b6/pkg/transport/listener.go#L53
|
||||
if scheme == "https" || scheme == "unixs" {
|
||||
|
|
@ -27,6 +32,8 @@ func isSecureScheme(scheme string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// GetEtcdStartMessage returns an start message to inform if the client is or not insecure.
|
||||
// It will return true when the URL informed has the scheme == "https" || scheme == "unixs"
|
||||
func GetEtcdStartMessage(listenURL url.URL) string {
|
||||
if isSecureScheme(listenURL.Scheme) {
|
||||
// https://github.com/coreos/etcd/blob/a7f1fbe00ec216fcb3a1919397a103b41dca8413/embed/serve.go#L167
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import (
|
|||
"sigs.k8s.io/controller-runtime/pkg/internal/testing/integration/addr"
|
||||
)
|
||||
|
||||
// ProcessState define the state of the process.
|
||||
type ProcessState struct {
|
||||
DefaultedProcessInput
|
||||
Session *gexec.Session
|
||||
|
|
@ -46,6 +47,7 @@ type ProcessState struct {
|
|||
ready bool
|
||||
}
|
||||
|
||||
// DefaultedProcessInput defines the default process input required to perform the test.
|
||||
type DefaultedProcessInput struct {
|
||||
URL url.URL
|
||||
Dir string
|
||||
|
|
@ -55,6 +57,8 @@ type DefaultedProcessInput struct {
|
|||
StartTimeout time.Duration
|
||||
}
|
||||
|
||||
// DoDefaulting sets the default configuration according to the data informed and return an DefaultedProcessInput
|
||||
// and an error if some requirement was not informed.
|
||||
func DoDefaulting(
|
||||
name string,
|
||||
listenURL *url.URL,
|
||||
|
|
@ -112,6 +116,8 @@ func DoDefaulting(
|
|||
|
||||
type stopChannel chan struct{}
|
||||
|
||||
// Start starts the apiserver, waits for it to come up, and returns an error,
|
||||
// if occurred.
|
||||
func (ps *ProcessState) Start(stdout, stderr io.Writer) (err error) {
|
||||
if ps.ready {
|
||||
return nil
|
||||
|
|
@ -187,6 +193,8 @@ func pollURLUntilOK(url url.URL, interval time.Duration, ready chan bool, stopCh
|
|||
}
|
||||
}
|
||||
|
||||
// Stop stops this process gracefully, waits for its termination, and cleans up
|
||||
// the CertDir if necessary.
|
||||
func (ps *ProcessState) Stop() error {
|
||||
if ps.Session == nil {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ func newPrivateKey() (crypto.Signer, error) {
|
|||
return rsa.GenerateKey(crand.Reader, rsaKeySize)
|
||||
}
|
||||
|
||||
// NewTinyCA creates a new a tiny CA utility for provisioning serving certs and client certs FOR TESTING ONLY.
|
||||
// Don't use this for anything else!
|
||||
func NewTinyCA() (*TinyCA, error) {
|
||||
caPrivateKey, err := newPrivateKey()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue