Skip to content

Commit ccb762c

Browse files
authored
Merge pull request #2 from appwrite-labs/logs
fix: make logs return plain-text instead of wrapping as resource
2 parents 6f1d467 + aedcc31 commit ccb762c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/KubernetesCluster.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ public function runOperation(string $operation, string $path, $payload = '', arr
213213
default: break;
214214
}
215215

216-
$method = static::$operations[$operation] ?? static::$operations[static::GET_OP];
217-
218-
return $this->makeRequest($method, $path, $payload, $query);
216+
return $this->makeRequest($operation, $path, $payload, $query);
219217
}
220218

221219
/**
@@ -303,7 +301,7 @@ protected function execPath(
303301
array $query = ['pretty' => 1, 'stdin' => 1, 'stdout' => 1, 'stderr' => 1, 'tty' => 1]
304302
) {
305303
try {
306-
return $this->makeRequest(static::$operations[static::EXEC_OP], $path, '', $query);
304+
return $this->makeRequest(static::EXEC_OP, $path, '', $query);
307305
} catch (KubernetesAPIException $e) {
308306
$payload = $e->getPayload();
309307

@@ -336,7 +334,7 @@ protected function attachPath(
336334
array $query = ['pretty' => 1, 'stdin' => 1, 'stdout' => 1, 'stderr' => 1, 'tty' => 1]
337335
) {
338336
try {
339-
return $this->makeRequest(static::$operations[static::ATTACH_OP], $path, '', $query);
337+
return $this->makeRequest(static::ATTACH_OP, $path, '', $query);
340338
} catch (KubernetesAPIException $e) {
341339
$payload = $e->getPayload();
342340

src/Traits/Cluster/MakesHttpCalls.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,27 +99,32 @@ public function call(string $method, string $path, string $payload = '', array $
9999
/**
100100
* Call the API with the specified method and path.
101101
*
102-
* @param string $method
102+
* @param string $operation
103103
* @param string $path
104104
* @param string $payload
105105
* @param array $query
106106
* @return mixed
107107
*
108108
* @throws \RenokiCo\PhpK8s\Exceptions\KubernetesAPIException
109109
*/
110-
protected function makeRequest(string $method, string $path, string $payload = '', array $query = ['pretty' => 1])
110+
protected function makeRequest(string $operation, string $path, string $payload = '', array $query = ['pretty' => 1])
111111
{
112112
$resourceClass = $this->resourceClass;
113113

114+
$method = static::$operations[$operation] ?? static::$operations[static::GET_OP];
114115
$response = $this->call($method, $path, $payload, $query);
115116

117+
if ($operation === static::LOG_OP) {
118+
return (string) $response->getBody();
119+
}
120+
116121
$json = @json_decode($response->getBody(), true);
117122

118123
// If the output is not JSONable, return the response itself.
119124
// This can be encountered in case of a pod log request, for example,
120125
// where the data returned are just console logs.
121126

122-
if (! $json) {
127+
if (!$json) {
123128
return (string) $response->getBody();
124129
}
125130

0 commit comments

Comments
 (0)