Skip to content

Commit

Permalink
feat: migration between secrets operator
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Sep 8, 2024
1 parent 2184aa6 commit ccc1d89
Show file tree
Hide file tree
Showing 5 changed files with 324 additions and 307 deletions.
4 changes: 2 additions & 2 deletions src/books/secrets-operator-destruction/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { $ } from 'bun';
import type { CloudTreeCluster, ServiceTreeService } from '../../lib/service-tree-def.ts';
import type { TaskRunner } from '../../tasks/tasks.ts';

class GenericSecretsOperatorDestructor {
class GenericSecretOperatorDestructor {
constructor(
private task: TaskRunner,
private sulfoxide_infisical: ServiceTreeService,
Expand Down Expand Up @@ -62,4 +62,4 @@ class GenericSecretsOperatorDestructor {
}
}

export { GenericSecretsOperatorDestructor };
export { GenericSecretOperatorDestructor };
25 changes: 11 additions & 14 deletions src/books/secrets-operator-destruction/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import type { CloudTreeCluster } from "../../lib/service-tree-def.ts";
import type { ServiceTreePrompter } from "../../lib/prompts/landscape.ts";
import type { RunBook } from "../run-book.ts";
import type { GenericSecretsOperatorDestructor } from "./generic.ts";
import type { CloudTreeCluster } from '../../lib/service-tree-def.ts';
import type { ServiceTreePrompter } from '../../lib/prompts/landscape.ts';
import type { RunBook } from '../run-book.ts';
import type { GenericSecretOperatorDestructor } from './generic.ts';

class SecretsOperatorDestructor implements RunBook {
constructor(
private destructor: GenericSecretsOperatorDestructor,
private stp: ServiceTreePrompter
) {
}
private destructor: GenericSecretOperatorDestructor,
private stp: ServiceTreePrompter,
) {}

name: string = "Destroy Secrets Operator";
desc: string = "Teardown the secrets operator to a selected cloud-cluster";
name: string = 'Destroy Secrets Operator';
desc: string = 'Teardown the secrets operator to a selected cloud-cluster';

async Run(): Promise<void> {
const cluster: CloudTreeCluster = await this.stp.Cluster(
"Which cloud do you want to create infisical in?",
"Which cluster do you want to create infisical in?"
'Which cloud do you want to create infisical in?',
'Which cluster do you want to create infisical in?',
);

await this.destructor.Run(cluster);


}
}

Expand Down
14 changes: 13 additions & 1 deletion src/books/secrets-operator-migration/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import type { RunBook } from "../run-book.ts";
import { GenericSecretOperatorCreator } from "../secrets-operator-creation/generic.ts";
import { GenericSecretOperatorDestructor } from "../secrets-operator-destruction/generic.ts";
import type { ServiceTreePrompter } from "../../lib/prompts/landscape.ts";

class SecretsOperatorMigrator implements RunBook {
constructor() {
constructor(
private creator: GenericSecretOperatorCreator,
private destructor: GenericSecretOperatorDestructor,
private stp: ServiceTreePrompter
) {

}

name: string = "Migrate Secrets Operator";
desc: string = "Migrate the secrets operator to from one cloud-cluster to another";

async Run(): Promise<void> {
const fromCluster = await this.stp.Cluster("Which cloud do you want to migrate infisical from?", "Which cluster do you want to migrate infisical from?");
const toCluster = await this.stp.Cluster("Which cloud do you want to migrate infisical to?", "Which cluster do you want to migrate infisical to?");

await this.creator.Run(toCluster);
await this.destructor.Run(fromCluster);
}
}

Expand Down
14 changes: 11 additions & 3 deletions src/init/runbooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import { VultrGracefulPhysicalClusterDestructor } from "../books/graceful-physic
import { SecretsOperatorDestructor } from "../books/secrets-operator-destruction";
import { SecretsOperatorCreator } from "../books/secrets-operator-creation";
import { GenericSecretOperatorCreator } from "../books/secrets-operator-creation/generic.ts";
import { GenericSecretsOperatorDestructor } from "../books/secrets-operator-destruction/generic.ts";
import { GenericSecretOperatorDestructor } from "../books/secrets-operator-destruction/generic.ts";
import { SecretsOperatorMigrator } from "../books/secrets-operator-migration";

function initRunBooks(d: Dependencies, t: TaskGenerator): RunBook[] {
const sulfoxide = SERVICE_TREE.sulfoxide;
Expand Down Expand Up @@ -193,7 +194,7 @@ function initRunBooks(d: Dependencies, t: TaskGenerator): RunBook[] {
d.stp
);

const genericSecretsOperatorDestructor = new GenericSecretsOperatorDestructor(
const genericSecretsOperatorDestructor = new GenericSecretOperatorDestructor(
d.taskRunner,
sulfoxide.services.infisical
);
Expand All @@ -203,6 +204,12 @@ function initRunBooks(d: Dependencies, t: TaskGenerator): RunBook[] {
d.stp
);

const secretsOperatorMigrator = new SecretsOperatorMigrator(
genericSecretOperatorCreator,
genericSecretsOperatorDestructor,
d.stp
);


return [
physicalClusterCreator,
Expand All @@ -212,7 +219,8 @@ function initRunBooks(d: Dependencies, t: TaskGenerator): RunBook[] {
adminGracefulDestructor,
adminClusterMigrator,
secretsOperatorCreator,
secretsOperatorDestructor
secretsOperatorDestructor,
secretsOperatorMigrator
];
}

Expand Down
Loading

0 comments on commit ccc1d89

Please sign in to comment.