-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
latest_major
and lastest_minor
tag for docker init cont…
…ainer (#3643) * Implement latest_major and lastest_minor tag for docker init container tags * Update with latest_major condition and ensure gem presence * Use Ruby image * Abort when fail
- Loading branch information
Showing
3 changed files
with
104 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'bundler/inline' | ||
|
||
gemfile { gem 'gems', source: 'https://rubygems.org' } | ||
|
||
require 'rubygems' | ||
require 'gems' | ||
|
||
version = ARGV[0].chomp | ||
version = version.delete_prefix('v') if version.start_with?('v') | ||
|
||
candidate = Gem::Version.new(version) | ||
|
||
retry_count = 0 | ||
max_retries = 60 | ||
interval = 60 | ||
|
||
loop do | ||
versions = Gems.versions('datadog').map { |h| Gem::Version.new(h['number']) } | ||
|
||
if versions.include?(candidate) | ||
puts "Gem version #{candidate} found!" | ||
exit 0 | ||
else | ||
retry_count += 1 | ||
puts "Attempt(#{retry_count}): Gem 'datadog' version '#{candidate}' not found." | ||
|
||
if retry_count >= max_retries | ||
puts "Max retries(#{max_retries}) reached, stopping..." | ||
exit 1 | ||
else | ||
puts "Retrying in #{interval} seconds..." | ||
sleep interval | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'bundler/inline' | ||
|
||
gemfile { gem 'gems', source: 'https://rubygems.org' } | ||
|
||
require 'rubygems' | ||
require 'gems' | ||
|
||
image_name = ARGV[0].chomp | ||
version = ARGV[1].chomp | ||
version = version.delete_prefix('v') if version.start_with?('v') | ||
|
||
candidate = Gem::Version.new(version) | ||
versions = Gems.versions('datadog').map { |h| Gem::Version.new(h['number']) } | ||
|
||
# Make sure candidate has already been published to 'https://rubygems.org' | ||
unless versions.include?(candidate) | ||
warn "Version #{candidate} not found in RubyGems" | ||
exit 1 | ||
end | ||
|
||
# Skip pre-releases | ||
if candidate.prerelease? | ||
warn 'No tags for pre-releases' | ||
exit 1 | ||
end | ||
|
||
major, minor, = candidate.to_s.split('.') | ||
current_major_versions = versions.select { |v| v.to_s.start_with?("#{major}.") } | ||
|
||
tags = [] | ||
|
||
tags << 'latest' if versions.all? { |v| candidate >= v } | ||
tags << "v#{major}" if current_major_versions.all? { |v| candidate >= v } | ||
tags << "v#{major}.#{minor}" | ||
tags << "v#{candidate}" | ||
|
||
# $stdout.puts "tags: #{tags}" # Uncomment for debugging | ||
|
||
destinations = tags.map { |tag| "#{image_name}:#{tag}" } | ||
$stdout.puts destinations.join(',') |