inspec/lib/vulcano/backend.rb

45 lines
1.1 KiB
Ruby
Raw Normal View History

# encoding: utf-8
require 'uri'
require 'vulcano/plugins'
module Vulcano
class Backend
# Expose all registered backends
def self.registry
@registry ||= {}
end
# Resolve target configuration in URI-scheme into
# all respective fields and merge with existing configuration.
# e.g. ssh://bob@remote => backend: ssh, user: bob, host: remote
2015-09-03 18:43:58 +00:00
def self.target_config(config)
conf = config.dup
return conf if conf['target'].to_s.empty?
2015-09-05 14:07:54 +00:00
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
def self.backend(version = 1)
if version != 1
2015-09-03 21:18:28 +00:00
fail 'Only backend version 1 is supported!'
end
Vulcano::Plugins::Backend
end
end
require 'vulcano/backend/docker'
require 'vulcano/backend/local'
require 'vulcano/backend/mock'
require 'vulcano/backend/specinfra'
require 'vulcano/backend/ssh'