generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a mechanism to fail the CD when required environment variables…
… are missing | issue#257 - 2 (#285) * issue#257 | Madge changes to fail CD when required env are missing * use loadEnv method in register.ts * rename to env in register.ts * renamed env in inedx.ts * renamed variables * removed unnecessary comments * removed redundant comments * fixed code format * format fix
- Loading branch information
1 parent
bd4d987
commit 36e04eb
Showing
7 changed files
with
131 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { env } from "../src/typeDefinitions/default.types"; | ||
import { loadEnv } from "./config"; | ||
|
||
/** | ||
* Validate if all the required environment variables are set to a non empty value | ||
* else throw an error | ||
* --- | ||
*/ | ||
export function validateEnv() { | ||
const env: env = loadEnv({}, false); | ||
const missingEnvVariables = Object.keys(env).filter((key) => env[key] == ""); | ||
|
||
if (missingEnvVariables.length > 0) { | ||
throw new Error( | ||
`Missing environment variables: ${missingEnvVariables.join(", ")}` | ||
); | ||
} else { | ||
console.log("All required environment variables are set."); | ||
} | ||
} | ||
|
||
validateEnv(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters