@@ -74,9 +74,7 @@ struct DynamicReplicatorConfig {
7474
7575impl DynamicReplicatorConfig {
7676 /// Loads the runtime limits for the current environment.
77- fn load ( ) -> Result < Self , K8sError > {
78- let environment = Environment :: load ( ) . map_err ( |_| K8sError :: ReplicatorConfiguration ) ?;
79-
77+ fn load ( environment : & Environment ) -> Result < Self , K8sError > {
8078 let config = match environment {
8179 Environment :: Prod => Self {
8280 max_memory : REPLICATOR_MAX_MEMORY_PROD ,
@@ -302,6 +300,9 @@ impl K8sClient for HttpK8sClient {
302300 ) -> Result < ( ) , K8sError > {
303301 info ! ( "patching stateful set" ) ;
304302
303+ let environment = Environment :: load ( ) . map_err ( |_| K8sError :: MissingEnvironment ) ?;
304+ let config = DynamicReplicatorConfig :: load ( & environment) ?;
305+
305306 let stateful_set_name = format ! ( "{prefix}-{REPLICATOR_STATEFUL_SET_SUFFIX}" ) ;
306307 let replicator_app_name = format ! ( "{prefix}-{REPLICATOR_APP_SUFFIX}" ) ;
307308 let replicator_container_name = format ! ( "{prefix}-{REPLICATOR_CONTAINER_NAME_SUFFIX}" ) ;
@@ -310,8 +311,6 @@ impl K8sClient for HttpK8sClient {
310311 let bq_secret_name = format ! ( "{prefix}-{BQ_SECRET_NAME_SUFFIX}" ) ;
311312 let replicator_config_map_name = format ! ( "{prefix}-{REPLICATOR_CONFIG_MAP_NAME_SUFFIX}" ) ;
312313
313- let config = DynamicReplicatorConfig :: load ( ) ?;
314-
315314 let mut stateful_set_json = json ! ( {
316315 "apiVersion" : "apps/v1" ,
317316 "kind" : "StatefulSet" ,
@@ -419,7 +418,7 @@ impl K8sClient for HttpK8sClient {
419418 "env" : [
420419 {
421420 "name" : "APP_ENVIRONMENT" ,
422- "value" : "prod"
421+ "value" : environment . to_string ( )
423422 } ,
424423 {
425424 "name" : "APP_SENTRY__DSN" ,
0 commit comments