Skip to content

Commit

Permalink
fix(do/swarm): fix do-swarm generator
Browse files Browse the repository at this point in the history
  • Loading branch information
opichon authored and AntPho committed Feb 13, 2025
1 parent c4716e2 commit f876f60
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 30 deletions.
8 changes: 4 additions & 4 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ export default class IaCGenerator extends Generator {

{
choices: [
{
name: "DigitalOcean swarm",
value: "do-swarm"
},
{
name: "Ansible for DigitalOcean swarm",
value: "ansible-do"
Expand Down Expand Up @@ -171,6 +167,10 @@ export default class IaCGenerator extends Generator {
name: "DigitalOcean SSH keys",
value: "do-ssh-keys"
},
{
name: "DigitalOcean swarm",
value: "do-swarm"
},
{ type: "separator" },
{
name: "Pulumi S3 Backend",
Expand Down
8 changes: 7 additions & 1 deletion generators/aws-resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ export default class AWSResourcesGenerator extends PulumiGenerator {
this.option("environment", {
type: String,
default: "staging",
desc: "environment."
desc: "environment"
});

this.option("projectName", {
default: this._getDefaultProjectName(),
desc: "Pulumi project name",
type: String,
});
}

Expand Down
31 changes: 17 additions & 14 deletions generators/do-swarm/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import chalk from "chalk";

import Generator from "yeoman-generator";
import PulumiGenerator from "../pulumi/index.js";

export default class DigitalOceanDockerSwarmGenerator extends Generator {
export default class DigitalOceanDockerSwarmGenerator extends PulumiGenerator {
constructor(args, opts) {
super(args, opts);

this.displayName = "DigitalOcean swarm";
this.name = "do-swarm";
this.resourcesList = [
"aws-credentials",
"aws-resources",
"do-resources",
"do-swarm-leader",
"cloudflare-dns",
"ansible-do"
// "aws-resources",
// "do-resources",
// "do-nfs-server",
// "do-swarm-leader",
// "cloudflare-dns",
// "ansible-do"
];
}

Expand All @@ -28,7 +29,7 @@ export default class DigitalOceanDockerSwarmGenerator extends Generator {
},
{
default: "sgp1",
message: "Enter the name of the do-resrouces and do-swarm-leader DigitalOcean region",
message: "In what region should the resources be provisioned?",
name: "region",
type: "input",
},
Expand All @@ -39,19 +40,16 @@ export default class DigitalOceanDockerSwarmGenerator extends Generator {
type: "input",
},
{
default: "USERNAME",
message: "Enter the username for the user of the swarm-leader and ansible",
name: "username",
type: "input",
},
{
default: "DOMAIN",
message: "Enter the domain name for cloudflare-dns and ansible",
name: "domain",
type: "input",
},
{
default: "",
message: "Enter the traefik ACME email for ansible",
name: "email",
type: "input",
Expand All @@ -65,17 +63,22 @@ export default class DigitalOceanDockerSwarmGenerator extends Generator {

// Define specific properties for each generator
const generatorsProps = {
"aws-resources": {
...this.options,
...this.props,
projectName: `${this.options.prefix}-aws-resources`,
},
"aws-credentials": {
environment: this.props.environment,
timestamp: this.props.nameSuffix,
},
"aws-resources": {
environment: this.props.environment,
},
"do-resources": {
environment: this.props.environment,
nameSuffix: this.props.nameSuffix,
region: this.props.region,
},
"do-nfs-server": {

},
"do-swarm-leader": {
environment: this.props.environment,
Expand Down
22 changes: 11 additions & 11 deletions generators/pulumi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ class PulumiGenerator extends Generator {
constructor(args, opts) {
super(args, opts);

this.option("createStackConfig", {
type: Boolean,
defaults: true,
desc: "Whether to generate the stack config."
});

this.option("environment", {
type: String,
desc: "Environment (stack)."
});

this.option("prefix", {
type: String,
required: false,
Expand All @@ -19,17 +30,6 @@ class PulumiGenerator extends Generator {
defaults: false,
desc: "Whether to use the prefix in the project folder name."
});

this.option("environment", {
type: String,
desc: "Environment (stack)."
});

this.option("createStackConfig", {
type: Boolean,
defaults: true,
desc: "Whether to generate the stack config."
});
}

async prompting() {
Expand Down

0 comments on commit f876f60

Please sign in to comment.