Skip to content

Commit f4d8694

Browse files
authored
Merge pull request ceph#64827 from rhcs-dashboard/72408-rgw-crypt-kmip-addr-format-change
mgr/dashboard: rgw_crypt_kmip_addr in SSE-KMS kmip address input field validation updated Reviewed-by: Aashish Sharma <[email protected]> Reviewed-by: Ankush Behl <[email protected]>
2 parents 4a7d36d + 4aa462b commit f4d8694

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-config-modal/rgw-config-modal.component.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import { KmipConfig, VaultConfig } from '~/app/shared/models/rgw-encryption-conf
2525
styleUrls: ['./rgw-config-modal.component.scss']
2626
})
2727
export class RgwConfigModalComponent implements OnInit {
28-
readonly vaultAddress = /^((https?:\/\/)|(www.))(?:([a-zA-Z]+)|(\d+\.\d+.\d+.\d+)):\d{4}$/;
29-
3028
kmsProviders: string[];
3129

3230
configForm: CdFormGroup;
@@ -133,18 +131,7 @@ export class RgwConfigModalComponent implements OnInit {
133131

134132
createForm() {
135133
this.configForm = this.formBuilder.group({
136-
addr: [
137-
null,
138-
[
139-
Validators.required,
140-
CdValidators.custom('vaultPattern', (value: string) => {
141-
if (_.isEmpty(value)) {
142-
return false;
143-
}
144-
return !this.vaultAddress.test(value);
145-
})
146-
]
147-
],
134+
addr: [null, [CdValidators.urlWithProtocolOption(false), Validators.required]],
148135
kms_provider: ['vault', Validators.required],
149136
encryptionType: ['kms', Validators.required],
150137
auth: [

src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,20 @@ export class CdValidators {
689689
* Validator function to validate endpoints, allowing FQDN, IPv4, and IPv6 addresses with ports.
690690
* Accepts multiple endpoints separated by commas.
691691
*/
692+
692693
static url(control: AbstractControl): ValidationErrors | null {
694+
return CdValidators.urlInternal(control, true);
695+
}
696+
697+
static urlWithProtocolOption(require_protocol: boolean) {
698+
return (control: AbstractControl): ValidationErrors | null =>
699+
CdValidators.urlInternal(control, require_protocol);
700+
}
701+
702+
private static urlInternal(
703+
control: AbstractControl,
704+
require_protocol: boolean
705+
): ValidationErrors | null {
693706
const value = control.value;
694707

695708
if (_.isEmpty(value)) {
@@ -701,7 +714,7 @@ export class CdValidators {
701714
const invalidUrls = urls.filter(
702715
(url: string) =>
703716
!validator.isURL(url, {
704-
require_protocol: true,
717+
require_protocol: require_protocol,
705718
allow_underscores: true,
706719
require_tld: false
707720
}) && !validator.isIP(url)

0 commit comments

Comments
 (0)