From 0f97dd873a0bff4195acc3cf4cc7ace3f93f21ff Mon Sep 17 00:00:00 2001 From: Jason Song Date: Fri, 2 Dec 2022 12:01:50 +0800 Subject: [PATCH] Use default labels with no interactive register (#5) Co-authored-by: Jason Song Reviewed-on: https://gitea.com/gitea/act_runner/pulls/5 --- cmd/register.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/register.go b/cmd/register.go index efb0109..d939b9a 100644 --- a/cmd/register.go +++ b/cmd/register.go @@ -87,6 +87,15 @@ const ( StageExit ) +var ( + defaultLabels = []string{ + "ubuntu-latest:docker://node:16-bullseye", + "ubuntu-22.04:docker://node:16-bullseye", // There's no node:16-bookworm yet + "ubuntu-20.04:docker://node:16-bullseye", + "ubuntu-18.04:docker://node:16-buster", + } +) + type registerInputs struct { InstanceAddr string Token string @@ -148,15 +157,9 @@ func (r *registerInputs) assignToNext(stage registerStage, value string) registe r.RunnerName = value return StageInputCustomLabels case StageInputCustomLabels: + r.CustomLabels = defaultLabels if value != "" { r.CustomLabels = strings.Split(value, ",") - } else { - r.CustomLabels = []string{ - "ubuntu-latest:docker://node:16-bullseye", - "ubuntu-22.04:docker://node:16-bullseye", // There's no node:16-bookworm yet - "ubuntu-20.04:docker://node:16-bullseye", - "ubuntu-18.04:docker://node:16-buster", - } } if validateLabels(r.CustomLabels) != nil { @@ -237,6 +240,7 @@ func registerNoInteractive(envFile string, regArgs *registerArgs) error { InstanceAddr: regArgs.InstanceAddr, Token: regArgs.Token, RunnerName: regArgs.RunnerName, + CustomLabels: defaultLabels, } regArgs.Labels = strings.TrimSpace(regArgs.Labels) if regArgs.Labels != "" {