-
Notifications
You must be signed in to change notification settings - Fork 2.5k
rewrite macos_userdefaults using corefoundation gem #11898
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
Conversation
@rishichawda This POC code is already reviewed and could really help, #11785 |
@logwolvy Yeah I had seen that code when the PR was raised and it was incorrect somewhere in the start itself so I didn't refer to it further. I did go through the thread in the PR though and kept those in mind while working on the resource. 😄 |
b7eaebf
to
b337b55
Compare
@rishichawda Could you point to that? Let's check if that works and re-use |
Yeah I think it was the method call in load current value at the start. That wouldn't work. Anyways, the resource has already been updated in this branch so it doesn't seem like a good use of time to go back to an old code and fix it when we don't need it anymore. |
That POC code was working and already reviewed, so that was a head start anyway. Moving on, I recommend, checking/reusing as much as possible before starting out since we are time bound in development/review efforts. |
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.
Also, this would absolutely require kitchen tests
end | ||
end | ||
|
||
action :delete, description: "Delete a key from a domain." do | ||
# if it's not there there's nothing to remove | ||
return unless current_resource |
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 need not be changed
end | ||
end | ||
|
||
action_class do |
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.
using action_class
would make passing new_resource
redundant, a good thing here
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.
action_class
context is not available to load_current_resource
.
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.
not referring to load_current_resource
here
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
be057ab
to
37cccb1
Compare
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
468c998
to
162e387
Compare
chef.gemspec
Outdated
@@ -52,6 +52,7 @@ Gem::Specification.new do |s| | |||
s.add_dependency "addressable" | |||
s.add_dependency "syslog-logger", "~> 1.6" | |||
s.add_dependency "uuidtools", ">= 2.1.5", "< 3.0" # osx_profile resource | |||
s.add_dependency "corefoundation", "~> 0.3.4" # corefoundation framework utilities |
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.
the comment should say where we're using it more than what it gives us.
# macos_userdefaults
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.
Done.
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
d521866
to
c39731e
Compare
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
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.
end | ||
def set_preference(new_resource) | ||
CF::Preferences.set!(new_resource.key, new_resource.value, new_resource.domain, new_resource.user, new_resource.host) | ||
end |
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.
don't think this method is getting used (might be causing some confusion over the action_class block)
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.
oh yeah I might have overlooked this after I moved the call directly inside the action.. will remove this now.. Thank you!
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.
the :write
action was using this function but :delete
was using the .set!
method from CF
directly. Changed the :write
to also use set!
method in 858cc22.
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
2a96bf8
to
858cc22
Compare
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
4d28605
to
6d61daa
Compare
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
6d61daa
to
1b811ab
Compare
cmd | ||
end | ||
action_class do | ||
require "corefoundation" if RUBY_PLATFORM.match?(/darwin/) |
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.
would it work if this was declared at the top?
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.
actions won't find the module then so it needs to go here 🤷🏻♂️
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
Signed-off-by: rishichawda rishichawda@users.noreply.github.com
Rewrite of
macos_userdefaults
resource using the corefoundation gem.Description
Replace usage of
defaults
command and use the preference interface from the corefoundation gem we're developing at corefoundation.NOTE: The tests in the pipeline would currently fail for this PR since I'm developing it against a local version of the corefoundation gem. All updates are being tracked in PRs on the gem's repo. Once the required changes are released, we can update the Gemfile in this branch.
Related Issue
#10307
#10083
https://github.com/chef/desktop-config/issues/214
Types of changes
Checklist: