support watch namespaces matched namespace selector (#7472)
skip caching namespaces at cluster scope if only watching single namespace add --watch-namespace-selector in user guide add e2e test
This commit is contained in:
parent
67e13bf692
commit
7203a0b8bd
26 changed files with 461 additions and 19 deletions
|
|
@ -38,7 +38,7 @@ import (
|
|||
|
||||
// EnsureSecret creates a Secret object or returns it if it already exists.
|
||||
func (f *Framework) EnsureSecret(secret *api.Secret) *api.Secret {
|
||||
err := createSecretWithRetries(f.KubeClientSet, f.Namespace, secret)
|
||||
err := createSecretWithRetries(f.KubeClientSet, secret.Namespace, secret)
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "creating secret")
|
||||
|
||||
s, err := f.KubeClientSet.CoreV1().Secrets(secret.Namespace).Get(context.TODO(), secret.Name, metav1.GetOptions{})
|
||||
|
|
@ -50,10 +50,10 @@ func (f *Framework) EnsureSecret(secret *api.Secret) *api.Secret {
|
|||
|
||||
// EnsureConfigMap creates a ConfigMap object or returns it if it already exists.
|
||||
func (f *Framework) EnsureConfigMap(configMap *api.ConfigMap) (*api.ConfigMap, error) {
|
||||
cm, err := f.KubeClientSet.CoreV1().ConfigMaps(f.Namespace).Create(context.TODO(), configMap, metav1.CreateOptions{})
|
||||
cm, err := f.KubeClientSet.CoreV1().ConfigMaps(configMap.Namespace).Create(context.TODO(), configMap, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
if k8sErrors.IsAlreadyExists(err) {
|
||||
return f.KubeClientSet.CoreV1().ConfigMaps(f.Namespace).Update(context.TODO(), configMap, metav1.UpdateOptions{})
|
||||
return f.KubeClientSet.CoreV1().ConfigMaps(configMap.Namespace).Update(context.TODO(), configMap, metav1.UpdateOptions{})
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -72,13 +72,13 @@ func (f *Framework) GetIngress(namespace string, name string) *networking.Ingres
|
|||
// EnsureIngress creates an Ingress object and returns it, throws error if it already exists.
|
||||
func (f *Framework) EnsureIngress(ingress *networking.Ingress) *networking.Ingress {
|
||||
fn := func() {
|
||||
err := createIngressWithRetries(f.KubeClientSet, f.Namespace, ingress)
|
||||
err := createIngressWithRetries(f.KubeClientSet, ingress.Namespace, ingress)
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "creating ingress")
|
||||
}
|
||||
|
||||
f.WaitForReload(fn)
|
||||
|
||||
ing := f.GetIngress(f.Namespace, ingress.Name)
|
||||
ing := f.GetIngress(ingress.Namespace, ingress.Name)
|
||||
if ing.Annotations == nil {
|
||||
ing.Annotations = make(map[string]string)
|
||||
}
|
||||
|
|
@ -88,10 +88,10 @@ func (f *Framework) EnsureIngress(ingress *networking.Ingress) *networking.Ingre
|
|||
|
||||
// UpdateIngress updates an Ingress object and returns the updated object.
|
||||
func (f *Framework) UpdateIngress(ingress *networking.Ingress) *networking.Ingress {
|
||||
err := updateIngressWithRetries(f.KubeClientSet, f.Namespace, ingress)
|
||||
err := updateIngressWithRetries(f.KubeClientSet, ingress.Namespace, ingress)
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "updating ingress")
|
||||
|
||||
ing := f.GetIngress(f.Namespace, ingress.Name)
|
||||
ing := f.GetIngress(ingress.Namespace, ingress.Name)
|
||||
if ing.Annotations == nil {
|
||||
ing.Annotations = make(map[string]string)
|
||||
}
|
||||
|
|
@ -113,15 +113,15 @@ func (f *Framework) GetService(namespace string, name string) *core.Service {
|
|||
|
||||
// EnsureService creates a Service object and returns it, throws error if it already exists.
|
||||
func (f *Framework) EnsureService(service *core.Service) *core.Service {
|
||||
err := createServiceWithRetries(f.KubeClientSet, f.Namespace, service)
|
||||
err := createServiceWithRetries(f.KubeClientSet, service.Namespace, service)
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "creating service")
|
||||
|
||||
return f.GetService(f.Namespace, service.Name)
|
||||
return f.GetService(service.Namespace, service.Name)
|
||||
}
|
||||
|
||||
// EnsureDeployment creates a Deployment object and returns it, throws error if it already exists.
|
||||
func (f *Framework) EnsureDeployment(deployment *appsv1.Deployment) *appsv1.Deployment {
|
||||
err := createDeploymentWithRetries(f.KubeClientSet, f.Namespace, deployment)
|
||||
err := createDeploymentWithRetries(f.KubeClientSet, deployment.Namespace, deployment)
|
||||
assert.Nil(ginkgo.GinkgoT(), err, "creating deployment")
|
||||
|
||||
d, err := f.KubeClientSet.AppsV1().Deployments(deployment.Namespace).Get(context.TODO(), deployment.Name, metav1.GetOptions{})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue