Last active
February 4, 2022 20:00
-
-
Save ihcsim/0f99d30a8c26d9e35dc09fbef6a2492c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::collections::HashMap; | |
#[derive(Debug)] | |
struct Service { | |
name: String, | |
namespace: String, | |
endpoints: Vec<String>, | |
mappings: HashMap<String, String>, | |
} | |
fn main() { | |
let svc = Service { | |
name: "nginx".to_string(), | |
namespace: "default".to_string(), | |
endpoints: vec!["192.168.0.1".to_string(), "192.168.0.2".to_string()], | |
mappings: HashMap::from([ | |
("pod-0".to_string(), "192.168.0.1".to_string()), | |
("pod-1".to_string(), "192.168.0.2".to_string()), | |
]), | |
}; | |
let mut nginx = svc; | |
nginx.namespace = "ingress".to_string(); | |
nginx.endpoints.push("192.168.0.3".to_string()); | |
nginx | |
.mappings | |
.insert("pod-2".to_string(), "192.168.0.3".to_string()); | |
println!("{:?}\n{:?}", svc, nginx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment