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' => [ diff --git a/src/Kinds/K8sIngress.php b/src/Kinds/K8sIngress.php index 81e56d60..41821bf2 100644 --- a/src/Kinds/K8sIngress.php +++ b/src/Kinds/K8sIngress.php @@ -81,4 +81,25 @@ 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', []); + } } diff --git a/tests/IngressTest.php b/tests/IngressTest.php index 7ed8364a..73d46f1f 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()); }