Skip to content

Commit 7cdc39f

Browse files
apollo_deployments: improve replacer strings (#9837)
1 parent c356483 commit 7cdc39f

File tree

3 files changed

+24
-28
lines changed

3 files changed

+24
-28
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
2-
"base_layer_config.starknet_contract_address": "$$$_REPLACE_base_layer_config.starknet_contract_address$$$",
3-
"chain_id": "$$$_REPLACE_chain_id$$$",
4-
"consensus_manager_config.context_config.num_validators": "$$$_REPLACE_consensus_manager_config.context_config.num_validators$$$",
5-
"consensus_manager_config.network_config.bootstrap_peer_multiaddr": "$$$_REPLACE_consensus_manager_config.network_config.bootstrap_peer_multiaddr$$$",
6-
"consensus_manager_config.network_config.bootstrap_peer_multiaddr.#is_none": "$$$_REPLACE_consensus_manager_config.network_config.bootstrap_peer_multiaddr.#is_none$$$",
7-
"eth_fee_token_address": "$$$_REPLACE_eth_fee_token_address$$$",
8-
"l1_provider_config.provider_startup_height_override": "$$$_REPLACE_l1_provider_config.provider_startup_height_override$$$",
9-
"l1_provider_config.provider_startup_height_override.#is_none": "$$$_REPLACE_l1_provider_config.provider_startup_height_override.#is_none$$$",
10-
"mempool_p2p_config.network_config.bootstrap_peer_multiaddr": "$$$_REPLACE_mempool_p2p_config.network_config.bootstrap_peer_multiaddr$$$",
11-
"mempool_p2p_config.network_config.bootstrap_peer_multiaddr.#is_none": "$$$_REPLACE_mempool_p2p_config.network_config.bootstrap_peer_multiaddr.#is_none$$$",
12-
"sierra_compiler_config.audited_libfuncs_only": "$$$_REPLACE_sierra_compiler_config.audited_libfuncs_only$$$",
13-
"starknet_url": "$$$_REPLACE_starknet_url$$$",
14-
"state_sync_config.central_sync_client_config.#is_none": "$$$_REPLACE_state_sync_config.central_sync_client_config.#is_none$$$",
15-
"state_sync_config.network_config.#is_none": "$$$_REPLACE_state_sync_config.network_config.#is_none$$$",
16-
"state_sync_config.p2p_sync_client_config.#is_none": "$$$_REPLACE_state_sync_config.p2p_sync_client_config.#is_none$$$",
17-
"strk_fee_token_address": "$$$_REPLACE_strk_fee_token_address$$$"
2+
"base_layer_config.starknet_contract_address": "$$$_BASE_LAYER_CONFIG-STARKNET_CONTRACT_ADDRESS_$$$",
3+
"chain_id": "$$$_CHAIN_ID_$$$",
4+
"consensus_manager_config.context_config.num_validators": "$$$_CONSENSUS_MANAGER_CONFIG-CONTEXT_CONFIG-NUM_VALIDATORS_$$$",
5+
"consensus_manager_config.network_config.bootstrap_peer_multiaddr": "$$$_CONSENSUS_MANAGER_CONFIG-NETWORK_CONFIG-BOOTSTRAP_PEER_MULTIADDR_$$$",
6+
"consensus_manager_config.network_config.bootstrap_peer_multiaddr.#is_none": "$$$_CONSENSUS_MANAGER_CONFIG-NETWORK_CONFIG-BOOTSTRAP_PEER_MULTIADDR-IS_NONE_$$$",
7+
"eth_fee_token_address": "$$$_ETH_FEE_TOKEN_ADDRESS_$$$",
8+
"l1_provider_config.provider_startup_height_override": "$$$_L1_PROVIDER_CONFIG-PROVIDER_STARTUP_HEIGHT_OVERRIDE_$$$",
9+
"l1_provider_config.provider_startup_height_override.#is_none": "$$$_L1_PROVIDER_CONFIG-PROVIDER_STARTUP_HEIGHT_OVERRIDE-IS_NONE_$$$",
10+
"mempool_p2p_config.network_config.bootstrap_peer_multiaddr": "$$$_MEMPOOL_P2P_CONFIG-NETWORK_CONFIG-BOOTSTRAP_PEER_MULTIADDR_$$$",
11+
"mempool_p2p_config.network_config.bootstrap_peer_multiaddr.#is_none": "$$$_MEMPOOL_P2P_CONFIG-NETWORK_CONFIG-BOOTSTRAP_PEER_MULTIADDR-IS_NONE_$$$",
12+
"sierra_compiler_config.audited_libfuncs_only": "$$$_SIERRA_COMPILER_CONFIG-AUDITED_LIBFUNCS_ONLY_$$$",
13+
"starknet_url": "$$$_STARKNET_URL_$$$",
14+
"state_sync_config.central_sync_client_config.#is_none": "$$$_STATE_SYNC_CONFIG-CENTRAL_SYNC_CLIENT_CONFIG-IS_NONE_$$$",
15+
"state_sync_config.network_config.#is_none": "$$$_STATE_SYNC_CONFIG-NETWORK_CONFIG-IS_NONE_$$$",
16+
"state_sync_config.p2p_sync_client_config.#is_none": "$$$_STATE_SYNC_CONFIG-P2P_SYNC_CLIENT_CONFIG-IS_NONE_$$$",
17+
"strk_fee_token_address": "$$$_STRK_FEE_TOKEN_ADDRESS_$$$"
1818
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"consensus_manager_config.network_config.advertised_multiaddr": "$$$_REPLACE_consensus_manager_config.network_config.advertised_multiaddr$$$",
3-
"consensus_manager_config.network_config.advertised_multiaddr.#is_none": "$$$_REPLACE_consensus_manager_config.network_config.advertised_multiaddr.#is_none$$$",
4-
"mempool_p2p_config.network_config.advertised_multiaddr": "$$$_REPLACE_mempool_p2p_config.network_config.advertised_multiaddr$$$",
5-
"mempool_p2p_config.network_config.advertised_multiaddr.#is_none": "$$$_REPLACE_mempool_p2p_config.network_config.advertised_multiaddr.#is_none$$$",
6-
"validator_id": "$$$_REPLACE_validator_id$$$"
2+
"consensus_manager_config.network_config.advertised_multiaddr": "$$$_CONSENSUS_MANAGER_CONFIG-NETWORK_CONFIG-ADVERTISED_MULTIADDR_$$$",
3+
"consensus_manager_config.network_config.advertised_multiaddr.#is_none": "$$$_CONSENSUS_MANAGER_CONFIG-NETWORK_CONFIG-ADVERTISED_MULTIADDR-IS_NONE_$$$",
4+
"mempool_p2p_config.network_config.advertised_multiaddr": "$$$_MEMPOOL_P2P_CONFIG-NETWORK_CONFIG-ADVERTISED_MULTIADDR_$$$",
5+
"mempool_p2p_config.network_config.advertised_multiaddr.#is_none": "$$$_MEMPOOL_P2P_CONFIG-NETWORK_CONFIG-ADVERTISED_MULTIADDR-IS_NONE_$$$",
6+
"validator_id": "$$$_VALIDATOR_ID_$$$"
77
}
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
use apollo_infra_utils::template::Template;
22
use serde_json::Value;
33

4-
const REPLACER_FORMAT: &str = "$$$_REPLACE_{}$$$";
4+
const REPLACER_FORMAT: &str = "$$$_{}_$$$";
55

66
/// Given a flattened JSON object, overwrite each `key`'s value with `format_key(key)`.
77
pub(crate) fn insert_replacer_annotations(mut json: Value) -> Value {
8-
// Assert it’s an object (serde_json::Value::Object)
9-
assert!(json.is_object(), "expected a JSON object, got: {}", json);
10-
11-
// SAFETY: we just asserted it's an object.
12-
let map = json.as_object_mut().unwrap();
8+
let map = json.as_object_mut().expect("Should be a JSON object");
139

1410
// Collect keys to avoid mutable borrow issues while iterating.
1511
let keys: Vec<String> = map.keys().cloned().collect();
@@ -21,5 +17,5 @@ pub(crate) fn insert_replacer_annotations(mut json: Value) -> Value {
2117
}
2218

2319
fn format_key(key: String) -> String {
24-
Template::new(REPLACER_FORMAT).format(&[&key])
20+
Template::new(REPLACER_FORMAT).format(&[&key]).to_uppercase().replace('.', "-").replace('#', "")
2521
}

0 commit comments

Comments
 (0)