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, BuildCommand, Cli, Deb, Docker, DockerCommand, Foreman, ListCommand, Rpm, S3Writer, TarDiff

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#instance ⇒ Object (readonly)

Returns the value of attribute instance.



13
14
15
# File 'lib/dockly.rb', line 13

def instance
  @instance
end

#load_file=(value) ⇒ Object (writeonly)

Sets the attribute load_file

Parameters:

  • value —

    the value to set the attribute load_file to.



14
15
16
# File 'lib/dockly.rb', line 14

def load_file=(value)
  @load_file = value
end

Class Method Details

.assume_role(role_name = nil) ⇒ Object



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

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

.aws_region(region = nil) ⇒ Object



74
75
76
77
# File 'lib/dockly.rb', line 74

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

.git_sha ⇒ Object



54
55
56
# File 'lib/dockly.rb', line 54

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

.inst ⇒ Object



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

def inst
  @instance ||= load_inst
end

.load_file ⇒ Object



29
30
31
# File 'lib/dockly.rb', line 29

def load_file
  @load_file || LOAD_FILE
end

.load_inst ⇒ Object



37
38
39
40
41
42
43
# File 'lib/dockly.rb', line 37

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_assumption ⇒ Object



63
64
65
66
67
68
69
70
71
72
# File 'lib/dockly.rb', line 63

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

.s3 ⇒ Object



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

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

.setup ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/dockly.rb', line 45

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