4
4
5
5
use Carbon \Carbon ;
6
6
use Cron \CronExpression ;
7
+ use DateTime ;
8
+ use Illuminate \Support \Collection ;
7
9
use RenokiCo \PhpK8s \Contracts \InteractsWithK8sCluster ;
8
10
use RenokiCo \PhpK8s \Contracts \Watchable ;
9
11
use RenokiCo \PhpK8s \Traits \Resource \HasSpec ;
@@ -26,7 +28,7 @@ class K8sCronJob extends K8sResource implements InteractsWithK8sCluster, Watchab
26
28
*
27
29
* @var string
28
30
*/
29
- protected static $ defaultVersion = 'batch/v1beta1 ' ;
31
+ protected static $ defaultVersion = 'batch/v1 ' ;
30
32
31
33
/**
32
34
* Wether the resource has a namespace.
@@ -38,7 +40,7 @@ class K8sCronJob extends K8sResource implements InteractsWithK8sCluster, Watchab
38
40
/**
39
41
* Set the job template.
40
42
*
41
- * @param array|\RenokiCo\PhpK8s\Kinds\ K8sJob $job
43
+ * @param array|K8sJob $job
42
44
* @return $this
43
45
*/
44
46
public function setJobTemplate ($ job )
@@ -54,7 +56,7 @@ public function setJobTemplate($job)
54
56
* Get the template job.
55
57
*
56
58
* @param bool $asInstance
57
- * @return array|\RenokiCo\PhpK8s\Kinds\ K8sJob
59
+ * @return array|K8sJob
58
60
*/
59
61
public function getJobTemplate (bool $ asInstance = true )
60
62
{
@@ -70,7 +72,7 @@ public function getJobTemplate(bool $asInstance = true)
70
72
/**
71
73
* Set the schedule for the cronjob.
72
74
*
73
- * @param \Cron\ CronExpression|string $schedule
75
+ * @param CronExpression|string $schedule
74
76
* @return $this
75
77
*/
76
78
public function setSchedule ($ schedule )
@@ -86,7 +88,7 @@ public function setSchedule($schedule)
86
88
* Retrieve the schedule.
87
89
*
88
90
* @param bool $asInstance
89
- * @return \Cron\ CronExpression|string
91
+ * @return CronExpression|string
90
92
*/
91
93
public function getSchedule (bool $ asInstance = true )
92
94
{
@@ -102,7 +104,7 @@ public function getSchedule(bool $asInstance = true)
102
104
/**
103
105
* Get the last time a job was scheduled.
104
106
*
105
- * @return \ DateTime|null
107
+ * @return DateTime|null
106
108
*/
107
109
public function getLastSchedule ()
108
110
{
@@ -116,12 +118,12 @@ public function getLastSchedule()
116
118
/**
117
119
* Get the active jobs created by the cronjob.
118
120
*
119
- * @return \Illuminate\Support\ Collection
121
+ * @return Collection
120
122
*/
121
123
public function getActiveJobs ()
122
124
{
123
125
return collect ($ this ->getStatus ('active ' , []))->map (function ($ job ) {
124
- return $ this ->cluster ->job ($ job)-> refresh ( );
126
+ return $ this ->cluster ->getJobByName ($ job[ ' name ' ], $ this -> getNamespace () );
125
127
});
126
128
}
127
129
}
0 commit comments