Sha256: 2bd257b373fe22280693f3d98b7f5a21cd1fdb1ccaef0a8238919dfcbadb8a0f
Contents?: true
Size: 1.66 KB
Versions: 9
Compression:
Stored size: 1.66 KB
Contents
# frozen_string_literal: true require 'avm/with_application_stereotype' require 'avm/with_dynamic_runners' require 'eac_ruby_utils/require_sub' require 'eac_ruby_utils/simple_cache' require 'avm/instances/entries' module Avm module Instances class Base enable_abstract_methods enable_listable enable_simple_cache require_sub __FILE__, include_modules: true include ::Avm::Instances::Entries include ::Avm::WithDynamicRunners include ::Avm::WithApplicationStereotype lists.add_string :access, :local, :ssh ID_PATTERN = /\A([a-z0-9]+(?:\-[a-z0-9]+)*)_(.+)\z/.freeze class << self def by_id(id) application_id, suffix = parse_id(id) require 'avm/applications/base' new(::Avm::Applications::Base.new(application_id), suffix) end private def parse_id(id) m = ID_PATTERN.match(id) return [m[1], m[2]] if m raise "ID Pattern no matched: \"#{id}\"" end end common_constructor :application, :suffix do self.suffix = suffix.to_s end def id "#{application.id}_#{suffix}" end def to_s id end def host_env_uncached access = read_entry(:access, list: ::Avm::Instances::Base.lists.access.values) case access when 'local' then ::EacRubyUtils::Envs.local when 'ssh' then ::EacRubyUtils::Envs.ssh(read_entry('ssh.url')) else raise("Unmapped access value: \"#{access}\"") end end private def source_instance_uncached ::Avm::Instances::Base.by_id(source_instance_id) end end end end
Version data entries
9 entries across 9 versions & 2 rubygems