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

Fix secret environment variables being updated with empty string #1618

Merged
merged 2 commits into from Apr 16, 2024

Conversation

vandyliu
Copy link
Contributor

@vandyliu vandyliu commented Apr 10, 2024

Description

Fix secret environment variables being updated. Nil values for existing secret env vars will no longer update the secret variables but keep them with the same value.

🎟 Issue(s)

#1593

🧪 Functional Testing

  • Added/updated unit tests

List the functional testing steps to confirm this feature or fix.

📸 Screenshots

Updated the secret variable via ./astro deployment update <deploymentId> --deployment-file deployment.yaml
Screenshot 2024-04-11 at 11 30 10 AM

Saw on airflow UI that the env var did not get set back to ""

Add screenshots to illustrate the validity of these changes.

📋 Checklist

  • Rebased from the main (or release if patching) branch (before testing)
  • Ran make test before taking out of draft
  • Ran make lint before taking out of draft
  • Added/updated applicable tests
  • Tested against Astro-API (if necessary).
  • Tested against Houston-API and Astronomer (if necessary).
  • Communicated to/tagged owners of respective clients potentially impacted by these changes.
  • Updated any related documentation

Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.56%. Comparing base (bf3ec8f) to head (5960ad1).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1618   +/-   ##
=======================================
  Coverage   86.56%   86.56%           
=======================================
  Files         114      114           
  Lines       16087    16087           
=======================================
  Hits        13925    13925           
  Misses       1297     1297           
  Partials      865      865           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

envVars = []astroplatformcore.DeploymentEnvironmentVariableRequest{}
for i := range deploymentFromFile.Deployment.EnvVars {
var envVar astroplatformcore.DeploymentEnvironmentVariableRequest
envVar.IsSecret = deploymentFromFile.Deployment.EnvVars[i].IsSecret
envVar.Key = deploymentFromFile.Deployment.EnvVars[i].Key
envVar.Value = &deploymentFromFile.Deployment.EnvVars[i].Value
// If the action is update, isSecret is true and value is empty, then the value should be left as nil
if !(action == updateAction && deploymentFromFile.Deployment.EnvVars[i].IsSecret && deploymentFromFile.Deployment.EnvVars[i].Value == "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean, i cannot add an empty string for a secret env var? Not an ideal use-case but thinking what if i wanted to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that would be a strange case
i don't see why you would want to have a secret variable as ""
anyways if that were the case, i made some updates to the code to allow nil values for no-ops and to allow "" to be updated

@vandyliu vandyliu merged commit 5cc493d into main Apr 16, 2024
4 of 5 checks passed
@vandyliu vandyliu deleted the env-var-secret-fix branch April 16, 2024 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants