Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix foundation deploy when the platform just has a single module #229

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading