Summary
ResourcesList currently extends Collection with no additional state, so the resourceVersion from the Kubernetes list response is silently discarded. This means callers cannot use the list's resourceVersion to resume a watch from a known point.
Current behaviour
makeRequest in MakesHttpCalls builds the list as:
return new ResourcesList($results);
The resourceVersion in the API response's metadata block (e.g. "metadata": { "resourceVersion": "12345" }) is never stored.
Expected behaviour
After calling e.g. $cluster->getAllPods(), callers should be able to do:
$list = $cluster->getAllPods();
$rv = $list->getResourceVersion(); // "12345"
// Resume watch from exactly this point — no missed or duplicate events
$pod->watchAll(function ($type, $pod) { ... }, ['resourceVersion' => $rv]);
This is the standard Kubernetes watch pattern documented in the Efficient detection of changes guide.
Proposed fix
Extend ResourcesList to carry the metadata and expose getResourceVersion():
class ResourcesList extends Collection
{
protected ?string $resourceVersion = null;
public static function fromResponse(array $items, array $metadata): static
{
$list = new static($items);
$list->resourceVersion = $metadata['resourceVersion'] ?? null;
return $list;
}
public function getResourceVersion(): ?string
{
return $this->resourceVersion;
}
}
And in MakesHttpCalls::makeRequest:
return ResourcesList::fromResponse($results, $json['metadata'] ?? []);
This is a non-breaking additive change, so existing code that ignores the return value is unaffected. Happy to open a PR if the approach looks good.
Summary
ResourcesListcurrently extendsCollectionwith no additional state, so theresourceVersionfrom the Kubernetes list response is silently discarded. This means callers cannot use the list'sresourceVersionto resume a watch from a known point.Current behaviour
makeRequestinMakesHttpCallsbuilds the list as:The
resourceVersionin the API response'smetadatablock (e.g."metadata": { "resourceVersion": "12345" }) is never stored.Expected behaviour
After calling e.g.
$cluster->getAllPods(), callers should be able to do:This is the standard Kubernetes watch pattern documented in the Efficient detection of changes guide.
Proposed fix
Extend
ResourcesListto carry the metadata and exposegetResourceVersion():And in
MakesHttpCalls::makeRequest:This is a non-breaking additive change, so existing code that ignores the return value is unaffected. Happy to open a PR if the approach looks good.