@@ -9,7 +9,7 @@ def requires_account?
99 LIST_COMMAND = "secret list"
1010 GET_COMMAND = "secret get"
1111
12- def fetch_secrets ( secrets , from :, account :, session : )
12+ def fetch_secrets ( secrets , from :, server_url :, ** )
1313 raise RuntimeError , "You must specify what to retrieve from Bitwarden Secrets Manager" if secrets . length == 0
1414
1515 secrets = prefixed_secrets ( secrets , from : from )
@@ -18,13 +18,13 @@ def fetch_secrets(secrets, from:, account:, session:)
1818 { } . tap do |results |
1919 if command . nil?
2020 secrets . each do |secret_uuid |
21- item_json = run_command ( "#{ GET_COMMAND } #{ secret_uuid . shellescape } " )
21+ item_json = run_command ( "#{ GET_COMMAND } #{ secret_uuid . shellescape } " , server_url : server_url )
2222 raise RuntimeError , "Could not read #{ secret_uuid } from Bitwarden Secrets Manager" unless $?. success?
2323 item_json = JSON . parse ( item_json )
2424 results [ item_json [ "key" ] ] = item_json [ "value" ]
2525 end
2626 else
27- items_json = run_command ( command )
27+ items_json = run_command ( command , server_url : server_url )
2828 raise RuntimeError , "Could not read secrets from Bitwarden Secrets Manager" unless $?. success?
2929
3030 JSON . parse ( items_json ) . each do |item_json |
@@ -45,13 +45,14 @@ def extract_command_and_project(secrets)
4545 end
4646 end
4747
48- def run_command ( command , session : nil )
49- full_command = [ "bws" , command ] . join ( " " )
50- `#{ full_command } `
48+ def run_command ( command , server_url : nil )
49+ full_command = [ "bws" , command ]
50+ full_command << "--server-url=#{ server_url } " if server_url
51+ `#{ full_command . join ( " " ) } `
5152 end
5253
53- def login ( account )
54- run_command ( "project list" )
54+ def login ( _account , server_url : nil )
55+ run_command ( "project list" , server_url : server_url )
5556 raise RuntimeError , "Could not authenticate to Bitwarden Secrets Manager. Did you set a valid access token?" unless $?. success?
5657 end
5758
0 commit comments