Skip to content
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

Minor bug fixes. #882

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/bin/commands/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ impl CreateVolume {

#[derive(Args, Debug)]
pub struct RemoveVolume {
/// Triple for the target platform.
#[clap(long)]
pub target: String,
/// FIXME: remove in 0.3.0, remains since it's a breaking change.
#[clap(long, hide = true)]
pub target: Option<String>,
/// If cross is running inside a container.
#[clap(short, long)]
pub docker_in_docker: bool,
Expand Down Expand Up @@ -473,7 +473,6 @@ pub fn create_persistent_volume(

pub fn remove_persistent_volume(
RemoveVolume {
target,
docker_in_docker,
verbose,
quiet,
Expand All @@ -484,8 +483,9 @@ pub fn remove_persistent_volume(
channel: Option<&str>,
) -> cross::Result<()> {
let msg_info = MessageInfo::create(verbose, quiet, color.as_deref())?;
let triple = cross::Host::X86_64UnknownLinuxGnu.triple();
let (_, _, dirs) =
docker::get_package_info(engine, &target, channel, docker_in_docker, msg_info)?;
docker::get_package_info(engine, triple, channel, docker_in_docker, msg_info)?;
let volume = docker::remote::unique_toolchain_identifier(&dirs.sysroot)?;

if !docker::remote::volume_exists(engine, &volume, msg_info)? {
Expand Down
14 changes: 6 additions & 8 deletions xtask/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub fn gha_output(tag: &str, content: &str) {
println!("::set-output name={tag}::{}", content)
}

pub fn read_dockerfiles(msg_info: MessageInfo) -> cross::Result<Vec<String>> {
pub fn read_dockerfiles(msg_info: MessageInfo) -> cross::Result<Vec<(PathBuf, String)>> {
let root = project_dir(msg_info)?;
let docker = root.join("docker");
let mut dockerfiles = vec![];
Expand All @@ -225,18 +225,18 @@ pub fn read_dockerfiles(msg_info: MessageInfo) -> cross::Result<Vec<String>> {
let file_type = entry.file_type()?;
let file_name = entry.file_name();
if file_type.is_file() && file_name.to_utf8()?.starts_with("Dockerfile") {
dockerfiles.push(fs::read_to_string(entry.path())?);
let contents = fs::read_to_string(entry.path())?;
dockerfiles.push((entry.path().to_path_buf(), contents));
}
}

Ok(dockerfiles)
}

#[cfg(tests)]
#[cfg(test)]
mod tests {
use super::*;

use crate::util::read_dockerfiles;
use cross::shell::Verbosity;
use std::collections::BTreeMap;

Expand All @@ -245,15 +245,13 @@ mod tests {
// count all the entries of FROM for our images
let mut counts = BTreeMap::new();
let dockerfiles = read_dockerfiles(Verbosity::Verbose.into())?;
for dockerfile in dockerfiles {
for (path, dockerfile) in dockerfiles {
let lines: Vec<&str> = dockerfile.lines().collect();
let index = lines
.iter()
.map(|x| x.trim())
.position(|x| x.to_lowercase().starts_with("from"))
.ok_or_else(|| {
eyre::eyre!("unable to find FROM instruction for {:?}", entry.path())
})?;
.ok_or_else(|| eyre::eyre!("unable to find FROM instruction for {:?}", path))?;
let tag = lines[index]
.split_whitespace()
.nth(1)
Expand Down