-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(composer): allow setting 'host' network mode #96
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: Diwakar Sharma <[email protected]>
@@ -694,6 +702,12 @@ impl Builder { | |||
Ok(self) | |||
} | |||
|
|||
/// set the network mode for this test. | |||
pub fn network_mode(mut self, mode: &str) -> Result<Builder, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is mode? Suggest you use an enum for the public facing api
if self.network_mode.is_none() { | ||
compose.network_id = compose.network_create().await.map_err(|e| e.to_string())?; | ||
} else { | ||
let host_nw = &compose.host_network().await?[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is [0] index here?
compose.network_id = compose.network_create().await.map_err(|e| e.to_string())?; | ||
} else { | ||
let host_nw = &compose.host_network().await?[0]; | ||
compose.network_id = host_nw.id.clone().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should return an error if no [0] and this unwrap
@@ -1282,7 +1319,7 @@ impl ComposeTest { | |||
async fn create_container( | |||
&self, | |||
spec: &ContainerSpec, | |||
ipv4: Ipv4Addr, | |||
ipv4: Option<Ipv4Addr>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the ip optional, because it's not in control of docker so it's up to the host?
Can we not set 127.0.0.1 in case of host?
let mut env = self.spec_environment(spec); | ||
env.push(format!("MY_POD_IP={ipv4}")); | ||
let mut env = spec.environment(); | ||
env.push(format!("MY_POD_IP={:?}", ipv4.unwrap_or(Ipv4Addr::new(127, 0, 0, 1)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah so every container gets the same ip?
Can be refined further as use case evolves.