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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fixed an issue in the extensions emulator where parameter default values would not be substitued into resource definitions.
- Keep artifact registry dry run off for policy changes #8419
1 change: 1 addition & 0 deletions src/functions/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
const SECONDS_IN_DAY = 24 * 60 * 60;

/**
* Construct the full path to a repository in Artifact Registry

Check warning on line 29 in src/functions/artifacts.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @returns The full path to the repository

Check warning on line 31 in src/functions/artifacts.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid JSDoc tag (preference). Replace "returns" JSDoc tag with "return"
*/
export function makeRepoPath(
projectId: string,
Expand All @@ -55,7 +55,7 @@
): Promise<artifactregistry.Repository> {
const repoPath = makeRepoPath(projectId, location, repoName);
if (!forceRefresh && getRepoCache.has(repoPath)) {
return getRepoCache.get(repoPath)!;

Check warning on line 58 in src/functions/artifacts.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Forbidden non-null assertion
}
const repo = await artifactregistry.getRepository(repoPath);
getRepoCache.set(repoPath, repo);
Expand All @@ -63,9 +63,9 @@
}

/**
* Extract an existing cleanup policy from the repository if it exists

Check warning on line 66 in src/functions/artifacts.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @returns The existing policy if found, undefined otherwise

Check warning on line 68 in src/functions/artifacts.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid JSDoc tag (preference). Replace "returns" JSDoc tag with "return"
*/
export function findExistingPolicy(
repository: artifactregistry.Repository,
Expand All @@ -74,9 +74,9 @@
}

/**
* Convert days to seconds for olderThan property in cleanup policy.

Check warning on line 77 in src/functions/artifacts.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @returns String representation of seconds with 's' suffix (e.g., "432000s")

Check warning on line 79 in src/functions/artifacts.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid JSDoc tag (preference). Replace "returns" JSDoc tag with "return"
*/
export function daysToSeconds(days: number): string {
const seconds = days * SECONDS_IN_DAY;
Expand All @@ -84,13 +84,13 @@
}

/**
* Extract the number of days from a policy's olderThan string

Check warning on line 87 in src/functions/artifacts.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @example "432000s" -> 5 (5 days in seconds)
* @returns The number of days, or undefined if format is invalid

Check warning on line 90 in src/functions/artifacts.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid JSDoc tag (preference). Replace "returns" JSDoc tag with "return"
*/
export function parseDaysFromPolicy(olderThan: string): number | undefined {
const match = olderThan.match(/^(\d+)s$/);

Check warning on line 93 in src/functions/artifacts.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Use the `RegExp#exec()` method instead
if (match && match[1]) {
const seconds = parseInt(match[1], 10);
return Math.floor(seconds / SECONDS_IN_DAY);
Expand Down Expand Up @@ -173,6 +173,7 @@
...repository.cleanupPolicies,
...generateCleanupPolicy(daysToKeep),
},
cleanupPolicyDryRun: false,
labels,
};
await exports.updateRepository(update);
Expand Down
3 changes: 2 additions & 1 deletion src/gcp/artifactregistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface Repository {
createTime: string;
updateTime: string;
cleanupPolicies?: Record<string, CleanupPolicy | undefined>;
cleanupPolicyDryRun?: boolean;
labels?: Record<string, string>;
}

Expand Down Expand Up @@ -84,7 +85,7 @@ export async function getRepository(repoPath: string): Promise<Repository> {
* Update an Artifact Registry repository.
*/
export async function updateRepository(repo: RepositoryInput): Promise<Repository> {
const updateMask = proto.fieldMasks(repo, "cleanupPolicies", "labels");
const updateMask = proto.fieldMasks(repo, "cleanupPolicies", "cleanupPolicyDryRun", "labels");
if (updateMask.length === 0) {
const res = await client.get<Repository>(repo.name!);
return res.body;
Expand Down
Loading