class Hako::Scripts::CodebuildTag
Constants
- TARGET_TAG
Public Instance Methods
codebuild()
click to toggle source
# File lib/hako/scripts/codebuild_tag.rb, line 26 def codebuild @codebuild ||= begin options = {} options[:region] = @region if @region Aws::CodeBuild::Client.new(options) end end
configure(options)
click to toggle source
Calls superclass method
# File lib/hako/scripts/codebuild_tag.rb, line 11 def configure(options) super @region = options['region'] @project_name = options.fetch('project', @app.id) end
deploy_starting(containers)
click to toggle source
# File lib/hako/scripts/codebuild_tag.rb, line 17 def deploy_starting(containers) app = containers.fetch('app') if app.definition['tag'] == TARGET_TAG rewrite_tag(app) end end
Also aliased as: oneshot_starting
Private Instance Methods
fetch_version()
click to toggle source
# File lib/hako/scripts/codebuild_tag.rb, line 42 def fetch_version codebuild.list_builds_for_project(project_name: @project_name, sort_order: 'DESCENDING').each do |page| builds = codebuild.batch_get_builds(ids: page.ids).builds.map do |build| [build.id, build] end.to_h page.ids.each do |id| build = builds.fetch(id) next unless build.build_status == 'SUCCEEDED' return build.source_version end end raise NoSuccessfulBuildError end
rewrite_tag(app)
click to toggle source
# File lib/hako/scripts/codebuild_tag.rb, line 36 def rewrite_tag(app) tag = fetch_version app.definition['tag'] = tag Hako.logger.info("Rewrite tag to #{app.image_tag}") end