Add way to unlock BitWarden on the CLI

Added a helper function to BitWarden to unlock the CLI
Updated cfetch to fetch that information
This commit is contained in:
Greg Hellings
2024-06-12 14:27:50 -05:00
committed by greg-compass
parent d022f16470
commit f6daf93553
2 changed files with 18 additions and 1 deletions
-1
View File
@@ -42,7 +42,6 @@
cci = "compass workspace run src/python3/uc/tools:circleci-checks";
ccover = "compass workspace cover --extra-cmd-args=\"--test_output=errors\"";
cexec = "compass workspace exec";
cfetch = "compass workspace exec bazel run src/go/compass.com/tools/circleci_results_cache/fetch/cmd/fetch:fetch";
cgh = "$GH_CONFIG_DIR=\"${config.home.homeDirectory}/.config/gh/compass\" gh";
cpip = "compass workspace run src/python3/uc/tools:run_pip_compile";
crun = "compass workspace run";
+18
View File
@@ -1,5 +1,22 @@
# vim: set ft=python :
def bw_unlock():
if "BW_SESSION" in ${...}:
return $BW_SESSION
result = !(bw unlock)
while not result:
result = !(bw unlock)
l = [k for k in result.lines if 'BW_SESSION="' in k][0]
left, right = l.split("=")
token = right[1:-1]
$BW_SESSION = token
return token
def _cfetch(args):
bw_unlock()
$CIRCLECI_CLI_TOKEN=$(bw get password CircleCI)
compass workspace exec bazel run src/go/compass.com/tools/circleci_results_cache/fetch/cmd/fetch:fetch
def _rebuild(args):
system = uname()
if system.sysname == 'Darwin':
@@ -48,6 +65,7 @@ def _bake(args):
git clone src:greg/copier-templates.git ~/.copier-templates
copier copy @(str(templates / args[0])) .
aliases['cfetch'] = _cfetch
aliases['bake'] = _bake
aliases['rebuild'] = _rebuild
aliases['yaml2json'] = _yaml2json