Skip to content

Commit 3246d92

Browse files
authored
Merge pull request #1048 from hooten/modules9915
(MODULES-9915) Add type aliases for cloud object store uris
2 parents 353352a + f86c4b2 commit 3246d92

7 files changed

Lines changed: 150 additions & 0 deletions

File tree

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,51 @@ Match an IPv6 address which may contain `::` used to compress zeros as documente
458458
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',
459459
but not 'FF01:0:0:0:0:0:0:101', 'FF01::101', '::').
460460

461+
#### `Stdlib::ObjectStore`
462+
463+
Matches cloud object store uris.
464+
465+
Acceptable input example:
466+
467+
```shell
468+
s3://mybucket/path/to/file
469+
470+
gs://bucket/file
471+
472+
```
473+
Valid values: cloud object store uris.
474+
475+
476+
#### `Stdlib::ObjectStore::GSUri`
477+
478+
Matches Google Cloud object store uris.
479+
480+
Acceptable input example:
481+
482+
```shell
483+
484+
gs://bucket/file
485+
486+
gs://bucket/path/to/file
487+
488+
```
489+
Valid values: Google Cloud object store uris.
490+
491+
492+
#### `Stdlib::ObjectStore::S3Uri`
493+
494+
Matches Amazon Web Services S3 object store uris.
495+
496+
Acceptable input example:
497+
498+
```shell
499+
s3://bucket/file
500+
501+
s3://bucket/path/to/file
502+
503+
```
504+
Valid values: Amazon Web Services S3 object store uris.
505+
461506
<a id="facts"></a>
462507
### Facts
463508

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'spec_helper'
2+
3+
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
4+
describe 'Stdlib::ObjectStore::GSUri' do
5+
describe 'accepts case-sensitive google cloud gs uris' do
6+
[
7+
'gs://mybucket/myfile.csv',
8+
'gs://bucket/path/to/file.tar.gz',
9+
].each do |value|
10+
describe value.inspect do
11+
it { is_expected.to allow_value(value) }
12+
end
13+
end
14+
end
15+
16+
describe 'rejects other values' do
17+
[
18+
'',
19+
'GS://mybucket/myfile.csv',
20+
5,
21+
'gs//mybucket/myfile.csv',
22+
'gs:/mybucket/myfile.csv',
23+
'gs:mybucket/myfile.csv',
24+
'gs-mybucket/myfile.csv',
25+
].each do |value|
26+
describe value.inspect do
27+
it { is_expected.not_to allow_value(value) }
28+
end
29+
end
30+
end
31+
end
32+
end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'spec_helper'
2+
3+
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
4+
describe 'Stdlib::ObjectStore::S3Uri' do
5+
describe 'accepts case-sensitive amazon web services s3 uris' do
6+
[
7+
's3://bucket-name/path',
8+
's3://bucket/path/to/file.txt',
9+
].each do |value|
10+
describe value.inspect do
11+
it { is_expected.to allow_value(value) }
12+
end
13+
end
14+
end
15+
16+
describe 'rejects other values' do
17+
[
18+
'',
19+
'S3://bucket-name/path',
20+
3,
21+
's3:/bucket-name/path',
22+
's3//bucket-name/path',
23+
's3:bucket-name/path',
24+
's3-bucket-name/path',
25+
].each do |value|
26+
describe value.inspect do
27+
it { is_expected.not_to allow_value(value) }
28+
end
29+
end
30+
end
31+
end
32+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
require 'spec_helper'
2+
3+
if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0
4+
describe 'Stdlib::ObjectStore' do
5+
describe 'accepts case-sensitive google cloud gs or amazon web services s3 uris' do
6+
[
7+
's3://bucket-name/path',
8+
's3://bucket/path/to/file.txt',
9+
'gs://mybucket/myfile.csv',
10+
'gs://bucket/path/to/file.tar.gz',
11+
].each do |value|
12+
describe value.inspect do
13+
it { is_expected.to allow_value(value) }
14+
end
15+
end
16+
end
17+
18+
describe 'rejects other values' do
19+
[
20+
'',
21+
'S3://bucket/path',
22+
'GS://bucket/path',
23+
5,
24+
3,
25+
'gs//bucket/path/to/file',
26+
's3//bucket/path/to/file',
27+
].each do |value|
28+
describe value.inspect do
29+
it { is_expected.not_to allow_value(value) }
30+
end
31+
end
32+
end
33+
end
34+
end

types/objectstore.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
type Stdlib::ObjectStore = Variant[
2+
Stdlib::ObjectStore::GSUri,
3+
Stdlib::ObjectStore::S3Uri,
4+
]

types/objectstore/gsuri.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type Stdlib::ObjectStore::GSUri = Pattern[/^gs:\/\//]
2+

types/objectstore/s3uri.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Stdlib::ObjectStore::S3Uri = Pattern[/^s3:\/\//]

0 commit comments

Comments
 (0)