Class: Rockette::Configurator
- Inherits:
-
Object
- Object
- Rockette::Configurator
show all
- Includes:
- TextHelper
- Defined in:
- lib/rockette/controller/configurator.rb
Overview
Configure Rockette application
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from TextHelper
#bail, #check_input, #file_not_found, #no_rockette_dir, #padder
Constructor Details
Returns a new instance of Configurator.
12
13
14
15
16
17
18
19
|
# File 'lib/rockette/controller/configurator.rb', line 12
def initialize
@config = TTY::Config.new
@config.append_path APP_PATH
@config.read
@pastel = Pastel.new
@prompt = TTY::Prompt.new
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
10
11
12
|
# File 'lib/rockette/controller/configurator.rb', line 10
def config
@config
end
|
Class Method Details
.config ⇒ Object
21
22
23
|
# File 'lib/rockette/controller/configurator.rb', line 21
def self.config
@config ||= self.class.new.config
end
|
Instance Method Details
#add_controller_cred ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/rockette/controller/configurator.rb', line 50
def add_controller_cred
puts "Now that you have entered a controller url, please enter the OAuth client credentials for the controller."
user = @prompt.ask("User:")
pass = @prompt.ask("Pass:")
basey = 'Basic ' + Base64.encode64(user + ":" + pass).tr("\n", "")
@config.set(:rockette, :controller_cred, value: basey)
@config.write(force: true)
refresh_conf
puts "Choose View Resources and then All Applications to automate adding client credentials for each environment."
puts "You will need these credentials to use Rockette to deploy, export, and update applications."
end
|
#add_url ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/rockette/controller/configurator.rb', line 62
def add_url
uri = @prompt.ask("Please enter APEX deployment URI (base path):") do |u|
u.validate(%r{^https://\w+.\w+})
end
@config.set(:rockette, :controller_url, value: uri)
@config.write(force: true)
refresh_conf
end
|
#do_action(action) ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/rockette/controller/configurator.rb', line 39
def do_action(action)
case action
when "editor"
edit_config
when "url"
add_url
else
puts "\nI don't understand that command.\n\n"
end
end
|
#edit_config ⇒ Object
71
72
73
74
75
|
# File 'lib/rockette/controller/configurator.rb', line 71
def edit_config
edit = TTY::Editor.open(CONF)
puts "There seems to have been an issue trying to open the file: #{CONF}" unless edit
refresh_conf if edit
end
|
#first_run ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/rockette/controller/configurator.rb', line 77
def first_run
puts
puts "I see this is your first time running Rockette. Entering an APEX deployment"
puts "uri will allow me to discover more about your environments."
puts
response = @prompt.yes?("Would you like to enter a URI?")
if response == true
add_url
add_controller_cred
else
response = @prompt.yes?("Would you like to disable these checks in the future?")
@config.set(:rockette, :check_for_url, value: false) if response == true
end
@config.write(force: true) if response == true
refresh_conf
end
|
#launch! ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/rockette/controller/configurator.rb', line 25
def launch!
puts
puts @pastel.yellow("Configure Rockette here. Choosing 'editor' will let you edit the config file directly.")
puts @pastel.yellow("Choose 'url' to enter a controller url, the api endpoint with your environments, etc.")
puts
loop do
action = @prompt.select("What will it be?", %w[editor url back])
break if action == "back"
do_action(action)
end
end
|
#refresh_conf ⇒ Object
94
95
96
|
# File 'lib/rockette/controller/configurator.rb', line 94
def refresh_conf
@config.read
end
|