fixed problem with official images
This commit is contained in:
parent
7b1501f4d8
commit
db5216b100
25
src/tags.rs
25
src/tags.rs
@ -29,6 +29,7 @@ pub struct Tags {
|
|||||||
pub results: Vec<Images>,
|
pub results: Vec<Images>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
InvalidCharacter(char),
|
InvalidCharacter(char),
|
||||||
Fetching(String),
|
Fetching(String),
|
||||||
@ -37,13 +38,9 @@ pub enum Error {
|
|||||||
|
|
||||||
impl Tags {
|
impl Tags {
|
||||||
pub fn new(repo: String) -> Result<Self, Error> {
|
pub fn new(repo: String) -> Result<Self, Error> {
|
||||||
|
// let repo = Self::check_repo(repo)?;
|
||||||
let request = format!("https://hub.docker.com/v2/repositories/{}/tags", repo);
|
let request = format!("https://hub.docker.com/v2/repositories/{}/tags", repo);
|
||||||
|
|
||||||
//check for right set of characters
|
|
||||||
if request.bytes().any(|c| !c.is_ascii()) {
|
|
||||||
return Err(Error::InvalidCharacter('a'));
|
|
||||||
}
|
|
||||||
|
|
||||||
//get response
|
//get response
|
||||||
let res = match reqwest::blocking::get(request) {
|
let res = match reqwest::blocking::get(request) {
|
||||||
Ok(result) => result,
|
Ok(result) => result,
|
||||||
@ -60,14 +57,18 @@ impl Tags {
|
|||||||
Ok(tags)
|
Ok(tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_images(&self) -> &Vec<Images> {
|
pub fn check_repo(mut name: String) -> Result<String, Error> {
|
||||||
&self.results
|
//check for right set of characters
|
||||||
}
|
if name.bytes().any(|c| !c.is_ascii()) {
|
||||||
}
|
return Err(Error::InvalidCharacter('a'));
|
||||||
|
}
|
||||||
|
|
||||||
impl Images {
|
//check if need to inject "library" of given repo
|
||||||
pub fn get_name(&self) -> &str {
|
let regex = regex::Regex::new(r".*/.*").unwrap();
|
||||||
&self.tag_name
|
if !regex.is_match(&name) {
|
||||||
|
name.insert_str(0, "library/");
|
||||||
|
}
|
||||||
|
Ok(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/ui.rs
12
src/ui.rs
@ -93,10 +93,7 @@ impl Ui {
|
|||||||
ui.tags = tag_list::TagList::with_repo(ui.repo.get());
|
ui.tags = tag_list::TagList::with_repo(ui.repo.get());
|
||||||
}
|
}
|
||||||
State::SelectTag => {
|
State::SelectTag => {
|
||||||
let mut repo = match ui.services.extract_repo() {
|
let mut repo = ui.repo.get();
|
||||||
Err(_) => continue,
|
|
||||||
Ok(s) => s,
|
|
||||||
};
|
|
||||||
let tag = match ui.tags.get_selected() {
|
let tag = match ui.tags.get_selected() {
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
Ok(tag) => tag,
|
Ok(tag) => tag,
|
||||||
@ -136,8 +133,11 @@ impl Ui {
|
|||||||
match ui.services.extract_repo() {
|
match ui.services.extract_repo() {
|
||||||
Err(_) => ui.tags = tag_list::TagList::with_status("No image found"),
|
Err(_) => ui.tags = tag_list::TagList::with_status("No image found"),
|
||||||
Ok(s) => {
|
Ok(s) => {
|
||||||
ui.repo.set(s);
|
let repo = match crate::tags::Tags::check_repo(s) {
|
||||||
ui.tags = tag_list::TagList::with_repo(ui.repo.get());
|
Err(_) => continue,
|
||||||
|
Ok(s) => s,
|
||||||
|
};
|
||||||
|
ui.repo.set(repo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user