From ab86b8dfac22710f938f54a27e648375e33dcca8 Mon Sep 17 00:00:00 2001 From: Florent Benoit Date: Fri, 19 Jan 2024 13:07:15 +0100 Subject: [PATCH] chore: update to planned 1.7.0 release API fix build parameters (also remove the usage of first connection) and let Podman Desktop pickup one remove local copy of the API --- package.json | 2 +- .../src/managers/applicationManager.ts | 15 +- types/podman-desktop-api.d.ts | 309 ------------------ yarn.lock | 8 +- 4 files changed, 12 insertions(+), 322 deletions(-) diff --git a/package.json b/package.json index 632f3078f..09d7c53c1 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "typecheck": "npm run typecheck:shared && npm run typecheck:frontend && npm run typecheck:backend" }, "devDependencies": { - "@podman-desktop/api": "1.6.4", + "@podman-desktop/api": "0.0.202401191125-9c1aea6", "@typescript-eslint/eslint-plugin": "^6.16.0", "@typescript-eslint/parser": "^6.16.0", "@vitest/coverage-v8": "^1.1.0", diff --git a/packages/backend/src/managers/applicationManager.ts b/packages/backend/src/managers/applicationManager.ts index 971bfe1fd..6b77d5796 100644 --- a/packages/backend/src/managers/applicationManager.ts +++ b/packages/backend/src/managers/applicationManager.ts @@ -118,10 +118,6 @@ export class ApplicationManager { loadingConfiguration.state = 'success'; taskUtil.setTask(loadingConfiguration); - // Getting the provider to use for building - const connections = provider.getContainerConnections(); - const connection = connections[0]; - // Filter the containers based on architecture const filteredContainers = aiConfig.application.containers.filter( container => container.arch === undefined || container.arch === arch(), @@ -162,13 +158,15 @@ export class ApplicationManager { } let isErrored = false; + + const buildOptions = { + containerFile: container.containerfile, + tag: `${container.name}:latest`, + }; + return containerEngine .buildImage( context, - container.containerfile, - `${container.name}:latest`, - '', // keep empty chain so it use default - connection.connection, (event, data) => { // todo: do something with the event if (event === 'error' || (event === 'finish' && data !== '')) { @@ -180,6 +178,7 @@ export class ApplicationManager { taskUtil.setTaskState(container.name, 'success'); } }, + buildOptions, ) .catch((err: unknown) => { console.error('Something went wrong while building the image: ', err); diff --git a/types/podman-desktop-api.d.ts b/types/podman-desktop-api.d.ts index 77fa58b44..fd69ff26b 100644 --- a/types/podman-desktop-api.d.ts +++ b/types/podman-desktop-api.d.ts @@ -13,312 +13,3 @@ declare global { } export { PodmanDesktopApi }; - -// TODO: remove when podman desktop API exposes this interface -declare module '@podman-desktop/api' { - - /** - * Resource identifier for a resource - */ - export class Uri { - /** - * Create an URI from a string, e.g. `http://www.example.com/some/path`, - * `file:///usr/home`, or `scheme:with/path`. - * - * *Note* that for a while uris without a `scheme` were accepted. That is not correct - * as all uris should have a scheme. To avoid breakage of existing code the optional - * `strict`-argument has been added. We *strongly* advise to use it, e.g. `Uri.parse('my:uri', true)` - * - * @see {@link Uri.toString} - * @param value The string value of an Uri. - * @param strict Throw an error when `value` is empty or when no `scheme` can be parsed. - * @return A new Uri instance. - */ - static parse(value: string, strict?: boolean): Uri; - - /** - * Create an URI from a file system path. The {@link Uri.scheme scheme} - * will be `file`. - */ - static file(path: string): Uri; - - /** - * Create a new uri which path is the result of joining - * the path of the base uri with the provided path segments. - * - * @param base An uri. Must have a path. - * @param pathSegments One more more path fragments - * @returns A new uri which path is joined with the given fragments - */ - static joinPath(base: Uri, ...pathSegments: string[]): Uri; - - /** - * Use the `file` and `parse` factory functions to create new `Uri` objects. - */ - private constructor(scheme: string, authority: string, path: string, query: string, fragment: string); - - /** - * Scheme is the `http` part of `http://www.example.com/some/path?query#fragment`. - * The part before the first colon. - */ - readonly scheme: string; - - /** - * Authority is the `www.example.com` part of `http://www.example.com/some/path?query#fragment`. - * The part between the first double slashes and the next slash. - */ - readonly authority: string; - - /** - * Path is the `/some/path` part of `http://www.example.com/some/path?query#fragment`. - */ - readonly path: string; - - /** - * The string representing the corresponding file system path of this Uri. - */ - readonly fsPath: string; - - /** - * Query is the `query` part of `http://www.example.com/some/path?query#fragment`. - */ - readonly query: string; - - /** - * Fragment is the `fragment` part of `http://www.example.com/some/path?query#fragment`. - */ - readonly fragment: string; - - /** - * Derive a new Uri from this Uri. - * - * ```ts - * const foo = Uri.parse('http://foo'); - * const httpsFoo = foo.with({ scheme: 'https' }); - * // httpsFoo is now 'https://foo' - * ``` - * - * @param change An object that describes a change to this Uri. To unset components use `undefined` or - * the empty string. - * @returns A new Uri that reflects the given change. Will return `this` Uri if the change - * is not changing anything. - */ - with(change: { - /** - * The new scheme, defaults to this Uri's scheme. - */ - scheme?: string; - /** - * The new authority, defaults to this Uri's authority. - */ - authority?: string; - /** - * The new path, defaults to this Uri's path. - */ - path?: string; - /** - * The new query, defaults to this Uri's query. - */ - query?: string; - /** - * The new fragment, defaults to this Uri's fragment. - */ - fragment?: string; - }): Uri; - - toString(): string; - } - - export namespace window { - export function createWebviewPanel(viewType: string, title: string, options?: WebviewOptions): WebviewPanel; - } - export interface Webview { - /** - * Content settings for the webview. - */ - options: WebviewOptions; - - /** - * HTML contents of the webview. - * - * This should be a complete, valid html document. Changing this property causes the webview to be reloaded. - * - */ - html: string; - - /** - * Fired when the webview content posts a message. - * - * Webview content can post strings or json serializable objects back to an extension. - */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - readonly onDidReceiveMessage: Event; - - /** - * Post a message to the webview content. - */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - postMessage(message: any): Promise; - - /** - * Convert a uri for the local file system to one that can be used inside webviews. - */ - asWebviewUri(localResource: Uri): Uri; - - /** - * Content security policy source for webview resources. - * - */ - readonly cspSource: string; - } - - export interface WebviewOptions { - readonly localResourceRoots?: readonly Uri[]; - } - - interface WebviewPanel { - /** - * Identifies the type of the webview panel. - */ - readonly viewType: string; - - /** - * Title of the panel shown in UI. - */ - title: string; - - /** - * Icon for the panel shown in UI. - */ - iconPath?: - | Uri - | { - /** - * The icon path for the light theme. - */ - readonly light: Uri; - /** - * The icon path for the dark theme. - */ - readonly dark: Uri; - }; - - /** - * {@linkcode Webview} belonging to the panel. - */ - readonly webview: Webview; - - /** - * Whether the panel is active (focused by the user). - */ - readonly active: boolean; - - /** - * Whether the panel is visible. - */ - readonly visible: boolean; - - /** - * Fired when the panel's view state changes. - */ - readonly onDidChangeViewState: Event; - - /** - * Fired when the panel is disposed. - * - * This may be because the user closed the panel or because `.dispose()` was - * called on it. - * - * Trying to use the panel after it has been disposed throws an exception. - */ - readonly onDidDispose: Event; - - /** - * Show the webview panel. - * @param preserveFocus When `true`, the webview will not take focus. - */ - reveal(preserveFocus?: boolean): void; - - /** - * Dispose of the webview panel. - * - * This closes the panel if it showing and disposes of the resources owned by the webview. - * Webview panels are also disposed when the user closes the webview panel. Both cases - * fire the `onDispose` event. - */ - dispose(): void; - } - - export namespace containerEngine { - export function listContainers(): Promise; - export function inspectContainer(engineId: string, id: string): Promise; - - export function createContainer( - engineId: string, - containerCreateOptions: ContainerCreateOptions, - ): Promise; - export function startContainer(engineId: string, id: string): Promise; - export function logsContainer( - engineId: string, - id: string, - callback: (name: string, data: string) => void, - ): Promise; - export function stopContainer(engineId: string, id: string): Promise; - export function deleteContainer(engineId: string, id: string): Promise; - export function buildImage( - containerBuildContextDirectory: string, - relativeContainerfilePath: string, - imageName: string, - platform: string, - selectedProvider: ProviderContainerConnectionInfo | containerDesktopAPI.ContainerProviderConnection, - eventCollect: (eventName: 'stream' | 'error' | 'finish', data: string) => void, - abortController?: AbortController, - ); - export function saveImage(engineId: string, id: string, filename: string): Promise; - export function listImages(): Promise; - export function tagImage(engineId: string, imageId: string, repo: string, tag?: string): Promise; - export function pushImage( - engineId: string, - imageId: string, - callback: (name: string, data: string) => void, - authInfo?: ContainerAuthInfo, - ): Promise; - - export function pullImage( - containerProviderConnection: ContainerProviderConnection, - imageName: string, - callback: (event: PullEvent) => void, - ): Promise; - export function deleteImage(engineId: string, id: string): Promise; - - export function info(engineId: string): Promise; - export const onEvent: Event; - - export function listNetworks(): Promise; - export function createNetwork( - containerProviderConnection: ContainerProviderConnection, - networkCreateOptions: NetworkCreateOptions, - ): Promise; - } - - export interface ExtensionContext { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - readonly subscriptions: { dispose(): any }[]; - - /** - * An absolute file path in which the extension can store state. - * The directory might not exist on disk and creation is - * up to the extension. - */ - readonly storagePath: string; - - /** - * The uri of the directory containing the extension. - */ - readonly extensionUri: Uri; - } - - - -} - diff --git a/yarn.lock b/yarn.lock index c2b2be913..32cd7680d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -410,10 +410,10 @@ resolved "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== -"@podman-desktop/api@1.6.4": - version "1.6.4" - resolved "https://registry.yarnpkg.com/@podman-desktop/api/-/api-1.6.4.tgz#f6da8228523e787f408d366f1d99d12a7b9e6924" - integrity sha512-8sxPcFvepxVM0iANq9h+QbnxAPAEE03KhrDTUp8AEzMPHZhascBSi11xhaLaDUujXVaKHUysEt0hh+0ccL479w== +"@podman-desktop/api@0.0.202401191125-9c1aea6": + version "0.0.202401191125-9c1aea6" + resolved "https://registry.yarnpkg.com/@podman-desktop/api/-/api-0.0.202401191125-9c1aea6.tgz#a6dd84efaa1769cc3eedde320c9d5524e2f920f1" + integrity sha512-4oMQmfCXpnQrnEihe1yn3mGZULle4a0MlXdyOZ4vlKx04e2rZK7jFI45EjU6L64pwN0bGHWLFRI12Ut2sAirHQ== "@rollup/rollup-android-arm-eabi@4.9.1": version "4.9.1"