mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00

These parser functions are called for `--set` to resolve entitlement paths that would be automatically added and will fail for empty value. The empty values would already be ignored but in v0.19 is done after merging the `--set` values and then calling parse again. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
40 lines
757 B
Go
40 lines
757 B
Go
package buildflags
|
|
|
|
import (
|
|
"strings"
|
|
|
|
controllerapi "github.com/docker/buildx/controller/pb"
|
|
"github.com/moby/buildkit/util/gitutil"
|
|
)
|
|
|
|
func ParseSSHSpecs(sl []string) ([]*controllerapi.SSH, error) {
|
|
var outs []*controllerapi.SSH
|
|
if len(sl) == 0 {
|
|
return nil, nil
|
|
}
|
|
|
|
for _, s := range sl {
|
|
if s == "" {
|
|
continue
|
|
}
|
|
parts := strings.SplitN(s, "=", 2)
|
|
out := controllerapi.SSH{
|
|
ID: parts[0],
|
|
}
|
|
if len(parts) > 1 {
|
|
out.Paths = strings.Split(parts[1], ",")
|
|
}
|
|
outs = append(outs, &out)
|
|
}
|
|
return outs, nil
|
|
}
|
|
|
|
// IsGitSSH returns true if the given repo URL is accessed over ssh
|
|
func IsGitSSH(repo string) bool {
|
|
url, err := gitutil.ParseURL(repo)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return url.Scheme == gitutil.SSHProtocol
|
|
}
|