-
Notifications
You must be signed in to change notification settings - Fork 680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial attempt at isolating resources between dependencies #994
Conversation
# Load the configuration file on initialization | ||
def initialize | ||
@params = {} | ||
@path = '/tmp/gordon/config.yaml' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may simplify the resource to just return a version number. Otherwise we are relying on external configuration. eg.
def version
1
end
3b9175d
to
1603398
Compare
@@ -10,7 +10,7 @@ def load(content) | |||
'inspec.yml' => "name: mock", | |||
'controls/mock.rb' => "control '1' do\n#{content}\nend\n", | |||
} | |||
opts = { test_collector: Inspec::RunnerMock.new } | |||
opts = { test_collector: Inspec::RunnerMock.new, backend: Inspec::Backend.create({}) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't that require Inspec::Backend.create({ backend: 'mock' })
?
8371f11
to
491aef1
Compare
491aef1
to
bf2be50
Compare
👍 |
Previously, all resources were loaded into a single resource registry. Now, each profile context has a resource registry, when a profile's library is loaded into the profile context, we update the profile-context-specific resource registry. This local registry is then used to populate the execution context that the rules are evaluated in. Signed-off-by: Steven Danna <steve@chef.io>
The goal of these changes is to ensure that the libraries from dependencies are loaded even if their controls are never included. To facilitate this, we break up the loading into seperate steps, and move the loading code into the Profile which has acceess to the dependency information. Signed-off-by: Steven Danna <steve@chef.io>
Previously, libraries were loaded by instance_eval'ing them against the same execution context used for control files. All resources were registered against a single global registry when the `name` dsl method was invoked. To obtain seperation of resources, we would mutate the instance variable holding the globale registry and then change it back at the end. Now, we instance_eval library files inside an anonymous class. This class has its own version of `Inspec.resource` that returns another class with the resource DSL method and the profile-specific resource registry.
bf2be50
to
9bb65bd
Compare
@@ -70,7 +70,7 @@ def run_tests(targets, opts) | |||
o[:logger].level = get_log_level(o.log_level) | |||
|
|||
runner = Inspec::Runner.new(o) | |||
targets.each { |target| runner.add_target(target, opts) } | |||
targets.each { |target| runner.add_target(target) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
- Add comment describing describe - Fixup to_s output to be more accurate Signed-off-by: Steven Danna <steve@chef.io>
Great improvements @stevendanna and @vjeffrey |
Previously, all resources were loaded into a single resource registry.
Now, each profile context has a resource registry, when a profile's
library is loaded into the profile context, we update the
profile-context-specific resource registry. This local registry is
then used to populate the execution context that the rules are
evaluated in.
Signed-off-by: Steven Danna steve@chef.io