Class: EYCli::Controller::Environments
- Inherits:
-
Object
- Object
- EYCli::Controller::Environments
- Defined in:
- lib/ey_cli/controllers/environments.rb
Instance Method Summary collapse
- #create(app, options = {}) ⇒ Object
- #deploy(app, options = {}) ⇒ Object
- #fetch_cluster_options(options) ⇒ Object
- #fetch_custom_arguments(options) ⇒ Object
- #fetch_environment(app, options = {}) ⇒ Object
Instance Method Details
#create(app, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ey_cli/controllers/environments.rb', line 4 def create(app, = {}) framework_env = [:framework_env] || 'production' env_name = [:name] || "#{app.name}_#{framework_env}" = { :app => app, 'environment[name]' => env_name, 'environment[framework_env]' => framework_env } .merge! fetch_custom_arguments() .merge! ([:cluster_configuration]) env = EYCli::Model::Environment.create() if env.errors? EYCli.term.print_errors(env.errors, "Environment creation failed:") else EYCli.term.success("Environment '#{env.name}' created successfully") end env end |
#deploy(app, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ey_cli/controllers/environments.rb', line 26 def deploy(app, = {}) env = fetch_environment(app, ) if env deploy = env.deploy(app, ) if deploy.errors? EYCli.term.print_errors(deploy.errors, "Application deployment failed:") else EYCli.term.success('Application deployed successfully') end else EYCli.term.say('Nothing deployed') end end |
#fetch_cluster_options(options) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ey_cli/controllers/environments.rb', line 42 def () return {} unless cluster = { 'cluster_configuration[configuration]' => [:configuration], 'cluster_configuration[ip_id]' => 'new' } if [:configuration] == 'custom' cluster['cluster_configuration[app_server_count]'] = [:app_instances] || 2 cluster['cluster_configuration[use_separate_db]'] = [:use_separate_db] || 'true' cluster['cluster_configuration[db_slave_count]'] = [:db_instances] || 0 cluster['cluster_configuration[instance_size]'] = [:app_size] if [:app_size] cluster['cluster_configuration[db_instance_size]'] = [:db_size] if [:db_size] end cluster end |
#fetch_custom_arguments(options) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/ey_cli/controllers/environments.rb', line 58 def fetch_custom_arguments() custom = {} custom['app_deployment[new][domain_name]'] = [:url] if [:url] custom['environment[app_server_stack_name]'] = [:stack] if [:stack] custom['environment[db_stack_name]'] = [:db_stack] if [:db_stack] custom['environment[ruby_version]'] = [:ruby_version] if [:ruby_version] custom end |
#fetch_environment(app, options = {}) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ey_cli/controllers/environments.rb', line 67 def fetch_environment(app, = {}) if !app.environments? || app.environments.empty? EYCli.term.error <<-EOF You don't have any environment associated to this application. Try running `ey_cli create_env' to create your first environment. EOF elsif app.environments.size == 1 app.environments.first else name = EYCli.term.choose_resource(app.environments, "I don't know which environment deploy on.", "Please, select and environment") EYCli::Model::Environment.find_by_name(name, app.environments) end end |