Class: Webbynode::Commands::ChangeDns

Inherits:
Webbynode::Command show all
Defined in:
lib/webbynode/commands/change_dns.rb

Constant Summary

Constants inherited from Webbynode::Command

Webbynode::Command::Aliases, Webbynode::Command::CommandError, Webbynode::Command::InvalidCommand, Webbynode::Command::InvalidOption, Webbynode::Command::Settings

Instance Method Summary collapse

Methods inherited from Webbynode::Command

add_alias, #api, class_for, command, command_class_name, description, for, #gemfile, #git, help, inherited, #initialize, #io, #no?, #notify, option, #option, #options, options_help, #param, #param_values, parameter, #params, #params_hash, params_help, #pushand, #remote_executor, requires_initialization!, requires_options!, requires_pushed_application!, #run, #server, setting, #settings, summary, summary_help, usage, #validate_initialization, #validate_options, #yes?

Constructor Details

This class inherits a constructor from Webbynode::Command

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/webbynode/commands/change_dns.rb', line 10

def execute
  raise CommandError, 
    "Cannot change DNS because you have pending changes. Do a git commit or add changes to .gitignore." unless git.clean?
  
  io.log "Changing DNS to #{param(:dns_entry)}...", :quiet_start
  
  git.delete_file ".webbynode/config"
  handle_dns param(:dns_entry)
  
  app_name = io.app_name
  pushand.create!(app_name, param(:dns_entry))

  git.add ".pushand"
  git.add ".webbynode/settings" if io.file_exists?(".webbynode/settings")
  result = git.commit3("Changed DNS to \"#{param(:dns_entry)}\"")
  
  unless result[0]
    io.log ""
    raise CommandError, "Error from git commit:\n#{result[1]}"
  end

  io.log "Your application will start responding to #{param(:dns_entry)} after next deployment."
rescue Webbynode::ApiClient::InactiveZone
  io.log "Domain #{$!.message.color(:yellow)} already setup on Webbynode DNS, but it's inactive."
  io.log "Please reactivate it and try again."
end