mirror of
https://gitea.com/gitea/act_runner.git
synced 2024-12-30 21:07:09 +01:00
27 lines
507 B
Go
27 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
|
||
|
}
|