fix: filter tags from registry

This commit is contained in:
椰子 2023-11-13 22:54:25 +08:00
parent fa9aa4e74b
commit be99d9c21a
3 changed files with 7 additions and 2 deletions

View File

@ -23,7 +23,7 @@ fn main() {
let args = Args::parse();
let query_args = QueryArgs::new(args.repository.as_str(), args.filter, args.arch);
let config = docker_config::read_config();
let tags = match config {
let mut tags = match config {
None => {
let fetcher = DockerHubTagsFetcher::new();
fetcher.get_tags(&query_args)
@ -33,6 +33,7 @@ fn main() {
fetcher.get_tags(&query_args)
}
};
tags.sort();
for tag in tags {
let _ = writeln!(std::io::stdout(), "{}", &tag);
}

View File

@ -93,7 +93,6 @@ impl DockerTagsFetcher for DockerHubTagsFetcher {
for x in &filtered {
results.push(x.name.clone().unwrap());
}
results.sort();
results
}
}

View File

@ -44,6 +44,11 @@ impl DockerTagsFetcher for RegistryTagsFetcher {
None => { results.push(format!("Image not found: {}/{}", namespace, repository)); }
}
};
if args.name.is_some() {
let pat = args.name.clone().unwrap();
results = results.into_iter().filter(|x| x.contains(&pat))
.collect::<Vec<String>>();
};
results
}
}