From 5a798f97a5ce71dffd87da6766baf9825606671a Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Tue, 26 Mar 2024 13:23:39 +0530 Subject: [PATCH] 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 (cherry picked from commit 242318452c8111717e49b896c7f9cf0ec5f5b262) --- .../ceph/cephfs/cephfs-form/cephfs-form.component.html | 2 +- .../cephfs/cephfs-form/cephfs-form.component.spec.ts | 10 +++++++++- .../ceph/cephfs/cephfs-form/cephfs-form.component.ts | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html index 05235d16ccd44..71e31e2d0c003 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html @@ -35,7 +35,7 @@ i18n>This field is required! File System name should start with a letter and can only contain letters, numbers, '.', '-' or '_' + i18n>File System name should start with a letter or dot (.) and can only contain letters, numbers, '.', '-' or '_' diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts index 461f4bca052d8..4ec520577f928 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts @@ -42,7 +42,15 @@ describe('CephfsVolumeFormComponent', () => { }); it('should validate proper names', fakeAsync(() => { - const validNames = ['test', 'test1234', 'test_1234', 'test-1234', 'test.1234', 'test12test']; + const validNames = [ + 'test', + 'test1234', + 'test_1234', + 'test-1234', + 'test.1234', + 'test12test', + '.test' + ]; const invalidNames = ['1234', 'test@', 'test)']; for (const validName of validNames) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts index 6d84e33c7b614..dfd7cbfe4a1ef 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts @@ -82,7 +82,10 @@ export class CephfsVolumeFormComponent extends CdForm implements OnInit { }); this.form = this.formBuilder.group({ name: new FormControl('', { - validators: [Validators.pattern(/^[a-zA-Z][.A-Za-z0-9_-]+$/), Validators.required] + validators: [ + Validators.pattern(/^(?:[.][A-Za-z0-9_-]+|[A-Za-z][.A-Za-z0-9_-]*)$/), + Validators.required + ] }), placement: ['hosts'], hosts: [[]], -- 2.39.5