Skip to content
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

Merged
merged 4 commits into from
Sep 5, 2016

Conversation

stevendanna
Copy link
Contributor

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

# Load the configuration file on initialization
def initialize
@params = {}
@path = '/tmp/gordon/config.yaml'
Copy link
Contributor

@chris-rock chris-rock Aug 31, 2016

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

@@ -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({}) }
Copy link
Contributor

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' })?

@stevendanna stevendanna changed the title WIP: Initial attempt at isolating resources between dependencies Initial attempt at isolating resources between dependencies Aug 31, 2016
@vjeffrey
Copy link

vjeffrey commented Sep 2, 2016

👍

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.
@@ -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) }
Copy link
Contributor

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>
@chris-rock
Copy link
Contributor

Great improvements @stevendanna and @vjeffrey

@chris-rock chris-rock merged commit 90a8584 into master Sep 5, 2016
@chris-rock chris-rock deleted the ssd/resource-isolation branch September 5, 2016 09:07
@chris-rock chris-rock modified the milestone: 0.33.0 Sep 5, 2016
@chris-rock
Copy link
Contributor

#958

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants