Class: GcloudHosts::Runner
- Inherits:
-
Object
- Object
- GcloudHosts::Runner
- Defined in:
- lib/gcloud_hosts/runner.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ Runner
constructor
A new instance of Runner.
- #run! ⇒ Object
Constructor Details
#initialize(args) ⇒ Runner
Returns a new instance of Runner.
6 7 8 |
# File 'lib/gcloud_hosts/runner.rb', line 6 def initialize(args) = Options.new(args). end |
Instance Method Details
#run! ⇒ Object
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 36 37 38 39 40 41 42 43 |
# File 'lib/gcloud_hosts/runner.rb', line 10 def run! project = [:project].to_s.strip if [:clear] if project != "" raise ArgumentError.new("Cannot specify 'clear' and 'project' at the same time.") end end if project == "" project = env["core"]["project"].to_s.strip end backup = [:backup] || [:file] + '.bak' if [:clear] Updater.clear([:file], backup, [:dry_run]) else if project == "" raise AuthError.new("No gcloud project specified.") end if [:domain] domain = [:domain].to_s.strip else domain = "c.#{project}.internal" end if [:delete] new_hosts_list = [] else new_hosts_list = Hosts.hosts([:gcloud], project, [:network], domain, [:public], [:exclude_public]) end Updater.update(new_hosts_list.join("\n"), project, [:file], backup, [:dry_run], [:delete]) end end |