Skip to content

Commit 8981324

Browse files
committed
Updated exceptions
1 parent 3689cf5 commit 8981324

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace RenokiCo\PhpK8s\Exceptions;
4+
5+
class KubernetesLogsException extends PhpK8sException
6+
{
7+
//
8+
}

src/Kinds/K8sResource.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ public function containerLogsByName(string $name, string $container, array $quer
655655
* @param Closure $callback
656656
* @param array $query
657657
* @return mixed
658+
* @throws \RenokiCo\PhpK8s\Exceptions\KubernetesWatchException
659+
* @throws \RenokiCo\PhpK8s\Exceptions\KubernetesLogsException
658660
*/
659661
public function watchLogs(Closure $callback, array $query = ['pretty' => 1])
660662
{
@@ -664,6 +666,12 @@ public function watchLogs(Closure $callback, array $query = ['pretty' => 1])
664666
);
665667
}
666668

669+
if (! $this instanceof Watchable) {
670+
throw new KubernetesLogsException(
671+
'The resource '.get_class($this).' does not support watch actions.'
672+
);
673+
}
674+
667675
// Ensure the ?follow=1 query exists to trigger the watch.
668676
$query = array_merge($query, ['follow' => 1]);
669677

@@ -685,6 +693,7 @@ public function watchLogs(Closure $callback, array $query = ['pretty' => 1])
685693
* @param array $query
686694
* @return mixed
687695
* @throws \RenokiCo\PhpK8s\Exceptions\KubernetesWatchException
696+
* @throws \RenokiCo\PhpK8s\Exceptions\KubernetesLogsException
688697
*/
689698
public function watchContainerLogs(string $container, Closure $callback, array $query = ['pretty' => 1])
690699
{
@@ -713,6 +722,7 @@ public function watchLogsByName(string $name, Closure $callback, array $query =
713722
* @param array $query
714723
* @return mixed
715724
* @throws \RenokiCo\PhpK8s\Exceptions\KubernetesWatchException
725+
* @throws \RenokiCo\PhpK8s\Exceptions\KubernetesLogsException
716726
*/
717727
public function watchContainerLogsByName(string $name, string $container, Closure $callback, array $query = ['pretty' => 1])
718728
{

0 commit comments

Comments
 (0)