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

Return 0.3 behavior. Fixes #49 #52

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,8 @@ venv.bak/
.idea/

# mac
.DS_Store
.DS_Store

pyvenv.cfg
bin
man
15 changes: 12 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
ruamel.yaml
hvac
GitPython
certifi==2021.10.8
charset-normalizer==2.0.12
gitdb==4.0.9
GitPython==3.1.27
hvac==0.11.2
idna==3.3
requests==2.27.1
ruamel.yaml==0.17.21
ruamel.yaml.clib==0.2.6
six==1.16.0
smmap==5.0.0
urllib3==1.26.9
17 changes: 8 additions & 9 deletions src/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,21 @@ def vault_read(self, value, path, key, full_path=None):
if self.args.verbose is True:
print(f"Using KV Version: {self.kvversion}")
print(f"Attempting to write to url: {self.envs.vault_addr}/v1/{mount_point}/data{_path}")

if self.kvversion == "v1":
value = self.client.read(_path)
value = value.get("data", {}).get("value")
elif self.kvversion == "v2":
value = self.client.secrets.kv.v2.read_secret_version(path=_path,mount_point=mount_point)
value = value.get("data", {}).get("data", {}).get("value")
if self.kvversion in ['v1', 'v2']:
if self.kvversion == "v1":
value = self.client.read(_path)
value = value.get("data", {}).get("value")
else:
value = self.client.secrets.kv.v2.read_secret_version(path=_path,mount_point=mount_point)
value = value.get("data", {}).get("data", {}).get("value")
return value
else:
print("Wrong KV Version specified, either v1 or v2")
except AttributeError as ex:
print(f"Vault not configured correctly, check VAULT_ADDR and VAULT_TOKEN env variables. {ex}")
except Exception as ex:
print(f"Error: {ex}")

return value

def load_yaml(yaml_file):
# Load the YAML file
yaml = ruamel.yaml.YAML()
Expand Down