-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some improvement with last version of Kubernetes API (#105)
* Set content type to "application/json" for post request Allow illuminate/support 9+ * Remove beta in api add role,rolebinding and service account
- Loading branch information
1 parent
1eaff45
commit b726e64
Showing
32 changed files
with
457 additions
and
20 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
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Maclof\Kubernetes\Collections; | ||
|
||
use Maclof\Kubernetes\Models\RoleBinding; | ||
|
||
/** | ||
* @author Richard Déloge <[email protected]> | ||
*/ | ||
class RoleBindingCollection extends Collection | ||
{ | ||
/** | ||
* @param array<int, array<mixed>|RoleBinding> $items | ||
*/ | ||
public function __construct(array $items) | ||
{ | ||
parent::__construct($this->getServiceAccounts($items)); | ||
} | ||
|
||
/** | ||
* Get an array of serviceAccounts. | ||
* | ||
* @param array<int, array<mixed>|RoleBinding> $items | ||
* @return array<RoleBinding> | ||
*/ | ||
protected function getServiceAccounts(array $items) | ||
{ | ||
$final = []; | ||
foreach ($items as &$item) { | ||
if (!$item instanceof RoleBinding) { | ||
$final[] = new RoleBinding($item); | ||
} else { | ||
$final[] = $item; | ||
} | ||
} | ||
|
||
return $final; | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Maclof\Kubernetes\Collections; | ||
|
||
use Maclof\Kubernetes\Models\Role; | ||
|
||
/** | ||
* @author Richard Déloge <[email protected]> | ||
*/ | ||
class RoleCollection extends Collection | ||
{ | ||
/** | ||
* @param array<int, array<mixed>|Role> $items | ||
*/ | ||
public function __construct(array $items) | ||
{ | ||
parent::__construct($this->getServiceAccounts($items)); | ||
} | ||
|
||
/** | ||
* Get an array of serviceAccounts. | ||
* | ||
* @param array<int, array<mixed>|Role> $items | ||
* @return array<Role> | ||
*/ | ||
protected function getServiceAccounts(array $items) | ||
{ | ||
$final = []; | ||
foreach ($items as &$item) { | ||
if (!$item instanceof Role) { | ||
$final[] = new Role($item); | ||
} else { | ||
$final[] = $item; | ||
} | ||
} | ||
|
||
return $final; | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Maclof\Kubernetes\Collections; | ||
|
||
use Maclof\Kubernetes\Models\ServiceAccount; | ||
|
||
/** | ||
* @author Richard Déloge <[email protected]> | ||
*/ | ||
class ServiceAccountCollection extends Collection | ||
{ | ||
/** | ||
* @param array<int, array<mixed>|ServiceAccount> $items | ||
*/ | ||
public function __construct(array $items) | ||
{ | ||
parent::__construct($this->getServiceAccounts($items)); | ||
} | ||
|
||
/** | ||
* Get an array of serviceAccounts. | ||
* | ||
* @param array<int, array<mixed>|ServiceAccount> $items | ||
* @return array<ServiceAccount> | ||
*/ | ||
protected function getServiceAccounts(array $items) | ||
{ | ||
$final = []; | ||
foreach ($items as &$item) { | ||
if (!$item instanceof ServiceAccount) { | ||
$final[] = new ServiceAccount($item); | ||
} else { | ||
$final[] = $item; | ||
} | ||
} | ||
|
||
return $final; | ||
} | ||
} |
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
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
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Maclof\Kubernetes\Models; | ||
|
||
/** | ||
* @author Richard Déloge <[email protected]> | ||
*/ | ||
class Role extends Model | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected string $apiVersion = 'rbac.authorization.k8s.io/v1'; | ||
} |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Maclof\Kubernetes\Models; | ||
|
||
/** | ||
* @author Richard Déloge <[email protected]> | ||
*/ | ||
class RoleBinding extends Model | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected string $apiVersion = 'rbac.authorization.k8s.io/v1'; | ||
} |
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Maclof\Kubernetes\Models; | ||
|
||
/** | ||
* @author Richard Déloge <[email protected]> | ||
*/ | ||
class ServiceAccount extends Model | ||
{ | ||
} |
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Maclof\Kubernetes\Repositories; | ||
|
||
use Maclof\Kubernetes\Collections\RoleBindingCollection; | ||
use Maclof\Kubernetes\Models\RoleBinding; | ||
use Maclof\Kubernetes\Collections\Collection; | ||
|
||
/** | ||
* @author Richard Déloge <[email protected]> | ||
*/ | ||
class RoleBindingRepository extends Repository | ||
{ | ||
protected string $uri = 'rolebindings'; | ||
|
||
/** | ||
* @param array{items: array<int, array<mixed>|RoleBinding>} $response | ||
*/ | ||
protected function createCollection(array $response): Collection | ||
{ | ||
return new RoleBindingCollection($response['items']); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Maclof\Kubernetes\Repositories; | ||
|
||
use Maclof\Kubernetes\Collections\RoleCollection; | ||
use Maclof\Kubernetes\Models\Role; | ||
use Maclof\Kubernetes\Collections\Collection; | ||
|
||
/** | ||
* @author Richard Déloge <[email protected]> | ||
*/ | ||
class RoleRepository extends Repository | ||
{ | ||
protected string $uri = 'roles'; | ||
|
||
/** | ||
* @param array{items: array<int, array<mixed>|Role>} $response | ||
*/ | ||
protected function createCollection(array $response): Collection | ||
{ | ||
return new RoleCollection($response['items']); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Maclof\Kubernetes\Repositories; | ||
|
||
use Maclof\Kubernetes\Collections\ServiceAccountCollection; | ||
use Maclof\Kubernetes\Models\ServiceAccount; | ||
use Maclof\Kubernetes\Collections\Collection; | ||
|
||
/** | ||
* @author Richard Déloge <[email protected]> | ||
*/ | ||
class ServiceAccountRepository extends Repository | ||
{ | ||
protected string $uri = 'serviceaccounts'; | ||
|
||
/** | ||
* @param array{items: array<int, array<mixed>|ServiceAccount>} $response | ||
*/ | ||
protected function createCollection(array $response): Collection | ||
{ | ||
return new ServiceAccountCollection($response['items']); | ||
} | ||
} |
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
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.