Class: Tomo::Plugin::Env::Tasks
Overview
rubocop:disable Metrics/ClassLength
Instance Method Summary
collapse
Methods inherited from TaskLibrary
#initialize
Instance Method Details
#set ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/tomo/plugin/env/tasks.rb', line 44
def set
return if settings[:run_args].empty?
modify_env_file do |env|
settings[:run_args].each do |arg|
name, value = arg.split("=", 2)
value ||= prompt_for(name)
replace_entry(env, name, value)
end
end
end
|
#setup ⇒ Object
15
16
17
18
|
# File 'lib/tomo/plugin/env/tasks.rb', line 15
def setup
modify_bashrc
update
end
|
#show ⇒ Object
10
11
12
13
|
# File 'lib/tomo/plugin/env/tasks.rb', line 10
def show
env = read_existing
logger.info env.gsub(/^export /, "").strip
end
|
#unset ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'lib/tomo/plugin/env/tasks.rb', line 56
def unset
return if settings[:run_args].empty?
modify_env_file do |env|
settings[:run_args].each do |name|
remove_entry(env, name)
end
end
end
|
#update ⇒ Object
rubocop:disable Metrics/MethodLength
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/tomo/plugin/env/tasks.rb', line 20
def update return if settings[:env_vars].empty?
modify_env_file do |env|
settings[:env_vars].each do |name, value|
case value
when :prompt
next if contains_entry?(env, name)
value = prompt_for(name, message: <<~MSG)
The remote host needs a value for the $#{name} environment variable.
Please provide a value at the prompt.
MSG
when :generate_secret
next if contains_entry?(env, name)
value = SecureRandom.hex(64)
end
replace_entry(env, name, value)
end
end
end
|