Module: Dockly

Defined in:
lib/dockly.rb,
lib/dockly/version.rb,
lib/dockly/s3_writer.rb,
lib/dockly/bash_builder.rb

Defined Under Namespace

Modules: BuildCache, History, RakeHelper Classes: AbstractCommand, BashBuilder, BuildCacheCommand, BuildDebCommand, BuildOrCopyAllCommand, BuildRpmCommand, Cli, Deb, Docker, DockerCommand, Foreman, ListCommand, Rpm, S3Writer, TarDiff

Constant Summary collapse

LOAD_FILE =
'dockly.rb'
MAJOR =
4
MINOR =
3
PATCH =
0
RELEASE =
nil
VERSION =
[MAJOR, MINOR, PATCH, RELEASE].compact.join('.')

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.load_fileObject



32
33
34
# File 'lib/dockly.rb', line 32

def load_file
  @load_file || LOAD_FILE
end

Class Method Details

.assume_role(role_name = nil) ⇒ Object



61
62
63
64
# File 'lib/dockly.rb', line 61

def assume_role(role_name = nil)
  @assume_role = role_name if role_name
  @assume_role
end

.aws_region(region = nil) ⇒ Object



77
78
79
80
# File 'lib/dockly.rb', line 77

def aws_region(region = nil)
  @aws_region = region unless region.nil?
  @aws_region || 'us-east-1'
end

.git_shaObject



57
58
59
# File 'lib/dockly.rb', line 57

def git_sha
  @git_sha ||= Dockly::Util::Git.sha
end

.instanceObject



36
37
38
# File 'lib/dockly.rb', line 36

def instance
  @instance ||= load_inst
end

.load_instObject



40
41
42
43
44
45
46
# File 'lib/dockly.rb', line 40

def load_inst
  setup.tap do |state|
    if File.exists?(load_file)
      instance_eval(IO.read(load_file), load_file)
    end
  end
end

.perform_role_assumptionObject



66
67
68
69
70
71
72
73
74
75
# File 'lib/dockly.rb', line 66

def perform_role_assumption
  return if assume_role.nil?
  Aws.config.update(
    credentials: Aws::AssumeRoleCredentials.new(
      role_arn: assume_role, role_session_name: 'dockly',
      client: Aws::STS::Client.new(region: aws_region)
    ),
    region: aws_region
  )
end

.s3Object



82
83
84
# File 'lib/dockly.rb', line 82

def s3
  @s3 ||= Aws::S3::Client.new(region: aws_region)
end

.setupObject



48
49
50
51
52
53
54
55
# File 'lib/dockly.rb', line 48

def setup
  {
    :debs => Dockly::Deb.instances,
    :rpms => Dockly::Rpm.instances,
    :dockers => Dockly::Docker.instances,
    :foremans => Dockly::Foreman.instances
  }
end