Class: Renuo::Cli::Services::Deploio
- Inherits:
-
Object
- Object
- Renuo::Cli::Services::Deploio
- Defined in:
- lib/renuo/cli/services/deploio.rb
Class Method Summary collapse
- .fetch_apps ⇒ Object
- .fetch_vms ⇒ Object
- .fetch_whoami_orgs ⇒ Object
- .parse_apps(yaml, organization) ⇒ Object
Class Method Details
.fetch_apps ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/renuo/cli/services/deploio.rb', line 7 def fetch_apps active_org, available_orgs = fetch_whoami_orgs available_orgs.flat_map do |organization| set_organization(organization) parse_apps(fetch_apps_yaml, organization) end ensure set_organization(active_org) end |
.fetch_vms ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/renuo/cli/services/deploio.rb', line 35 def fetch_vms fetch_vms_cmd = %(nctl get cloudvm -A -o yaml) stdout, stderr, status = Open3.capture3 fetch_vms_cmd raise "Error fetching Deploio app list: #{stderr}" unless status.success? YAML.load_stream(stdout).map do |app| { name: app.dig("metadata", "name"), namespace: app.dig("metadata", "namespace"), hostname: app.dig("spec", "forProvider", "hostname"), ip: app.dig("status", "atProvider", "ipAddress"), reverse_dns: app.dig("status", "atProvider", "reverseDNS"), fqdn: app.dig("status", "atProvider", "fqdn") } end end |
.fetch_whoami_orgs ⇒ Object
18 19 20 21 22 23 |
# File 'lib/renuo/cli/services/deploio.rb', line 18 def fetch_whoami_orgs stdout, = run_nctl_command('nctl auth whoami -o "yaml"') whoami = YAML.safe_load(stdout) [whoami["organization"], whoami["orgs"]] end |
.parse_apps(yaml, organization) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/renuo/cli/services/deploio.rb', line 25 def parse_apps(yaml, organization) YAML.load_stream(yaml).filter_map do |app| name = app.dig("metadata", "name") namespace = app.dig("metadata", "namespace") spec_hosts = app.dig("spec", "forProvider", "hosts") || [] { name: name, namespace: namespace, hosts: spec_hosts, organization: organization } end end |