Skip to content

Commit

Permalink
Explose call() to public for cluster calls
Browse files Browse the repository at this point in the history
  • Loading branch information
rennokki committed May 8, 2021
1 parent d9f054b commit 9dd84d6
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/KubernetesCluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,16 @@ public function getWsClient(string $url): array
}

/**
* Call the API with the specified method and path.
* Make a HTTP call to a given path with a method and payload.
*
* @param string $method
* @param string $path
* @param string $payload
* @param array $query
* @return mixed
* @throws \RenokiCo\PhpK8s\Exceptions\KubernetesAPIException
* @return \Psr\Http\Message\ResponseInterface
*/
protected function makeRequest(string $method, string $path, string $payload = '', array $query = ['pretty' => 1])
public function call(string $method, string $path, string $payload = '', array $query = ['pretty' => 1])
{
$resourceClass = $this->resourceClass;

try {
$response = $this->getClient()->request($method, $this->getCallableUrl($path, $query), [
RequestOptions::BODY => $payload,
Expand All @@ -231,6 +228,25 @@ protected function makeRequest(string $method, string $path, string $payload = '
);
}

return $response;
}

/**
* Call the API with the specified method and path.
*
* @param string $method
* @param string $path
* @param string $payload
* @param array $query
* @return mixed
* @throws \RenokiCo\PhpK8s\Exceptions\KubernetesAPIException
*/
protected function makeRequest(string $method, string $path, string $payload = '', array $query = ['pretty' => 1])
{
$resourceClass = $this->resourceClass;

$response = $this->call($method, $path, $payload, $query);

$json = @json_decode($response->getBody(), true);

// If the output is not JSONable, return the response itself.
Expand Down

0 comments on commit 9dd84d6

Please sign in to comment.