Skip to content
Merged
Show file tree
Hide file tree
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
37 changes: 37 additions & 0 deletions src/frameworks/openTofuFramework.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { exec } from 'child_process';
import { promisify } from 'util';
import { TerraformFramework } from './terraformFramework.js';
import path from 'path';
import { Logger } from '../logger.js';
import fs from 'fs/promises';

export const execAsync = promisify(exec);

Expand All @@ -15,6 +18,40 @@ export class OpenTofuFramework extends TerraformFramework {
return 'opentofu';
}

/**
* Can this class handle the current project
* @returns
*/
public async canHandle(): Promise<boolean> {
// check for any file with .tf, .tf.json, .tofu, or .tofu.json extension
const files = await fs.readdir(process.cwd());
const r = files.some(
(f) =>
f.endsWith('.tf') ||
f.endsWith('.tf.json') ||
f.endsWith('.tofu') ||
f.endsWith('.tofu.json'),
);

if (!r) {
Logger.verbose(
`[${this.logName}] This is not a ${this.logName} project. There are no *.tf, *.tf.json, *.tofu, or *.tofu.json files in ${path.resolve('.')} folder.`,
);
return false;
} else {
// check if Terraform or OpenTofu is installed
try {
await execAsync(this.checkInstalledCommand);
return true;
} catch {
Logger.verbose(
`[${this.logName}] This is not a ${this.logName} project. ${this.logName} is not installed.`,
);
return false;
}
}
}

/**
* Name of the framework in logs
*/
Expand Down
6 changes: 3 additions & 3 deletions src/frameworks/terraformFramework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ export class TerraformFramework implements IFramework {
* @returns
*/
public async canHandle(): Promise<boolean> {
// is there any filey with *.tf extension
// check for any files with .tf or .tf.json extension
const files = await fs.readdir(process.cwd());
const r = files.some((f) => f.endsWith('.tf'));
const r = files.some((f) => f.endsWith('.tf') || f.endsWith('.tf.json'));

if (!r) {
Logger.verbose(
`[${this.logName}] This is not a ${this.logName} project. There are no *.tf files in ${path.resolve('.')} folder.`,
`[${this.logName}] This is not a ${this.logName} project. There are no *.tf or *.tf.json files in ${path.resolve('.')} folder.`,
);
return false;
} else {
Expand Down
Empty file.
72 changes: 72 additions & 0 deletions test/cdk-basic/cdk-synth.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
use `logGroup` instead
This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
use `logGroup` instead
This API will be removed in the next major release.
Bundling asset CdkbasicStack/TestTsCommonJs/Code/Stage...

...5d8888acd02a3a8300fd1812aaaadea60eb4d5e94fdc8b74-building/index.js 2.5kb

⚡ Done in 5ms
[WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
use `logGroup` instead
This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
use `logGroup` instead
This API will be removed in the next major release.
Bundling asset CdkbasicStack/TestTsEsModule/Code/Stage...

...6da3d4a35f4bd8700dc1cd1e51cb1f8e221896ac5b1e3a6-building/index.mjs 952b

⚡ Done in 3ms
[WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
use `logGroup` instead
This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
use `logGroup` instead
This API will be removed in the next major release.
Bundling asset CdkbasicStack/TestJsCommonJs/Code/Stage...

...13fdc37e5dff5529e8d38cc279c44a91ddc79ee0a6999101-building/index.js 970b

⚡ Done in 3ms
[WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
use `logGroup` instead
This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
use `logGroup` instead
This API will be removed in the next major release.
Bundling asset CdkbasicStack2/TestJsEsModule/Code/Stage...

...8ac79e932e94cba6a9050b4975ea1709894b6ab846714ba-building/index.mjs 952b

⚡ Done in 3ms
[WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
use `logGroup` instead
This API will be removed in the next major release.
[WARNING] aws-cdk-lib.aws_lambda.FunctionOptions#logRetention is deprecated.
use `logGroup` instead
This API will be removed in the next major release.
You currently have 50 unconfigured feature flags that may require attention to keep your application up-to-date. Run 'cdk flags' to learn more.

NOTICES (What's this? https://github.com/aws/aws-cdk/wiki/CLI-Notices)

34892 CDK CLI will collect telemetry data on command usage starting at version 2.1100.0 (unless opted out)

Overview: We do not collect customer content and we anonymize the
telemetry we do collect. See the attached issue for more
information on what data is collected, why, and how to
opt-out. Telemetry will NOT be collected for any CDK CLI
version prior to version 2.1100.0 - regardless of
opt-in/out. You can also preview the telemetry we will start
collecting by logging it to a local file, by adding
`--unstable=telemetry --telemetry-file=my/local/file` to any
`cdk` command.

Affected versions: cli: ^2.0.0

More information at: https://github.com/aws/aws-cdk/issues/34892


If you don’t want to see a notice anymore, use "cdk acknowledge <id>". For example, "cdk acknowledge 34892".
File renamed without changes.
Loading