Skip to content

Commit d20d2db

Browse files
Merge pull request #165 from devcontainers/samruddhikhandale/add-logs
Adds warning logs for the auto-mapped features
2 parents d256274 + c4b9792 commit d20d2db

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/spec-configuration/containerFeaturesConfiguration.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -520,31 +520,39 @@ export async function getFeatureIdType(output: Log, env: NodeJS.ProcessEnv, user
520520
}
521521
}
522522

523-
export function getBackwardCompatibleFeatureId(id: string) {
523+
export function getBackwardCompatibleFeatureId(output: Log, id: string) {
524524
const migratedfeatures = ['aws-cli', 'azure-cli', 'desktop-lite', 'docker-in-docker', 'docker-from-docker', 'dotnet', 'git', 'git-lfs', 'github-cli', 'java', 'kubectl-helm-minikube', 'node', 'powershell', 'python', 'ruby', 'rust', 'sshd', 'terraform'];
525525
const renamedFeatures = new Map();
526526
renamedFeatures.set('golang', 'go');
527527
renamedFeatures.set('common', 'common-utils');
528-
// TODO: Add warning log messages only when auto-mapping is ready to be put in Remote-Containers STABLE version.
529-
// const deprecatedFeatures = ['fish', 'gradle', 'homebrew', 'jupyterlab', 'maven'];
528+
529+
const deprecatedFeaturesIntoOptions = new Map();
530+
deprecatedFeaturesIntoOptions.set('gradle', 'java');
531+
deprecatedFeaturesIntoOptions.set('maven', 'java');
532+
deprecatedFeaturesIntoOptions.set('jupyterlab', 'python');
533+
534+
// TODO: add warning logs once we have context on the new location for these Features.
535+
// const deprecatedFeatures = ['fish', 'homebrew'];
530536

531537
const newFeaturePath = 'ghcr.io/devcontainers/features';
532538
// Note: Pin the versionBackwardComp to '1' to avoid breaking changes.
533539
const versionBackwardComp = '1';
534540

535541
// Mapping feature references (old shorthand syntax) from "microsoft/vscode-dev-containers" to "ghcr.io/devcontainers/features"
536542
if (migratedfeatures.includes(id)) {
543+
output.write(`(!) WARNING: Using the deprecated '${id}' Feature. See https://github.com/devcontainers/features/tree/main/src/${id}#example-usage for the updated Feature.`, LogLevel.Warning);
537544
return `${newFeaturePath}/${id}:${versionBackwardComp}`;
538545
}
539546

540547
// Mapping feature references (renamed old shorthand syntax) from "microsoft/vscode-dev-containers" to "ghcr.io/devcontainers/features"
541548
if (renamedFeatures.get(id) !== undefined) {
549+
output.write(`(!) WARNING: Using the deprecated '${id}' Feature. See https://github.com/devcontainers/features/tree/main/src/${renamedFeatures.get(id)}#example-usage for the updated Feature.`, LogLevel.Warning);
542550
return `${newFeaturePath}/${renamedFeatures.get(id)}:${versionBackwardComp}`;
543551
}
544552

545-
// if (deprecatedFeatures.includes(id)) {
546-
// output.write(`(!) WARNING: Falling back to deprecated '${id}' feature.`, LogLevel.Warning);
547-
// }
553+
if (deprecatedFeaturesIntoOptions.get(id) !== undefined) {
554+
output.write(`(!) WARNING: Falling back to the deprecated '${id}' Feature. It is now part of the '${deprecatedFeaturesIntoOptions.get(id)}' Feature. See https://github.com/devcontainers/features/tree/main/src/${deprecatedFeaturesIntoOptions.get(id)}#options for the updated Feature.`, LogLevel.Warning);
555+
}
548556

549557
// Deprecated and all other features references (eg. fish, ghcr.io/devcontainers/features/go, ghcr.io/owner/repo/id etc)
550558
return id;
@@ -559,7 +567,7 @@ export async function processFeatureIdentifier(output: Log, configPath: string,
559567
const originalUserFeatureId = userFeature.id;
560568
// Adding backward compatibility
561569
if (!skipFeatureAutoMapping) {
562-
userFeature.id = getBackwardCompatibleFeatureId(userFeature.id);
570+
userFeature.id = getBackwardCompatibleFeatureId(output, userFeature.id);
563571
}
564572

565573
const { type, manifest } = await getFeatureIdType(output, env, userFeature.id);

src/test/container-features/featureHelpers.test.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -384,61 +384,61 @@ describe('validate function getBackwardCompatibleFeatureId', () => {
384384
it('should map the migrated (old shorthand syntax) features to ghcr.io/devcontainers/features/*', () => {
385385
let id = 'node';
386386
let expectedId = 'ghcr.io/devcontainers/features/node:1';
387-
let mappedId = getBackwardCompatibleFeatureId(id);
387+
let mappedId = getBackwardCompatibleFeatureId(output, id);
388388

389389
assert.strictEqual(mappedId, expectedId);
390390

391391
id = 'python';
392392
expectedId = 'ghcr.io/devcontainers/features/python:1';
393-
mappedId = getBackwardCompatibleFeatureId(id);
393+
mappedId = getBackwardCompatibleFeatureId(output, id);
394394

395395
assert.strictEqual(mappedId, expectedId);
396396
});
397397

398398
it('should map the renamed (old shorthand syntax) features to ghcr.io/devcontainers/features/*', () => {
399399
let id = 'golang';
400400
let expectedId = 'ghcr.io/devcontainers/features/go:1';
401-
let mappedId = getBackwardCompatibleFeatureId(id);
401+
let mappedId = getBackwardCompatibleFeatureId(output, id);
402402

403403
assert.strictEqual(mappedId, expectedId);
404404

405405
id = 'common';
406406
expectedId = 'ghcr.io/devcontainers/features/common-utils:1';
407-
mappedId = getBackwardCompatibleFeatureId(id);
407+
mappedId = getBackwardCompatibleFeatureId(output, id);
408408

409409
assert.strictEqual(mappedId, expectedId);
410410
});
411411

412412
it('should keep the deprecated (old shorthand syntax) features id intact', () => {
413413
let id = 'fish';
414414
let expectedId = 'fish';
415-
let mappedId = getBackwardCompatibleFeatureId(id);
415+
let mappedId = getBackwardCompatibleFeatureId(output, id);
416416

417417
assert.strictEqual(mappedId, expectedId);
418418

419419
id = 'maven';
420420
expectedId = 'maven';
421-
mappedId = getBackwardCompatibleFeatureId(id);
421+
mappedId = getBackwardCompatibleFeatureId(output, id);
422422

423423
assert.strictEqual(mappedId, expectedId);
424424
});
425425

426426
it('should keep all other features id intact', () => {
427427
let id = 'ghcr.io/devcontainers/features/node:1';
428428
let expectedId = id;
429-
let mappedId = getBackwardCompatibleFeatureId(id);
429+
let mappedId = getBackwardCompatibleFeatureId(output, id);
430430

431431
assert.strictEqual(mappedId, expectedId);
432432

433433
id = 'ghcr.io/user/repo/go:1';
434434
expectedId = id;
435-
mappedId = getBackwardCompatibleFeatureId(id);
435+
mappedId = getBackwardCompatibleFeatureId(output, id);
436436

437437
assert.strictEqual(mappedId, expectedId);
438438

439439
id = 'ghcr.io/user/repo/go';
440440
expectedId = id;
441-
mappedId = getBackwardCompatibleFeatureId(id);
441+
mappedId = getBackwardCompatibleFeatureId(output, id);
442442

443443
assert.strictEqual(mappedId, expectedId);
444444
});

0 commit comments

Comments
 (0)