Skip to content

Commit

Permalink
feat(auth): Allow command on user, password config attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
lperdereau committed Dec 17, 2024
1 parent 11e9be0 commit 521d812
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/pvecontrol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,21 @@ def _parser():

return parser.parse_args()


def _execute_command(cmd):
return subprocess.run(cmd, shell=True, check=True, capture_output=True).stdout.rstrip()
return subprocess.run(cmd, shell=True, check=True, capture_output=True).stdout.rstrip()


def run_auth_commands(clusterconfig):
regex = r"^\$\((.*)\)$"
result = re.match(regex, clusterconfig.user)
if result:
clusterconfig.user = _execute_command(result.group(1))

result = re.match(regex, clusterconfig.password)
if result:
clusterconfig.password = _execute_command(result.group(1))
regex = r"^\$\((.*)\)$"
result = re.match(regex, clusterconfig.user)
if result:
clusterconfig.user = _execute_command(result.group(1))

result = re.match(regex, clusterconfig.password)
if result:
clusterconfig.password = _execute_command(result.group(1))


def main():
# Disable urllib3 warnings about invalid certs
Expand Down

0 comments on commit 521d812

Please sign in to comment.