Class: Bolt::Plugin::EnvVar

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt/plugin/env_var.rb

Instance Method Summary collapse

Constructor Details

#initialize(*_args) ⇒ EnvVar

Returns a new instance of EnvVar.



6
# File 'lib/bolt/plugin/env_var.rb', line 6

def initialize(*_args); end

Instance Method Details

#hook_descriptionsObject



16
17
18
19
20
21
# File 'lib/bolt/plugin/env_var.rb', line 16

def hook_descriptions
  {
    resolve_reference: 'Read values stored in environment variables.',
    validate_resolve_reference: nil
  }
end

#hooksObject



12
13
14
# File 'lib/bolt/plugin/env_var.rb', line 12

def hooks
  hook_descriptions.keys
end

#nameObject



8
9
10
# File 'lib/bolt/plugin/env_var.rb', line 8

def name
  'env_var'
end

#resolve_reference(opts) ⇒ Object



33
34
35
# File 'lib/bolt/plugin/env_var.rb', line 33

def resolve_reference(opts)
  ENV[opts['var']] || opts['default']
end

#validate_resolve_reference(opts) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/bolt/plugin/env_var.rb', line 23

def validate_resolve_reference(opts)
  unless opts['var']
    raise Bolt::ValidationError, "env_var plugin requires that the 'var' is specified"
  end
  return if opts['optional'] || opts['default']
  unless ENV[opts['var']]
    raise Bolt::ValidationError, "env_var plugin requires that the var '#{opts['var']}' be set"
  end
end