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

#hooksObject



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

def hooks
  %i[resolve_reference validate_resolve_reference]
end

#nameObject



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

def name
  'env_var'
end

#resolve_reference(opts) ⇒ Object



26
27
28
# File 'lib/bolt/plugin/env_var.rb', line 26

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

#validate_resolve_reference(opts) ⇒ Object



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

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