class Centurion::Dogestry
Attributes
options[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/centurion/dogestry.rb, line 11 def initialize(options = {}) @options = options end
Public Instance Methods
aws_access_key_id()
click to toggle source
# File lib/centurion/dogestry.rb, line 36 def aws_access_key_id @options[:aws_access_key_id] end
aws_secret_key()
click to toggle source
# File lib/centurion/dogestry.rb, line 40 def aws_secret_key @options[:aws_secret_key] end
exec_command(command, repo, flags="")
click to toggle source
# File lib/centurion/dogestry.rb, line 77 def exec_command(command, repo, flags="") command = "dogestry #{flags} #{command} #{s3_url} #{repo}" info "Executing: #{command}" command end
pull(repo, pull_hosts)
click to toggle source
# File lib/centurion/dogestry.rb, line 83 def pull(repo, pull_hosts) validate_before_exec set_envs() hosts = pull_hosts.join(",") flags = "-pullhosts #{hosts}" Centurion::Shell.echo(exec_command('pull', repo, flags)) end
s3_bucket()
click to toggle source
# File lib/centurion/dogestry.rb, line 44 def s3_bucket @options[:s3_bucket] end
s3_region()
click to toggle source
# File lib/centurion/dogestry.rb, line 48 def s3_region @options[:s3_region] || 'us-east-1' end
s3_url()
click to toggle source
# File lib/centurion/dogestry.rb, line 52 def s3_url "s3://#{s3_bucket}/?region=#{s3_region}" end
set_envs()
click to toggle source
# File lib/centurion/dogestry.rb, line 56 def set_envs() ENV['AWS_ACCESS_KEY'] = aws_access_key_id ENV['AWS_SECRET_KEY'] = aws_secret_key # If we want TLS, then try to pass a sane directory to Dogestry, which doesn't # speak individual filenames. if @options[:tlsverify] ENV['DOCKER_CERT_PATH'] = if @options[:tlscacert] || @options[:tlscert] File.dirname( @options[:tlscacert] || @options[:tlscert] ) else @options[:original_docker_cert_path] end end info "Dogestry ENV: #{ENV.inspect}" end
validate_before_exec()
click to toggle source
# File lib/centurion/dogestry.rb, line 28 def validate_before_exec unless which('dogestry') message = 'Unable to find "dogestry" executable' error message raise message end end
which(cmd)
click to toggle source
Cross-platform way of finding an executable in the $PATH.
which('ruby') #=> /usr/bin/ruby
# File lib/centurion/dogestry.rb, line 17 def which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each do |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable?(exe) && !File.directory?(exe) end end return nil end