Class: Jets::Cfn::Resource::Codebuild::Project::Env

Inherits:
Object
  • Object
show all
Includes:
FormatEnv
Defined in:
lib/jets/cfn/resource/codebuild/project/env.rb

Instance Method Summary collapse

Methods included from FormatEnv

#standardize_env_vars

Instance Method Details

#always_blockObject



47
48
49
50
51
52
53
# File 'lib/jets/cfn/resource/codebuild/project/env.rb', line 47

def always_block
  %w[
    JETS_APP_SRC
    JETS_SIG
    JETS_TEMPLATES
  ]
end

#pass_vars(overrides = {}) ⇒ Object

Used for codebuild.start_build in runner.rb



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
# File 'lib/jets/cfn/resource/codebuild/project/env.rb', line 16

def pass_vars(overrides = {})
  # config/jets/bootstrap.rb defined ENV vars
  env = Jets.bootstrap.config.codebuild.project.env

  vars = {}
  pass = (env.default_pass + env.pass).uniq

  # pass vars from your local machine to the codebuild remote runner
  pass.each do |x|
    ENV.each do |k, v|
      k = k.to_s
      match = x.is_a?(Regexp) ? k =~ x : k == x
      if match && v.is_a?(String)
        vars[k.to_sym] = v
      end
    end
  end

  # block gets the final say
  vars.reject! do |k, v|
    k = k.to_s
    env.block.any? do |x|
      x.is_a?(Regexp) ? k =~ x : k == x
    end
  end

  vars.merge!(overrides)

  standardize_env_vars(vars, casing: :underscore_keys)
end

#varsObject

config/jets/bootstrap.rb

Jets.bootstrap.configure do
  config.codebuild.project.env.vars


10
11
12
13
# File 'lib/jets/cfn/resource/codebuild/project/env.rb', line 10

def vars
  vars = Jets.bootstrap.config.codebuild.project.env.vars.symbolize_keys!
  standardize_env_vars(vars)
end