mirror of
https://github.com/inspec/inspec
synced 2025-02-17 06:28:40 +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
|
end
|
||||||
|
|
||||||
def result
|
def result
|
||||||
@result ||= vulcano.run_command(@command)
|
@result ||= vulcano.backend.run_command(@command)
|
||||||
end
|
end
|
||||||
|
|
||||||
def stdout
|
def stdout
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Vulcano::Resources
|
||||||
|
|
||||||
def initialize(path)
|
def initialize(path)
|
||||||
@path = path
|
@path = path
|
||||||
@file = vulcano.file(@path)
|
@file = vulcano.backend.file(@path)
|
||||||
end
|
end
|
||||||
|
|
||||||
%w{
|
%w{
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Vulcano::Resources
|
||||||
name 'os'
|
name 'os'
|
||||||
|
|
||||||
def [](name)
|
def [](name)
|
||||||
vulcano.os[name]
|
vulcano.backend.os[name]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,8 +36,11 @@ module Vulcano
|
||||||
RSpec.configuration.add_formatter(@conf['format'] || 'progress')
|
RSpec.configuration.add_formatter(@conf['format'] || 'progress')
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_resources_to_backend(backend_class)
|
def create_backend_container(backend_instance)
|
||||||
Class.new(backend_class) do
|
Class.new do
|
||||||
|
define_method :backend do
|
||||||
|
backend_instance
|
||||||
|
end
|
||||||
Vulcano::Resource.registry.each do |id, r|
|
Vulcano::Resource.registry.each do |id, r|
|
||||||
define_method id.to_sym do |*args|
|
define_method id.to_sym do |*args|
|
||||||
r.new(self, *args)
|
r.new(self, *args)
|
||||||
|
@ -60,8 +63,9 @@ module Vulcano
|
||||||
end
|
end
|
||||||
|
|
||||||
# create the backend based on the config
|
# create the backend based on the config
|
||||||
enriched_backend = add_resources_to_backend(backend_class)
|
backend_instance = backend_class.new(@conf)
|
||||||
@backend = enriched_backend.new(@conf)
|
outer_cls = create_backend_container(backend_instance)
|
||||||
|
@backend = outer_cls.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_tests(tests)
|
def add_tests(tests)
|
||||||
|
|
Loading…
Add table
Reference in a new issue