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

CFINSPEC-70 Added resource_id attribute for the custom resources in the base class #5875

Merged
merged 5 commits into from
Mar 3, 2022

Conversation

Nik08
Copy link
Contributor

@Nik08 Nik08 commented Feb 23, 2022

Signed-off-by: Nikita Mathur nikita.mathur@chef.io

Description

  1. Added resource_id attribute for the custom resources in the base class
  2. Test cases covered

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New content (non-breaking change)
  • Breaking change (a content change which would break existing functionality or processes)

Checklist:

  • I have read the CONTRIBUTING document.

@Nik08 Nik08 requested a review from a team as a code owner February 23, 2022 11:00
@netlify
Copy link

netlify bot commented Feb 23, 2022

✔️ 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

@Nik08 Nik08 requested a review from a team as a code owner February 24, 2022 10:13
@Nik08 Nik08 changed the title [W.I.P] CFINSPEC-70 Added resource_id attribute for the custom resources in the base class CFINSPEC-70 Added resource_id attribute for the custom resources in the base class Feb 24, 2022
@github-actions github-actions bot added the Documentation ZH multi-repo label for the docs-team label Feb 24, 2022
@@ -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
Copy link
Contributor

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

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.

Nik08 and others added 5 commits March 3, 2022 12:26
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation ZH multi-repo label for the docs-team Expeditor: Bump Minor Version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants