@@ -47,35 +47,45 @@ pub enum WellKnownSecretData {
4747}
4848
4949impl WellKnownSecretData {
50- pub fn into_files ( self , names : NamingOptions ) -> SecretFiles {
50+ pub fn into_files ( self , names : NamingOptions , only_identity : bool ) -> SecretFiles {
5151 match self {
5252 WellKnownSecretData :: TlsPem ( TlsPem {
5353 certificate_pem,
5454 key_pem,
5555 ca_pem,
56- } ) => [
57- Some ( names. tls_pem_cert_name ) . zip ( certificate_pem) ,
58- Some ( names. tls_pem_key_name ) . zip ( key_pem) ,
59- Some ( ( names. tls_pem_ca_name , ca_pem) ) ,
60- ]
61- . into_iter ( )
62- . flatten ( )
63- . collect ( ) ,
56+ } ) => {
57+ let mut files = vec ! [ Some ( ( names. tls_pem_ca_name, ca_pem) ) ] ;
58+
59+ if !only_identity {
60+ files. extend ( [
61+ Some ( names. tls_pem_cert_name ) . zip ( certificate_pem) ,
62+ Some ( names. tls_pem_key_name ) . zip ( key_pem) ,
63+ ] ) ;
64+ }
65+
66+ files. into_iter ( ) . flatten ( ) . collect ( )
67+ }
6468 WellKnownSecretData :: TlsPkcs12 ( TlsPkcs12 {
6569 keystore,
6670 truststore,
67- } ) => [
68- Some ( names. tls_pkcs12_keystore_name ) . zip ( keystore) ,
69- Some ( ( names. tls_pkcs12_truststore_name , truststore) ) ,
70- ]
71- . into_iter ( )
72- . flatten ( )
73- . collect ( ) ,
74- WellKnownSecretData :: Kerberos ( Kerberos { keytab, krb5_conf } ) => [
75- ( FILE_KERBEROS_KEYTAB_KEYTAB . to_string ( ) , keytab) ,
76- ( FILE_KERBEROS_KEYTAB_KRB5_CONF . to_string ( ) , krb5_conf) ,
77- ]
78- . into ( ) ,
71+ } ) => {
72+ let mut files = vec ! [ Some ( ( names. tls_pkcs12_truststore_name, truststore) ) ] ;
73+
74+ if !only_identity {
75+ files. push ( Some ( names. tls_pkcs12_keystore_name ) . zip ( keystore) ) ;
76+ }
77+
78+ files. into_iter ( ) . flatten ( ) . collect ( )
79+ }
80+ WellKnownSecretData :: Kerberos ( Kerberos { keytab, krb5_conf } ) => {
81+ let mut files = vec ! [ ( FILE_KERBEROS_KEYTAB_KRB5_CONF . to_string( ) , krb5_conf) ] ;
82+
83+ if !only_identity {
84+ files. push ( ( FILE_KERBEROS_KEYTAB_KEYTAB . to_string ( ) , keytab) ) ;
85+ }
86+
87+ SecretFiles :: from_iter ( files)
88+ }
7989 }
8090 }
8191
0 commit comments