mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
api: wrap transport and add resources to backend
What is currently available as `vulcano` inside resources (e.g. to call `vulcano.file(...)`, is now wrapped inside `vulcano.backend`. All other resources are now added to `vulcano.<RESOURCE>`, e.g. `vulcano.user`.
This commit is contained in:
parent
5912f0d3f1
commit
76572df292
4 changed files with 11 additions and 7 deletions
|
@ -9,7 +9,7 @@ class Cmd < Vulcano.resource(1)
|
|||
end
|
||||
|
||||
def result
|
||||
@result ||= vulcano.run_command(@command)
|
||||
@result ||= vulcano.backend.run_command(@command)
|
||||
end
|
||||
|
||||
def stdout
|
||||
|
|
|
@ -8,7 +8,7 @@ module Vulcano::Resources
|
|||
|
||||
def initialize(path)
|
||||
@path = path
|
||||
@file = vulcano.file(@path)
|
||||
@file = vulcano.backend.file(@path)
|
||||
end
|
||||
|
||||
%w{
|
||||
|
|
|
@ -5,7 +5,7 @@ module Vulcano::Resources
|
|||
name 'os'
|
||||
|
||||
def [](name)
|
||||
vulcano.os[name]
|
||||
vulcano.backend.os[name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,8 +36,11 @@ module Vulcano
|
|||
RSpec.configuration.add_formatter(@conf['format'] || 'progress')
|
||||
end
|
||||
|
||||
def add_resources_to_backend(backend_class)
|
||||
Class.new(backend_class) do
|
||||
def create_backend_container(backend_instance)
|
||||
Class.new do
|
||||
define_method :backend do
|
||||
backend_instance
|
||||
end
|
||||
Vulcano::Resource.registry.each do |id, r|
|
||||
define_method id.to_sym do |*args|
|
||||
r.new(self, *args)
|
||||
|
@ -60,8 +63,9 @@ module Vulcano
|
|||
end
|
||||
|
||||
# create the backend based on the config
|
||||
enriched_backend = add_resources_to_backend(backend_class)
|
||||
@backend = enriched_backend.new(@conf)
|
||||
backend_instance = backend_class.new(@conf)
|
||||
outer_cls = create_backend_container(backend_instance)
|
||||
@backend = outer_cls.new
|
||||
end
|
||||
|
||||
def add_tests(tests)
|
||||
|
|
Loading…
Reference in a new issue