Skip to content

Commit

Permalink
Allow group and owner attributes of s3_file to be String or Integer (#…
Browse files Browse the repository at this point in the history
…476)

* Allow group attribute of s3_file to be String or Integer

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>

* Update dead link

* Allow owner attribute of s3_file to be String or Integer

As the resource remote_file allows type String or Integer for the owner 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>

---------

Signed-off-by: David Schmidt <david.dv.schmidt@deutschebahn.com>
  • Loading branch information
DavidSchmidt00 authored Aug 17, 2023
1 parent f9c0b71 commit 08901ec
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
4 changes: 3 additions & 1 deletion 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 attributes group and owner of s3_file to be String or Integer

## 9.0.16 - *2023-07-10*

## 9.0.15 - *2023-05-17*
Expand Down Expand Up @@ -88,7 +90,7 @@ Update checkout to v3 in ci.yml

## 8.3.1 (2020-12-04)

- Resolve cookstyle warnings - [@cookstyle](https://github.com/cookstyle)
- Resolve cookstyle warnings - [@cookstyle](https://github.com/chef/cookstyle)
- Update AWS S3 gem dependency - [@arothian](https://github.com/arothian)

## 8.3.0 (2020-08-06)
Expand Down
4 changes: 2 additions & 2 deletions resources/s3_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
property :region, String, default: lazy { fallback_region }
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 :owner, [String, Integer], regex: Chef::Config[:user_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 08901ec

Please sign in to comment.