Add support for docker images

This commit is contained in:
Ferran Basora 2020-05-05 18:30:47 +00:00
parent f0cab14a9f
commit 25a3856aac
3 changed files with 22 additions and 1 deletions

View File

@ -21,6 +21,7 @@ letter hint to yank the text in your tmux buffer.
- Hex numbers
- Markdown urls
- IP4 addresses
- Docker images
- kubernetes resources
- UUIDs

View File

@ -35,3 +35,9 @@ home: ~/.gnu/.config.txt
10.3.23.42 lorem 123.2.3.4 lorem 230.23.33.34
10.3.23.42 lorem 123.2.3.4 lorem 230.23.33.34
10.3.23.42 lorem 123.2.3.4 lorem 230.23.33.34
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> sha256:77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB
committest latest sha256:b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB
<none> <none> sha256:78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB
docker latest sha256:30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB

View File

@ -4,11 +4,12 @@ use std::fmt;
const EXCLUDE_PATTERNS: [(&'static str, &'static str); 1] = [("bash", r"[[:cntrl:]]\[([0-9]{1,2};)?([0-9]{1,2})?m")];
const PATTERNS: [(&'static str, &'static str); 13] = [
const PATTERNS: [(&'static str, &'static str); 14] = [
("markdown_url", r"\[[^]]*\]\(([^)]+)\)"),
("url", r"((https?://|git@|git://|ssh://|ftp://|file:///)[^ ]+)"),
("diff_a", r"--- a/([^ ]+)"),
("diff_b", r"\+\+\+ b/([^ ]+)"),
("docker", r"sha256:([0-9a-f]{64})"),
("path", r"(([.\w\-@~]+)?(/[.\w\-@]+)+)"),
("color", r"#[0-9a-fA-F]{6}"),
("uid", r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"),
@ -200,6 +201,19 @@ mod tests {
assert_eq!(results.last().unwrap().hint.clone().unwrap(), "a");
}
#[test]
fn match_docker() {
let lines = split("latest sha256:30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago");
let custom = [].to_vec();
let results = State::new(&lines, "abcd", &custom).matches(false, false);
assert_eq!(results.len(), 1);
assert_eq!(
results.get(0).unwrap().text,
"30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4"
);
}
#[test]
fn match_bash() {
let lines = split("path: /var/log/nginx.log\npath: test/log/nginx-2.log:32folder/.nginx@4df2.log");