Skip to content

Commit

Permalink
clean up tf scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Sep 26, 2024
1 parent f79f33c commit 221228f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 4 additions & 1 deletion integrations/terraform-cloud-scanner/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export const env = createEnv({

CONCURRENT_REQUESTS: z.number().default(10),

CRON_ENABLED: z.string().default("true"),
CRON_ENABLED: z
.enum(["true", "false"])
.default("true")
.transform((value) => value === "true"),
CRON_TIME: z.string().default("*/5 * * * *"),
},
runtimeEnv: process.env,
Expand Down
10 changes: 2 additions & 8 deletions integrations/terraform-cloud-scanner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ logger.info(
`Starting Terraform Cloud scanner for organization '${env.TFE_ORGANIZATION}' in workspace '${env.CTRLPLANE_WORKSPACE_ID}'`,
);

if (env.CRON_ENABLED.toLowerCase() === "true") {
if (env.CRON_ENABLED) {
logger.info(`Cron job enabled. Scheduling scans at '${env.CRON_TIME}'`);
new CronJob(env.CRON_TIME, () => {
scan().catch((error) => {
Expand All @@ -18,10 +18,4 @@ if (env.CRON_ENABLED.toLowerCase() === "true") {
}).start();
}

scan()
.catch((error) => {
logger.error("Initial scan failed:", error);
})
.finally(() => {
process.exit(0);
});
scan().then(() => logger.info("Done init scanning."));

0 comments on commit 221228f

Please sign in to comment.