Skip to content

Commit

Permalink
Merge pull request #32 from gd-jroberts/master
Browse files Browse the repository at this point in the history
Add HPA support
  • Loading branch information
maclof authored May 8, 2018
2 parents 0e34e6b + c36b777 commit 8a7ab98
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* @method IngressRepository ingresses()
* @method NamespaceRepository namespaces()
* @method NetworkPolicyRepository networkPolicies()
* @method HorizontalPodAutoscalerRepository horizontalPodAutoscalers()
*/
class Client
{
Expand Down Expand Up @@ -160,6 +161,9 @@ class Client
'deployments' => 'Repositories\DeploymentRepository',
'ingresses' => 'Repositories\IngressRepository',

// autoscaling/v2beta1
'horizontalPodAutoscalers' => 'Repositories\HorizontalPodAutoscalerRepository',

// networking.k8s.io/v1
'networkPolicies' => 'Repositories\NetworkPolicyRepository',
];
Expand Down
31 changes: 31 additions & 0 deletions src/Collections/HorizontalPodAutoscalerCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php namespace Maclof\Kubernetes\Collections;

use Maclof\Kubernetes\Models\HorizontalPodAutoscaler;

class HorizontalPodAutoscalerCollection extends Collection
{
/**
* The constructor.
*
* @param array $data
*/
public function __construct(array $data)
{
parent::__construct($this->getHorizontalPodAutoscalers(isset($data['items']) ? $data['items'] : []));
}

/**
* Get an array of autoscalers.
*
* @param array $items
* @return array
*/
protected function getHorizontalPodAutoscalers(array $items)
{
foreach ($items as &$item) {
$item = new HorizontalPodAutoscaler($item);
}

return $items;
}
}
11 changes: 11 additions & 0 deletions src/Models/HorizontalPodAutoscaler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php namespace Maclof\Kubernetes\Models;

class HorizontalPodAutoscaler extends \Maclof\Kubernetes\Models\Model
{
/**
* The api version.
*
* @var string
*/
protected $apiVersion = 'autoscaling/v2beta1';
}
13 changes: 13 additions & 0 deletions src/Repositories/HorizontalPodAutoscalerRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php namespace Maclof\Kubernetes\Repositories;

use Maclof\Kubernetes\Collections\HorizontalPodAutoscalerCollection;

class HorizontalPodAutoscalerRepository extends Repository
{
protected $uri = 'horizontalpodautoscalers';

protected function createCollection($response)
{
return new HorizontalPodAutoscalerCollection($response);
}
}

0 comments on commit 8a7ab98

Please sign in to comment.