fixed comments & structure
This commit is contained in:
Родитель
4cce9c2ddc
Коммит
c480b7a9f6
|
@ -6,7 +6,6 @@
|
|||
import { IActionContext, openReadOnlyJson } from '@microsoft/vscode-azext-utils';
|
||||
import * as vscode from 'vscode';
|
||||
import { ext } from '../../extensionVariables';
|
||||
import { ImageSbomItem } from '../../runtimes/docker';
|
||||
import { ImageTreeItem } from '../../tree/images/ImageTreeItem';
|
||||
|
||||
export async function generateSbom(context: IActionContext, node?: ImageTreeItem): Promise<void> {
|
||||
|
@ -20,10 +19,10 @@ export async function generateSbom(context: IActionContext, node?: ImageTreeItem
|
|||
|
||||
const generating: string = vscode.l10n.t('Generating Software Bill of Materials...');
|
||||
|
||||
let sbomResult: ImageSbomItem[];
|
||||
let sbomResult: string;
|
||||
await vscode.window.withProgress( { location: vscode.ProgressLocation.Notification, title: generating }, async () => {
|
||||
sbomResult = await ext.runWithDefaults(client => client.imageGenerateSbom({ imageRef: node.imageId }));
|
||||
sbomResult = await ext.runWithDefaults(client => client.sbomForImage({ imageRef: node.imageId }));
|
||||
});
|
||||
|
||||
await openReadOnlyJson(node, JSON.parse(sbomResult[0].raw));
|
||||
await openReadOnlyJson(node, JSON.parse(sbomResult));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { ext } from './extensionVariables';
|
|||
import { AutoConfigurableDockerClient } from './runtimes/clients/AutoConfigurableDockerClient';
|
||||
import { AutoConfigurableDockerComposeClient } from './runtimes/clients/AutoConfigurableDockerComposeClient';
|
||||
import { ContainerRuntimeManager } from './runtimes/ContainerRuntimeManager';
|
||||
import { DockerPlugins } from './runtimes/docker/clients/DockerClientBase/DockerInfoRecord';
|
||||
import { DockerPlugins } from './runtimes/docker';
|
||||
import { ContainerFilesProvider } from './runtimes/files/ContainerFilesProvider';
|
||||
import { OrchestratorRuntimeManager } from './runtimes/OrchestratorRuntimeManager';
|
||||
import { registerTaskProviders } from './tasks/TaskHelper';
|
||||
|
|
|
@ -16,8 +16,6 @@ import {
|
|||
EventStreamCommandOptions,
|
||||
ExecContainerCommandOptions,
|
||||
IContainersClient,
|
||||
ImageGenerateSbomCommandOptions,
|
||||
ImageSbomItem,
|
||||
InfoCommandOptions,
|
||||
InfoItem,
|
||||
InspectContainersCommandOptions,
|
||||
|
@ -62,8 +60,7 @@ import {
|
|||
RemoveNetworksCommandOptions,
|
||||
RemoveVolumesCommandOptions,
|
||||
RestartContainersCommandOptions,
|
||||
RunContainerCommandOptions,
|
||||
StartContainersCommandOptions,
|
||||
RunContainerCommandOptions, SbomForImageCommandOptions, StartContainersCommandOptions,
|
||||
StatPathCommandOptions,
|
||||
StatPathItem,
|
||||
StopContainersCommandOptions,
|
||||
|
@ -657,12 +654,12 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
|
|||
//#region ImagesGenerateSbom Command
|
||||
|
||||
/**
|
||||
* Generate the command line arguments for invoking a pull image command on
|
||||
* a Docker-like client
|
||||
* @param options Pull image command options
|
||||
* @returns Command line arguments for pulling a container image
|
||||
* Generate the command line arguments for invoking the generation of an image wide
|
||||
* Software Bill of Rights on a Docker-like client
|
||||
* @param options generate Software Bill of Rights command options
|
||||
* @returns Command line arguments for generating Software Bill of Rights on an image
|
||||
*/
|
||||
protected getGenerateSbomCommandArgs(options: ImageGenerateSbomCommandOptions): CommandLineArgs {
|
||||
protected getGenerateSbomCommandArgs(options: SbomForImageCommandOptions): CommandLineArgs {
|
||||
return composeArgs(
|
||||
withArg('sbom'),
|
||||
withNamedArg('--format', 'spdx-json', {shouldQuote: false}),
|
||||
|
@ -671,16 +668,14 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
|
|||
}
|
||||
|
||||
protected async parseImageGenerateSbomCommandOutput(
|
||||
options: ImageGenerateSbomCommandOptions,
|
||||
options: SbomForImageCommandOptions,
|
||||
output: string,
|
||||
strict: boolean,
|
||||
): Promise<Array<ImageSbomItem>> {
|
||||
const sboms = new Array<ImageSbomItem>();
|
||||
sboms.push({raw: output});
|
||||
return sboms;
|
||||
): Promise<string> {
|
||||
return output;
|
||||
}
|
||||
|
||||
async imageGenerateSbom(options: ImageGenerateSbomCommandOptions): Promise<PromiseCommandResponse<Array<ImageSbomItem>>> {
|
||||
async sbomForImage(options: SbomForImageCommandOptions): Promise<PromiseCommandResponse<string>> {
|
||||
return {
|
||||
command: this.commandName,
|
||||
args: this.getGenerateSbomCommandArgs(options),
|
||||
|
|
|
@ -3,15 +3,7 @@
|
|||
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ContainerOS, isContainerOS } from "../../contracts/ContainerClient";
|
||||
|
||||
export type DockerPlugins = {
|
||||
Name?: string;
|
||||
};
|
||||
|
||||
export type DockerClientInfo = {
|
||||
Plugins?: DockerPlugins[];
|
||||
};
|
||||
import { ContainerOS, DockerClientInfo, isContainerOS } from "../../contracts/ContainerClient";
|
||||
|
||||
export type DockerInfoRecord = {
|
||||
OperatingSystem?: string;
|
||||
|
@ -25,10 +17,10 @@ export function isDockerInfoRecord(maybeInfo: unknown): maybeInfo is DockerInfoR
|
|||
if (typeof info.OSType === 'string' && !isContainerOS(info.OSType)) {
|
||||
return false;
|
||||
}
|
||||
else if (!info.ClientInfo) {
|
||||
|
||||
if (info.ClientInfo && typeof info.ClientInfo !== 'object') {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import type { FileType, ShellQuotedString } from 'vscode';
|
||||
import { DockerClientInfo } from '../clients/DockerClientBase/DockerInfoRecord';
|
||||
import { GeneratorCommandResponse, PromiseCommandResponse, VoidCommandResponse } from './CommandRunner';
|
||||
import { IShell } from './Shell';
|
||||
|
||||
|
@ -137,6 +136,14 @@ export type InfoCommandOptions = CommonCommandOptions & {
|
|||
// Intentionally empty for now
|
||||
};
|
||||
|
||||
export type DockerPlugins = {
|
||||
Name?: string;
|
||||
};
|
||||
|
||||
export type DockerClientInfo = {
|
||||
Plugins?: DockerPlugins[];
|
||||
};
|
||||
|
||||
export type InfoItem = {
|
||||
/**
|
||||
* The operating system for the container runtime (e.g. Docker Desktop)
|
||||
|
@ -614,28 +621,22 @@ type InspectImagesCommand = {
|
|||
inspectImages(options: InspectImagesCommandOptions): Promise<PromiseCommandResponse<Array<InspectImagesItem>>>;
|
||||
};
|
||||
|
||||
export type ImageSbomItem = {
|
||||
/**
|
||||
* The RAW inspect output
|
||||
*/
|
||||
raw: string;
|
||||
};
|
||||
/**
|
||||
* Options for inspecting images
|
||||
*/
|
||||
export type ImageGenerateSbomCommandOptions = CommonCommandOptions & {
|
||||
export type SbomForImageCommandOptions = CommonCommandOptions & {
|
||||
/**
|
||||
* The image names/IDs/etc. to inspect, passed directly to the CLI
|
||||
*/
|
||||
imageRef: string;
|
||||
};
|
||||
|
||||
type ImageGenerateSbomCommand = {
|
||||
type SbomForImageCommand = {
|
||||
/**
|
||||
* Generate a CommandResponse for pruning images
|
||||
* @param options Command options
|
||||
*/
|
||||
imageGenerateSbom(options: ImageGenerateSbomCommandOptions): Promise<PromiseCommandResponse<Array<ImageSbomItem>>>;
|
||||
sbomForImage(options: SbomForImageCommandOptions): Promise<PromiseCommandResponse<string>>;
|
||||
};
|
||||
|
||||
//#endregion
|
||||
|
@ -1892,7 +1893,7 @@ export interface IContainersClient extends
|
|||
TagImageCommand,
|
||||
InspectImagesCommand,
|
||||
PushImageCommand,
|
||||
ImageGenerateSbomCommand,
|
||||
SbomForImageCommand,
|
||||
// Container Commands
|
||||
RunContainerCommand,
|
||||
ExecContainerCommand,
|
||||
|
|
Загрузка…
Ссылка в новой задаче