Skip to content

Commit

Permalink
CASMTRIAGE 7272 debug
Browse files Browse the repository at this point in the history
  • Loading branch information
annapoorna-s-alt committed Sep 26, 2024
1 parent 6e706ee commit ab00779
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.2.2] - 2024-09-26

### Fixed
- CASMTRIAGE-7272 debug

## [2.2.1] - 2024-09-11

### Fixed
Expand Down
20 changes: 16 additions & 4 deletions csm_api_client/service/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,23 @@ def vcs_creds_helper() -> Generator[Dict[str, str], None, None]:
set to the path to the script for obtaining VCS credentials.
"""
# Get the password directly from k8s to avoid leaking it via the /proc filesystem
password_file_path = '/tmp/vcs_passwd'

try:
with NamedTemporaryFile(delete=False) as cred_helper_script:
cred_helper_script.write('#!/bin/bash\n'
'kubectl get secret -n services vcs-user-credentials '
'--template={{.data.vcs_password}} | base64 -d'.encode())
if os.path.exists(password_file_path):
# If the file exists, create a script that cats the file
with NamedTemporaryFile(delete=False) as cred_helper_script:
cred_helper_script.write((
'#!/bin/bash\n'
'cat {}\n'
'echo "{}"\n'.format(password_file_path, password_file_path).encode()
))
else:
# If the file doesn't exist, create a script to fetch from Kubernetes
with NamedTemporaryFile(delete=False) as cred_helper_script:
cred_helper_script.write('#!/bin/bash\n'
'kubectl get secret -n services vcs-user-credentials '
'--template={{.data.vcs_password}} | base64 -d'.encode())

os.chmod(cred_helper_script.name, 0o700) # Make executable by user
env = dict(os.environ)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "csm-api-client"
version = "2.2.1"
version = "2.2.2"
description = "Python client library for CSM APIs"
authors = [
"Ryan Haasken <[email protected]>",
Expand Down

0 comments on commit ab00779

Please sign in to comment.