]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix cephfs name validation 56501/head
authorNizamudeen A <nia@redhat.com>
Tue, 26 Mar 2024 07:53:39 +0000 (13:23 +0530)
committerNizamudeen A <nia@redhat.com>
Wed, 27 Mar 2024 04:36:02 +0000 (10:06 +0530)
allow volume name to start with dot (.)

Fixes: https://tracker.ceph.com/issues/65143
Signed-off-by: Nizamudeen A <nia@redhat.com>
(cherry picked from commit 242318452c8111717e49b896c7f9cf0ec5f5b262)

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 05235d16ccd44989977a88388c774245c342de8a..71e31e2d0c00395e74701cb677f76dba0a95538d 100644 (file)
@@ -35,7 +35,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 461f4bca052d85f49d0a2dceb925cdca770587a9..4ec520577f928987cb938506b62acc094d7625f6 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 6d84e33c7b6145197c9c00eb3ab4ff57b1a43ae2..dfd7cbfe4a1ef44f6480b1cfe96162d45c6ae9fd 100644 (file)
@@ -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: [[]],