@@ -663,21 +663,31 @@ function DockerForm({
663663
664664 function onValidation ( ) {
665665 if ( selectedDockerRegistryType . value === RegistryType . ECR ) {
666- if (
667- ( ! isIAMAuthType &&
668- ( ! customState . awsAccessKeyId . value || ! ( customState . awsSecretAccessKey . value || id ) ) ) ||
669- ! customState . registryUrl . value
670- ) {
671- setCustomState ( ( st ) => ( {
672- ...st ,
673- awsAccessKeyId : { ...st . awsAccessKeyId , error : st . awsAccessKeyId . value ? '' : 'Mandatory' } ,
674- awsSecretAccessKey : {
675- ...st . awsSecretAccessKey ,
676- error : id || st . awsSecretAccessKey . value ? '' : 'Mandatory' ,
677- } ,
678- registryUrl : { ...st . registryUrl , error : st . registryUrl . value ? '' : 'Mandatory' } ,
679- } ) )
680- return
666+ if ( registryStorageType === RegistryStorageType . OCI_PRIVATE ) {
667+ if (
668+ ( ! isIAMAuthType &&
669+ ( ! customState . awsAccessKeyId . value || ! ( customState . awsSecretAccessKey . value || id ) ) ) ||
670+ ! customState . registryUrl . value
671+ ) {
672+ setCustomState ( ( st ) => ( {
673+ ...st ,
674+ awsAccessKeyId : { ...st . awsAccessKeyId , error : st . awsAccessKeyId . value ? '' : 'Mandatory' } ,
675+ awsSecretAccessKey : {
676+ ...st . awsSecretAccessKey ,
677+ error : id || st . awsSecretAccessKey . value ? '' : 'Mandatory' ,
678+ } ,
679+ registryUrl : { ...st . registryUrl , error : st . registryUrl . value ? '' : 'Mandatory' } ,
680+ } ) )
681+ return
682+ }
683+ } else {
684+ if ( ! customState . registryUrl . value ) {
685+ setCustomState ( ( st ) => ( {
686+ ...st ,
687+ registryUrl : { ...st . registryUrl , error : st . registryUrl . value ? '' : 'Mandatory' } ,
688+ } ) )
689+ return
690+ }
681691 }
682692 } else if ( selectedDockerRegistryType . value === RegistryType . DOCKER_HUB ) {
683693 if (
@@ -697,40 +707,58 @@ function DockerForm({
697707 ) {
698708 const isValidJsonFile = isValidJson ( customState . password . value ) || id
699709 const isValidJsonStr = isValidJsonFile ? '' : 'Invalid JSON'
700- if (
701- ( registryStorageType === RegistryStorageType . OCI_PRIVATE && ! customState . username . value ) ||
702- ! ( customState . password . value || id ) ||
703- ! isValidJsonFile
704- ) {
705- setCustomState ( ( st ) => ( {
706- ...st ,
707- username : { ...st . username , error : st . username . value ? '' : 'Mandatory' } ,
708- password : {
709- ...st . password ,
710- error : id || st . password . value ? isValidJsonStr : 'Mandatory' ,
711- } ,
712- } ) )
713- return
710+ if ( registryStorageType === RegistryStorageType . OCI_PRIVATE ) {
711+ if ( ! customState . username . value || ! ( customState . password . value || id ) || ! isValidJsonFile ) {
712+ setCustomState ( ( st ) => ( {
713+ ...st ,
714+ username : { ...st . username , error : st . username . value ? '' : 'Mandatory' } ,
715+ password : {
716+ ...st . password ,
717+ error : id || st . password . value ? isValidJsonStr : 'Mandatory' ,
718+ } ,
719+ registryUrl : { ...st . registryUrl , error : st . registryUrl . value ? '' : 'Mandatory' } ,
720+ } ) )
721+ return
722+ }
723+ } else {
724+ if ( ! customState . registryUrl . value ) {
725+ setCustomState ( ( st ) => ( {
726+ ...st ,
727+ registryUrl : { ...st . registryUrl , error : st . registryUrl . value ? '' : 'Mandatory' } ,
728+ } ) )
729+ return
730+ }
714731 }
715732 } else if (
716733 selectedDockerRegistryType . value === RegistryType . ACR ||
717734 selectedDockerRegistryType . value === RegistryType . QUAY ||
718735 selectedDockerRegistryType . value === RegistryType . OTHER
719736 ) {
720737 let error = false
721- if (
722- ( ! isPublic && ! customState . username . value ) ||
723- ! ( customState . password . value || id ) ||
724- ! customState . registryUrl . value
725- ) {
726- setCustomState ( ( st ) => ( {
727- ...st ,
728- username : { ...st . username , error : st . username . value ? '' : 'Mandatory' } ,
729- password : { ...st . password , error : id || st . password . value ? '' : 'Mandatory' } ,
730- registryUrl : { ...st . registryUrl , error : st . registryUrl . value ? '' : 'Mandatory' } ,
731- } ) )
732- error = true
738+ if ( registryStorageType !== RegistryStorageType . OCI_PUBLIC ) {
739+ if (
740+ ! customState . username . value ||
741+ ! ( customState . password . value || id ) ||
742+ ! customState . registryUrl . value
743+ ) {
744+ setCustomState ( ( st ) => ( {
745+ ...st ,
746+ username : { ...st . username , error : st . username . value ? '' : 'Mandatory' } ,
747+ password : { ...st . password , error : id || st . password . value ? '' : 'Mandatory' } ,
748+ registryUrl : { ...st . registryUrl , error : st . registryUrl . value ? '' : 'Mandatory' } ,
749+ } ) )
750+ error = true
751+ }
752+ } else {
753+ if ( ! customState . registryUrl . value ) {
754+ setCustomState ( ( st ) => ( {
755+ ...st ,
756+ registryUrl : { ...st . registryUrl , error : st . registryUrl . value ? '' : 'Mandatory' } ,
757+ } ) )
758+ error = true
759+ }
733760 }
761+
734762 if (
735763 selectedDockerRegistryType . value === RegistryType . OTHER &&
736764 state . advanceSelect . value === CERTTYPE . SECURE_WITH_CERT
0 commit comments