Use default labels with no interactive register (#5)

Co-authored-by: Jason Song <i@wolfogre.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/5
This commit is contained in:
Jason Song 2022-12-02 12:01:50 +08:00
parent 8996b9b0e4
commit 0f97dd873a
1 changed files with 11 additions and 7 deletions

View File

@ -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 != "" {