Class: Bolt::Plugin::EnvVar
- Inherits:
-
Object
- Object
- Bolt::Plugin::EnvVar
show all
- Defined in:
- lib/bolt/plugin/env_var.rb
Defined Under Namespace
Classes: InvalidPluginData
Instance Method Summary
collapse
Constructor Details
#initialize(*_args) ⇒ EnvVar
Returns a new instance of EnvVar.
14
|
# File 'lib/bolt/plugin/env_var.rb', line 14
def initialize(*_args); end
|
Instance Method Details
#hook_descriptions ⇒ Object
24
25
26
27
28
29
|
# File 'lib/bolt/plugin/env_var.rb', line 24
def hook_descriptions
{
resolve_reference: 'Read values stored in environment variables.',
validate_resolve_reference: nil
}
end
|
#hooks ⇒ Object
20
21
22
|
# File 'lib/bolt/plugin/env_var.rb', line 20
def hooks
hook_descriptions.keys
end
|
#name ⇒ Object
16
17
18
|
# File 'lib/bolt/plugin/env_var.rb', line 16
def name
'env_var'
end
|
#resolve_reference(opts) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/bolt/plugin/env_var.rb', line 41
def resolve_reference(opts)
reference = ENV[opts['var']]
if opts['json'] && reference
begin
reference = JSON.parse(reference)
rescue JSON::ParserError => e
raise InvalidPluginData.new(e.message, name)
end
end
reference || opts['default']
end
|
#validate_resolve_reference(opts) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/bolt/plugin/env_var.rb', line 31
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
|