-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/k8sReleases' into 'master'
Add support for Kubernetes cluster upgrades See merge request transip/restapi-php-library!242
- Loading branch information
Showing
5 changed files
with
96 additions
and
1 deletion.
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,16 @@ | ||
<?php | ||
|
||
namespace Transip\Api\Library\Entity\Kubernetes\Cluster; | ||
|
||
class Release extends \Transip\Api\Library\Entity\Kubernetes\Release | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
protected $isCompatibleUpgrade; | ||
|
||
public function isCompatibleUpgrade(): bool | ||
{ | ||
return $this->isCompatibleUpgrade; | ||
} | ||
} |
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,55 @@ | ||
<?php | ||
|
||
namespace Transip\Api\Library\Repository\Kubernetes\Cluster; | ||
|
||
use Transip\Api\Library\Entity\Kubernetes\Cluster\Release as KubernetesRelease; | ||
use Transip\Api\Library\Repository\ApiRepository; | ||
|
||
class ReleaseRepository extends ApiRepository | ||
{ | ||
public const RESOURCE_NAME = 'releases'; | ||
public const RESOURCE_PARAMETER_SINGULAR = 'release'; | ||
public const RESOURCE_PARAMETER_PLURAL = 'releases'; | ||
|
||
/** | ||
* @return KubernetesRelease[] | ||
*/ | ||
public function getAll(string $clusterName): array | ||
{ | ||
return $this->getReleases($clusterName, []); | ||
} | ||
|
||
/** | ||
* @return KubernetesRelease[] | ||
*/ | ||
public function getCompatibleUpgrades(string $clusterName): array | ||
{ | ||
return $this->getReleases($clusterName, ['isCompatibleUpgrade' => true]); | ||
} | ||
|
||
public function getByVersion(string $clusterName, string $version): KubernetesRelease | ||
{ | ||
$response = $this->httpClient->get($this->getResourceUrl($clusterName, $version)); | ||
|
||
return new KubernetesRelease($this->getParameterFromResponse($response, self::RESOURCE_PARAMETER_SINGULAR)); | ||
} | ||
|
||
/** | ||
* @param string $clusterName | ||
* @param array<string, mixed> $query | ||
* @return KubernetesRelease[] | ||
*/ | ||
private function getReleases(string $clusterName, array $query = []): array | ||
{ | ||
$releases = []; | ||
|
||
$response = $this->httpClient->get($this->getResourceUrl($clusterName), $query); | ||
$releasesArrays = $this->getParameterFromResponse($response, self::RESOURCE_PARAMETER_PLURAL); | ||
|
||
foreach ($releasesArrays as $releasesArray) { | ||
$releases[] = new KubernetesRelease($releasesArray); | ||
} | ||
|
||
return $releases; | ||
} | ||
} |
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