Skip to content

Commit

Permalink
redundant dockerfile issue with build
Browse files Browse the repository at this point in the history
  • Loading branch information
prathameshzarkar9 committed Apr 29, 2024
1 parent c1c8b08 commit 16d9d10
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"${workspaceFolder}/src/test/configs/example", // Edit this example config to test the CLI against a custom configuration.
"--log-level",
"debug",
],
],
"console": "integratedTerminal",
},
{
Expand Down
9 changes: 4 additions & 5 deletions src/spec-node/containerFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ export async function extendImage(params: DockerResolverParameters, config: Subs
cliHost.mkdirp(emptyTempDir);
args.push(
'--target', featureBuildInfo.overrideTarget,
'-t', updatedImageName,
...additionalImageNames.map(name => ['-t', name]).flat(),
'-f', dockerfilePath,
emptyTempDir
'-f', dockerfilePath,
emptyTempDir,
...additionalImageNames.length > 0 ? additionalImageNames.map(name => ['-t', name]).flat() : ['-t', updatedImageName]
);

if (params.isTTY) {
Expand All @@ -125,7 +124,7 @@ export async function extendImage(params: DockerResolverParameters, config: Subs
await dockerCLI(infoParams, ...args);
}
return {
updatedImageName: [ updatedImageName ],
updatedImageName: additionalImageNames.length > 0 ? additionalImageNames : [updatedImageName],
imageMetadata: getDevcontainerMetadata(imageBuildInfo.metadata, config, featuresConfig),
imageDetails: async () => imageBuildInfo.imageDetails,
};
Expand Down
14 changes: 14 additions & 0 deletions src/test/cli.build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ describe('Dev Containers CLI', function () {

describe('Command build', () => {

it('should fail to push --image-name with --push true', async () => {
let success = false;
const testFolder = `${__dirname}/configs/example-push`;
try {
await shellExec(`${cli} build --workspace-folder ${testFolder} --image-name demo:v1 --push true`);
} catch (error) {
assert.equal(error.error.code, 1, 'Should fail with exit code 1');
const res = JSON.parse(error.stdout);
assert.equal(res.outcome, 'error');
assert.match(JSON.stringify(error.error.message), /unauthorized: access token has insufficient scopes/);
}
assert.equal(success, false, 'expect non-successful call');
});

buildKitOptions.forEach(({ text, options }) => {
it(`should execute successfully with valid image config [${text}]`, async () => {
const testFolder = `${__dirname}/configs/image`;
Expand Down
10 changes: 10 additions & 0 deletions src/test/configs/example-push/.devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Example devcontainer.json configuration,
// wired into the vscode launch task (.vscode/launch.json)
{
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "16.18.1"
}
}
}

0 comments on commit 16d9d10

Please sign in to comment.