Allow registry username to be a reference to secret

This commit is contained in:
Rasmus
2023-03-07 09:49:08 +01:00
parent 8c69990dbb
commit f531874be4
2 changed files with 15 additions and 9 deletions

View File

@@ -2,7 +2,7 @@ class Mrsk::Commands::Registry < Mrsk::Commands::Base
delegate :registry, to: :config
def login
docker :login, registry["server"], "-u", redact(registry["username"]), "-p", redact(lookup_password)
docker :login, registry["server"], "-u", redact_credentials("username"), "-p", redact_credentials("password")
end
def logout
@@ -10,11 +10,13 @@ class Mrsk::Commands::Registry < Mrsk::Commands::Base
end
private
def lookup_password
if registry["password"].is_a?(Array)
ENV.fetch(registry["password"].first).dup
else
registry["password"]
end
def redact_credentials(key)
value = if registry[key].is_a?(Array)
ENV.fetch(registry[key].first).dup
else
registry[key]
end
redact(value)
end
end