This repository has been archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate valid ECR URL in refreshECRToken() by calling isECRregistry()
- Loading branch information
Lucas Rodriguez
committed
Dec 8, 2023
1 parent
a37e285
commit 7413693
Showing
5 changed files
with
58 additions
and
47 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,34 @@ | ||
import { getZarfRegistryURL } from "./zarf"; | ||
import { isPrivateECRURL } from "./utils"; | ||
import { isPublicECRURL } from "./utils"; | ||
|
||
/** | ||
* Represents the result of checking whether the Zarf registry is an ECR registry. | ||
*/ | ||
interface ECRCheckResult { | ||
isECR: boolean; // Indicates if the registry is an ECR registry. | ||
registryURL: string; // The URL of the ECR registry. | ||
} | ||
|
||
/** | ||
* Check whether the configured Zarf registry is an ECR registry. | ||
* @returns {Promise<ECRCheckResult>} The result of the ECR registry check. | ||
* @throws {Error} If an error occurs while fetching or parsing the Zarf state secret. | ||
*/ | ||
export async function isECRregistry(): Promise<ECRCheckResult> { | ||
try { | ||
const registryURL = await getZarfRegistryURL(); | ||
|
||
if (isPrivateECRURL(registryURL) || isPublicECRURL(registryURL)) { | ||
return { isECR: true, registryURL }; | ||
} | ||
} catch (err) { | ||
throw new Error( | ||
`unable to determine if Zarf is configured to use an ECR registry: ${JSON.stringify( | ||
err, | ||
)}`, | ||
); | ||
} | ||
|
||
return { isECR: false, registryURL: "" }; | ||
} |
18 changes: 9 additions & 9 deletions
18
manifests/pepr-module-b95dbd80-e078-5eb9-aaf3-bcb9567417d0.yaml
Large diffs are not rendered by default.
Oops, something went wrong.