Skip to content

Commit 2423184

Browse files
committed
mgr/dashboard: fix cephfs name validation
allow volume name to start with dot (.) Fixes: https://tracker.ceph.com/issues/65143 Signed-off-by: Nizamudeen A <[email protected]>
1 parent 50d48d9 commit 2423184

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
i18n>This field is required!</span>
4848
<span *ngIf="form.showError('name', formDir, 'pattern')"
4949
class="invalid-feedback"
50-
i18n>File System name should start with a letter and can only contain letters, numbers, '.', '-' or '_'</span>
50+
i18n>File System name should start with a letter or dot (.) and can only contain letters, numbers, '.', '-' or '_'</span>
5151
</div>
5252
</div>
5353

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ describe('CephfsVolumeFormComponent', () => {
4242
});
4343

4444
it('should validate proper names', fakeAsync(() => {
45-
const validNames = ['test', 'test1234', 'test_1234', 'test-1234', 'test.1234', 'test12test'];
45+
const validNames = [
46+
'test',
47+
'test1234',
48+
'test_1234',
49+
'test-1234',
50+
'test.1234',
51+
'test12test',
52+
'.test'
53+
];
4654
const invalidNames = ['1234', 'test@', 'test)'];
4755

4856
for (const validName of validNames) {

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ export class CephfsVolumeFormComponent extends CdForm implements OnInit {
8787
});
8888
this.form = this.formBuilder.group({
8989
name: new FormControl('', {
90-
validators: [Validators.pattern(/^[a-zA-Z][.A-Za-z0-9_-]+$/), Validators.required]
90+
validators: [
91+
Validators.pattern(/^(?:[.][A-Za-z0-9_-]+|[A-Za-z][.A-Za-z0-9_-]*)$/),
92+
Validators.required
93+
]
9194
}),
9295
placement: ['hosts'],
9396
hosts: [[]],

0 commit comments

Comments
 (0)