Skip to content

Commit

Permalink
Allow group attribute of s3_file to be String or Integer
Browse files Browse the repository at this point in the history
As the resource remote_file allows type String or Integer for the group attribute, s3_file should do the same. (https://docs.chef.io/resources/remote_file/)

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the
    best of my knowledge, is covered under an appropriate open
    source license and I have the right under that license to
    submit that work with modifications, whether created in whole
    or in part by me, under the same open source license (unless
    I am permitted to submit under a different license), as
    Indicated in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including
    all personal information I submit with it, including my
    sign-off) is maintained indefinitely and may be redistributed
    consistent with this project or the open source license(s)
    involved.

Signed-off-by: David Schmidt <david.dv.schmidt@deutschebahn.com>
  • Loading branch information
DavidSchmidt00 committed Aug 15, 2023
1 parent f9c0b71 commit a49fbdf
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the aws cookbook.

## Unreleased

Allow group attribute of s3_file to be String or Integer

## 9.0.16 - *2023-07-10*

## 9.0.15 - *2023-05-17*
Expand Down
2 changes: 1 addition & 1 deletion resources/s3_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
property :bucket, String
property :requester_pays, [true, false], default: false
property :owner, String, regex: Chef::Config[:user_valid_regex]
property :group, String, regex: Chef::Config[:group_valid_regex]
property :group, [String, Integer], regex: Chef::Config[:group_valid_regex]
property :mode, [String, nil]
property :checksum, [String, nil]
property :backup, [Integer, false], default: 5
Expand Down
26 changes: 26 additions & 0 deletions test/fixtures/cookbooks/aws_test/recipes/s3_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,29 @@
aws_session_token node['aws_test']['session_token']
region 'us-west-2'
end

# create group to test if group property works
group 'testgroup' do
gid 4711
action :create
end

# create a s3_file with a group specified by its name
aws_s3_file '/tmp/file_with_group_by_name' do
bucket node['aws_test']['bucket']
remote_path node['aws_test']['s3key']
aws_access_key node['aws_test']['key_id']
aws_secret_access_key node['aws_test']['access_key']
aws_session_token node['aws_test']['session_token']
group 'testgroup'
end

# create a s3_file with a group specified by its gid
aws_s3_file '/tmp/file_with_group_by_gid' do
bucket node['aws_test']['bucket']
remote_path node['aws_test']['s3key']
aws_access_key node['aws_test']['key_id']
aws_secret_access_key node['aws_test']['access_key']
aws_session_token node['aws_test']['session_token']
group 4712
end
9 changes: 9 additions & 0 deletions test/integration/s3_file/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@
describe file('/tmp/a_file') do
it { should be_file }
end

describe file('/tmp/file_with_group_by_name') do
it { should be_file }
its('group') { should eq 'testgroup' }
end

describe file('/tmp/file_with_group_by_gid') do
it { should be_file }
end

0 comments on commit a49fbdf

Please sign in to comment.