Skip to content

Commit 7738f16

Browse files
fix: Handle legacy networks without chain prefix
1 parent d1fe678 commit 7738f16

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

bootstrap/feature/operator.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ resource "kubernetes_deployment_v1" "operator" {
7272

7373
env {
7474
name = "DB_NAMES"
75-
value = "mainnet=dbsync-mainnet,preprod=dbsync-preprod,preview=dbsync-preview,vector-testnet=dbsync-vector-testnet,prime-testnet=dbsync-prime-testnet"
75+
value = "vector-testnet=dbsync-vector-testnet,prime-testnet=dbsync-prime-testnet,cardano-mainnet=dbsync-mainnet,cardano-preprod=dbsync-preprod,cardano-preview=dbsync-preview"
7676
}
7777

7878
env {

operator/src/controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use sha3::{Digest, Sha3_256};
1818
use std::{sync::Arc, time::Duration};
1919
use tracing::{error, info, instrument};
2020

21-
use crate::{postgres::Postgres, Error, State};
21+
use crate::{postgres::Postgres, utils::handle_legacy_networks, Error, State};
2222

2323
pub static DB_SYNC_PORT_FINALIZER: &str = "dbsyncports.demeter.run";
2424

@@ -138,7 +138,7 @@ async fn reconcile(crd: Arc<DbSyncPort>, state: Arc<State>) -> Result<Action, Er
138138
let ns = crd.namespace().unwrap();
139139
let crds: Api<DbSyncPort> = Api::namespaced(state.kube_client.clone(), &ns);
140140

141-
let pg_connections = state.get_pg_by_network(&crd.spec.network)?;
141+
let pg_connections = state.get_pg_by_network(&handle_legacy_networks(&crd.spec.network))?;
142142

143143
finalizer(&crds, DB_SYNC_PORT_FINALIZER, crd, |event| async {
144144
match event {

operator/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl State {
139139
pub mod controller;
140140
pub mod metrics;
141141
pub mod postgres;
142+
pub mod utils;
142143

143144
pub use controller::*;
144145
pub use metrics::*;

operator/src/utils.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use lazy_static::lazy_static;
2+
use std::collections::HashMap;
3+
4+
lazy_static! {
5+
static ref LEGACY_NETWORKS: HashMap<&'static str, String> = {
6+
let mut m = HashMap::new();
7+
m.insert("mainnet", "cardano-mainnet".into());
8+
m.insert("preprod", "cardano-preprod".into());
9+
m.insert("preview", "cardano-preview".into());
10+
m
11+
};
12+
}
13+
14+
pub fn handle_legacy_networks(network: &str) -> String {
15+
let default = network.to_string();
16+
LEGACY_NETWORKS.get(network).unwrap_or(&default).to_string()
17+
}

0 commit comments

Comments
 (0)