Skip to content

Commit

Permalink
chore: fix foundation deploy when the platform just has a single module
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesRudolph committed Sep 4, 2023
1 parent a49d1a1 commit 944afb4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/foundation/PlatformDeployer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as fs from "std/fs";
import * as path from "std/path";

import {
TerragruntArguments,
Expand Down Expand Up @@ -44,23 +45,23 @@ export class PlatformDeployer<T extends PlatformConfig> {
module: string | undefined,
autoApprove: boolean,
) {
const modulePath = this.foundation.resolvePlatformPath(
const platformOrModulePath = this.foundation.resolvePlatformPath(
this.platform,
module || "",
);

const progress = this.buildProgressReporter(
mode,
this.repo.relativePath(modulePath),
this.repo.relativePath(platformOrModulePath),
);

const tgfiles = await this.terragruntFiles(modulePath);
const tgfiles = await this.terragruntFiles(platformOrModulePath);
if (tgfiles.length === 0) {
this.logger.warn(
(fmt) =>
`detected no platform modules at ${
fmt.kitPath(
modulePath,
platformOrModulePath,
)
}, will skip invoking "terragrunt <cmd>"`,
);
Expand All @@ -70,26 +71,30 @@ export class PlatformDeployer<T extends PlatformConfig> {
"kit apply",
);
} else if (tgfiles.length === 1) {
// we can't run terragrunt in the platform dir, so we have to infer the platformModule path from
// the discovered terragrunt file
const singleModulePath = path.dirname(tgfiles[0].path);

this.logger.debug(
(fmt) =>
`detected a single platform module at ${
fmt.kitPath(
modulePath,
singleModulePath,
)
}, will deploy with "terragrunt <cmd>"`,
);
await this.terragrunt.run(modulePath, mode, { autoApprove });
await this.terragrunt.run(singleModulePath, mode, { autoApprove });
} else {
this.logger.debug(
(fmt) =>
`detected a stack of platform modules at ${
fmt.kitPath(
modulePath,
platformOrModulePath,
)
}, will deploy with "terragrunt run-all <cmd>"`,
);

await this.terragrunt.runAll(modulePath, mode, {
await this.terragrunt.runAll(platformOrModulePath, mode, {
excludeDirs: [this.bootstrapModuleDir()],
autoApprove,
});
Expand Down

0 comments on commit 944afb4

Please sign in to comment.