Skip to content

Commit 040ee07

Browse files
committed
feat: Standardize KMS context key to 'env'
This commit standardizes the KMS encryption context to use the key 'env' instead of 'environment' for consistency. The following changes have been made: - Modified to use 'env' in the encryption context for the and commands. - Modified to use 'env' in the encryption context for the function. - Updated to reflect the changes in the encryption context. - Added verbose logging to the command in .
1 parent a681329 commit 040ee07

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/envars/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def add_env_var(
295295
"app": manager.app or "",
296296
}
297297
if env:
298-
encryption_context["environment"] = env
298+
encryption_context["env"] = env
299299
if loc:
300300
encryption_context["location"] = loc
301301

@@ -647,7 +647,7 @@ def rotate_kms_key(
647647
"app": new_manager.app or "",
648648
}
649649
if vv.environment_name:
650-
encryption_context["environment"] = vv.environment_name
650+
encryption_context["env"] = vv.environment_name
651651
if vv.location_id:
652652
loc_name = next(
653653
(l.name for l in new_manager.locations.values() if l.location_id == vv.location_id), None

src/envars/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def _get_decrypted_value(manager: VariableManager, vv: VariableValue):
293293
# Get encryption context from the variable's scope
294294
encryption_context = {"app": manager.app or ""}
295295
if vv.environment_name:
296-
encryption_context["environment"] = vv.environment_name
296+
encryption_context["env"] = vv.environment_name
297297
if vv.location_id:
298298
loc_name = next((l.name for l in manager.locations.values() if l.location_id == vv.location_id), None)
299299
if loc_name:

tests/test_cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_add_secret_variable(tmp_path):
150150
{
151151
"KeyId": "arn:aws:kms:us-east-1:123456789012:key/mrk-12345",
152152
"Plaintext": b"super_secret_value",
153-
"EncryptionContext": {"app": "MyApp", "environment": "dev", "location": "my_loc"},
153+
"EncryptionContext": {"app": "MyApp", "env": "dev", "location": "my_loc"},
154154
},
155155
)
156156
with patch("boto3.client", return_value=kms_client):
@@ -250,7 +250,7 @@ def test_print_decrypt_secret(tmp_path):
250250
{"Plaintext": b"decrypted_value"},
251251
{
252252
"CiphertextBlob": b"some_encrypted_bytes",
253-
"EncryptionContext": {"app": "MyApp", "environment": "dev", "location": "my_loc"},
253+
"EncryptionContext": {"app": "MyApp", "env": "dev", "location": "my_loc"},
254254
},
255255
)
256256
with patch("boto3.client", return_value=kms_client):
@@ -527,7 +527,7 @@ def test_output_yaml_command(tmp_path):
527527
{"Plaintext": b"decrypted_value"},
528528
{
529529
"CiphertextBlob": b"some_encrypted_bytes",
530-
"EncryptionContext": {"app": "MyApp", "environment": "dev", "location": "my_loc"},
530+
"EncryptionContext": {"app": "MyApp", "env": "dev", "location": "my_loc"},
531531
},
532532
)
533533
with patch("boto3.client", return_value=kms_client):

0 commit comments

Comments
 (0)