Skip to content

Commit

Permalink
fix: remove commented code from reconciler
Browse files Browse the repository at this point in the history
  • Loading branch information
scottydawg committed Aug 9, 2022
1 parent 3a6f6b0 commit 952c86d
Showing 1 changed file with 6 additions and 82 deletions.
88 changes: 6 additions & 82 deletions packages/events-example/src/commands/reconcile/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import { CliUx, Command, Flags } from '@oclif/core';
import { Command, Flags } from '@oclif/core';
import Nile, { Instance, NileApi } from '@theniledev/js';
import {
DestroyResult,
InlineProgramArgs,
LocalWorkspace,
StackSummary,
Stack,
UpResult,
PulumiFn,
} from '@pulumi/pulumi/automation';

import { pulumiProgramGenerator } from '../../pulumiS3';
import PulumiAwsDeployment from '../../deployments/pulumi';
Expand Down Expand Up @@ -39,70 +30,9 @@ export default class Reconcile extends Command {
status: Flags.boolean({ char: 's', description: 'status', default: false }),
};

//localWorkspace!: LocalWorkspace;
nile!: NileApi;
deployment!: PulumiAwsDeployment;

/*
async waitOnStack(stack: Stack): Promise<void> {
let stackInfo;
do {
stackInfo = await stack.info();
this.debug(stackInfo);
} while (stackInfo != undefined && stackInfo?.result !== 'succeeded');
}
async getStack(stackName: string, program: PulumiFn): Promise<Stack> {
const args: InlineProgramArgs = {
stackName,
projectName: 'tryhard',
program,
};
const stack = await LocalWorkspace.createOrSelectStack(args);
await stack.setConfig('aws:region', { value: 'us-west-2' });
return stack;
}
async createStack(instance: Instance): Promise<UpResult> {
const stack = await this.getStack(instance.id, pulumiProgram(instance));
await this.waitOnStack(stack);
try {
CliUx.ux.action.start(`Creating a stack id=${instance.id}`);
return await stack.up({ onOutput: console.log });
} finally {
CliUx.ux.action.stop();
}
}
async destroyStack(id: string): Promise<DestroyResult> {
const stack = await this.getStack(id, pulumiProgram({}));
await this.waitOnStack(stack);
try {
CliUx.ux.action.start(`Destroying a stack id=${id}`);
return await stack.destroy({ onOutput: console.log });
} finally {
CliUx.ux.action.stop();
}
}
async loadPulumiStacks(): Promise<{ [key: string]: StackSummary }> {
const stacks = await (
await this.localWorkspace.listStacks()
).reduce(async (accP, stack) => {
const acc = await accP;
const fullStack = await this.getStack(stack.name, pulumiProgram({}));
const info = await fullStack.info();
if (info?.kind != 'destroy') {
acc[stack.name] = stack;
this.debug('adding stack', stack);
}
return acc;
}, Promise.resolve({} as { [key: string]: StackSummary }));
this.debug(stacks);
return stacks;
}
*/

async loadInstances(
organization: string,
entity: string
Expand All @@ -127,17 +57,11 @@ export default class Reconcile extends Command {
const { flags } = await this.parse(Reconcile);

// pulumi setup
/*
this.localWorkspace = await LocalWorkspace.create({
projectSettings: { name: flags.workspace, runtime: 'nodejs' },
});
this.localWorkspace.installPlugin('aws', 'v4.0.0');
*/
this.deployment = await PulumiAwsDeployment.create(
"tryhard",
{ projectSettings: { name: flags.workspace, runtime: 'nodejs' } },
pulumiProgramGenerator
)
this.deployment = await PulumiAwsDeployment.create(
"tryhard",
{ projectSettings: { name: flags.workspace, runtime: 'nodejs' } },
pulumiProgramGenerator
)

// nile setup
this.nile = Nile({ basePath: flags.basePath, workspace: flags.workspace });
Expand Down

0 comments on commit 952c86d

Please sign in to comment.