-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
603 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/* Icinga for Kubernetes Web | (c) 2024 Icinga GmbH | AGPLv3 */ | ||
|
||
namespace Icinga\Module\Kubernetes\Web; | ||
|
||
use Icinga\Module\Kubernetes\Model\CronJob; | ||
use ipl\Html\Attributes; | ||
use ipl\Html\HtmlDocument; | ||
use ipl\Html\HtmlElement; | ||
use ipl\Html\Text; | ||
use ipl\Html\ValidHtml; | ||
use ipl\Stdlib\Filter; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
class CronJobEnvironment implements ValidHtml | ||
{ | ||
private CronJob $cronJob; | ||
|
||
public function __construct($cronJob) | ||
{ | ||
$this->cronJob = $cronJob; | ||
} | ||
|
||
public function render(): ValidHtml | ||
{ | ||
$childrenFilter = Filter::all( | ||
Filter::equal('namespace', $this->cronJob->namespace), | ||
Filter::equal('job.owner.owner_uuid', Uuid::fromBytes($this->cronJob->uuid)->toString()), | ||
); | ||
|
||
$jobs = $this->cronJob->job | ||
->filter($childrenFilter) | ||
->limit(3); | ||
|
||
return (new HtmlDocument()) | ||
->addHtml( | ||
new HtmlElement( | ||
'h2', | ||
Attributes::create(['class' => 'environment-widget-title']), | ||
Text::create(t('Environment')) | ||
), | ||
new Environment($this->cronJob, null, $jobs, null, $childrenFilter) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* Icinga for Kubernetes Web | (c) 2024 Icinga GmbH | AGPLv3 */ | ||
|
||
namespace Icinga\Module\Kubernetes\Web; | ||
|
||
use Icinga\Module\Kubernetes\Common\Database; | ||
use Icinga\Module\Kubernetes\Model\DaemonSet; | ||
use Icinga\Module\Kubernetes\Model\Pod; | ||
use ipl\Html\Attributes; | ||
use ipl\Html\HtmlDocument; | ||
use ipl\Html\HtmlElement; | ||
use ipl\Html\Text; | ||
use ipl\Html\ValidHtml; | ||
use ipl\Stdlib\Filter; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
class DaemonSetEnvironment implements ValidHtml | ||
{ | ||
private DaemonSet $daemonSet; | ||
|
||
public function __construct($daemonSet) | ||
{ | ||
$this->daemonSet = $daemonSet; | ||
} | ||
|
||
public function render(): ValidHtml | ||
{ | ||
$childrenFilter = Filter::all( | ||
Filter::equal('namespace', $this->daemonSet->namespace), | ||
Filter::equal('pod.owner.owner_uuid', Uuid::fromBytes($this->daemonSet->uuid)->toString()) | ||
); | ||
|
||
$pods = Pod::on(Database::connection()) | ||
->filter($childrenFilter) | ||
->limit(3); | ||
|
||
return (new HtmlDocument()) | ||
->addHtml( | ||
new HtmlElement( | ||
'h2', | ||
Attributes::create(['class' => 'environment-widget-title']), | ||
Text::create(t('Environment')) | ||
), | ||
new Environment($this->daemonSet, null, $pods, null, $childrenFilter) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* Icinga for Kubernetes Web | (c) 2024 Icinga GmbH | AGPLv3 */ | ||
|
||
namespace Icinga\Module\Kubernetes\Web; | ||
|
||
use Icinga\Module\Kubernetes\Common\Database; | ||
use Icinga\Module\Kubernetes\Model\Deployment; | ||
use Icinga\Module\Kubernetes\Model\ReplicaSet; | ||
use ipl\Html\Attributes; | ||
use ipl\Html\HtmlDocument; | ||
use ipl\Html\HtmlElement; | ||
use ipl\Html\Text; | ||
use ipl\Html\ValidHtml; | ||
use ipl\Stdlib\Filter; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
class DeploymentEnvironment implements ValidHtml | ||
{ | ||
private Deployment $deployment; | ||
|
||
public function __construct($deployment) | ||
{ | ||
$this->deployment = $deployment; | ||
} | ||
|
||
public function render(): ValidHtml | ||
{ | ||
$childrenFilter = Filter::all( | ||
Filter::equal('namespace', $this->deployment->namespace), | ||
Filter::equal('replica_set.owner.owner_uuid', Uuid::fromBytes($this->deployment->uuid)->toString()) | ||
); | ||
|
||
$replicaSets = ReplicaSet::on(Database::connection()) | ||
->filter($childrenFilter) | ||
->limit(3); | ||
|
||
return (new HtmlDocument()) | ||
->addHtml( | ||
new HtmlElement( | ||
'h2', | ||
Attributes::create(['class' => 'environment-widget-title']), | ||
Text::create(t('Environment')) | ||
), | ||
new Environment($this->deployment, null, $replicaSets, $childrenFilter) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* Icinga for Kubernetes Web | (c) 2024 Icinga GmbH | AGPLv3 */ | ||
|
||
namespace Icinga\Module\Kubernetes\Web; | ||
|
||
use Icinga\Module\Kubernetes\Common\Database; | ||
use Icinga\Module\Kubernetes\Model\Ingress; | ||
use Icinga\Module\Kubernetes\Model\Service; | ||
use ipl\Html\Attributes; | ||
use ipl\Html\HtmlDocument; | ||
use ipl\Html\HtmlElement; | ||
use ipl\Html\Text; | ||
use ipl\Html\ValidHtml; | ||
use ipl\Stdlib\Filter; | ||
|
||
class IngressEnvironment implements ValidHtml | ||
{ | ||
private Ingress $ingress; | ||
|
||
public function __construct($ingress) | ||
{ | ||
$this->ingress = $ingress; | ||
} | ||
|
||
public function render(): ValidHtml | ||
{ | ||
$services = Service::on(Database::connection()) | ||
->filter(Filter::equal('namespace', $this->ingress->namespace)); | ||
|
||
$filters = []; | ||
foreach ($this->ingress->backend_service as $backendService) { | ||
$filters[] = Filter::all( | ||
Filter::equal('service.name', $backendService->service_name), | ||
Filter::equal('service.port.port', $backendService->service_port_number) | ||
); | ||
} | ||
|
||
$services->filter(Filter::any(...$filters)) | ||
->limit(3); | ||
|
||
return (new HtmlDocument()) | ||
->addHtml( | ||
new HtmlElement( | ||
'h2', | ||
Attributes::create(['class' => 'environment-widget-title']), | ||
Text::create(t('Environment')) | ||
), | ||
new Environment($this->ingress, null, $services, null, Filter::any(...$filters)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/* Icinga for Kubernetes Web | (c) 2024 Icinga GmbH | AGPLv3 */ | ||
|
||
namespace Icinga\Module\Kubernetes\Web; | ||
|
||
use Icinga\Module\Kubernetes\Common\Database; | ||
use Icinga\Module\Kubernetes\Model\CronJob; | ||
use Icinga\Module\Kubernetes\Model\Job; | ||
use Icinga\Module\Kubernetes\Model\JobOwner; | ||
use Icinga\Module\Kubernetes\Model\Pod; | ||
use ipl\Html\Attributes; | ||
use ipl\Html\HtmlDocument; | ||
use ipl\Html\HtmlElement; | ||
use ipl\Html\Text; | ||
use ipl\Html\ValidHtml; | ||
use ipl\Stdlib\Filter; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
class JobEnvironment implements ValidHtml | ||
{ | ||
private Job $job; | ||
|
||
public function __construct($job) | ||
{ | ||
$this->job = $job; | ||
} | ||
|
||
public function render(): ValidHtml | ||
{ | ||
$jobOwner = JobOwner::on(Database::connection()) | ||
->filter(Filter::equal('job_uuid', Uuid::fromBytes($this->job->uuid)->toString()))->first(); | ||
|
||
$parentsFilter = Filter::all(); | ||
|
||
if ($jobOwner !== null) { | ||
$parentsFilter = Filter::equal('uuid', Uuid::fromBytes($jobOwner->owner_uuid)->toString()); | ||
|
||
$cronJobs = CronJob::on(Database::connection()) | ||
->filter($parentsFilter) | ||
->limit(3); | ||
} else { | ||
$cronJobs = null; | ||
} | ||
|
||
$childrenFilter = Filter::all( | ||
Filter::equal('namespace', $this->job->namespace), | ||
Filter::equal('pod.owner.owner_uuid', Uuid::fromBytes($this->job->uuid)->toString()) | ||
); | ||
|
||
$pods = Pod::on(Database::connection()) | ||
->filter($childrenFilter) | ||
->limit(3); | ||
|
||
return (new HtmlDocument()) | ||
->addHtml( | ||
new HtmlElement( | ||
'h2', | ||
Attributes::create(['class' => 'environment-widget-title']), | ||
Text::create(t('Environment')) | ||
), | ||
new Environment($this->job, $cronJobs, $pods, $parentsFilter, $childrenFilter) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
library/Kubernetes/Web/PersistentVolumeClaimEnvironment.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* Icinga for Kubernetes Web | (c) 2024 Icinga GmbH | AGPLv3 */ | ||
|
||
namespace Icinga\Module\Kubernetes\Web; | ||
|
||
use Icinga\Module\Kubernetes\Model\PersistentVolumeClaim; | ||
use ipl\Html\Attributes; | ||
use ipl\Html\HtmlDocument; | ||
use ipl\Html\HtmlElement; | ||
use ipl\Html\Text; | ||
use ipl\Html\ValidHtml; | ||
use ipl\Stdlib\Filter; | ||
|
||
class PersistentVolumeClaimEnvironment implements ValidHtml | ||
{ | ||
private PersistentVolumeClaim $pvc; | ||
|
||
public function __construct($pvc) | ||
{ | ||
$this->pvc = $pvc; | ||
} | ||
|
||
public function render(): ValidHtml | ||
{ | ||
$childrenFilter = Filter::equal('pod.pvc.name', $this->pvc->name); | ||
|
||
$pods = $this->pvc->pod | ||
->filter($childrenFilter) | ||
->limit(3); | ||
|
||
return (new HtmlDocument()) | ||
->addHtml( | ||
new HtmlElement( | ||
'h2', | ||
Attributes::create(['class' => 'environment-widget-title']), | ||
Text::create(t('Environment')) | ||
), | ||
new Environment($this->pvc, $this->pvc->persistent_volume, $pods, null, $childrenFilter) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.