Skip to content

Commit

Permalink
Merge pull request #1048 from hooten/modules9915
Browse files Browse the repository at this point in the history
(MODULES-9915) Add type aliases for cloud object store uris
  • Loading branch information
tphoney committed Sep 17, 2019
2 parents 353352a + f86c4b2 commit 3246d92
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,51 @@ Match an IPv6 address which may contain `::` used to compress zeros as documente
Match an IPv6 address in the CIDR format. It will only match if the address contains an address prefix (for example, it will match 'FF01:0:0:0:0:0:0:101/32', 'FF01::101/60', '::/0',
but not 'FF01:0:0:0:0:0:0:101', 'FF01::101', '::').

#### `Stdlib::ObjectStore`

Matches cloud object store uris.

Acceptable input example:

```shell
s3://mybucket/path/to/file
gs://bucket/file
```
Valid values: cloud object store uris.


#### `Stdlib::ObjectStore::GSUri`

Matches Google Cloud object store uris.

Acceptable input example:

```shell
gs://bucket/file
gs://bucket/path/to/file
```
Valid values: Google Cloud object store uris.


#### `Stdlib::ObjectStore::S3Uri`

Matches Amazon Web Services S3 object store uris.

Acceptable input example:

```shell
s3://bucket/file
s3://bucket/path/to/file
```
Valid values: Amazon Web Services S3 object store uris.

<a id="facts"></a>
### Facts

Expand Down
32 changes: 32 additions & 0 deletions spec/type_aliases/objectstore_gsuri_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'spec_helper'

if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
describe 'Stdlib::ObjectStore::GSUri' do
describe 'accepts case-sensitive google cloud gs uris' do
[
'gs://mybucket/myfile.csv',
'gs://bucket/path/to/file.tar.gz',
].each do |value|
describe value.inspect do
it { is_expected.to allow_value(value) }
end
end
end

describe 'rejects other values' do
[
'',
'GS://mybucket/myfile.csv',
5,
'gs//mybucket/myfile.csv',
'gs:/mybucket/myfile.csv',
'gs:mybucket/myfile.csv',
'gs-mybucket/myfile.csv',
].each do |value|
describe value.inspect do
it { is_expected.not_to allow_value(value) }
end
end
end
end
end
32 changes: 32 additions & 0 deletions spec/type_aliases/objectstore_s3uri_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'spec_helper'

if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
describe 'Stdlib::ObjectStore::S3Uri' do
describe 'accepts case-sensitive amazon web services s3 uris' do
[
's3://bucket-name/path',
's3://bucket/path/to/file.txt',
].each do |value|
describe value.inspect do
it { is_expected.to allow_value(value) }
end
end
end

describe 'rejects other values' do
[
'',
'S3://bucket-name/path',
3,
's3:/bucket-name/path',
's3//bucket-name/path',
's3:bucket-name/path',
's3-bucket-name/path',
].each do |value|
describe value.inspect do
it { is_expected.not_to allow_value(value) }
end
end
end
end
end
34 changes: 34 additions & 0 deletions spec/type_aliases/objectstore_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'spec_helper'

if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
describe 'Stdlib::ObjectStore' do
describe 'accepts case-sensitive google cloud gs or amazon web services s3 uris' do
[
's3://bucket-name/path',
's3://bucket/path/to/file.txt',
'gs://mybucket/myfile.csv',
'gs://bucket/path/to/file.tar.gz',
].each do |value|
describe value.inspect do
it { is_expected.to allow_value(value) }
end
end
end

describe 'rejects other values' do
[
'',
'S3://bucket/path',
'GS://bucket/path',
5,
3,
'gs//bucket/path/to/file',
's3//bucket/path/to/file',
].each do |value|
describe value.inspect do
it { is_expected.not_to allow_value(value) }
end
end
end
end
end
4 changes: 4 additions & 0 deletions types/objectstore.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type Stdlib::ObjectStore = Variant[
Stdlib::ObjectStore::GSUri,
Stdlib::ObjectStore::S3Uri,
]
2 changes: 2 additions & 0 deletions types/objectstore/gsuri.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type Stdlib::ObjectStore::GSUri = Pattern[/^gs:\/\//]

1 change: 1 addition & 0 deletions types/objectstore/s3uri.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Stdlib::ObjectStore::S3Uri = Pattern[/^s3:\/\//]

0 comments on commit 3246d92

Please sign in to comment.