]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix cephfs name validation 56463/head
authorNizamudeen A <nia@redhat.com>
Tue, 26 Mar 2024 07:53:39 +0000 (13:23 +0530)
committerNizamudeen A <nia@redhat.com>
Tue, 26 Mar 2024 09:46:42 +0000 (15:16 +0530)
allow volume name to start with dot (.)

Fixes: https://tracker.ceph.com/issues/65143
Signed-off-by: Nizamudeen A <nia@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts

index f8d0fa80320405fb2f7e2a33de13a44901d006be..958a4bff2a2d68160b385c0e37a108ca2b986ec0 100644 (file)
@@ -47,7 +47,7 @@
                   i18n>This field is required!</span>
             <span *ngIf="form.showError('name', formDir, 'pattern')"
                   class="invalid-feedback"
-                  i18n>File System name should start with a letter and can only contain letters, numbers, '.', '-' or '_'</span>
+                  i18n>File System name should start with a letter or dot (.) and can only contain letters, numbers, '.', '-' or '_'</span>
           </div>
         </div>
 
index 520f726d5553c57e99a1d2b5b0463d5daf78eefd..3bcedd1cd66931ec45e9e4663cdb9b78e5fff1e8 100644 (file)
@@ -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) {
index b0f90979c252b4b4b335eb5a7be702d5f470e57b..dbbe522fa0a19f6b48549c90924c43d63a889874 100644 (file)
@@ -87,7 +87,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: [[]],