Skip to content

Commit ff8376e

Browse files
committed
feat: add metadata and resourceVersion to ResourcesList
1 parent d9bfc81 commit ff8376e

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/ResourcesList.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,22 @@
33
namespace RenokiCo\PhpK8s;
44

55
use Illuminate\Support\Collection;
6+
use RenokiCo\PhpK8s\Traits\Resource\HasAttributes;
67

78
class ResourcesList extends Collection
89
{
9-
//
10+
use HasAttributes;
11+
12+
public function __construct($items, $metadata)
13+
{
14+
parent::__construct($items);
15+
foreach ($metadata as $key => $value) {
16+
$this->setAttribute("metadata.$key", $value);
17+
}
18+
}
19+
20+
public function getResourceVersion(): ?string
21+
{
22+
return $this->getAttribute('metadata.resourceVersion', null);
23+
}
1024
}

src/Traits/Cluster/MakesHttpCalls.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected function makeRequest(Operation $operation, string $path, string $paylo
184184
$results[] = (new $resourceClass($this, $item))->synced();
185185
}
186186

187-
return new ResourcesList($results);
187+
return new ResourcesList($results, $json['metadata']);
188188
}
189189

190190
// If the items does not exist, it means the Kind

src/Traits/Resource/HasAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function syncOriginalWith(array $attributes = [])
160160
*
161161
* @return mixed
162162
*/
163-
public function __call(string $method, array $parameters)
163+
public function __call($method, $parameters)
164164
{
165165
if (static::hasMacro($method)) {
166166
return $this->macroCall($method, $parameters);

0 commit comments

Comments
 (0)