-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend check_cont to include no dockerhub registries
- Loading branch information
Showing
11 changed files
with
143 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
check_cont_dockerhub <- function(cont, | ||
domain = | ||
"https://hub.docker.com/v2/repositories/", | ||
verbose = TRUE){ | ||
requireNamespace("jsonlite") | ||
for(co in cont){ | ||
if(is.null(co)) next() | ||
co <- gsub("docker\\.io/","",co) | ||
splt <- strsplit(co,":")[[1]] | ||
URL <- paste(domain, splt[1], | ||
"tags?page_size=1000",sep="/" | ||
) | ||
#### Check repo exists #### | ||
messager("Checking public container repository exists:",shQuote(splt[1]), | ||
v=verbose) | ||
js <- tryCatch({ | ||
jsonlite::read_json(URL) | ||
}, error=function(e){ | ||
stopper("Unable to find public container:",co) | ||
}) | ||
#### Check tag exists #### | ||
tags <- sapply(js$results ,function(x){x$name}) | ||
check_tags(tags = tags, | ||
splt = splt, | ||
verbose = verbose) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
check_cont_general <- function(cont){ | ||
lapply(cont, function(co){ | ||
if(is.null(co)) return(NULL) | ||
if(!grepl("/",co)){ | ||
stopper("Container must be specified in the following format:", | ||
"'registry/owner/repo:tag'") | ||
} | ||
n_parts <- length(strsplit(gsub("[/]+","/",co),"/")[[1]]) | ||
return(n_parts) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
check_cont_ghcr <- function(cont, | ||
verbose = TRUE){ | ||
requireNamespace("rvest") | ||
|
||
for(co in cont){ | ||
if(is.null(co)) next() | ||
# co <- "ghcr.io/bioconductor/bioconductor_docker:devel" | ||
co_notag <- gsub("ghcr.io/","",strsplit(co,":")[[1]][1]) | ||
##### Only works if you have permissions to the repo ##### | ||
# get_ghcr_tags <- function(container) { | ||
# url <- paste0("https://ghcr.io/v2/", container, "/tags/list") | ||
# response <- jsonlite::fromJSON(url) | ||
# tags <- response$tags | ||
# return(tags) | ||
# } | ||
# tags <- get_ghcr_tags("bioconductor/bioconductor_docker") | ||
# | ||
URL <- paste0( | ||
"https://github.com/", | ||
co_notag, | ||
"/pkgs/container/",basename(co_notag), | ||
"/versions?filters%5Bversion_type%5D=tagged" | ||
) | ||
#### Check if container exists #### | ||
x <- tryCatch({ | ||
rvest::read_html(URL) | ||
}, error=function(e){ | ||
stopper("Unable to find public container:",co)} | ||
) | ||
#### Check if container has tags #### | ||
tags <- x |> rvest::html_nodes(".Label") |> rvest::html_text() | ||
if(length(tags)==0){ | ||
stopper("Unable to find tags for container:",co) | ||
} else { | ||
check_tags(tags = tags, | ||
splt = strsplit(co,":")[[1]][1], | ||
verbose = verbose) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
check_tags <- function(splt, | ||
tags, | ||
verbose=TRUE){ | ||
if(length(splt)==2){ | ||
messager("Checking tag exists:",shQuote(splt[2]), | ||
v=verbose) | ||
if(!splt[2] %in% tags){ | ||
stopper("The tag", shQuote(splt[2]), | ||
"does not exist in the repo",shQuote(splt[1])) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters