Skip to content

Commit

Permalink
Make more options variable-expanded (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj authored Nov 7, 2024
2 parents b11fcdd + aa1240b commit 4678ab8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interval = 30
# - Any variables defined in runners.<runner_name>.config_variables
# - Any environment variables provided by gitlab-runner to this custom executor
[launch]
# Executable name or path, will NOT be variable-expanded
# Executable name or path, will be variable-expanded
executable = "sbatch"
# Arguments to pass to the executable, they will be variable-expanded
args = []
Expand Down Expand Up @@ -91,7 +91,7 @@ image_cache_dir = "$HOME/image_cache"
image_tmp_dir = "$HOME/image_tmp"
# Pull policy to use for images, will NOT be variable-expanded
pull_policy = "if-not-present"
# Path to the apptainer executable (may be relative to workdir or $PATH), will NOT be variable-expanded
# Path to the apptainer executable (may be relative to workdir or $PATH), will be variable-expanded
apptainer_executable = "apptainer"
# Mount AMD GPU devices, will be variable-expanded
gpu_amd = false
Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub struct GitLabRunnerInstance {

#[derive(Debug, DocumentedFields, FieldNamesAsArray, Deserialize, Serialize)]
pub struct GitLabLaunchConfig {
/// Executable name or path, will NOT be variable-expanded
/// Executable name or path, will be variable-expanded
pub executable: String,
/// Arguments to pass to the executable, they will be variable-expanded
pub args: Vec<String>,
Expand Down Expand Up @@ -150,8 +150,8 @@ pub struct GitLabCustomExecutorConfigTemplate {
pub image_tmp_dir: Option<String>,
/// Pull policy to use for images, will NOT be variable-expanded
pub pull_policy: GitLabExecutorPullPolicy,
/// Path to the apptainer executable (may be relative to workdir or $PATH), will NOT be variable-expanded
pub apptainer_executable: PathBuf,
/// Path to the apptainer executable (may be relative to workdir or $PATH), will be variable-expanded
pub apptainer_executable: String,
#[serde(default = "false_bool_or_string")]
/// Mount AMD GPU devices, will be variable-expanded
pub gpu_amd: BoolOrString,
Expand Down
14 changes: 10 additions & 4 deletions src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ pub fn expand_runner_config_template(
.environment
.as_ref()
.map(|m| m.iter().map(|v| string_expand(v)).collect())
.transpose()?,
.transpose()
.context("environment")?,
executor: match &config.executor {
Executor::Custom {
custom:
Expand Down Expand Up @@ -143,14 +144,17 @@ pub fn expand_executor_config_template(
.transpose()
.context("image_tmp_dir")?,
pull_policy: executor.pull_policy,
apptainer_executable: executor.apptainer_executable.clone(),
apptainer_executable: string_expand(&executor.apptainer_executable)
.context("apptainer_executable")?
.into(),
gpu_amd: expand_to_bool(&executor.gpu_amd).context("gpu_amd")?,
gpu_nvidia: expand_to_bool(&executor.gpu_nvidia).context("gpu_nvidia")?,
mount: executor
.mount
.iter()
.map(|v| string_expand(v))
.collect::<anyhow::Result<Vec<_>>>()?,
.collect::<anyhow::Result<Vec<_>>>()
.context("mount")?,
builds_dir: string_expand(
executor
.builds_dir
Expand Down Expand Up @@ -195,7 +199,9 @@ pub fn expand_launch_config_template(
v.into_iter().map(|s| string_expand(s)).collect()
};
Ok(GitLabLaunchConfig {
executable: launch.executable.clone(),
executable: string_expand(&launch.executable)
.context("executable")?
.into(),
args: string_array_expand(&launch.args).context("args")?,
workdir: optional_string_expand(&launch.workdir).context("workdir")?,
stdin: optional_string_expand(&launch.stdin).context("stdin")?,
Expand Down

0 comments on commit 4678ab8

Please sign in to comment.