From 62a9bb2a718f3d71be95371a599923c163ad93ae Mon Sep 17 00:00:00 2001 From: Sven van Hees Date: Thu, 18 Feb 2021 10:45:13 +0100 Subject: [PATCH 1/4] Added Tls to the IngressTest.php --- tests/IngressTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/IngressTest.php b/tests/IngressTest.php index 7ed8364a..90933b95 100644 --- a/tests/IngressTest.php +++ b/tests/IngressTest.php @@ -27,12 +27,25 @@ class IngressTest extends TestCase ], ]]; + /** + * The default testing tls. + * + * @var array + */ + protected static $tls = [[ + 'hosts' => [ + 'nginx.test.com' + ], + 'secretName' => 'verySecretName', + ]]; + public function test_ingress_build() { $ing = $this->cluster->ingress() ->setName('nginx') ->setLabels(['tier' => 'backend']) ->setAnnotations(['nginx/ann' => 'yes']) + ->setTls(self::$tls) ->addRules(self::$rules) ->setRules(self::$rules); @@ -40,6 +53,7 @@ public function test_ingress_build() $this->assertEquals('nginx', $ing->getName()); $this->assertEquals(['tier' => 'backend'], $ing->getLabels()); $this->assertEquals(['nginx/ann' => 'yes'], $ing->getAnnotations()); + $this->assertEquals(self::$tls, $ing->getTls()); $this->assertEquals(self::$rules, $ing->getRules()); } @@ -71,6 +85,7 @@ public function runCreationTests() ->setName('nginx') ->setLabels(['tier' => 'backend']) ->setAnnotations(['nginx/ann' => 'yes']) + ->setTls(self::$tls) ->setRules(self::$rules); $this->assertFalse($ing->isSynced()); @@ -87,6 +102,7 @@ public function runCreationTests() $this->assertEquals('nginx', $ing->getName()); $this->assertEquals(['tier' => 'backend'], $ing->getLabels()); $this->assertEquals(['nginx/ann' => 'yes'], $ing->getAnnotations()); + $this->assertEquals(self::$tls, $ing->getTls()); $this->assertEquals(self::$rules, $ing->getRules()); } @@ -134,6 +150,7 @@ public function runUpdateTests() $this->assertEquals('nginx', $ing->getName()); $this->assertEquals(['tier' => 'backend'], $ing->getLabels()); $this->assertEquals([], $ing->getAnnotations()); + $this->assertEquals(self::$tls, $ing->getTls()); $this->assertEquals(self::$rules, $ing->getRules()); } From 2c8ee08aa07ef86181fbb7abca4c3a95d04f962b Mon Sep 17 00:00:00 2001 From: Sven van Hees Date: Thu, 18 Feb 2021 10:46:53 +0100 Subject: [PATCH 2/4] Added a setTls and getTls spec to satisfy new test --- src/Kinds/K8sIngress.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Kinds/K8sIngress.php b/src/Kinds/K8sIngress.php index 81e56d60..10d4ec20 100644 --- a/src/Kinds/K8sIngress.php +++ b/src/Kinds/K8sIngress.php @@ -81,4 +81,26 @@ public function getRules(): array { return $this->getSpec('rules', []); } + + /** + * Set the spec tls. + * + * @param array $rules + * @return $this + */ + public function setTls(array $tlsData = []) + { + return $this->setSpec('tls', $tlsData); + } + + + /** + * Get the tls spec. + * + * @return array + */ + public function getTls(): array + { + return $this->getSpec('tls', []); + } } From ce5c6c25241d8e6d8b971668449427ce1856950b Mon Sep 17 00:00:00 2001 From: Sven van Hees Date: Thu, 18 Feb 2021 10:51:18 +0100 Subject: [PATCH 3/4] Added new tls spec to the ingress doc. --- docs/kinds/Ingress.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/kinds/Ingress.md b/docs/kinds/Ingress.md index add5b358..075bb0d9 100644 --- a/docs/kinds/Ingress.md +++ b/docs/kinds/Ingress.md @@ -9,6 +9,12 @@ $ingress = $cluster->ingress() ->setName('nginx') ->setLabels(['tier' => 'backend']) ->setSelectors(['app' => 'frontend']) + ->setTls([[ + 'hosts' => [ + 'test.com' + ], + 'secretName'=> 'verySecretName' + ]]) ->setRules([[ 'host' => 'nginx.test.com', 'http' => [ From a462e7c3e56c03991844e44d2e9598731f17fa01 Mon Sep 17 00:00:00 2001 From: Sven van Hees Date: Thu, 18 Feb 2021 10:59:37 +0100 Subject: [PATCH 4/4] Apply styleci fixes. --- src/Kinds/K8sIngress.php | 1 - tests/IngressTest.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Kinds/K8sIngress.php b/src/Kinds/K8sIngress.php index 10d4ec20..41821bf2 100644 --- a/src/Kinds/K8sIngress.php +++ b/src/Kinds/K8sIngress.php @@ -93,7 +93,6 @@ public function setTls(array $tlsData = []) return $this->setSpec('tls', $tlsData); } - /** * Get the tls spec. * diff --git a/tests/IngressTest.php b/tests/IngressTest.php index 90933b95..73d46f1f 100644 --- a/tests/IngressTest.php +++ b/tests/IngressTest.php @@ -34,7 +34,7 @@ class IngressTest extends TestCase */ protected static $tls = [[ 'hosts' => [ - 'nginx.test.com' + 'nginx.test.com', ], 'secretName' => 'verySecretName', ]];