Class: Drunker::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/drunker/config.rb

Defined Under Namespace

Classes: InvalidConfigException

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image:, commands:, config:, concurrency:, compute_type:, timeout:, env:, buildspec:, file_pattern:, aggregator:, access_key:, secret_key:, region:, profile_name:, debug:, logger:) ⇒ Config

Returns a new instance of Config.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/drunker/config.rb', line 15

def initialize(image:,
               commands:,
               config:,
               concurrency:,
               compute_type:,
               timeout:,
               env:,
               buildspec:,
               file_pattern:,
               aggregator:,
               access_key:,
               secret_key:,
               region:,
               profile_name:,
               debug:,
               logger:)
  @logger = logger
  yaml = load!(config)

  @image = image
  @commands = commands
  @concurrency = yaml["concurrency"] || concurrency
  @compute_type = compute_name[ yaml["compute_type"] || compute_type ]
  @timeout =  yaml["timeout"] || timeout
  @environment_variables = codebuild_environments_format(yaml["environment_variables"] || env)
  @buildspec = buildspec_body!(yaml["buildspec"] || buildspec)
  @file_pattern = yaml["file_pattern"] || file_pattern
  @aggregator = aggregator_gem!(yaml["aggregator"] || aggregator)
  @credentials = aws_credentials(profile_name: yaml.dig("aws_credentials", "profile_name") || profile_name,
                                 access_key: yaml.dig("aws_credentials", "access_key") || access_key,
                                 secret_key: yaml.dig("aws_credentials", "secret_key") || secret_key)
  @region = yaml.dig("aws_credentials", "region") || region
  @debug = debug

  validate!
end

Instance Attribute Details

#aggregatorObject (readonly)

Returns the value of attribute aggregator.



11
12
13
# File 'lib/drunker/config.rb', line 11

def aggregator
  @aggregator
end

#buildspecObject (readonly)

Returns the value of attribute buildspec.



9
10
11
# File 'lib/drunker/config.rb', line 9

def buildspec
  @buildspec
end

#commandsObject (readonly)

Returns the value of attribute commands.



4
5
6
# File 'lib/drunker/config.rb', line 4

def commands
  @commands
end

#compute_typeObject (readonly)

Returns the value of attribute compute_type.



6
7
8
# File 'lib/drunker/config.rb', line 6

def compute_type
  @compute_type
end

#concurrencyObject (readonly)

Returns the value of attribute concurrency.



5
6
7
# File 'lib/drunker/config.rb', line 5

def concurrency
  @concurrency
end

#environment_variablesObject (readonly)

Returns the value of attribute environment_variables.



8
9
10
# File 'lib/drunker/config.rb', line 8

def environment_variables
  @environment_variables
end

#file_patternObject (readonly)

Returns the value of attribute file_pattern.



10
11
12
# File 'lib/drunker/config.rb', line 10

def file_pattern
  @file_pattern
end

#imageObject (readonly)

Returns the value of attribute image.



3
4
5
# File 'lib/drunker/config.rb', line 3

def image
  @image
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



7
8
9
# File 'lib/drunker/config.rb', line 7

def timeout
  @timeout
end

Instance Method Details

#aws_client_optionsObject



56
57
58
# File 'lib/drunker/config.rb', line 56

def aws_client_options
  { credentials: credentials, region: region }.delete_if { |_k, v| v.nil? }
end

#debug?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/drunker/config.rb', line 52

def debug?
  debug
end