Skip to content
Snippets Groups Projects
Commit 87bd62aa authored by Yas Naoi's avatar Yas Naoi
Browse files

Issue #3284108 by yas, Xiaohua Guan, shota niioka: Refactor to update K8s resources

parent 0da61b68
No related branches found
No related tags found
3 merge requests!1316Issue #3310263: Release 4.5.0,!1260Issue #3307397: Release 4.4.0,!1021Issue #3284108: Refactor to update K8s resources
Showing
with 185 additions and 372 deletions
<?php
namespace Drupal\k8s\Service\K8sClientExtension\Repositories;
use Drupal\k8s\Service\K8sClientExtension\Collections\K8sServiceAccountCollection;
use Maclof\Kubernetes\Repositories\Repository;
/**
* K8s ServiceAccount repository.
*/
class K8sServiceAccountRepository extends Repository {
/**
* The uri.
*
* @var string
*/
protected string $uri = 'serviceaccounts';
/**
* {@inheritdoc}
*/
protected function createCollection(array $response): K8sServiceAccountCollection {
return new K8sServiceAccountCollection($response['items']);
}
}
......@@ -2,13 +2,13 @@
namespace Drupal\k8s\Service\K8sClientExtension\Repositories;
use Drupal\k8s\Service\K8sClientExtension\Collections\K8sLimitRangeCollection;
use Drupal\k8s\Service\K8sClientExtension\Collections\LimitRangeCollection;
use Maclof\Kubernetes\Repositories\Repository;
/**
* K8s LimitRange repository.
*/
class K8sLimitRangeRepository extends Repository {
class LimitRangeRepository extends Repository {
/**
* The uri.
......@@ -20,8 +20,8 @@ class K8sLimitRangeRepository extends Repository {
/**
* {@inheritdoc}
*/
protected function createCollection(array $response): K8sLimitRangeCollection {
return new K8sLimitRangeCollection($response['items']);
protected function createCollection(array $response): LimitRangeCollection {
return new LimitRangeCollection($response['items']);
}
}
......@@ -2,13 +2,13 @@
namespace Drupal\k8s\Service\K8sClientExtension\Repositories;
use Drupal\k8s\Service\K8sClientExtension\Collections\K8sMetricsNodeCollection;
use Drupal\k8s\Service\K8sClientExtension\Collections\MetricsNodeCollection;
use Maclof\Kubernetes\Repositories\Repository;
/**
* K8s node repository for metrics.
*/
class K8sMetricsNodeRepository extends Repository {
class MetricsNodeRepository extends Repository {
/**
* The uri.
......@@ -27,9 +27,9 @@ class K8sMetricsNodeRepository extends Repository {
/**
* {@inheritdoc}
*/
protected function createCollection($response): K8sMetricsNodeCollection {
protected function createCollection($response): MetricsNodeCollection {
// K8s API server may return a string '404 page not found', not an array.
return new K8sMetricsNodeCollection(is_array($response)
return new MetricsNodeCollection(is_array($response)
? $response['items']
: ['items' => []]
);
......
......@@ -2,13 +2,13 @@
namespace Drupal\k8s\Service\K8sClientExtension\Repositories;
use Drupal\k8s\Service\K8sClientExtension\Collections\K8sMetricsPodCollection;
use Drupal\k8s\Service\K8sClientExtension\Collections\MetricsPodCollection;
use Maclof\Kubernetes\Repositories\Repository;
/**
* K8s pod repository for metrics.
*/
class K8sMetricsPodRepository extends Repository {
class MetricsPodRepository extends Repository {
/**
* The uri.
......@@ -20,9 +20,9 @@ class K8sMetricsPodRepository extends Repository {
/**
* {@inheritdoc}
*/
protected function createCollection($response): K8sMetricsPodCollection {
protected function createCollection($response): MetricsPodCollection {
// K8s API server may return a string '404 page not found', not an array.
return new K8sMetricsPodCollection(is_array($response)
return new MetricsPodCollection(is_array($response)
? $response['items']
: ['items' => []]
);
......
......@@ -2,13 +2,13 @@
namespace Drupal\k8s\Service\K8sClientExtension\Repositories;
use Drupal\k8s\Service\K8sClientExtension\Collections\K8sPriorityClassCollection;
use Drupal\k8s\Service\K8sClientExtension\Collections\PriorityClassCollection;
use Maclof\Kubernetes\Repositories\Repository;
/**
* K8s cluster priority class repository.
*/
class K8sPriorityClassRepository extends Repository {
class PriorityClassRepository extends Repository {
/**
* The uri.
......@@ -27,8 +27,8 @@ class K8sPriorityClassRepository extends Repository {
/**
* {@inheritdoc}
*/
protected function createCollection(array $response): K8sPriorityClassCollection {
return new K8sPriorityClassCollection($response['items']);
protected function createCollection(array $response): PriorityClassCollection {
return new PriorityClassCollection($response['items']);
}
/**
......
......@@ -2,13 +2,13 @@
namespace Drupal\k8s\Service\K8sClientExtension\Repositories;
use Drupal\k8s\Service\K8sClientExtension\Collections\K8sStatefulSetCollection;
use Drupal\k8s\Service\K8sClientExtension\Collections\StatefulSetCollection;
use Maclof\Kubernetes\Repositories\Repository;
/**
* K8s StatefulSet repository.
*/
class K8sStatefulSetRepository extends Repository {
class StatefulSetRepository extends Repository {
/**
* The uri.
......@@ -20,8 +20,8 @@ class K8sStatefulSetRepository extends Repository {
/**
* {@inheritdoc}
*/
protected function createCollection(array $response): K8sStatefulSetCollection {
return new K8sStatefulSetCollection($response['items']);
protected function createCollection(array $response): StatefulSetCollection {
return new StatefulSetCollection($response['items']);
}
/**
......
......@@ -2,13 +2,13 @@
namespace Drupal\k8s\Service\K8sClientExtension\Repositories;
use Drupal\k8s\Service\K8sClientExtension\Collections\K8sStorageClassCollection;
use Drupal\k8s\Service\K8sClientExtension\Collections\StorageClassCollection;
use Maclof\Kubernetes\Repositories\Repository;
/**
* K8s storage class repository.
*/
class K8sStorageClassRepository extends Repository {
class StorageClassRepository extends Repository {
/**
* The uri.
......@@ -20,8 +20,8 @@ class K8sStorageClassRepository extends Repository {
/**
* {@inheritdoc}
*/
protected function createCollection(array $response): K8sStorageClassCollection {
return new K8sStorageClassCollection($response['items']);
protected function createCollection(array $response): StorageClassCollection {
return new StorageClassCollection($response['items']);
}
/**
......
......@@ -110,7 +110,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updatePod($namespace, array $params = []): ?array;
......@@ -180,7 +180,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateNamespace(array $params = []): ?array;
......@@ -346,10 +346,10 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateDeployment($namespace, array $params = []): array;
public function updateDeployment($namespace, array $params = []): ?array;
/**
* Delete k8s deployment.
......@@ -396,7 +396,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateReplicaSet($namespace, array $params = []): ?array;
......@@ -462,7 +462,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateNetworkPolicy($namespace, array $params = []): ?array;
......@@ -540,7 +540,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updatePersistentVolume(array $params = []): ?array;
......@@ -600,7 +600,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateClusterRole(array $params = []): ?array;
......@@ -660,7 +660,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateClusterRoleBinding(array $params = []): ?array;
......@@ -720,7 +720,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateStorageClass(array $params = []): ?array;
......@@ -784,7 +784,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateStatefulSet($namespace, array $params = []): ?array;
......@@ -850,7 +850,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateIngress($namespace, array $params = []): ?array;
......@@ -916,7 +916,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateDaemonSet($namespace, array $params = []): ?array;
......@@ -986,7 +986,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateEndpoint($namespace, array $params = []): ?array;
......@@ -1080,7 +1080,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updatePersistentVolumeClaim($namespace, array $params = []): ?array;
......@@ -1146,7 +1146,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateRoleBinding($namespace, array $params = []): ?array;
......@@ -1208,7 +1208,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateApiService(array $params = []): ?array;
......@@ -1272,7 +1272,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateServiceAccount($namespace, array $params = []): ?array;
......@@ -1318,7 +1318,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updatePriorityClass(array $params = []): ?array;
......@@ -1366,7 +1366,7 @@ interface K8sServiceInterface {
* @param array $params
* Parameters array to send to API.
*
* @return mixed
* @return array|null
* An array of results or NULL if there is an error.
*/
public function updateHorizontalPodAutoscaler($namespace, array $params = []): ?array;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment