@@ -45,10 +45,7 @@ export async function generateKubernetesFiles() {
4545 vscode . window . showInformationMessage ( 'Jobs Folder not created.' ) ;
4646
4747 }
48- let jobNames : string [ ] = [ ]
49- if ( jobsInput ) {
50- jobNames = checkSpacesAndReplace ( jobsInput . split ( ',' ) . map ( name => name . trim ( ) ) ) ;
51- }
48+
5249
5350 // Folder Generation
5451 const kubernetesFolder = vscode . Uri . joinPath ( vscode . workspace . workspaceFolders [ 0 ] . uri , 'kubernetes' ) ;
@@ -65,8 +62,7 @@ export async function generateKubernetesFiles() {
6562 const secretsFolder = vscode . Uri . joinPath ( kubernetesFolder , 'secrets' ) ;
6663 fs . mkdirSync ( secretsFolder . fsPath , { recursive : true } ) ;
6764
68- const jobsFolder = vscode . Uri . joinPath ( kubernetesFolder , 'jobs' ) ;
69- fs . mkdirSync ( jobsFolder . fsPath , { recursive : true } ) ;
65+
7066
7167 // Deployment Yaml fs operations
7268 const namespaceYAML = `
@@ -170,29 +166,36 @@ data:
170166 vscode . window . showInformationMessage ( `${ deploymentNames . length } deployment, service, and ingress files generated successfully.` ) ;
171167
172168 // Jobs Yaml fs operations
173- const jobPromises = jobNames . map ( async jobNames => { } )
174- const jobYAML = `
169+ if ( jobsInput ) {
170+ const jobsFolder = vscode . Uri . joinPath ( kubernetesFolder , 'jobs' ) ;
171+ fs . mkdirSync ( jobsFolder . fsPath , { recursive : true } ) ;
172+
173+ const jobNames = checkSpacesAndReplace ( jobsInput . split ( ',' ) . map ( name => name . trim ( ) ) ) ;
174+
175+ const jobPromises = jobNames . map ( async jobName => {
176+ const jobYAML = `
175177apiVersion: batch/v1
176178kind: Job
177179metadata:
178- name: ${ jobNames }
180+ name: ${ jobName }
179181spec:
180182 completions: 1
181183 template:
182184 metadata:
183- name: ${ jobNames } -pod
185+ name: ${ jobName } -pod
184186 spec:
185187 containers:
186- - name: ${ jobNames } -container
188+ - name: ${ jobName } -container
187189 image: nginx
188190 restartPolicy: Never
189191
190192 ` ;
191- await writeFileWithDirectoryCheck ( path . join ( jobsFolder . fsPath , `${ jobNames } -job.yaml` ) , jobYAML ) ;
192-
193+ await writeFileWithDirectoryCheck ( path . join ( jobsFolder . fsPath , `${ jobName } -job.yaml` ) , jobYAML ) ;
194+ } )
193195 await Promise . all ( jobPromises ) ;
194196 vscode . window . showInformationMessage ( `${ jobNames . length } deployment, service, and ingress files generated successfully.` ) ;
195197 }
198+ }
196199
197200async function writeFileWithDirectoryCheck ( filePath : string , content : string ) {
198201 const folderPath = path . dirname ( filePath ) ;
0 commit comments