We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I’ve been looking at the setGCPSecret function, and I think we could make it more robust by enhancing its error handling and logging.
Wrap the main logic of the function in a try-catch block to catch any errors that occur during the execution of asynchronous operations.
Implement more detailed logging within the catch block to capture and record error details. This will make debugging much easier.
export async function setGCPSecret( secretName: string, secret: string, labels: Record<string, string>, ) { const fileName = `/tmp/${secretName}.txt`; try { await writeFile(fileName, secret); const exists = await gcpSecretExists(secretName); if (!exists) { const labelString = Object.keys(labels) .map((key) => `${key}=${labels[key]}`) .join(','); await execCmd( `gcloud secrets create ${secretName} --data-file=${fileName} --replication-policy=automatic --labels=${labelString}`, ); debugLog(`Created new GCP secret for ${secretName}`); } else { await execCmd( `gcloud secrets versions add ${secretName} --data-file=${fileName}`, ); debugLog(`Added new version to existing GCP secret for ${secretName}`); } } catch (error) { console.error(`Error setting GCP secret '${secretName}':`, error); throw error; // Re-throw after logging } finally { try { await rm(fileName); } catch (cleanupError) { console.warn(`Issue when trying to remove temporary file '${fileName}':`, cleanupError); } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I’ve been looking at the setGCPSecret function, and I think we could make it more robust by enhancing its error handling and logging.
Proposed Changes
Add Try-Catch Blocks:
Wrap the main logic of the function in a try-catch block to catch any errors that occur during the execution of asynchronous operations.
Enhance Logging:
Implement more detailed logging within the catch block to capture and record error details. This will make debugging much easier.
Example Update
The text was updated successfully, but these errors were encountered: