-
Notifications
You must be signed in to change notification settings - Fork 682
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
CFINSPEC-70 Added resource_id attribute for the custom resources in the base class #5875
Conversation
✔️ Deploy Preview for chef-inspec ready! 🔨 Explore the source changes: bb410b8 🔍 Inspect the deploy log: https://app.netlify.com/sites/chef-inspec/deploys/6220fb35f6bb9a0007dce65e 😎 Browse the preview: https://deploy-preview-5875--chef-inspec.netlify.app/inspec/dsl_resource |
d756fae
to
cb87710
Compare
lib/inspec/resource.rb
Outdated
@@ -34,6 +34,11 @@ def self.supports(criteria = nil) | |||
Inspec::Resource.support_registry[key].push(criteria) | |||
end | |||
|
|||
def resource_id(value = nil) | |||
resource_id_value = value || "" | |||
@resource_id ||= resource_id_value |
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.
This logic makes the instance variable write-once. That seems like a subtle bug to me.
res.resource_id('a')
res.resource_id => 'a'
res.resource_id('b')
res.resource_id => 'a' # this is surprising
@@ -48,6 +48,7 @@ The following attributes can be configured: | |||
- desc - Description of the resource (optional) | |||
- example - Example usage of the resource (optional) | |||
- supports - (Chef InSpec 2.0+) Platform restrictions of the resource (optional) | |||
- resource_id - A unique identifier for each node of resource. Should specify the implementation to determine it (optional) |
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.
I think this needs to be separated out from the rest of the DSL. It should be clearer that this is not a DSL method you can call on your own as a DSL method, but a method you have to call as an instance method in your resource.
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
…hema Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
b591644
to
bb410b8
Compare
Signed-off-by: Nikita Mathur nikita.mathur@chef.io
Description
Related Issue
Types of changes
Checklist: