Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop pruning secrets on function deploys/secret updates. #4519

Merged
merged 4 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Add support for secrets to v2 functions (#4451).
- Fixes an issue where `ext:export` would write different param values than what it displayed in the prompt (#4515).
- Enhances the functions IAM permission process and updates the error messages (#4511).
- Removes logic for automatically pruning stale secrets after function deploys (#4519).
22 changes: 1 addition & 21 deletions src/commands/functions-secrets-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,5 @@ export default new Command("functions:secrets:set <KEY>")
logBullet(`Updated function ${e.id}(${e.region}).`);
return updated;
});
const updatedEndpoints = await Promise.all(updateOps);

logBullet(`Pruning stale secrets...`);
const prunedResult = await pruneAndDestroySecrets(
{ projectId, projectNumber },
updatedEndpoints
);
if (prunedResult.destroyed.length > 0) {
logBullet(
`Detroyed unused secret versions: ${prunedResult.destroyed
.map((s) => `${s.secret}@${s.version}`)
.join(", ")}`
);
}
if (prunedResult.erred.length > 0) {
logWarning(
`Failed to destroy unused secret versions:\n\t${prunedResult.erred
.map((err) => err.message)
.join("\n\t")}`
);
}
await Promise.all(updateOps);
});
30 changes: 0 additions & 30 deletions src/deploy/functions/release/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,36 +101,6 @@ export async function release(
if (allErrors.length) {
const opts = allErrors.length === 1 ? { original: allErrors[0] } : { children: allErrors };
throw new FirebaseError("There was an error deploying functions", { ...opts, exit: 2 });
} else {
if (secrets.of(haveEndpoints).length > 0) {
const projectId = needProjectId(options);
const projectNumber = await needProjectNumber(options);
// Re-load backend with all endpoints, not just the ones deployed.
const reloadedBackend = await backend.existingBackend(
{ projectId } as args.Context,
/* forceRefresh= */ true
);
const prunedResult = await secrets.pruneAndDestroySecrets(
{ projectId, projectNumber },
backend.allEndpoints(reloadedBackend)
);
if (prunedResult.destroyed.length > 0) {
logLabeledBullet(
"functions",
`Destroyed unused secret versions: ${prunedResult.destroyed
.map((s) => `${s.secret}@${s.version}`)
.join(", ")}`
);
}
if (prunedResult.erred.length > 0) {
logLabeledWarning(
"functions",
`Failed to destroy unused secret versions:\n\t${prunedResult.erred
.map((err) => err.message)
.join("\n\t")}`
);
}
}
}
}

Expand Down