Skip to content

Commit

Permalink
Merge pull request #21 from SysBind/persistentVolume
Browse files Browse the repository at this point in the history
Persistent volume
  • Loading branch information
maclof authored Mar 13, 2018
2 parents 9d193d3 + 8e44ae0 commit 7bf127d
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
/clover.xml
/composer.lock
/.idea
/.settings/
/.buildpath
/.project
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ $ composer require maclof/kubernetes-client
* Events
* Config Maps
* Endpoints
* Persistent Volume
* Persistent Volume Claims

### batch/v1
Expand Down
4 changes: 4 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
use Maclof\Kubernetes\Repositories\IngressRepository;
use Maclof\Kubernetes\Repositories\JobRepository;
use Maclof\Kubernetes\Repositories\NodeRepository;
use Maclof\Kubernetes\Repositories\PersistentVolumeRepository;
use Maclof\Kubernetes\Repositories\PersistentVolumeClaimRepository;
use Maclof\Kubernetes\Repositories\PodRepository;
use Maclof\Kubernetes\Repositories\ReplicaSetRepository;
use Maclof\Kubernetes\Repositories\ReplicationControllerRepository;
use Maclof\Kubernetes\Repositories\SecretRepository;
use Maclof\Kubernetes\Repositories\ServiceRepository;
use Maclof\Kubernetes\Repositories\NamespaceRepository;
use Maclof\Kubernetes\Models\PersistentVolume;

/**
* @method NodeRepository nodes()
Expand All @@ -35,6 +37,7 @@
* @method ConfigMapRepository configMaps()
* @method EndpointRepository endpoints()
* @method PersistentVolumeClaimRepository persistentVolumeClaims()
* @method PersistentVolumeRepository persistentVolume()
* @method JobRepository jobs()
* @method CronJobRepository cronJobs()
* @method DaemonSetRepository daemonSets()
Expand Down Expand Up @@ -130,6 +133,7 @@ class Client
'events' => 'Repositories\EventRepository',
'configMaps' => 'Repositories\ConfigMapRepository',
'endpoints' => 'Repositories\EndpointRepository',
'persistentVolume' => 'Repositories\PersistentVolumeRepository',
'persistentVolumeClaims' => 'Repositories\PersistentVolumeClaimRepository',
'namespaces' => 'Repositories\NamespaceRepository',

Expand Down
27 changes: 27 additions & 0 deletions src/Collections/PersistentVolumeCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace Maclof\Kubernetes\Collections;

use Maclof\Kubernetes\Models\PersistentVolume;
use Maclof\Kubernetes\Collections\Collection;
/**
*
* @author avi
*
*/
class PersistentVolumeCollection extends Collection
{
public function __construct(array $data)
{
parent::__construct($this->getPersistentVolume(isset($data['items']) ? $data['items'] : []));
}

protected function getPersistentVolume(array $items)
{
foreach ($items as &$item) {
$item = new PersistentVolume($item);
}

return $items;
}
}

12 changes: 12 additions & 0 deletions src/Models/PersistentVolume.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
namespace Maclof\Kubernetes\Models;

/**
*
* @author avi
*
*/
class PersistentVolume extends Model
{
}

46 changes: 46 additions & 0 deletions src/Repositories/PersistentVolumeRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
namespace Maclof\Kubernetes\Repositories;

use Maclof\Kubernetes\Collections\PersistentVolumeCollection;

/**
*
* @author avi
*
*/
class PersistentVolumeRepository extends Repository
{
protected $uri = 'persistentvolumes';
/**
* (non-PHPdoc)
*
* @see \Maclof\Kubernetes\Repositories\Repository::createCollection()
*
*/
protected function createCollection($response)
{
return new PersistentVolumeCollection($response);
}

/**
* Send a request.
*
* @param string $method
* @param string $uri
* @param array $query
* @param mixed $body
* @param boolean $namespace
* @return array
*/
protected function sendRequest($method, $uri, $query = [], $body = [], $namespace = false)
{
$namespace = false;
$apiVersion = $this->getApiVersion();
if ($apiVersion == 'v1') {
$apiVersion = null;
}

return $this->client->sendRequest($method, $uri, $query, $body, $namespace, $apiVersion);
}
}

0 comments on commit 7bf127d

Please sign in to comment.