From f528de30aef86a2f57eac48cf6dd9fd048aa814c Mon Sep 17 00:00:00 2001 From: yzamir Date: Wed, 20 Sep 2023 10:39:43 +0300 Subject: [PATCH] Add project and reagion as required fields to all openstack authentications Signed-off-by: yzamir --- .../secret/openstackSecretValidator.ts | 22 ++++++++-- ...ionCredentialNameSecretFieldsFormGroup.tsx | 42 +++++++++++++++++++ .../ApplicationWithCredentialsIDFormGroup.tsx | 42 +++++++++++++++++++ .../TokenWithUserIDSecretFieldsFormGroup.tsx | 23 ++++++++++ ...TokenWithUsernameSecretFieldsFormGroup.tsx | 24 +++++++++++ 5 files changed, 150 insertions(+), 3 deletions(-) diff --git a/packages/forklift-console-plugin/src/modules/Providers/utils/validators/secret/openstackSecretValidator.ts b/packages/forklift-console-plugin/src/modules/Providers/utils/validators/secret/openstackSecretValidator.ts index 573a17413..d344f08a2 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/utils/validators/secret/openstackSecretValidator.ts +++ b/packages/forklift-console-plugin/src/modules/Providers/utils/validators/secret/openstackSecretValidator.ts @@ -35,8 +35,15 @@ export function openstackSecretValidator(secret: V1Secret) { 'insecureSkipVerify', ]; } else { - requiredFields = ['token', 'userID', 'projectID']; - validateFields = ['token', 'userID', 'projectID', 'cacert', 'insecureSkipVerify']; + requiredFields = ['token', 'userID', 'projectID', 'domainName']; + validateFields = [ + 'token', + 'userID', + 'projectID', + 'domainName', + 'cacert', + 'insecureSkipVerify', + ]; } break; case 'applicationcredential': @@ -45,23 +52,32 @@ export function openstackSecretValidator(secret: V1Secret) { 'applicationCredentialName', 'applicationCredentialSecret', 'username', + 'projectName', 'domainName', ]; validateFields = [ 'applicationCredentialName', 'applicationCredentialSecret', 'username', + 'projectName', 'domainName', 'cacert', 'insecureSkipVerify', ]; } else { - requiredFields = ['applicationCredentialID', 'applicationCredentialSecret']; + requiredFields = [ + 'applicationCredentialID', + 'applicationCredentialSecret', + 'projectName', + 'domainName', + ]; validateFields = [ 'applicationCredentialID', 'applicationCredentialSecret', 'cacert', 'insecureSkipVerify', + 'projectName', + 'domainName', ]; } break; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/components/CredentialsSection/components/edit/OpenstackCredentialsEditFormGroups/ApplicationCredentialNameSecretFieldsFormGroup.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/components/CredentialsSection/components/edit/OpenstackCredentialsEditFormGroups/ApplicationCredentialNameSecretFieldsFormGroup.tsx index 20def945c..5f50481cb 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/components/CredentialsSection/components/edit/OpenstackCredentialsEditFormGroups/ApplicationCredentialNameSecretFieldsFormGroup.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/components/CredentialsSection/components/edit/OpenstackCredentialsEditFormGroups/ApplicationCredentialNameSecretFieldsFormGroup.tsx @@ -25,6 +25,8 @@ export const ApplicationCredentialNameSecretFieldsFormGroup: React.FC + + handleChange('regionName', value)} + validated={state.validation.regionName} + /> + + + + handleChange('projectName', value)} + validated={state.validation.projectName} + /> + + const applicationCredentialSecret = safeBase64Decode( secret?.data?.applicationCredentialSecret || '', ); + const regionName = safeBase64Decode(secret?.data?.regionName || ''); + const projectName = safeBase64Decode(secret?.data?.projectName || ''); const initialState = { passwordHidden: true, validation: { applicationCredentialID: 'default' as Validation, applicationCredentialSecret: 'default' as Validation, + regionName: 'default' as Validation, + projectName: 'default' as Validation, }, }; @@ -114,6 +118,44 @@ export const ApplicationWithCredentialsIDFormGroup: React.FC {state.passwordHidden ? : } + + + handleChange('regionName', value)} + validated={state.validation.regionName} + /> + + + + handleChange('projectName', value)} + validated={state.validation.projectName} + /> + ); }; diff --git a/packages/forklift-console-plugin/src/modules/Providers/views/details/components/CredentialsSection/components/edit/OpenstackCredentialsEditFormGroups/TokenWithUserIDSecretFieldsFormGroup.tsx b/packages/forklift-console-plugin/src/modules/Providers/views/details/components/CredentialsSection/components/edit/OpenstackCredentialsEditFormGroups/TokenWithUserIDSecretFieldsFormGroup.tsx index 112d3dbf9..fd9d0e93a 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/views/details/components/CredentialsSection/components/edit/OpenstackCredentialsEditFormGroups/TokenWithUserIDSecretFieldsFormGroup.tsx +++ b/packages/forklift-console-plugin/src/modules/Providers/views/details/components/CredentialsSection/components/edit/OpenstackCredentialsEditFormGroups/TokenWithUserIDSecretFieldsFormGroup.tsx @@ -22,6 +22,7 @@ export const TokenWithUserIDSecretFieldsFormGroup: React.FC const token = safeBase64Decode(secret?.data?.token || ''); const userID = safeBase64Decode(secret?.data?.userID || ''); const projectID = safeBase64Decode(secret?.data?.projectID || ''); + const regionName = safeBase64Decode(secret?.data?.regionName || ''); const initialState = { passwordHidden: true, @@ -29,6 +30,7 @@ export const TokenWithUserIDSecretFieldsFormGroup: React.FC token: 'default' as Validation, userID: 'default' as Validation, projectID: 'default' as Validation, + regionName: 'default' as Validation, }, }; @@ -94,6 +96,7 @@ export const TokenWithUserIDSecretFieldsFormGroup: React.FC {state.passwordHidden ? : } + validated={state.validation.userID} /> + + + handleChange('regionName', value)} + validated={state.validation.regionName} + /> + + : } + + + + handleChange('regionName', value)} + validated={state.validation.regionName} + /> + + +