mirror of
https://github.com/inspec/inspec
synced 2025-02-16 22:18:38 +00:00
add aliases for target and backend
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
601abe2579
commit
04db46f116
4 changed files with 14 additions and 4 deletions
|
@ -45,9 +45,9 @@ class VulcanoCLI < Thor
|
|||
desc "exec PATHS", "run all test files"
|
||||
option :id, type: :string,
|
||||
desc: 'Attach a profile ID to all test results'
|
||||
option :target, type: :string, default: nil,
|
||||
option :target, aliases: :t, type: :string, default: nil,
|
||||
desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port'
|
||||
option :backend, type: :string, default: nil,
|
||||
option :backend, aliases: :b, type: :string, default: nil,
|
||||
desc: 'Choose a backend: exec (run locally), ssh, winrm.'
|
||||
option :host, type: :string,
|
||||
desc: 'Specify a remote host which is tested.'
|
||||
|
|
|
@ -7,14 +7,19 @@ module Vulcano
|
|||
@registry ||= {}
|
||||
end
|
||||
|
||||
def self.target_config( conf )
|
||||
def self.target_config( config )
|
||||
conf = config.dup
|
||||
|
||||
return conf if conf[:target].to_s.empty?
|
||||
|
||||
uri = URI::parse(conf[:target].to_s)
|
||||
conf[:backend] = conf[:backend] || uri.scheme
|
||||
conf[:host] = conf[:host] || uri.host
|
||||
conf[:port] = conf[:port] || uri.port
|
||||
conf[:user] = conf[:user] || uri.user
|
||||
conf[:password] = conf[:password] || uri.password
|
||||
|
||||
# return the updated config
|
||||
conf
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,12 @@ module Vulcano::Backends
|
|||
@conf = conf
|
||||
@files = {}
|
||||
type = @conf[:backend]
|
||||
|
||||
configure_shared_options
|
||||
|
||||
# configure the given backend, if we can handle it
|
||||
# e.g. backend = exec ==> try to call configure_exec
|
||||
# if we don't support it, error out
|
||||
m = "configure_#{type}"
|
||||
if self.respond_to?(m.to_sym)
|
||||
self.send(m)
|
||||
|
|
|
@ -21,7 +21,7 @@ module Vulcano
|
|||
def initialize(profile_id, conf)
|
||||
@rules = []
|
||||
@profile_id = profile_id
|
||||
@conf = Vulcano::Backend.target_config(conf).dup
|
||||
@conf = Vulcano::Backend.target_config(conf)
|
||||
configure_output
|
||||
configure_backend
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue