Files
Alloy/lib/std.alloy

86 lines
2.1 KiB
Plaintext

declare "fmt_repository_path" {
argument "repository" {
optional = true
comment = "The repository to use for url"
default = "https://git.kkarolis.lt/karolis/Alloy/"
}
argument "type" {
optional = true
comment = "Type of access to the repository, e.g. 'raw' for raw files"
default = "raw"
}
argument "branch" {
optional = true
comment = "The branch to use for the repository"
default = "main"
}
argument "path" {
optional = false
comment = "The path to the file in the repository"
default = ""
}
export "url" {
value = string.format("%s%s/branch/%s/%s", argument.repository.value, argument.type.value, argument.branch.value, argument.path.value)
}
}
declare "load_config" {
argument "config_file" {
optional = false
comment = "The path to the configuration file"
}
argument "repository" {
optional = true
comment = "The repository to use for loading the configuration"
default = "https://git.kkarolis.lt/karolis/Alloy/"
}
fmt_repository_path "config_file_url" {
repository = argument.repository.value
type = "raw"
branch = "main"
path = argument.config_file.value
}
remote.http "config_file" {
url = fmt_repository_path.config_file_url.url
}
export "config" {
value = remote.http.config_file.content
}
}
declare "load_host_config" {
argument "host" {
optional = true
comment = "The host to load the configuration for"
default = sys.env("GCLOUD_FM_COLLECTOR_ID")
}
argument "config_file" {
optional = false
comment = "The path to the configuration file"
}
argument "repository" {
optional = true
comment = "The repository to use for loading the configuration"
default = "https://git.kkarolis.lt/karolis/Alloy/"
}
load_config "remote" {
config_file = argument.config_file.value
repository = argument.repository.value
}
export "config" {
value = encoding.from_yaml(load_config.remote.config)[argument.host.value]
}
}