Skip to content

Commit 8c0d420

Browse files
gmeligiogithub-actions[bot]npalm
authored
feat: Add runners_pull_policies to support multiple pull policies (#544)
* 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]>
1 parent edf479e commit 8c0d420

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ Made with [contributors-img](https://contrib.rocks).
483483
| <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 |
484484
| <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 |
485485
| <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 |
486-
| <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 |
486+
| <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 |
487+
| <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 |
487488
| <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 |
488489
| <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 |
489490
| <a name="input_runners_root_size"></a> [runners\_root\_size](#input\_runners\_root\_size) | Runner instance root size in GB. | `number` | `16` | no |

locals.tf

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ locals {
2727
}
2828
)
2929

30+
runners_pull_policies = var.runners_pull_policy != "" ? "[\"${var.runners_pull_policy}\"]" : "[\"${join("\",\"", var.runners_pull_policies)}\"]"
31+
3032
/* determines if the docker machine executable adds the Name tag automatically (versions >= 0.16.2) */
3133
# make sure to skip pre-release stuff in the semver by ignoring everything after "-"
3234
docker_machine_version_used = split(".", split("-", var.docker_machine_version)[0])

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ locals {
105105
runners_docker_runtime = var.runners_docker_runtime
106106
runners_helper_image = var.runners_helper_image
107107
runners_shm_size = var.runners_shm_size
108-
runners_pull_policy = var.runners_pull_policy
108+
runners_pull_policies = local.runners_pull_policies
109109
runners_idle_count = var.runners_idle_count
110110
runners_idle_time = var.runners_idle_time
111111
runners_max_builds = local.runners_max_builds_string

template/runner-config.tpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ listen_address = "${prometheus_listen_address}"
2525
volumes = ["/cache"${runners_additional_volumes}]
2626
extra_hosts = ${jsonencode(runners_extra_hosts)}
2727
shm_size = ${runners_shm_size}
28-
pull_policy = "${runners_pull_policy}"
28+
allowed_pull_policies = ${runners_pull_policies}
2929
runtime = "${runners_docker_runtime}"
3030
helper_image = "${runners_helper_image}"
3131
[runners.docker.tmpfs]

variables.tf

+8-2
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,15 @@ variable "runners_helper_image" {
238238
}
239239

240240
variable "runners_pull_policy" {
241-
description = "pull_policy for the runners, will be used in the runner config.toml"
241+
description = "Deprecated! Use runners_pull_policies instead. pull_policy for the runners, will be used in the runner config.toml"
242242
type = string
243-
default = "always"
243+
default = ""
244+
}
245+
246+
variable "runners_pull_policies" {
247+
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 "
248+
type = list(string)
249+
default = ["always"]
244250
}
245251

246252
variable "runners_monitoring" {

0 commit comments

Comments
 (0)