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

Extend set_attribute plugin helper method to set sub-attributes. #822

Merged
merged 1 commit into from
Nov 29, 2016

Conversation

mcquin
Copy link
Contributor

@mcquin mcquin commented May 11, 2016

Use:

  • set_attribute(:attr, value) assigns attribute 'attr' value.
  • set_attribute(:attr, :subattr, value) assigns attribute 'attr/subattr' value. Extends to subattributes of arbitrary depth.

Raises a TypeError if some :subattr is not an Array, Hash, or Mash (e.g., a String value).

@tas50

@mcquin
Copy link
Contributor Author

mcquin commented May 11, 2016

Ready for review @chef/client-core

@@ -152,8 +152,19 @@ def from_with_regex(cmd, *regex_list)
end
end

def set_attribute(name, *values)
@data[name] = Array18(*values)
def set_attribute(name, value, *values)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this just be set_attribute(*keys, value)?

Use:
  - set_attribute(:attr, value) assigns attribute 'attr' value.
  - set_attribute(:attr, :subattr, value) assigns attribute 'attr/subattr' value. Extends to subattributes of arbitrary depth.

Raises a TypeError if some :subattr is not an Array, Hash, or Mash (e.g., a String value).
@lamont-granquist
Copy link
Contributor

You might want to look at chef/chef#5029, I'm implementing functional getter/setter APIs, but the words I'm using is read/write/unlink, also with a slightly different implementation.

@mcquin
Copy link
Contributor Author

mcquin commented Jul 5, 2016

That's a neat implementation @lamont-granquist . Are we okay with merging this as-is? I don't see the need for an implementation re-write now. Perhaps a future a mixlib-attribute library could prove useful for unifying attribute access between Chef and Ohai. ;)

@tas50
Copy link
Contributor

tas50 commented Sep 6, 2016

@mcquin @lamont-granquist Any update on this?

@thommay thommay merged commit 3decd17 into master Nov 29, 2016
@tas50 tas50 changed the title Extend set_attribute to set sub-attributes. Extend set_attribute plugin helper method to set sub-attributes. Nov 29, 2016
@thommay thommay added Type: Enhancement Adds new functionality. and removed Enhancement labels Jan 24, 2017
@tas50 tas50 deleted the OHAI-794/set-attribute branch January 24, 2017 18:32
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Enhancement Adds new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants