This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --flux-namespace setting that specifies namespaces to watch.
Currently, Flux expects to have access to all namespaces, even if no manifests in the repository reference another namespace, it will check all namespaces for controllers to update. This change adds a --flux-namespace setting which, if set, will restrict Flux to only watch the specified namespace and ignore all others.
- Loading branch information
Your Name
committed
Jul 2, 2018
1 parent
e0e6b70
commit 053f75f
Showing
3 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package kubernetes | ||
|
||
import ( | ||
apiv1 "k8s.io/api/core/v1" | ||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
fakekubernetes "k8s.io/client-go/kubernetes/fake" | ||
"testing" | ||
"reflect" | ||
) | ||
|
||
func newNamespace(name string) *apiv1.Namespace { | ||
return &apiv1.Namespace{ | ||
ObjectMeta: meta_v1.ObjectMeta{ | ||
Name: name, | ||
}, | ||
TypeMeta: meta_v1.TypeMeta{ | ||
APIVersion: "v1", | ||
Kind: "Namespace", | ||
}, | ||
} | ||
} | ||
|
||
func testGetNamespaces(t *testing.T, namespace string, expected []string) { | ||
clientset := fakekubernetes.NewSimpleClientset(newNamespace("default"), | ||
newNamespace("kube-system")) | ||
|
||
c := NewCluster(clientset, nil, nil, nil, namespace, nil) | ||
|
||
namespaces, err := c.GetNamespaces() | ||
if err != nil { | ||
t.Errorf("The error should be nil, not: %s", err) | ||
} | ||
|
||
result := []string{} | ||
for _, namespace := range namespaces { | ||
result = append(result, namespace.ObjectMeta.Name) | ||
} | ||
|
||
if reflect.DeepEqual(result, expected) != true { | ||
t.Errorf("Unexpected namespaces: %v != %v.", result, expected) | ||
} | ||
} | ||
|
||
func TestGetNamespacesDefault(t *testing.T) { | ||
testGetNamespaces(t, "", []string{"default","kube-system",}) | ||
} | ||
|
||
func TestGetNamespacesNamespaceSet(t *testing.T) { | ||
testGetNamespaces(t, "default", []string{"default",}) | ||
} | ||
|
||
func TestGetNamespacesNamespaceSetDoesNotExist(t *testing.T) { | ||
testGetNamespaces(t, "hello", []string{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters