Skip to content

Commit 2f87226

Browse files
committed
feat: add metadata to ResourceList response
1 parent 8f53aef commit 2f87226

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/ResourcesList.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,21 @@
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+
public function __construct($items, $metadata)
12+
{
13+
parent::__construct($items);
14+
foreach ($metadata as $key => $value) {
15+
$this->setAttribute("metadata.$key", $value);
16+
}
17+
}
18+
19+
public function getResourceVersion(): ?string
20+
{
21+
return $this->getAttribute('metadata.resourceVersion', null);
22+
}
1023
}

src/Traits/Cluster/MakesHttpCalls.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ protected function makeRequest(string $method, string $path, string $payload = '
133133
$results[] = (new $resourceClass($this, $item))->synced();
134134
}
135135

136-
return new ResourcesList($results);
136+
return new ResourcesList($results, $json['metadata']);
137137
}
138138

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

0 commit comments

Comments
 (0)