File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,14 @@ export async function buildAndExtendDockerCompose(configWithRaw: SubstitutedConf
220220 buildOverrideContent += ` target: ${ featureBuildInfo . overrideTarget } \n` ;
221221 }
222222
223+ // Add labels from params
224+ if ( params . additionalLabels && params . additionalLabels . length > 0 ) {
225+ buildOverrideContent += ` labels:\n` ;
226+ params . additionalLabels . forEach ( label => {
227+ buildOverrideContent += ` - ${ label } \n` ;
228+ } ) ;
229+ }
230+
223231 if ( ! serviceInfo . build ?. context ) {
224232 // need to supply a context as we don't have one inherited
225233 const emptyDir = getEmptyContextFolder ( common ) ;
Original file line number Diff line number Diff line change @@ -49,6 +49,20 @@ describe('Dev Containers CLI', function () {
4949 assert . equal ( labels . type , 'multiple-labels' ) ;
5050 } ) ;
5151
52+ it ( 'should build successfully with valid image metadata --label property (compose)' , async ( ) => {
53+ const testFolder = `${ __dirname } /configs/compose-without-name` ;
54+ const image1 = 'image-1' ;
55+ await shellExec ( `docker rmi -f ${ image1 } ` ) ;
56+ const res = await shellExec ( `${ cli } build --workspace-folder ${ testFolder } --image-name ${ image1 } --label 'name=label-test' --label 'type=multiple-labels'` ) ;
57+ const response = JSON . parse ( res . stdout ) ;
58+ assert . equal ( response . outcome , 'success' ) ;
59+ assert . equal ( response . imageName [ 0 ] , image1 ) ;
60+ const labelsResponse = await shellExec ( `docker inspect --format '{{json .Config.Labels}}' ${ response . imageName [ 0 ] } ` ) ;
61+ const labels = JSON . parse ( labelsResponse . stdout ) ;
62+ assert . equal ( labels . name , 'label-test' ) ;
63+ assert . equal ( labels . type , 'multiple-labels' ) ;
64+ } ) ;
65+
5266 it ( 'should fail to build with correct error message for local feature' , async ( ) => {
5367 const testFolder = `${ __dirname } /configs/image-with-local-feature` ;
5468 try {
You can’t perform that action at this time.
0 commit comments