File: ssh.go

package info (click to toggle)
docker-buildx 0.19.3%2Bds1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,852 kB
  • sloc: sh: 318; makefile: 73
file content (39 lines) | stat: -rw-r--r-- 757 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
}