mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-12 12:48:51 +00:00
Add option to require API tokens to exist in admission
This commit is contained in:
@@ -35,19 +35,10 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
// createNamespaceIfDoesNotExist ensures that the namespace with specified name exists, or returns an error
|
||||
func createNamespaceIfDoesNotExist(c *client.Client, name string) (*api.Namespace, error) {
|
||||
namespace, err := c.Namespaces().Get(name)
|
||||
if err != nil {
|
||||
namespace, err = c.Namespaces().Create(&api.Namespace{ObjectMeta: api.ObjectMeta{Name: name}})
|
||||
}
|
||||
return namespace, err
|
||||
}
|
||||
|
||||
func runLivenessTest(c *client.Client, podDescr *api.Pod, expectRestart bool) {
|
||||
ns := "e2e-test-" + string(util.NewUUID())
|
||||
_, err := createNamespaceIfDoesNotExist(c, ns)
|
||||
expectNoError(err, fmt.Sprintf("creating namespace %s", ns))
|
||||
namespace, err := createTestingNS("pods-liveness", c)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
ns := namespace.Name
|
||||
|
||||
By(fmt.Sprintf("Creating pod %s in namespace %s", podDescr.Name, ns))
|
||||
_, err = c.Pods(ns).Create(podDescr)
|
||||
@@ -96,9 +87,9 @@ func runLivenessTest(c *client.Client, podDescr *api.Pod, expectRestart bool) {
|
||||
|
||||
// testHostIP tests that a pod gets a host IP
|
||||
func testHostIP(c *client.Client, pod *api.Pod) {
|
||||
ns := "e2e-test-" + string(util.NewUUID())
|
||||
_, err := createNamespaceIfDoesNotExist(c, ns)
|
||||
expectNoError(err, fmt.Sprintf("creating namespace %s", ns))
|
||||
namespace, err := createTestingNS("pods-host-ip", c)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
ns := namespace.Name
|
||||
|
||||
podClient := c.Pods(ns)
|
||||
By("creating pod")
|
||||
|
Reference in New Issue
Block a user