From 364e53f0bcb95133945016f8ca53d683653f42be Mon Sep 17 00:00:00 2001 From: Xavier Mitault Date: Sun, 31 Mar 2024 22:27:34 +0000 Subject: [PATCH] Add Instance (not working but idk why) --- Dockerfile | 7 +++++-- src/Program.ts | 45 +-------------------------------------------- tests/src/index.ts | 25 ++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 47 deletions(-) diff --git a/Dockerfile b/Dockerfile index b88177f..c0fbe60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,13 +7,16 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update \ curl \ gnupg \ lsb-release \ - git + git \ + openssh-client RUN curl -fsSL https://get.pulumi.com | sh ENV PATH="/root/.pulumi/bin:${PATH}" RUN pulumi version -RUN curl -fsSL 'https://github.com/pulumi/pulumictl/releases/download/v0.0.45/pulumictl-v0.0.45-linux-amd64.tar.gz' -o pulumictl.tar.gz +RUN curl -fsSL 'https://github.com/pulumi/pulumictl/releases/download/v0.0.46/pulumictl-v0.0.46-linux-amd64.tar.gz' -o pulumictl.tar.gz RUN tar -f pulumictl.tar.gz -C /usr/local/bin -xz RUN rm pulumictl.tar.gz +RUN ssh-keygen -t ed25519 -N '' -f /root/.ssh/id_ed25519 + CMD ["/bin/bash"] diff --git a/src/Program.ts b/src/Program.ts index 8127888..7bb3818 100644 --- a/src/Program.ts +++ b/src/Program.ts @@ -3,53 +3,10 @@ import type { ItemType, MachineVolume } from '@aleph-sdk/message'; import { AuthenticatedAlephHttpClient } from '@aleph-sdk/client'; import { readFileSync } from 'fs'; import { getAccount, hashData, getAlephExplorerUrl, zipPath } from './utils'; +import type { Volume, ImmutableVolume, EphemeralVolume } from './volumes'; export type Subscription = Array<{ sender: string; channel: string }>; -type AbstractVolume = { - mount: Array; - _type: 'immutable' | 'ephemeral'; -}; - -type ImmutableVolume = AbstractVolume & { - ref: string; - use_latest: boolean; - _type: 'immutable'; -}; - -export const getImmutableVolume = ( - ref: string, - use_latest: boolean, - mount: Array -): ImmutableVolume => { - return { - mount: mount, - ref: ref, - use_latest: use_latest, - _type: 'immutable', - }; -}; - -type EphemeralVolume = AbstractVolume & { - ephemeral: true; - size_mib: number; - _type: 'ephemeral'; -}; - -export const getEphemeralVolume = ( - size_mib: number, - mount: Array -): EphemeralVolume => { - return { - mount: mount, - ephemeral: true, - size_mib: size_mib, - _type: 'ephemeral', - }; -}; - -export type Volume = ImmutableVolume | EphemeralVolume; - export interface ProgramInputs { channel: pulumi.Input; path: pulumi.Input; diff --git a/tests/src/index.ts b/tests/src/index.ts index acb0548..2824691 100644 --- a/tests/src/index.ts +++ b/tests/src/index.ts @@ -5,9 +5,12 @@ import { securityKey, Program, getDefaultRuntime, + Instance, + getDefaultImage, } from 'pulumi-dynamic-provider-aleph'; import { ItemType } from '@aleph-sdk/message'; import * as pulumi from '@pulumi/pulumi'; +import { readFileSync } from 'fs'; export const messageTest = new Post('messageTest', { content: { @@ -73,7 +76,27 @@ if (process.env.ETH_ACC_PERSO !== undefined) { programVmUrl = program.aleph_vm_url; programExplorer = program.aleph_explorer_url; } - export const exportProgram = program; export const exportProgramVmUrl = programVmUrl; export const exportProgramExplorer = programExplorer; + +// TODO: Fix? +// let instance: any = undefined; +// let instanceExplorer: any = undefined; +// if (process.env.ETH_ACC_PERSO !== undefined) { +// // this path is used in the dockerfile +// const filePath = '/root/.ssh/id_ed25519.pub' +// const fileContent = readFileSync(filePath, 'utf8'); +// instance = new Instance('instance-basic', { +// channel: 'pulumi-test-channel', +// memory: 128, +// image: getDefaultImage(), +// volumes: [], +// storageEngine: ItemType.storage, +// accountEnvName: 'ETH_ACC_PERSO', +// authorizedKeys: [fileContent], +// }); +// instanceExplorer = instance.aleph_explorer_url; +// } +// export const exportInstance = instance; +// export const exportInstanceExplorer = instanceExplorer;