Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/kinds/Ingress.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
21 changes: 21 additions & 0 deletions src/Kinds/K8sIngress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', []);
}
}
17 changes: 17 additions & 0 deletions tests/IngressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,33 @@ 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);

$this->assertEquals('networking.k8s.io/v1beta1', $ing->getApiVersion());
$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());
}

Expand Down Expand Up @@ -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());
Expand All @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down