2024-07-11 16:05:08 +02:00
let
conf = {
2024-07-16 16:47:17 +02:00
ARCHIVE_FORMATS = ["zip", "tar"],
2024-07-17 14:56:38 +02:00
PACKAGE_MANAGERS = ["dpkg", "rpm", "pacman", "pip", "conda"],
2024-07-30 18:06:16 +02:00
VIRT_TECHS = ["docker"],
2024-07-17 14:56:38 +02:00
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
2024-07-29 16:37:44 +02:00
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
VERNUMBER_REGEX = "[0-9]+(\\.([0-9])+)*"
2024-07-11 16:05:08 +02:00
}
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
),
2024-07-29 16:37:44 +02:00
VersionNumber = std.contract.from_predicate (
fun value => std.string.is_match conf.VERNUMBER_REGEX value
),
2024-07-30 18:06:16 +02:00
VirtTech = std.contract.from_predicate (
fun value => std.array.any (fun x => x == value) conf.VIRT_TECHS
),
2024-07-11 16:05:08 +02:00
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
2024-07-11 16:05:08 +02:00
},
MiscPackage = {
name
| doc "Name of the package for future identification"
| String,
url
| doc "URL of the package. Will be used to compute the hash"
2024-07-19 16:18:49 +02:00
| URL
2024-07-11 16:05:08 +02:00
},
2024-07-24 18:05:31 +02:00
PythonVenv = {
path
| doc "Path to the Python venv."
| FilePath
2024-07-29 16:37:44 +02:00
},
2024-07-11 16:05:08 +02:00
Artifact = {
2024-07-29 16:37:44 +02:00
version
| doc "Version of the Nickel contract"
| String,
2024-07-16 17:35:09 +02:00
artifact_url
2024-07-11 16:05:08 +02:00
| doc "URL where to download the artifact"
2024-07-17 14:56:38 +02:00
| URL,
2024-07-11 16:05:08 +02:00
type
2024-07-19 17:05:46 +02:00
| doc "Type of the archive. Possible values: zip, tar"
2024-07-11 16:05:08 +02:00
| ArchiveType,
doi
| doc "DOI of the artifact"
| String,
2024-07-19 17:05:46 +02:00
comment
| doc "Additional comments on the artifact that couldn't be written elsewhere"
| String,
2024-07-30 18:06:16 +02:00
virtualization
| doc "Virtualization technology used in the artifact. Possible values: docker"
| VirtTech,
buildfile_dir
| doc "Path to the directory containing the file used to build the container in the artifact"
2024-07-17 14:56:38 +02:00
| FilePath,
2024-07-11 16:05:08 +02:00
package_managers
2024-07-19 17:05:46 +02:00
| doc "Package Managers used in the container. Possible values: dpkg, rpm, pacman, pip, conda"
2024-07-11 16:05:08 +02:00
| Array PackageManager,
git_packages
| doc "Git repositories cloned in the container"
| Array GitPackage,
misc_packages
| doc "Misc. packages downloaded from the container"
| Array MiscPackage,
2024-07-24 18:05:31 +02:00
python_venvs
| doc "Python venvs created in the container"
| Array PythonVenv
2024-07-11 16:05:08 +02:00
}
}