mirror of
https://github.com/sergi0g/cup.git
synced 2025-11-09 13:43:49 -05:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06ec23520d |
28
Cargo.lock
generated
28
Cargo.lock
generated
@@ -140,21 +140,6 @@ version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "bit-set"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
|
||||
dependencies = [
|
||||
"bit-vec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit-vec"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
@@ -369,13 +354,13 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bollard",
|
||||
"clap",
|
||||
"fancy-regex",
|
||||
"http-auth",
|
||||
"indicatif",
|
||||
"json",
|
||||
"liquid",
|
||||
"once_cell",
|
||||
"rayon",
|
||||
"regex",
|
||||
"termsize",
|
||||
"tokio",
|
||||
"ureq",
|
||||
@@ -426,17 +411,6 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "fancy-regex"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2"
|
||||
dependencies = [
|
||||
"bit-set",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.30"
|
||||
|
||||
@@ -14,9 +14,9 @@ xitca-web = { version = "0.5.0", optional = true }
|
||||
liquid = { version = "0.26.6", optional = true }
|
||||
bollard = "0.16.1"
|
||||
once_cell = "1.19.0"
|
||||
fancy-regex = "0.13.0"
|
||||
http-auth = { version = "0.1.9", features = [] }
|
||||
termsize = { version = "0.1.8", optional = true }
|
||||
regex = "1.10.5"
|
||||
|
||||
[features]
|
||||
default = ["server", "cli"]
|
||||
|
||||
@@ -143,7 +143,7 @@ $ docker run -v /var/run/docker.sock:/var/run/docker.sock -p <PORT>:<PORT> cup s
|
||||
|
||||
Cup is a work in progress. It might not have as many features as What's up Docker. If one of these features is really important for you, please consider using another tool.
|
||||
|
||||
- Cup currently doesn't support registries which use repositories without slashes. This includes Azure. This problem may sound a bit weird, but it's due to the regex that's used at the moment. This will (hopefully) be fixed in the future.
|
||||
- ~~Cup currently doesn't support registries which use repositories without slashes. This includes Azure. This problem may sound a bit weird, but it's due to the regex that's used at the moment. This will (hopefully) be fixed in the future.~~
|
||||
- Cup doesn't support private images. This is on the roadmap. Currently, it just returns unknown for those images.
|
||||
- Cup cannot trigger your integrations. If you want that to happen automatically, please use What's up docker instead. Cup was created to be simple. The data is there, and it's up to you to retrieve it (e.g. by running `cup check -r` with a cronjob or periodically requesting the `/json` url from the server)
|
||||
|
||||
|
||||
19
src/utils.rs
19
src/utils.rs
@@ -1,4 +1,4 @@
|
||||
use fancy_regex::Regex;
|
||||
use regex::Regex;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
#[macro_export]
|
||||
@@ -9,27 +9,20 @@ macro_rules! error {
|
||||
})
|
||||
}
|
||||
|
||||
// Takes an image and splits it into registry, repository and tag. For example ghcr.io/sergi0g/cup:latest becomes ['ghcr.io', 'sergi0g/cup', 'latest']. ONLY REGISTRIES THAT USE A / IN THE REPOSITORY ARE SUPPORTED CURRENTLY. THAT MEANS AZURE WILL NOT WORK.
|
||||
// Takes an image and splits it into registry, repository and tag. For example ghcr.io/sergi0g/cup:latest becomes ['ghcr.io', 'sergi0g/cup', 'latest'].
|
||||
pub fn split_image(image: &str) -> (String, String, String) {
|
||||
static RE: Lazy<Regex> = Lazy::new(|| {
|
||||
Regex::new(
|
||||
r#"^(?P<registry>[\w.\-_]+((?::\d+|)(?=/[a-z0-9._-]+/[a-z0-9._-]+))|)(?:/|)(?P<repository>[a-z0-9.\-_]+(?:/[a-z0-9.\-_]+|))(:(?P<tag>[\w.\-_]{1,127})|)$"#, // From https://regex101.com/r/a98UqN/1
|
||||
r#"^(?P<name>(?:(?P<registry>(?:(?:localhost|[\w-]+(?:\.[\w-]+)+)(?::\d+)?)|[\w]+:\d+)/)?(?P<repository>[a-z0-9_.-]+(?:/[a-z0-9_.-]+)*))(?::(?P<tag>[\w][\w.-]{0,127}))?$"#, // From https://regex101.com/r/nmSDPA/1
|
||||
)
|
||||
.unwrap()
|
||||
});
|
||||
match RE.captures(image).unwrap() {
|
||||
match RE.captures(image) {
|
||||
Some(c) => {
|
||||
return (
|
||||
match c.name("registry") {
|
||||
Some(registry) => {
|
||||
let reg = registry.as_str().to_owned();
|
||||
if reg.is_empty() {
|
||||
String::from("registry-1.docker.io")
|
||||
} else {
|
||||
reg
|
||||
}
|
||||
}
|
||||
None => error!("Failed to parse image {}", image),
|
||||
Some(registry) => registry.as_str().to_owned(),
|
||||
None => String::from("registry-1.docker.io"),
|
||||
},
|
||||
match c.name("repository") {
|
||||
Some(repository) => {
|
||||
|
||||
Reference in New Issue
Block a user