Skip to content

Commit

Permalink
Add Instance (not working but idk why)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Apr 8, 2024
1 parent 2b6df5f commit 364e53f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 47 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
45 changes: 1 addition & 44 deletions src/Program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
_type: 'immutable' | 'ephemeral';
};

type ImmutableVolume = AbstractVolume & {
ref: string;
use_latest: boolean;
_type: 'immutable';
};

export const getImmutableVolume = (
ref: string,
use_latest: boolean,
mount: Array<string>
): 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<string>
): EphemeralVolume => {
return {
mount: mount,
ephemeral: true,
size_mib: size_mib,
_type: 'ephemeral',
};
};

export type Volume = ImmutableVolume | EphemeralVolume;

export interface ProgramInputs {
channel: pulumi.Input<string>;
path: pulumi.Input<string>;
Expand Down
25 changes: 24 additions & 1 deletion tests/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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;

0 comments on commit 364e53f

Please sign in to comment.