Skip to content

Commit 64fe139

Browse files
authored
Merge pull request #172 from Microsoft/release/2.9
Release/2.9
2 parents ff376ba + cb49318 commit 64fe139

File tree

12 files changed

+148
-11
lines changed

12 files changed

+148
-11
lines changed
File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Bug Report
3+
about: Create a report to help us improve
4+
title: "[BUG]"
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
## Describe the Bug
11+
A clear and concise description of what the bug is.
12+
13+
## Error Message
14+
Error message(s) if any.
15+
16+
## Chef Exception
17+
Chef exception(s) if any.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Feature Request
3+
about: Suggest an idea for this project
4+
title: "[FEATURE]"
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
## Describe the feature
11+
A clear and concise description of what the feature is.
12+
13+
## Describe the reasoning behind the feature
14+
A clear and concise description of why the feature should be implemented.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Pull Request
3+
about: File a pull request to help us improve
4+
title: "[PR]"
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
## Describe the Pull Request
11+
A clear and concise description of what the Pull Request aims to do.
12+
13+
## Justification
14+
A clear and concise description of issues the Pull Requests solves if any.

.kitchen.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ suites:
8585
- dock-appearance
8686
- show-all-files
8787
- updates-disabled
88+
- plist-creation
8889

8990
- name: power-management
9091
provisioner:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
3+
## [2.9.0] - 2018-12-06
4+
### Added
5+
- Added templates for bug reports, feature requests, and pull requests to adhere with Github's [recommended community standards](https://opensource.guide).
6+
- Added support for owner/group in the plist resource. Allows for plist files to be created under a specific owner. Defaults to root/wheel for compatibility with earlier versions of the cookbook. ([Issue #51](https://github.com/Microsoft/macos-cookbook/issues/51))
7+
- Added support for setting the mode property when creating a plist using the `plist` resource. This allows control over setting the file permissions. ([Issue #51](https://github.com/Microsoft/macos-cookbook/issues/51))
8+
39
## [2.8.1] - 2018-11-29
410
### Fixed
511
- Fixed an issue where the path for the `xcversion` utility was hard-coded when installed as a Chef gem, which caused failures when converging with ChefDK or Workstation.

documentation/resource_plist.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ plist 'description' do
3131
value TrueClass, FalseClass, String, Integer, Float
3232
action Symbol # defaults to :set if not specified
3333
encoding String # defaults to 'binary' if not specified.
34+
owner String # defaults to 'root' if not specified.
35+
group String # defaults to 'wheel' if not specified.
36+
mode String, Integer
3437
end
3538
```
3639

metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
description 'Resources for configuring and provisioning macOS'
66
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
77
chef_version '>= 13.0' if respond_to?(:chef_version)
8-
version '2.8.1'
8+
version '2.9.0'
99

1010
source_url 'https://github.com/Microsoft/macos-cookbook'
1111
issues_url 'https://github.com/Microsoft/macos-cookbook/issues'

resources/plist.rb

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
property :entry, String, desired_state: true
55
property :value, [TrueClass, FalseClass, String, Integer, Float], desired_state: true
66
property :encoding, String, desired_state: true, default: 'binary'
7+
property :owner, String, desired_state: true, default: 'root'
8+
property :group, String, desired_state: true, default: 'wheel'
9+
property :mode, [String, Integer]
710

811
load_current_value do |desired|
912
current_value_does_not_exist! unless ::File.exist? desired.path
@@ -14,20 +17,23 @@
1417

1518
file_type_cmd = shell_out '/usr/bin/file', '--brief', '--mime-encoding', '--preserve-date', desired.path
1619
encoding file_type_cmd.stdout.chomp
20+
21+
file_owner_cmd = shell_out('/usr/bin/stat', '-f', '%Su', desired.path)
22+
owner file_owner_cmd.stdout.chomp
23+
24+
file_group_cmd = shell_out('/usr/bin/stat', '-f', '%Sg', desired.path)
25+
group file_group_cmd.stdout.chomp
1726
end
1827

1928
action :set do
2029
converge_if_changed :path do
2130
converge_by "create new plist: '#{new_resource.path}'" do
2231
file new_resource.path do
23-
content <<-EOF
24-
<?xml version="1.0" encoding="UTF-8"?>
25-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
26-
<plist version="1.0">
27-
<dict>
28-
</dict>
29-
</plist>
30-
EOF
32+
empty_plist = {}.to_plist
33+
content empty_plist
34+
owner new_resource.owner
35+
group new_resource.group
36+
mode new_resource.mode if property_is_set?(:mode)
3137
end
3238
end
3339
end
@@ -60,4 +66,20 @@
6066
end
6167
end
6268
end
69+
70+
converge_if_changed :owner do
71+
converge_by "update owner to #{new_resource.owner}" do
72+
file new_resource.path do
73+
owner new_resource.owner
74+
end
75+
end
76+
end
77+
78+
converge_if_changed :group do
79+
converge_by "update group to #{new_resource.group}" do
80+
file new_resource.path do
81+
group new_resource.group
82+
end
83+
end
84+
end
6385
end
Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,45 @@
1+
dock_plist = '/Users/vagrant/Library/Preferences/com.apple.dock.plist'
2+
macoscookbook_plist = '/Users/vagrant/com.microsoft.macoscookbook.plist'
3+
14
plist 'show hidden files' do
25
path '/Users/vagrant/Library/Preferences/com.apple.finder.plist'
36
entry 'AppleShowAllFiles'
47
value true
8+
owner 'vagrant'
9+
group 'staff'
510
end
611

712
plist 'put the Dock on the left side' do
8-
path '/Users/vagrant/Library/Preferences/com.apple.dock.plist'
13+
path dock_plist
914
entry 'orientation'
1015
value 'left'
16+
owner 'vagrant'
17+
group 'staff'
1118
end
1219

1320
plist 'disable window animations and Get Info animations' do
14-
path '/Users/vagrant/Library/Preferences/com.apple.dock.plist'
21+
path dock_plist
1522
entry 'DisableAllAnimations'
1623
value true
24+
owner 'vagrant'
25+
group 'staff'
26+
end
27+
28+
plist 'create a plist that does not exist to test plist creation' do
29+
path macoscookbook_plist
30+
entry 'PokeballEatenByDog'
31+
value true
32+
owner 'vagrant'
33+
group 'staff'
34+
encoding 'us-ascii'
35+
mode '0600'
36+
end
37+
38+
plist 'add another value to the new plist' do
39+
path macoscookbook_plist
40+
entry 'CaughtEmAll'
41+
value false
42+
owner 'vagrant'
43+
group 'staff'
44+
encoding 'us-ascii'
1745
end

0 commit comments

Comments
 (0)