diff --git a/examples/datacenters/local/datacenter.arc b/examples/datacenters/local/datacenter.arc index 22e028fc..0e621243 100644 --- a/examples/datacenters/local/datacenter.arc +++ b/examples/datacenters/local/datacenter.arc @@ -99,8 +99,8 @@ environment { port = 5432 username = "postgres" password = "password" - database = module.postgres.name - url = "postgresql://postgres:password@host.docker.internal:5432/${module.postgres.name}" + database = module.database.name + url = "postgresql://postgres:password@host.docker.internal:5432/${module.database.name}" } } diff --git a/examples/datacenters/local/postgres-db/Dockerfile b/examples/datacenters/local/postgres-db/Dockerfile index 35cc3d9f..37ccc985 100644 --- a/examples/datacenters/local/postgres-db/Dockerfile +++ b/examples/datacenters/local/postgres-db/Dockerfile @@ -3,7 +3,7 @@ FROM alpine:3 # Needed for terraform modules that include a remote source -RUN apk add --no-cache git +RUN apk add --no-cache git jq RUN wget https://github.com/opentofu/opentofu/releases/download/v1.6.0-beta3/tofu_1.6.0-beta3_amd64.apk RUN apk add --allow-untrusted tofu_1.6.0-beta3_amd64.apk diff --git a/examples/datacenters/local/postgres-db/main.tf b/examples/datacenters/local/postgres-db/main.tf index f0f6c3fe..a8ffe7d3 100644 --- a/examples/datacenters/local/postgres-db/main.tf +++ b/examples/datacenters/local/postgres-db/main.tf @@ -28,6 +28,10 @@ variable "username" { variable "password" {} +locals { + name = replace(var.name, "/", "_") +} + provider "postgresql" { host = var.host port = var.port @@ -38,10 +42,10 @@ provider "postgresql" { } resource "postgresql_database" "my_db" { - name = var.name + name = local.name } output "name" { description = "Name of the database that was created" - value = var.name + value = local.name } diff --git a/examples/datacenters/local/postgres-db/module.yml b/examples/datacenters/local/postgres-db/module.yml index f687713c..abeb0616 100644 --- a/examples/datacenters/local/postgres-db/module.yml +++ b/examples/datacenters/local/postgres-db/module.yml @@ -1,5 +1,5 @@ init: tofu init plan: tofu plan -input=false -state=$STATE_FILE -detailed-exitcode -outputs: tofu output -state=$STATE_FILE -json +outputs: tofu output -state=$STATE_FILE -json | jq 'map_values(.value)' > $OUTPUT_FILE apply: VARS=$(echo $INPUTS | jq -r "to_entries | map(\"-var \" + .key + \"=\" + (.value | tostring)) | join(\" \")") && tofu apply -state=$STATE_FILE -auto-approve $VARS destroy: VARS=$(echo $INPUTS | jq -r "to_entries | map(\"-var \" + .key + \"=\" + (.value | tostring)) | join(\" \")") && tofu destroy -state=$STATE_FILE -auto-approve $VARS diff --git a/examples/datacenters/local/secret/Dockerfile b/examples/datacenters/local/secret/Dockerfile index 35cc3d9f..37ccc985 100644 --- a/examples/datacenters/local/secret/Dockerfile +++ b/examples/datacenters/local/secret/Dockerfile @@ -3,7 +3,7 @@ FROM alpine:3 # Needed for terraform modules that include a remote source -RUN apk add --no-cache git +RUN apk add --no-cache git jq RUN wget https://github.com/opentofu/opentofu/releases/download/v1.6.0-beta3/tofu_1.6.0-beta3_amd64.apk RUN apk add --allow-untrusted tofu_1.6.0-beta3_amd64.apk diff --git a/examples/datacenters/local/secret/module.yml b/examples/datacenters/local/secret/module.yml index f687713c..abeb0616 100644 --- a/examples/datacenters/local/secret/module.yml +++ b/examples/datacenters/local/secret/module.yml @@ -1,5 +1,5 @@ init: tofu init plan: tofu plan -input=false -state=$STATE_FILE -detailed-exitcode -outputs: tofu output -state=$STATE_FILE -json +outputs: tofu output -state=$STATE_FILE -json | jq 'map_values(.value)' > $OUTPUT_FILE apply: VARS=$(echo $INPUTS | jq -r "to_entries | map(\"-var \" + .key + \"=\" + (.value | tostring)) | join(\" \")") && tofu apply -state=$STATE_FILE -auto-approve $VARS destroy: VARS=$(echo $INPUTS | jq -r "to_entries | map(\"-var \" + .key + \"=\" + (.value | tostring)) | join(\" \")") && tofu destroy -state=$STATE_FILE -auto-approve $VARS diff --git a/src/commands/destroy/datacenter.ts b/src/commands/destroy/datacenter.ts index f39fb69a..d846c85e 100644 --- a/src/commands/destroy/datacenter.ts +++ b/src/commands/destroy/datacenter.ts @@ -24,7 +24,7 @@ const DestroyDatacenterCommand = BaseCommand() 'Destroy the datacenter store record, even if destruction of the datacenter fails', { default: false }, ) - .option('-c, --concurrency ', 'Maximum number of nodes to apply concurrently', { default: 1 }) + .option('-c, --concurrency ', 'Maximum number of nodes to apply concurrently', { default: 10 }) .arguments('[name:string]') .action(destroy_datacenter_action); diff --git a/src/commands/destroy/environment.ts b/src/commands/destroy/environment.ts index ca815457..92cdcc93 100644 --- a/src/commands/destroy/environment.ts +++ b/src/commands/destroy/environment.ts @@ -128,6 +128,6 @@ export default BaseCommand() .description('Destroy all the resources in the specified environment') .option('-v, --verbose [verbose:boolean]', 'Turn on verbose logs', { default: false }) .option('--auto-approve [autoApprove:boolean]', 'Skip all prompts and start the requested action', { default: false }) - .option('-c, --concurrency ', 'Maximum number of nodes to apply concurrently', { default: 1 }) + .option('-c, --concurrency ', 'Maximum number of nodes to apply concurrently', { default: 10 }) .arguments('') .action(destroyEnvironment); diff --git a/src/commands/remove.ts b/src/commands/remove.ts index 1349a3ea..4c4b58fa 100644 --- a/src/commands/remove.ts +++ b/src/commands/remove.ts @@ -9,6 +9,7 @@ type RemoveOptions = { verbose: boolean; autoApprove: boolean; refresh: boolean; + concurrency: number; } & GlobalOptions; const RemoveCommand = BaseCommand() @@ -21,6 +22,7 @@ const RemoveCommand = BaseCommand() }) .option('-v, --verbose [verbose:boolean]', 'Turn on verbose logs', { default: false }) .option('-r, --refresh [refresh:boolean]', 'Force update all resources', { default: false }) + .option('-c, --concurrency ', 'Maximum number of nodes to apply concurrently', { default: 10 }) .option('--auto-approve [autoApprove:boolean]', 'Skip all prompts and start the requested action', { default: false }) .action(remove_action); @@ -89,7 +91,7 @@ async function remove_action(options: RemoveOptions, name: string): Promise { await command_helper.environmentUtils.saveEnvironment( diff --git a/src/graphs/infra/node.ts b/src/graphs/infra/node.ts index c3e07653..3b0627fa 100644 --- a/src/graphs/infra/node.ts +++ b/src/graphs/infra/node.ts @@ -215,7 +215,7 @@ export class InfraGraphNode extends GraphNode | string> mount_path: '/module', }); - const flags = ['run', '--rm']; + const flags = ['run']; Object.values(volume_mounts).forEach((value) => { flags.push('-v', `${value.host_path}:${value.mount_path}`); }); diff --git a/src/utils/docker.ts b/src/utils/docker.ts index 00fc700f..425552ce 100644 --- a/src/utils/docker.ts +++ b/src/utils/docker.ts @@ -10,7 +10,14 @@ export const getImageLabels = async (tag_or_digest: string): Promise