study-docker-repro-longevity/workflow/nickel/artifact_contract.ncl

80 lines
2.8 KiB
Plaintext
Raw Normal View History

let
conf = {
ARCHIVE_FORMATS = ["zip", "tar"],
2024-07-17 14:56:38 +02:00
PACKAGE_MANAGERS = ["dpkg", "rpm", "pacman", "pip", "conda"],
FILEPATH_REGEX = "^[^\\x00]+$", # For UNIX, anything of length > 0 but without NULL characters, found at: https://stackoverflow.com/questions/537772/what-is-the-most-correct-regular-expression-for-a-unix-file-path
URL_REGEX = "^https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$", # Found at: https://uibakery.io/regex-library/url
IMAGENAME_REGEX = "^[a-z0-9]+(([.]{0,1}|[_]{0,2}|[-]*)[a-z0-9]+)*(:[a-zA-Z0-9_]+[a-zA-Z0-9._-]*){0,1}$" # Based on, with modifications: https://regexr.com/3bsog
}
in
{
PackageManager = std.contract.from_predicate (
fun value => std.array.any (fun x => x == value) conf.PACKAGE_MANAGERS
),
ArchiveType = std.contract.from_predicate (
fun value => std.array.any (fun x => x == value) conf.ARCHIVE_FORMATS
2024-07-17 14:56:38 +02:00
),
FilePath = std.contract.from_predicate (
fun value => std.string.is_match conf.FILEPATH_REGEX value
),
URL = std.contract.from_predicate (
fun value => std.string.is_match conf.URL_REGEX value
),
ImageName = std.contract.from_predicate (
fun value => (std.string.is_match conf.IMAGENAME_REGEX value) && (std.string.length value < 128) # Length could be more than 128, but it's easier that way...
),
GitPackage = {
name
| doc "Name of the package for future identification"
| String,
location
| doc "Path where cloned in the container"
2024-07-17 14:56:38 +02:00
| FilePath
},
MiscPackage = {
name
| doc "Name of the package for future identification"
| String,
url
| doc "URL of the package. Will be used to compute the hash"
| URL
},
PythonVenv = {
path
| doc "Path to the Python venv."
| FilePath
}
Artifact = {
artifact_url
| doc "URL where to download the artifact"
2024-07-17 14:56:38 +02:00
| URL,
type
| doc "Type of the archive. Possible values: zip, tar"
| ArchiveType,
doi
| doc "DOI of the artifact"
| String,
comment
| doc "Additional comments on the artifact that couldn't be written elsewhere"
| String,
image_name
| doc "Name to give the image when building"
2024-07-17 14:56:38 +02:00
| ImageName,
dockerfile_location
| doc "Path to the dockerfile in the artifact"
2024-07-17 14:56:38 +02:00
| FilePath,
package_managers
| doc "Package Managers used in the container. Possible values: dpkg, rpm, pacman, pip, conda"
| Array PackageManager,
git_packages
| doc "Git repositories cloned in the container"
| Array GitPackage,
misc_packages
| doc "Misc. packages downloaded from the container"
| Array MiscPackage,
python_venvs
| doc "Python venvs created in the container"
| Array PythonVenv
}
}