devops client prefix
This commit is contained in:
parent
b517183efd
commit
359b83b8be
@ -34,14 +34,14 @@ module DevopsClient
|
||||
abort(I18n.t("config.invalid.host"), :file => @@config_file)
|
||||
end
|
||||
[:api, :username, :password].each do |key|
|
||||
if config[key].nil?
|
||||
if config[key].nil? or config[key].empty?
|
||||
abort(I18n.t("config.invalid.empty", :file => @@config_file, :key => key))
|
||||
end
|
||||
end
|
||||
configure_proxy config
|
||||
|
||||
host = config[:host]
|
||||
default = {:username => config[:username], :api => config[:api], :host => config[:host]}
|
||||
default = {:username => config[:username], :api => config[:api], :host => config[:host], :prefix => ((config[:prefix].nil? or config[:prefix].empty?) ? nil : config[:prefix])}
|
||||
auth = {:username => config[:username], :password => config[:password], :type => "basic"}
|
||||
|
||||
handler = HandlerFactory.create(ARGV[0], host, auth, default)
|
||||
@ -102,7 +102,6 @@ module DevopsClient
|
||||
end
|
||||
end
|
||||
else
|
||||
puts I18n.t("log.warn", :msg => I18n.t("config.not_exist", :file => file))
|
||||
config = set_default_config(file)
|
||||
end
|
||||
config
|
||||
@ -112,6 +111,7 @@ module DevopsClient
|
||||
locales = I18n.locales
|
||||
config = {:api => "v2.0", :locale => "en"}
|
||||
I18n.language = config[:locale]
|
||||
puts I18n.t("log.warn", :msg => I18n.t("config.not_exist", :file => file))
|
||||
config[:locale] = begin
|
||||
l = get_config_parameter(I18n.t("config.property.lang", :langs => locales.join(", ")), config[:locale])
|
||||
raise ArgumentError unless locales.include?(l)
|
||||
@ -121,6 +121,7 @@ module DevopsClient
|
||||
retry
|
||||
end
|
||||
config[:host] = get_config_parameter(I18n.t("config.property.host"))
|
||||
config[:prefix] = get_config_parameter(I18n.t("config.property.prefix"))
|
||||
config[:api] = get_config_parameter(I18n.t("config.property.api"), config[:api])
|
||||
config[:username] = get_config_parameter(I18n.t("config.property.username"))
|
||||
config[:password] = get_config_parameter(I18n.t("config.property.password"))
|
||||
|
||||
@ -143,7 +143,11 @@ protected
|
||||
end
|
||||
|
||||
def create_url path
|
||||
URI.join(self.host, self.options[:api] + path).to_s
|
||||
a = [self.options[:api], path]
|
||||
a.unshift(self.options[:prefix]) unless self.options[:prefix].nil?
|
||||
p = ""
|
||||
a.each{|e| p << (e.start_with?("/") ? e : "/" + e)}
|
||||
URI.join(self.host, p).to_s
|
||||
end
|
||||
|
||||
def submit
|
||||
|
||||
@ -9,6 +9,7 @@ class Server < Handler
|
||||
|
||||
def initialize(host, def_options={})
|
||||
self.host = host
|
||||
self.options = def_options
|
||||
@options_parser = ServerOptions.new(ARGV, def_options)
|
||||
end
|
||||
|
||||
|
||||
@ -125,6 +125,11 @@ class CommonOptions
|
||||
o[:api] = a
|
||||
end
|
||||
|
||||
o[:prefix] = default_options[:prefix]
|
||||
opts.on("--prefix PREFIX", I18n.t("options.common.prefix", :prefix => o[:prefix])) do |p|
|
||||
o[:prefix] = p
|
||||
end
|
||||
|
||||
o[:username] = default_options[:username]
|
||||
opts.on("--user USERNAME", I18n.t("options.common.username", :username => o[:username])) do |u|
|
||||
o[:username] = u.strip
|
||||
|
||||
@ -8,6 +8,7 @@ en:
|
||||
property:
|
||||
lang: "Language (%{langs})"
|
||||
host: "Devops server host and port (host:port)"
|
||||
prefix: "Path prefix"
|
||||
api: "API version"
|
||||
username: "Username"
|
||||
password: "Password"
|
||||
@ -240,6 +241,7 @@ en:
|
||||
version: "devops client version"
|
||||
host: "devops service host address (%{host})"
|
||||
api: "devops service API version (%{api})"
|
||||
prefix: "devops service path prefix (%{prefix})"
|
||||
username: "devops username (%{username})"
|
||||
format: "Output format: '%{formats}' (%{format})"
|
||||
completion: "Initialize bash completion script"
|
||||
|
||||
@ -9,6 +9,7 @@ ru:
|
||||
property:
|
||||
lang: "Язык (%{langs})"
|
||||
host: "Адрес и порт сервера Devops (host:port)"
|
||||
prefix: "Префикс пути"
|
||||
api: "Версия API"
|
||||
username: "Имя пользователя"
|
||||
password: "Пароль"
|
||||
@ -241,6 +242,7 @@ ru:
|
||||
version: "Версия devops клиента"
|
||||
host: "Адрес хоста devops сервера (%{host})"
|
||||
api: "Версия API devops сервера (%{api})"
|
||||
prefix: "Префикс пути devops сервера (%{prefix})"
|
||||
username: "Имя пользователя devops (%{username})"
|
||||
format: "Формат вывода: '%{formats}' (%{format})"
|
||||
completion: "Инициализировать bash скрипт автодополнений"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user