Allow using device uuid in storage::mount

Previously, the `swift::storage::mount` allowed any type of string,
making it possible to use UUID=4aa242a4-0ab3-4037-9137-1d58c7f2b5f8 or
even 4aa242a4-0ab3-4037-9137-1d58c7f2b5f8 for example. But now, as
the device parameter is Swift::MountDevice, this cannot be done.

This patch fixes this regression.

Change-Id: I57619c628ee7a6d5e60260235fbd6d83f514be83
This commit is contained in:
Thomas Goirand 2024-05-01 17:03:26 +02:00 committed by Takashi Kajinami
parent 9ac945a2cb
commit f07444d3c4
2 changed files with 13 additions and 3 deletions

View File

@ -7,7 +7,9 @@ describe 'Swift::MountDevice' do
'/dev',
'/dev/sda',
'/opt/swift/diskfile',
'LABEL=foo'
'LABEL=foo',
'50e68500-9920-4ffa-a4cd-34fd2a893530',
'UUID=50e68500-9920-4ffa-a4cd-34fd2a893530',
].each do |value|
it { is_expected.to allow_value(value) }
end
@ -24,7 +26,13 @@ describe 'Swift::MountDevice' do
'dev',
'dev/sda',
'LABEL=',
'LABELfoo'
'LABELfoo',
'50e6850099204ffaa4cd34fd2a893530',
'50e68500-9920-3ffa-a4cd-34fd2a893530',
'UUID=',
'UUID=foo',
'UUID=50e6850099204ffaa4cd34fd2a893530',
'UUID=50e68500-9920-3ffa-a4cd-34fd2a893530',
].each do |value|
it { is_expected.not_to allow_value(value) }
end

View File

@ -1,4 +1,6 @@
type Swift::MountDevice = Variant[
Stdlib::Absolutepath,
Pattern[/^LABEL=.+$/]
Pattern[/^LABEL=.+$/],
Pattern[/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$/],
Pattern[/^UUID=[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$/],
]