class Bcnd::QuayIo
Attributes
conn[RW]
Public Class Methods
new(token)
click to toggle source
# File lib/bcnd/quay_io.rb, line 47 def initialize(token) @conn = Connection.new(token) end
Public Instance Methods
automated_build_status(repo:, git_sha:)
click to toggle source
# File lib/bcnd/quay_io.rb, line 58 def automated_build_status(repo:, git_sha:) builds = automated_builds_for(repo: repo, git_sha: git_sha) phases = builds.map { |b| b["phase"] } if !phases.include?("complete") && phases.include?("error") return :failed end if phases.include?("complete") return :finished else return :building end end
automated_builds_for(repo:, git_sha:)
click to toggle source
# File lib/bcnd/quay_io.rb, line 51 def automated_builds_for(repo:, git_sha:) builds = conn.get(path: "/repository/#{repo}/build/?limit=20")["builds"] builds.select do |b| b["trigger_metadata"]["commit"] == git_sha.downcase end end
docker_image_id_for_tag(repo:, tag:)
click to toggle source
# File lib/bcnd/quay_io.rb, line 90 def docker_image_id_for_tag(repo:, tag:) resp = conn.get( path: "/repository/#{repo}/tag/", query_params: { "specificTag" => tag } ) tag = resp["tags"].find { |tag| tag["end_ts"].nil? } tag.nil? ? nil : tag["docker_image_id"] end
put_tag(repo:, image_id:, tag:)
click to toggle source
# File lib/bcnd/quay_io.rb, line 101 def put_tag(repo:, image_id:, tag:) return if ENV["DRY_RUN"] conn.put( path: "/repository/#{repo}/tag/#{tag}", body: { image: image_id } ) end
wait_for_automated_build(repo:, git_sha:, timeout: 3600)
click to toggle source
# File lib/bcnd/quay_io.rb, line 73 def wait_for_automated_build(repo:, git_sha:, timeout: 3600) loop do status = automated_build_status(repo: repo, git_sha: git_sha) case status when :failed raise "The docker build failed" when :finished puts "" return when :building print '.' $stdout.flush sleep 5 end end end