1
1
import { consoleFetchJSON } from '@openshift-console/dynamic-plugin-sdk' ;
2
2
import { ConfigMapKind , CronJobKind , DeploymentConfigKind , DeploymentKind , JobKind , PersistentVolumeClaimKind , PodKind , RouteKind , SecretKind } from '../k8s-types' ;
3
- import { Application , cronjobToApplication , deploymentConfigToApplication , deploymentToApplication } from '../types' ;
3
+ import { Application , cronjobToApplication as cronJobToApplication , deploymentConfigToApplication , deploymentToApplication } from '../types' ;
4
4
import { sprintf } from 'sprintf-js' ;
5
5
import { camelApplicationStore } from '../state' ;
6
6
@@ -9,7 +9,6 @@ const PROMETHEUS_API_QUERY_PATH = '/api/prometheus/api/v1/query';
9
9
const PROMETHEUS_API_QUERYRANGE_PATH = '/api/prometheus/api/v1/query_range' ;
10
10
11
11
export async function fetchDeployments ( ns : string ) : Promise < Application [ ] > {
12
- debugger ;
13
12
let deploymentsUri = ns ? '/api/kubernetes/apis/apps/v1/namespaces/' + ns + '/deployments' : '/api/kubernetes/apis/apps/v1/deployments' ;
14
13
deploymentsUri += '?labelSelector=' + OPENSHIFT_RUNTIME_LABEL
15
14
return consoleFetchJSON ( deploymentsUri ) . then ( res => {
@@ -18,13 +17,12 @@ export async function fetchDeployments(ns: string): Promise<Application[]> {
18
17
} ) ;
19
18
}
20
19
21
- export async function fetchCronjobs ( ns : string ) : Promise < Application [ ] > {
22
- debugger ;
20
+ export async function fetchCronJobs ( ns : string ) : Promise < Application [ ] > {
23
21
let deploymentsUri = ns ? '/api/kubernetes/apis/batch/v1/namespaces/' + ns + '/cronjobs' : '/api/kubernetes/apis/batch/v1/cronjobs' ;
24
22
deploymentsUri += '?labelSelector=' + OPENSHIFT_RUNTIME_LABEL
25
23
return consoleFetchJSON ( deploymentsUri ) . then ( res => {
26
24
return res . items
27
- . map ( ( c : CronJobKind ) => cronjobToApplication ( c ) ) ;
25
+ . map ( ( c : CronJobKind ) => cronJobToApplication ( c ) ) ;
28
26
} ) ;
29
27
}
30
28
@@ -53,6 +51,12 @@ async function fetchDeploymentConfig(ns: string, name: string): Promise<Applicat
53
51
} ) ;
54
52
}
55
53
54
+ async function fetchCronJob ( ns : string , name : string ) : Promise < Application > {
55
+ return consoleFetchJSON ( '/api/kubernetes/apis/batch/v1/namespaces/' + ns + '/cronjobs/' + name ) . then ( res => {
56
+ return cronJobToApplication ( res ) ;
57
+ } ) ;
58
+ }
59
+
56
60
export async function fetchSecret ( ns : string , name : string ) : Promise < SecretKind > {
57
61
return consoleFetchJSON ( '/api/kubernetes/api/v1/namespaces/' + ns + '/secrets/' + name ) . then ( res => {
58
62
return res . data ;
@@ -308,14 +312,18 @@ export async function fetchApplicationWithMetrics(kind: string, ns: string, name
308
312
case 'DeploymentConfig' :
309
313
app = fetchDeploymentConfig ( ns , name ) ;
310
314
break ;
315
+ case 'CronJob' :
316
+ app = fetchCronJob ( ns , name ) ;
317
+ break ;
311
318
default :
312
319
throw new Error ( 'Invalid kind: ' + kind ) ;
313
320
}
314
321
return app . then ( populateRoute ) . then ( populateCpuMetrics ) . then ( populateMemMetrics ) ;
315
322
}
316
323
317
324
const CamelService = {
318
- fetchCronjobs,
325
+ fetchCronjobs : fetchCronJobs ,
326
+ fetchCronJob,
319
327
fetchDeployments,
320
328
fetchDeploymentConfigs,
321
329
fetchApplications,
0 commit comments