@@ -49,17 +49,27 @@ pub enum Error {
4949 source : crate :: builder:: pod:: container:: Error ,
5050 } ,
5151
52+ #[ snafu( display( "invalid environment variable" ) ) ]
53+ InvalidEnvVar {
54+ source : crate :: v2:: builder:: pod:: container:: Error ,
55+ } ,
56+
57+ #[ snafu( display( "invalid environment variable name" ) ) ]
58+ InvalidEnvVarName {
59+ source : crate :: v2:: macros:: attributed_string_type:: Error ,
60+ } ,
61+
62+ #[ snafu( display( "invalid Secret key" ) ) ]
63+ InvalidSecretKey {
64+ source : crate :: v2:: macros:: attributed_string_type:: Error ,
65+ } ,
66+
5267 #[ snafu( display( "invalid Secret name {name:?}" ) ) ]
5368 InvalidSecretName {
5469 source : crate :: v2:: macros:: attributed_string_type:: Error ,
5570 name : String ,
5671 } ,
5772
58- #[ snafu( display( "invalid environment variable" ) ) ]
59- InvalidEnvVar {
60- source : crate :: v2:: builder:: pod:: container:: Error ,
61- } ,
62-
6373 #[ snafu( display( "failed to add needed volumeMount" ) ) ]
6474 AddVolumeMount {
6575 source : crate :: builder:: pod:: container:: Error ,
@@ -136,35 +146,35 @@ impl GitSyncResources {
136146 env_vars = env_vars
137147 . with_secret_key_ref (
138148 & EnvVarName :: from_str ( "GITSYNC_USERNAME" )
139- . expect ( "must be a valid environment variable name" ) ,
149+ . context ( InvalidEnvVarNameSnafu ) ? ,
140150 & SecretName :: from_str ( basic_auth_secret_name) . with_context ( |_| {
141151 InvalidSecretNameSnafu {
142152 name : basic_auth_secret_name,
143153 }
144154 } ) ?,
145- & SecretKey :: from_str ( "user" ) . expect ( "must be a valid Secret key" ) ,
155+ & SecretKey :: from_str ( "user" ) . context ( InvalidSecretKeySnafu ) ? ,
146156 )
147157 . with_secret_key_ref (
148158 & EnvVarName :: from_str ( "GITSYNC_PASSWORD" )
149- . expect ( "must be a valid environment variable name" ) ,
159+ . context ( InvalidEnvVarNameSnafu ) ? ,
150160 & SecretName :: from_str ( basic_auth_secret_name) . with_context ( |_| {
151161 InvalidSecretNameSnafu {
152162 name : basic_auth_secret_name,
153163 }
154164 } ) ?,
155- & SecretKey :: from_str ( "password" ) . expect ( "must be a valid Secret key" ) ,
165+ & SecretKey :: from_str ( "password" ) . context ( InvalidSecretKeySnafu ) ? ,
156166 ) ;
157167 }
158168 if let Some ( Credentials :: SshPrivateKeySecretName { .. } ) = git_sync. credentials {
159169 env_vars = env_vars
160170 . with_value (
161171 & EnvVarName :: from_str ( "GITSYNC_SSH_KEY_FILE" )
162- . expect ( "must be a valid environment variable name" ) ,
172+ . context ( InvalidEnvVarNameSnafu ) ? ,
163173 format ! ( "{SSH_MOUNT_PATH_PREFIX}-{i}/key" ) ,
164174 )
165175 . with_value (
166176 & EnvVarName :: from_str ( "GITSYNC_SSH_KNOWN_HOSTS_FILE" )
167- . expect ( "must be a valid environment variable name" ) ,
177+ . context ( InvalidEnvVarNameSnafu ) ? ,
168178 format ! ( "{SSH_MOUNT_PATH_PREFIX}-{i}/knownHosts" ) ,
169179 ) ;
170180 }
0 commit comments