lib/avm/instances/base.rb in avm-tools-0.16.0 vs lib/avm/instances/base.rb in avm-tools-0.17.0

- old
+ new

@@ -1,16 +1,22 @@ # frozen_string_literal: true +require 'eac_ruby_utils/require_sub' require 'eac_ruby_utils/simple_cache' require 'avm/instances/entries' +::EacRubyUtils.require_sub(__FILE__) module Avm module Instances class Base + include ::EacRubyUtils::Listable include ::EacRubyUtils::SimpleCache + include ::Avm::Instances::Base::AutoValues include ::Avm::Instances::Entries + lists.add_string :access, :local, :ssh + ID_PATTERN = /\A([a-z]+(?:\-[a-z]+)*)_(.+)\z/.freeze class << self def by_id(id) application_id, suffix = parse_id(id) @@ -42,13 +48,14 @@ def to_s id end def host_env_uncached - if read_entry('host') == 'localhost' - ::EacRubyUtils::Envs.local - else - ::EacRubyUtils::Envs.ssh("#{read_entry('user')}@#{read_entry('host')}") + access = read_entry(:access, list: ::Avm::Instances::Base.lists.access.values) + case access + when 'local' then return ::EacRubyUtils::Envs.local + when 'ssh' then return ::EacRubyUtils::Envs.ssh(read_entry('ssh.url')) + else raise("Unmapped access value: \"#{access}\"") end end private