Module: Idcf::Cli::Controller::Extend::Util

Included in:
Init
Defined in:
lib/idcf/cli/controller/extend/util.rb

Overview

util

Instance Method Summary collapse

Instance Method Details

#get_region(o) ⇒ Object

get region

Parameters:

  • o (Hash)

    options

  • read_conf (Boolean)

Returns:

  • String



13
14
15
16
# File 'lib/idcf/cli/controller/extend/util.rb', line 13

def get_region(o)
  flg = !class_options[:region].nil?
  Idcf::Cli::Lib::Configure.get_region(o, flg)
end

#make_schema_path(o) ⇒ Object

make schema path

Parameters:

  • o (Hash)

Returns:

  • String



22
23
24
25
26
27
28
29
# File 'lib/idcf/cli/controller/extend/util.rb', line 22

def make_schema_path(o)
  fn     = name.underscore.split('/').pop
  dir    = Idcf::Cli::Conf::Const::CMD_FILE_DIR
  ext    = Idcf::Cli::Conf::Const::CMD_FILE_EXT
  region = get_region(o)
  v      = service_version(o)
  "#{dir}/#{fn}_#{v}_#{region}.#{ext}"
end

#service_version(o) ⇒ Object

service version

Parameters:

  • o (Hash)

Returns:

  • String

Raises:



35
36
37
38
39
40
41
# File 'lib/idcf/cli/controller/extend/util.rb', line 35

def service_version(o)
  versions = service_versions(get_region(o))
  result   = o[:version].nil? ? versions.last : o[:version]
  msg      = "not found input version[#{o[:version]}]"
  raise Idcf::Cli::Error::CliError, msg unless versions.include?(result)
  result
end