mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2024-12-18 11:52:16 +03:00
90b8cc6a7a
The label will follow the format `label[:schema[:args]]`, and the schema will be `host` if it's omitted. So - `ubuntu:docker://node:18`: Run jobs with label `ubuntu` via docker with image `node:18` - `ubuntu:host`: Run jobs with label `ubuntu` on the host directly. - `ubuntu`: Same as `ubuntu:host`. - `ubuntu:vm:ubuntu-latest`: (Just a example, not Implemented) Run jobs with label `ubuntu` via virtual machine with iso `ubuntu-latest`. Reviewed-on: https://gitea.com/gitea/act_runner/pulls/69 Reviewed-by: Zettat123 <zettat123@noreply.gitea.io> Reviewed-by: wxiaoguang <wxiaoguang@noreply.gitea.io>
26 lines
507 B
Go
26 lines
507 B
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package runtime
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func ParseLabel(str string) (label, schema, arg string, err error) {
|
|
splits := strings.SplitN(str, ":", 3)
|
|
label = splits[0]
|
|
schema = "host"
|
|
arg = ""
|
|
if len(splits) >= 2 {
|
|
schema = splits[1]
|
|
}
|
|
if len(splits) >= 3 {
|
|
arg = splits[2]
|
|
}
|
|
if schema != "host" && schema != "docker" {
|
|
return "", "", "", fmt.Errorf("unsupported schema: %s", schema)
|
|
}
|
|
return
|
|
}
|