Skip to content

Commit

Permalink
Merge pull request #58 from nutanix/bug/calm-18558-fix-dsl-for-http-s…
Browse files Browse the repository at this point in the history
…ecrets-upload

Fix the secrets stripping for HTTP endpoints upload
  • Loading branch information
Kritagya Dabi authored May 12, 2020
2 parents 11841d5 + 9b62dce commit f325311
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions calm/dsl/api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def strip_secrets(resources, secret_map, secret_variables, object_lists=[], obje
"name": default_creds[0]["name"] if default_creds else cred[0]["name"],
}

# Remove creds from HTTP endpoints resources
auth = resources.get("authentication", {}) or {}
if auth.get("type", None) == "basic":
name = auth["username"]
secret_map[name] = auth.pop("password", {})
auth["password"] = {'attrs': {'is_secret_modified': False, 'value': None}}

# Strip secret variable values
# TODO: Refactor and/or clean this up later

Expand Down Expand Up @@ -182,6 +189,12 @@ def patch_secrets(resources, secret_map, secret_variables):
name = cred["name"]
cred["secret"] = secret_map[name]

# Add creds back for HTTP endpoint
auth = resources.get("authentication", {})
username = auth.get("username")
if username:
auth["password"] = secret_map[username]

for path, secret in secret_variables:
variable = resources
for sub_path in path:
Expand Down

0 comments on commit f325311

Please sign in to comment.