Class: VPS::CLI::Service
- Inherits:
-
Thor
- Object
- Thor
- VPS::CLI::Service
- Defined in:
- lib/vps/cli/service.rb
Constant Summary collapse
- SERVICES =
"#{VPS::ROOT}/config/services.yml"
Instance Method Summary collapse
Instance Method Details
#add(host, service = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vps/cli/service.rb', line 8 def add(host, service = nil) config = VPS.read_config(host) unless service list = services.keys.sort - config[:services].keys service = list[Ask.list("Which service to you want to add?", list)] end if !config[:services].include?(service) && (yml = services[service]) list = (yml[:image] || "library/#{service}") tag = list[Ask.list("Choose which tag to use", list)] image = "#{yml[:image] || service}:#{tag}" yml, volumes = finalize_config(yml) config[:services][service] = {:image => image}.merge(yml) config[:volumes].concat(volumes).uniq! VPS.write_config(host, config) end end |
#list(host) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/vps/cli/service.rb', line 44 def list(host) config = VPS.read_config(host) services = config[:services].collect do |service, yml| "* #{yml[:image]}" end.sort puts services end |
#remove(host, service = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vps/cli/service.rb', line 30 def remove(host, service = nil) config = VPS.read_config(host) unless service list = config[:services].keys.sort service = list[Ask.list("Which service do you want to remove?", list)] end if config[:services].delete(service) VPS.write_config(host, config) end end |