Skip to content

Commit

Permalink
login before build and push
Browse files Browse the repository at this point in the history
  • Loading branch information
jwaldrip committed Jun 27, 2019
1 parent b05fff4 commit 66f2ee0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion shard.yml
@@ -1,5 +1,5 @@
name: psykube
version: 2.14.0
version: 2.15.0
crystal: 0.26.0

authors:
Expand Down
15 changes: 11 additions & 4 deletions src/cli/commands/concerns/docker.cr
Expand Up @@ -20,11 +20,20 @@ module Psykube::CLI::Commands::Docker
docker_push(*args)
end

def docker_login(build_context : BuildContext)
if flags.login && (login = build_context.login)
password = IO::Memory.new.tap(&.puts login.password).tap(&.rewind)
docker_run ["login", login.server, "-u=#{login.username}", "--password-stdin"], input: password
end
end

def docker_build(build_contexts : Array(BuildContext), tag : String? = nil)
build_contexts.each { |c| docker_build c, tag }
end

def docker_build(build_context : BuildContext, tag : String? = nil)
docker_login(build_context)

build_context.cache_from.each do |c|
docker_run ["pull", c], allow_failure: true
end
Expand Down Expand Up @@ -62,11 +71,9 @@ module Psykube::CLI::Commands::Docker
end

def docker_push(build_context : BuildContext, tag : String? = nil)
docker_login(build_context)

image = tag && tag.includes?(":") ? tag : build_context.image(tag)
if flags.login && (login = build_context.login)
password = IO::Memory.new.tap(&.puts login.password).tap(&.rewind)
docker_run ["login", login.server, "-u=#{login.username}", "--password-stdin"], input: password
end
build_context.build_tags.each do |build_tag|
docker_run ["push", build_tag]
end
Expand Down

0 comments on commit 66f2ee0

Please sign in to comment.