File tree 5 files changed +32
-11
lines changed
5 files changed +32
-11
lines changed Original file line number Diff line number Diff line change 9
9
runAsGroup : 3000
10
10
restartPolicy : Never
11
11
containers :
12
- - name : $job # overwirtes job container
12
+ - name : $job # overwrites job container
13
13
env :
14
14
- name : ENV1
15
15
value : " value1"
@@ -20,11 +20,22 @@ spec:
20
20
args :
21
21
- -c
22
22
- sleep 50
23
+ - name : $redis # overwrites redis service
24
+ env :
25
+ - name : ENV2
26
+ value : " value2"
27
+ image : " busybox:1.28" # Ignored
28
+ resources :
29
+ requests :
30
+ memory : " 1Mi"
31
+ cpu : " 1"
32
+ limits :
33
+ memory : " 1Gi"
34
+ cpu : " 2"
23
35
- name : side-car
24
36
image : " ubuntu:latest" # required
25
37
command :
26
- - sh
38
+ - sh
27
39
args :
28
- - -c
29
- - sleep 60
30
-
40
+ - -c
41
+ - sleep 60
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ export function getSecretName(): string {
41
41
42
42
export const MAX_POD_NAME_LENGTH = 63
43
43
export const STEP_POD_NAME_SUFFIX_LENGTH = 8
44
+ export const CONTAINER_EXTENSION_PREFIX = '$'
44
45
export const JOB_CONTAINER_NAME = 'job'
45
46
export const JOB_CONTAINER_EXTENSION_NAME = '$job'
46
47
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ import {
26
26
PodPhase ,
27
27
fixArgs
28
28
} from '../k8s/utils'
29
- import { JOB_CONTAINER_EXTENSION_NAME , JOB_CONTAINER_NAME } from './constants'
29
+ import { CONTAINER_EXTENSION_PREFIX , JOB_CONTAINER_NAME } from './constants'
30
30
31
31
export async function prepareJob (
32
32
args : PrepareJobArgs ,
@@ -60,7 +60,7 @@ export async function prepareJob(
60
60
service ,
61
61
generateContainerName ( service . image ) ,
62
62
false ,
63
- undefined
63
+ extension
64
64
)
65
65
} )
66
66
}
@@ -235,7 +235,7 @@ export function createContainerSpec(
235
235
}
236
236
237
237
const from = extension . spec ?. containers ?. find (
238
- c => c . name === JOB_CONTAINER_EXTENSION_NAME
238
+ c => c . name === CONTAINER_EXTENSION_PREFIX + name
239
239
)
240
240
241
241
if ( from ) {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { Mount } from 'hooklib'
6
6
import * as path from 'path'
7
7
import { v1 as uuidv4 } from 'uuid'
8
8
import { POD_VOLUME_NAME } from './index'
9
- import { JOB_CONTAINER_EXTENSION_NAME } from '../hooks/constants'
9
+ import { CONTAINER_EXTENSION_PREFIX } from '../hooks/constants'
10
10
import * as shlex from 'shlex'
11
11
12
12
export const DEFAULT_CONTAINER_ENTRY_POINT_ARGS = [ `-f` , `/dev/null` ]
@@ -180,7 +180,7 @@ export function mergeContainerWithOptions(
180
180
) : void {
181
181
for ( const [ key , value ] of Object . entries ( from ) ) {
182
182
if ( key === 'name' ) {
183
- if ( value !== base . name && value !== JOB_CONTAINER_EXTENSION_NAME ) {
183
+ if ( value !== CONTAINER_EXTENSION_PREFIX + base . name ) {
184
184
core . warning ( "Skipping name override: name can't be overwritten" )
185
185
}
186
186
continue
@@ -209,7 +209,9 @@ export function mergePodSpecWithOptions(
209
209
for ( const [ key , value ] of Object . entries ( from ) ) {
210
210
if ( key === 'containers' ) {
211
211
base . containers . push (
212
- ...from . containers . filter ( e => ! e . name ?. startsWith ( '$' ) )
212
+ ...from . containers . filter (
213
+ e => ! e . name ?. startsWith ( CONTAINER_EXTENSION_PREFIX )
214
+ )
213
215
)
214
216
} else if ( key === 'volumes' && value ) {
215
217
const volumes = value as k8s . V1Volume [ ]
Original file line number Diff line number Diff line change @@ -133,6 +133,13 @@ describe('Prepare job', () => {
133
133
expect ( got . spec ?. containers [ 1 ] . image ) . toBe ( 'redis' )
134
134
expect ( got . spec ?. containers [ 1 ] . command ) . toBeFalsy ( )
135
135
expect ( got . spec ?. containers [ 1 ] . args ) . toBeFalsy ( )
136
+ expect ( got . spec ?. containers [ 1 ] . env ) . toEqual ( [
137
+ { name : 'ENV2' , value : 'value2' }
138
+ ] )
139
+ expect ( got . spec ?. containers [ 1 ] . resources ) . toEqual ( {
140
+ requests : { memory : '1Mi' , cpu : '1' } ,
141
+ limits : { memory : '1Gi' , cpu : '2' }
142
+ } )
136
143
// side-car
137
144
expect ( got . spec ?. containers [ 2 ] . name ) . toBe ( 'side-car' )
138
145
expect ( got . spec ?. containers [ 2 ] . image ) . toBe ( 'ubuntu:latest' )
You can’t perform that action at this time.
0 commit comments