@ -6,7 +6,7 @@ import { Base64 } from 'js-base64';
import KubernetesFormValidationHelper from 'Kubernetes/helpers/formValidationHelper' ;
import KubernetesConfigurationHelper from 'Kubernetes/helpers/configurationHelper' ;
import { KubernetesConfigurationFormValuesEntry } from 'Kubernetes/models/configuration/formvalues' ;
import { KubernetesConfigurationKinds , KubernetesSecretType s } from 'Kubernetes/models/configuration/models' ;
import { KubernetesConfigurationKinds , KubernetesSecretType Option s } from 'Kubernetes/models/configuration/models' ;
class KubernetesConfigurationDataController {
/* @ngInject */
@ -20,7 +20,7 @@ class KubernetesConfigurationDataController {
this . showSimpleMode = this . showSimpleMode . bind ( this ) ;
this . showAdvancedMode = this . showAdvancedMode . bind ( this ) ;
this . KubernetesConfigurationKinds = KubernetesConfigurationKinds ;
this . KubernetesSecretType s = KubernetesSecretType s;
this . KubernetesSecretType Option s = KubernetesSecretType Option s;
}
onChangeKey ( entry ) {
@ -41,27 +41,26 @@ class KubernetesConfigurationDataController {
// logic for setting required keys for new entries, based on the secret type
if ( this . formValues . Kind === this . KubernetesConfigurationKinds . SECRET ) {
const newDataIndex = this . formValues . Data . length - 1 ;
const typeValue = typeof this . formValues . Type === 'string' ? this . formValues . Type : this . formValues . Type . value ;
switch ( typeValue ) {
case this . KubernetesSecretTypes . DOCKERCFG . value :
switch ( this . formValues . Type ) {
case this . KubernetesSecretTypeOptions . DOCKERCFG . value :
this . addMissingKeys ( [ 'dockercfg' ] , newDataIndex ) ;
break ;
case this . KubernetesSecretType s. DOCKERCONFIGJSON . value :
case this . KubernetesSecretType Option s. DOCKERCONFIGJSON . value :
this . addMissingKeys ( [ '.dockerconfigjson' ] , newDataIndex ) ;
break ;
case this . KubernetesSecretType s. BASICAUTH . value :
case this . KubernetesSecretType Option s. BASICAUTH . value :
// only add a required key if there is no required key out of username and password
if ( ! this . formValues . Data . some ( ( entry ) => entry . Key === 'username' || entry . Key === 'password' ) ) {
this . addMissingKeys ( [ 'username' , 'password' ] , newDataIndex ) ;
}
break ;
case this . KubernetesSecretType s. SSHAUTH . value :
case this . KubernetesSecretType Option s. SSHAUTH . value :
this . addMissingKeys ( [ 'ssh-privatekey' ] , newDataIndex ) ;
break ;
case this . KubernetesSecretType s. TLS . value :
case this . KubernetesSecretType Option s. TLS . value :
this . addMissingKeys ( [ 'tls.crt' , 'tls.key' ] , newDataIndex ) ;
break ;
case this . KubernetesSecretType s. BOOTSTRAPTOKEN . value :
case this . KubernetesSecretType Option s. BOOTSTRAPTOKEN . value :
this . addMissingKeys ( [ 'token-id' , 'token-secret' ] , newDataIndex ) ;
break ;
default :
@ -84,29 +83,28 @@ class KubernetesConfigurationDataController {
isRequiredKey ( key ) {
if ( this . formValues . Kind === this . KubernetesConfigurationKinds . SECRET ) {
const secretTypeValue = typeof this . formValues . Type === 'string' ? this . formValues . Type : this . formValues . Type . value ;
switch ( secretTypeValue ) {
case this . KubernetesSecretTypes . DOCKERCONFIGJSON . value :
switch ( this . formValues . Type ) {
case this . KubernetesSecretTypeOptions . DOCKERCONFIGJSON . value :
if ( key === '.dockerconfigjson' ) {
return true ;
}
break ;
case this . KubernetesSecretType s. DOCKERCFG . value :
case this . KubernetesSecretType Option s. DOCKERCFG . value :
if ( key === '.dockercfg' ) {
return true ;
}
break ;
case this . KubernetesSecretType s. SSHAUTH . value :
case this . KubernetesSecretType Option s. SSHAUTH . value :
if ( key === 'ssh-privatekey' ) {
return true ;
}
break ;
case this . KubernetesSecretType s. TLS . value :
case this . KubernetesSecretType Option s. TLS . value :
if ( key === 'tls.crt' || key === 'tls.key' ) {
return true ;
}
break ;
case this . KubernetesSecretType s. BOOTSTRAPTOKEN . value :
case this . KubernetesSecretType Option s. BOOTSTRAPTOKEN . value :
if ( key === 'token-id' || key === 'token-secret' ) {
return true ;
}
@ -168,14 +166,14 @@ class KubernetesConfigurationDataController {
if ( this . formValues . Kind === this . KubernetesConfigurationKinds . SECRET ) {
if ( this . isDockerConfig ) {
if ( this . formValues . Type . name === this . KubernetesSecretType s. DOCKERCFG . nam e) {
if ( this . formValues . Type === this . KubernetesSecretType Options. DOCKERCFG . valu e) {
entry . Key = '.dockercfg' ;
} else {
entry . Key = '.dockerconfigjson' ;
}
}
if ( this . formValues . Type . name === this . KubernetesSecretType s. TLS . nam e) {
if ( this . formValues . Type === this . KubernetesSecretType Options. TLS . valu e) {
const isCrt = entry . Value . indexOf ( 'BEGIN CERTIFICATE' ) !== - 1 ;
if ( isCrt ) {
entry . Key = 'tls.crt' ;
@ -200,9 +198,8 @@ class KubernetesConfigurationDataController {
isEntryRequired ( ) {
if ( this . formValues . Kind === this . KubernetesConfigurationKinds . SECRET ) {
const typeValue = typeof this . formValues . Type === 'string' ? this . formValues . Type : this . formValues . Type . value ;
if ( this . formValues . Data . length === 1 ) {
if ( typeValu e !== this . KubernetesSecretType s. SERVICEACCOUNTTOKEN . value ) {
if ( this . formValues . Typ e !== this . KubernetesSecretType Option s. SERVICEACCOUNTTOKEN . value ) {
return true ;
}
}