Implement OCI Layout Explorer#483
Open
jpinz wants to merge 5 commits into
Open
Conversation
…tions to the extension pack
- Introduced command to show prerequisites help for OCI Layout. - Added prerequisites documentation for using Podman or ORAS. - Implemented prerequisite warning in the OCI Layout tree item if podman isnt in use and oras is missing - Created a constant for `oras` to use across the OCI tooling.
… handling. This fixes issues with images published as a docker manifest v2, not OCI compatible when using docker save
…ndling - Introduced custom labels configuration in package.json and localization strings in package.nls.json. - Implemented logic for loading and matching custom label rules in customLabels.ts. - Added OciBlobContentProvider for handling OCI blob URIs and displaying content. - Updated OCI layout parsing to utilize custom labels and modified tree item classes to support new functionality.
Update README to explain the custom labels options.
Comment on lines
+188
to
+198
| async function podmanSaveToOciLayout( | ||
| podmanCommandName: string, | ||
| reference: string, | ||
| outputDir: string | ||
| ): Promise<void> { | ||
| await runTask( | ||
| podmanCommandName, | ||
| ['save', '--format', 'oci-dir', '--output', outputDir, reference], | ||
| vscode.l10n.t('Save {0} as OCI layout', reference) | ||
| ); | ||
| } |
Comment on lines
+15
to
+27
| const isWindows = process.platform === 'win32'; | ||
| const separator = isWindows ? ';' : ':'; | ||
| const extensions = isWindows | ||
| ? (process.env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean) | ||
| : ['']; | ||
|
|
||
| for (const dir of pathEnv.split(separator)) { | ||
| if (!dir) { | ||
| continue; | ||
| } | ||
|
|
||
| for (const ext of extensions) { | ||
| const candidate = path.join(dir, executable + ext); |
| kind: getReadableKind(descriptor.mediaType, jsonResult ? jsonResult.json : null), | ||
| digest, | ||
| mediaType: descriptor.mediaType || null, | ||
| size: descriptor.size || null, |
| } | ||
|
|
||
| function compileGlob(pattern: string): RegExp { | ||
| const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*'); |
| } | ||
|
|
||
| const markdown = new vscode.MarkdownString(lines.join('\n')); | ||
| markdown.isTrusted = true; |
Comment on lines
+18
to
+27
| export class OciBlobContentProvider implements vscode.TextDocumentContentProvider { | ||
| public provideTextDocumentContent(uri: vscode.Uri): string { | ||
| const raw = fs.readFileSync(uri.fsPath, 'utf8'); | ||
| try { | ||
| return JSON.stringify(JSON.parse(raw) as unknown, null, 4); | ||
| } catch { | ||
| return raw; | ||
| } | ||
| } | ||
| } |
| "vscode-containers.config.containers.truncateLongRegistryPaths": "Set to true to truncate long image and container registry paths in Container Images view", | ||
| "vscode-containers.config.containers.truncateMaxLength": "Maximum length of a registry paths displayed in Container Images view, including ellipsis. The truncateLongRegistryPaths setting must be set to true for truncateMaxLength setting to be effective.", | ||
| "vscode-containers.config.containers.environment": "Environment variables that will be applied to all VS Code terminals and to all background processes started by the Container Tools extension. Use for variables like `DOCKER_HOST`, etc.", | ||
| "vscode-containers.config.containers.oci.exportPath": "Directory where images exported as OCI layouts are stored. Leave empty to be prompted on first export. Supports `${workspaceFolder}` substitution.", |
Comment on lines
+131
to
+137
| if (position.character >= start && position.character <= end) { | ||
| return { | ||
| range: new vscode.Range(position.line, start, position.line, end), | ||
| algorithm: match[1].toLowerCase(), | ||
| hash: match[2].toLowerCase(), | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces comprehensive support for OCI (Open Container Initiative) image layouts in the Container Tools extension for Visual Studio Code. The changes add a new "OCI Layout Explorer" view, commands to explore and export images as OCI layouts, settings for layout export and JSON detection, and documentation updates. This enables users to inspect, browse, and stage OCI layouts directly from VS Code, enhancing workflows for image inspection and supply chain tooling.
Major features and improvements:
OCI Layout Explorer and Commands:
vscode-containers.views.ociLayout) to the activity bar, allowing users to browse OCI image layouts, manifests, configs, and blobs directly in VS Code. [1] [2]Settings and Localization:
containers.oci.exportPath(controls export directory for OCI layouts) andcontainers.oci.jsonDetectionMaxBytes(controls automatic JSON language detection for descriptor files), with localization and documentation. [1] [2] [3]Extension Initialization:
Documentation:
README.mdwith a detailed section on working with OCI image layouts, describing the new explorer, commands, settings, and usage notes for Docker and Podman runtimes. [1] [2]These enhancements significantly improve the extension’s capabilities for advanced container image workflows, especially for users working with OCI-compliant tools and registries.
This is a reimplementation of the extension I made earlier this week: https://github.com/jpinz/vscode-oci-extension with the webviews removed, and updated ORAS + Podman Compatibility
Screenshots
Demo
OCI.Layout.Export.mp4