Registry login from config credentials

This commit is contained in:
David Heinemeier Hansson
2023-01-07 21:31:13 +01:00
parent 8fa53a0f95
commit 705cd1033e
2 changed files with 13 additions and 14 deletions

View File

@@ -1,10 +1,13 @@
class Mrsk::Commands::Registry < Mrsk::Commands::Base
def login
if (user = ENV["DOCKER_USER"]).present? && (password = ENV["DOCKER_PASSWORD"]).present?
# FIXME: Find a way to hide PW so it's not shown on terminal
"docker login -u #{user} -p #{password}"
else
raise ArgumentError, "Missing DOCKER_USER or DOCKER_PASSWORD in ENV"
end
ensure_credentials_present
"docker login #{config.registry["server"]} -u #{config.registry["username"]} -p #{config.registry["password"]}"
end
private
def ensure_credentials_present
unless config.registry && config.registry["username"].present? && config.registry["password"].present?
raise ArgumentError, "You must configure registry/username and registry/password"
end
end
end