Skip to content

Commit 3044563

Browse files
additional property added in params object for labels
1 parent 774fbf5 commit 3044563

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

src/spec-common/injectHeadless.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export interface ResolverParameters {
6060
remoteEnv: Record<string, string>;
6161
buildxPlatform: string | undefined;
6262
buildxPush: boolean;
63-
buildxLabel: string | undefined;
6463
buildxOutput: string | undefined;
6564
buildxCacheTo: string | undefined;
6665
skipFeatureAutoMapping: boolean;

src/spec-node/containerFeatures.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const getSafeId = (str: string) => str
2828
.replace(/^[\d_]+/g, '_')
2929
.toUpperCase();
3030

31-
export async function extendImage(params: DockerResolverParameters, config: SubstitutedConfig<DevContainerConfig>, imageName: string, additionalImageNames: string[], imageLabels: string[], additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>, canAddLabelsToContainer: boolean) {
31+
export async function extendImage(params: DockerResolverParameters, config: SubstitutedConfig<DevContainerConfig>, imageName: string, additionalImageNames: string[], additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>, canAddLabelsToContainer: boolean) {
3232
const { common } = params;
3333
const { cliHost, output } = common;
3434

@@ -113,7 +113,7 @@ export async function extendImage(params: DockerResolverParameters, config: Subs
113113
'--target', featureBuildInfo.overrideTarget,
114114
'-f', dockerfilePath,
115115
...additionalImageNames.length > 0 ? additionalImageNames.map(name => ['-t', name]).flat() : ['-t', updatedImageName],
116-
...imageLabels.length > 0 ? imageLabels.map(label => ['--label', label]).flat() : [],
116+
...params.additionalLabels.length > 0 ? params.additionalLabels.map(label => ['--label', label]).flat() : [],
117117
emptyTempDir
118118
);
119119

src/spec-node/devContainers.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface ProvisionOptions {
5252
omitLoggerHeader?: boolean | undefined;
5353
buildxPlatform: string | undefined;
5454
buildxPush: boolean;
55-
buildxLabel: string | undefined;
55+
additionalLabels: string[];
5656
buildxOutput: string | undefined;
5757
buildxCacheTo: string | undefined;
5858
additionalFeatures?: Record<string, string | boolean | Record<string, string | boolean>>;
@@ -147,7 +147,6 @@ export async function createDockerParams(options: ProvisionOptions, disposables:
147147
secretsP,
148148
buildxPlatform: options.buildxPlatform,
149149
buildxPush: options.buildxPush,
150-
buildxLabel: options.buildxLabel,
151150
buildxOutput: options.buildxOutput,
152151
buildxCacheTo: options.buildxCacheTo,
153152
skipFeatureAutoMapping: options.skipFeatureAutoMapping,
@@ -229,7 +228,7 @@ export async function createDockerParams(options: ProvisionOptions, disposables:
229228
experimentalFrozenLockfile,
230229
buildxPlatform: common.buildxPlatform,
231230
buildxPush: common.buildxPush,
232-
buildxLabel: options.buildxLabel,
231+
additionalLabels: options.additionalLabels,
233232
buildxOutput: common.buildxOutput,
234233
buildxCacheTo: common.buildxCacheTo,
235234
platformInfo

src/spec-node/devContainersSpecCLI.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ async function provision({
267267
useBuildKit: buildkit,
268268
buildxPlatform: undefined,
269269
buildxPush: false,
270-
buildxLabel: undefined,
270+
additionalLabels: [],
271271
buildxOutput: undefined,
272272
buildxCacheTo: addCacheTo,
273273
additionalFeatures,
@@ -432,7 +432,7 @@ async function doSetUp({
432432
useBuildKit: 'auto',
433433
buildxPlatform: undefined,
434434
buildxPush: false,
435-
buildxLabel: undefined,
435+
additionalLabels: [],
436436
buildxOutput: undefined,
437437
buildxCacheTo: undefined,
438438
skipFeatureAutoMapping: false,
@@ -597,7 +597,7 @@ async function doBuild({
597597
useBuildKit: buildkit,
598598
buildxPlatform,
599599
buildxPush,
600-
buildxLabel,
600+
additionalLabels: [],
601601
buildxOutput,
602602
buildxCacheTo,
603603
skipFeatureAutoMapping,
@@ -635,12 +635,12 @@ async function doBuild({
635635
const imageNames = (argImageName && (Array.isArray(argImageName) ? argImageName : [argImageName]) as string[]) || undefined;
636636

637637
// Support multiple use of `--label`
638-
const imageLabels = (buildxLabel && (Array.isArray(buildxLabel) ? buildxLabel : [buildxLabel]) as string[]) || undefined;
638+
params.additionalLabels = (buildxLabel && (Array.isArray(buildxLabel) ? buildxLabel : [buildxLabel]) as string[]) || [];
639639

640640
if (isDockerFileConfig(config)) {
641641

642642
// Build the base image and extend with features etc.
643-
let { updatedImageName } = await buildNamedImageAndExtend(params, configWithRaw as SubstitutedConfig<DevContainerFromDockerfileConfig>, additionalFeatures, false, imageNames, imageLabels);
643+
let { updatedImageName } = await buildNamedImageAndExtend(params, configWithRaw as SubstitutedConfig<DevContainerFromDockerfileConfig>, additionalFeatures, false, imageNames);
644644

645645
if (imageNames) {
646646
imageNameResult = imageNames;
@@ -703,7 +703,7 @@ async function doBuild({
703703
}
704704

705705
await inspectDockerImage(params, config.image, true);
706-
const { updatedImageName } = await extendImage(params, configWithRaw, config.image, imageNames || [], imageLabels || [], additionalFeatures, false);
706+
const { updatedImageName } = await extendImage(params, configWithRaw, config.image, imageNames || [], additionalFeatures, false);
707707

708708
if (imageNames) {
709709
imageNameResult = imageNames;
@@ -866,7 +866,7 @@ async function doRunUserCommands({
866866
useBuildKit: 'auto',
867867
buildxPlatform: undefined,
868868
buildxPush: false,
869-
buildxLabel: undefined,
869+
additionalLabels: [],
870870
buildxOutput: undefined,
871871
buildxCacheTo: undefined,
872872
skipFeatureAutoMapping,
@@ -1315,7 +1315,7 @@ export async function doExec({
13151315
omitLoggerHeader: true,
13161316
buildxPlatform: undefined,
13171317
buildxPush: false,
1318-
buildxLabel: undefined,
1318+
additionalLabels: [],
13191319
buildxCacheTo: undefined,
13201320
skipFeatureAutoMapping,
13211321
buildxOutput: undefined,

src/spec-node/singleContainer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,15 @@ async function setupContainer(container: ContainerDetails, params: DockerResolve
119119
function getDefaultName(config: DevContainerFromDockerfileConfig | DevContainerFromImageConfig, params: DockerResolverParameters) {
120120
return 'image' in config && config.image ? config.image : getFolderImageName(params.common);
121121
}
122-
export async function buildNamedImageAndExtend(params: DockerResolverParameters, configWithRaw: SubstitutedConfig<DevContainerFromDockerfileConfig | DevContainerFromImageConfig>, additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>, canAddLabelsToContainer: boolean, argImageNames?: string[], imageLabels?: string[]): Promise<{ updatedImageName: string[]; imageMetadata: SubstitutedConfig<ImageMetadataEntry[]>; imageDetails: () => Promise<ImageDetails>; labels?: Record<string, string> }> {
122+
export async function buildNamedImageAndExtend(params: DockerResolverParameters, configWithRaw: SubstitutedConfig<DevContainerFromDockerfileConfig | DevContainerFromImageConfig>, additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>, canAddLabelsToContainer: boolean, argImageNames?: string[]): Promise<{ updatedImageName: string[]; imageMetadata: SubstitutedConfig<ImageMetadataEntry[]>; imageDetails: () => Promise<ImageDetails>; labels?: Record<string, string> }> {
123123
const { config } = configWithRaw;
124124
const imageNames = argImageNames ?? [getDefaultName(config, params)];
125-
const imagelabel = imageLabels;
126125
params.common.progress(ResolverProgress.BuildingImage);
127126
if (isDockerFileConfig(config)) {
128127
return await buildAndExtendImage(params, configWithRaw as SubstitutedConfig<DevContainerFromDockerfileConfig>, imageNames, params.buildNoCache ?? false, additionalFeatures);
129128
}
130129
// image-based dev container - extend
131-
return await extendImage(params, configWithRaw, imageNames[0], argImageNames || [], imagelabel || [], additionalFeatures, canAddLabelsToContainer);
130+
return await extendImage(params, configWithRaw, imageNames[0], argImageNames || [], additionalFeatures, canAddLabelsToContainer);
132131
}
133132

134133
async function buildAndExtendImage(buildParams: DockerResolverParameters, configWithRaw: SubstitutedConfig<DevContainerFromDockerfileConfig>, baseImageNames: string[], noCache: boolean, additionalFeatures: Record<string, string | boolean | Record<string, string | boolean>>) {

src/spec-node/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export interface DockerResolverParameters {
116116
experimentalFrozenLockfile?: boolean;
117117
buildxPlatform: string | undefined;
118118
buildxPush: boolean;
119-
buildxLabel: string | undefined;
119+
additionalLabels: string[];
120120
buildxOutput: string | undefined;
121121
buildxCacheTo: string | undefined;
122122
platformInfo: PlatformInfo;

0 commit comments

Comments
 (0)