Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Add testing helper to create labeled namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Manno committed Apr 21, 2020
1 parent bc0838f commit a1c5009
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion testing/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ func NewMachine() Machine {

// CreateNamespace creates a namespace, it doesn't return an error if the namespace exists
func (m *Machine) CreateNamespace(namespace string) (TearDownFunc, error) {
return m.CreateLabeledNamespace(namespace, map[string]string{})
}

// CreateLabeledNamespace creates a namespace, it doesn't return an error if the namespace exists
func (m *Machine) CreateLabeledNamespace(namespace string, labels map[string]string) (TearDownFunc, error) {
client := m.Clientset.CoreV1().Namespaces()
ns := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: namespace,
Name: namespace,
Labels: labels,
},
}
_, err := client.Create(ns)
Expand Down

0 comments on commit a1c5009

Please sign in to comment.