Skip to content

Commit

Permalink
feat: Add runners_pull_policies to support multiple pull policies (#544)
Browse files Browse the repository at this point in the history
* feat: add runners_pull_policies

* fix: typo in runner-config.tpl

* docs: auto update terraform docs

* fix: put separator before list in join

* Update locals.tf

* Update template/runner-config.tpl

* Update variables.tf

* docs: auto update terraform docs

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Niek Palm <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2022
1 parent edf479e commit 8c0d420
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ Made with [contributors-img](https://contrib.rocks).
| <a name="input_runners_pre_build_script"></a> [runners\_pre\_build\_script](#input\_runners\_pre\_build\_script) | Script to execute in the pipeline just before the build, will be used in the runner config.toml | `string` | `"\"\""` | no |
| <a name="input_runners_pre_clone_script"></a> [runners\_pre\_clone\_script](#input\_runners\_pre\_clone\_script) | Commands to be executed on the Runner before cloning the Git repository. this can be used to adjust the Git client configuration first, for example. | `string` | `"\"\""` | no |
| <a name="input_runners_privileged"></a> [runners\_privileged](#input\_runners\_privileged) | Runners will run in privileged mode, will be used in the runner config.toml | `bool` | `true` | no |
| <a name="input_runners_pull_policy"></a> [runners\_pull\_policy](#input\_runners\_pull\_policy) | pull\_policy for the runners, will be used in the runner config.toml | `string` | `"always"` | no |
| <a name="input_runners_pull_policies"></a> [runners\_pull\_policies](#input\_runners\_pull\_policies) | pull policies for the runners, will be used in the runner config.toml, for Gitlab Runner >= 13.8, see https://docs.gitlab.com/runner/executors/docker.html#using-multiple-pull-policies | `list(string)` | <pre>[<br> "always"<br>]</pre> | no |
| <a name="input_runners_pull_policy"></a> [runners\_pull\_policy](#input\_runners\_pull\_policy) | Deprecated! Use runners\_pull\_policies instead. pull\_policy for the runners, will be used in the runner config.toml | `string` | `""` | no |
| <a name="input_runners_request_concurrency"></a> [runners\_request\_concurrency](#input\_runners\_request\_concurrency) | Limit number of concurrent requests for new jobs from GitLab (default 1). | `number` | `1` | no |
| <a name="input_runners_request_spot_instance"></a> [runners\_request\_spot\_instance](#input\_runners\_request\_spot\_instance) | Whether or not to request spot instances via docker-machine | `bool` | `true` | no |
| <a name="input_runners_root_size"></a> [runners\_root\_size](#input\_runners\_root\_size) | Runner instance root size in GB. | `number` | `16` | no |
Expand Down
2 changes: 2 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ locals {
}
)

runners_pull_policies = var.runners_pull_policy != "" ? "[\"${var.runners_pull_policy}\"]" : "[\"${join("\",\"", var.runners_pull_policies)}\"]"

/* determines if the docker machine executable adds the Name tag automatically (versions >= 0.16.2) */
# make sure to skip pre-release stuff in the semver by ignoring everything after "-"
docker_machine_version_used = split(".", split("-", var.docker_machine_version)[0])
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ locals {
runners_docker_runtime = var.runners_docker_runtime
runners_helper_image = var.runners_helper_image
runners_shm_size = var.runners_shm_size
runners_pull_policy = var.runners_pull_policy
runners_pull_policies = local.runners_pull_policies
runners_idle_count = var.runners_idle_count
runners_idle_time = var.runners_idle_time
runners_max_builds = local.runners_max_builds_string
Expand Down
2 changes: 1 addition & 1 deletion template/runner-config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ listen_address = "${prometheus_listen_address}"
volumes = ["/cache"${runners_additional_volumes}]
extra_hosts = ${jsonencode(runners_extra_hosts)}
shm_size = ${runners_shm_size}
pull_policy = "${runners_pull_policy}"
allowed_pull_policies = ${runners_pull_policies}
runtime = "${runners_docker_runtime}"
helper_image = "${runners_helper_image}"
[runners.docker.tmpfs]
Expand Down
10 changes: 8 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,15 @@ variable "runners_helper_image" {
}

variable "runners_pull_policy" {
description = "pull_policy for the runners, will be used in the runner config.toml"
description = "Deprecated! Use runners_pull_policies instead. pull_policy for the runners, will be used in the runner config.toml"
type = string
default = "always"
default = ""
}

variable "runners_pull_policies" {
description = "pull policies for the runners, will be used in the runner config.toml, for Gitlab Runner >= 13.8, see https://docs.gitlab.com/runner/executors/docker.html#using-multiple-pull-policies "
type = list(string)
default = ["always"]
}

variable "runners_monitoring" {
Expand Down

0 comments on commit 8c0d420

Please sign in to comment.