Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obtuse and confusing error with local feature under WSL #834 #838

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/spec-configuration/containerFeaturesConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ export function updateDeprecatedFeaturesIntoOptions(userFeatures: DevContainerFe

export async function getFeatureIdType(params: CommonParams, userFeatureId: string, lockfile: Lockfile | undefined) {
const { output } = params;
const error_message = `Legacy feature '${userFeatureId}' not supported. Please check https://containers.dev/features for replacements.
prathameshzarkar9 marked this conversation as resolved.
Show resolved Hide resolved
prathameshzarkar9 marked this conversation as resolved.
Show resolved Hide resolved
If you were hoping to use local Features, remember to prepend your Feature name with "./". Please check https://containers.dev/implementors/features-distribution/#addendum-locally-referenced for more information.`;
prathameshzarkar9 marked this conversation as resolved.
Show resolved Hide resolved
// See the specification for valid feature identifiers:
// > https://github.com/devcontainers/spec/blob/main/proposals/devcontainer-features.md#referencing-a-feature
//
Expand All @@ -698,8 +700,10 @@ export async function getFeatureIdType(params: CommonParams, userFeatureId: stri

// Legacy feature-set ID
if (!userFeatureId.includes('/') && !userFeatureId.includes('\\')) {
output.write(`Legacy feature '${userFeatureId}' not supported. Please check https://containers.dev/features for replacements.`, LogLevel.Error);
throw new ContainerError({ description: `Legacy feature '${userFeatureId}' not supported. Please check https://containers.dev/features for replacements.` });
output.write(error_message, LogLevel.Error);
throw new ContainerError({
description: error_message
});
}

// Direct tarball reference
Expand Down
11 changes: 11 additions & 0 deletions src/test/cli.build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ describe('Dev Containers CLI', function () {

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

it('should fail to build with correct error message for local feature', async () => {
const testFolder = `${__dirname}/configs/image-with-local-feature`;
try {
await shellExec(`${cli} build --workspace-folder ${testFolder} --image-name demo:v1`);
} catch (error) {
const res = JSON.parse(error.stdout);
assert.equal(res.outcome, 'error');
assert.match(res.message, /prepend your Feature name with/);
prathameshzarkar9 marked this conversation as resolved.
Show resolved Hide resolved
prathameshzarkar9 marked this conversation as resolved.
Show resolved Hide resolved
}
});

it('should correctly configure the image name to push from --image-name with --push true', async () => {
const testFolder = `${__dirname}/configs/example`;
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"image": "ubuntu:latest",
"features": {
"myfeature": {}
}
}
Loading