44
55use Carbon \Carbon ;
66use Cron \CronExpression ;
7+ use DateTime ;
8+ use Illuminate \Support \Collection ;
79use RenokiCo \PhpK8s \Contracts \InteractsWithK8sCluster ;
810use RenokiCo \PhpK8s \Contracts \Watchable ;
911use RenokiCo \PhpK8s \Traits \Resource \HasSpec ;
@@ -26,7 +28,7 @@ class K8sCronJob extends K8sResource implements InteractsWithK8sCluster, Watchab
2628 *
2729 * @var string
2830 */
29- protected static $ defaultVersion = 'batch/v1beta1 ' ;
31+ protected static $ defaultVersion = 'batch/v1 ' ;
3032
3133 /**
3234 * Wether the resource has a namespace.
@@ -38,7 +40,7 @@ class K8sCronJob extends K8sResource implements InteractsWithK8sCluster, Watchab
3840 /**
3941 * Set the job template.
4042 *
41- * @param array|\RenokiCo\PhpK8s\Kinds\ K8sJob $job
43+ * @param array|K8sJob $job
4244 * @return $this
4345 */
4446 public function setJobTemplate ($ job )
@@ -54,7 +56,7 @@ public function setJobTemplate($job)
5456 * Get the template job.
5557 *
5658 * @param bool $asInstance
57- * @return array|\RenokiCo\PhpK8s\Kinds\ K8sJob
59+ * @return array|K8sJob
5860 */
5961 public function getJobTemplate (bool $ asInstance = true )
6062 {
@@ -70,7 +72,7 @@ public function getJobTemplate(bool $asInstance = true)
7072 /**
7173 * Set the schedule for the cronjob.
7274 *
73- * @param \Cron\ CronExpression|string $schedule
75+ * @param CronExpression|string $schedule
7476 * @return $this
7577 */
7678 public function setSchedule ($ schedule )
@@ -86,7 +88,7 @@ public function setSchedule($schedule)
8688 * Retrieve the schedule.
8789 *
8890 * @param bool $asInstance
89- * @return \Cron\ CronExpression|string
91+ * @return CronExpression|string
9092 */
9193 public function getSchedule (bool $ asInstance = true )
9294 {
@@ -102,7 +104,7 @@ public function getSchedule(bool $asInstance = true)
102104 /**
103105 * Get the last time a job was scheduled.
104106 *
105- * @return \ DateTime|null
107+ * @return DateTime|null
106108 */
107109 public function getLastSchedule ()
108110 {
@@ -116,12 +118,12 @@ public function getLastSchedule()
116118 /**
117119 * Get the active jobs created by the cronjob.
118120 *
119- * @return \Illuminate\Support\ Collection
121+ * @return Collection
120122 */
121123 public function getActiveJobs ()
122124 {
123125 return collect ($ this ->getStatus ('active ' , []))->map (function ($ job ) {
124- return $ this ->cluster ->job ($ job)-> refresh ( );
126+ return $ this ->cluster ->getJobByName ($ job[ ' name ' ], $ this -> getNamespace () );
125127 });
126128 }
127129}
0 commit comments