podman

Форк
0
45 строк · 1.2 Кб
1
//go:build amd64 || arm64
2

3
package connection
4

5
import (
6
	"fmt"
7
	"strconv"
8

9
	"github.com/containers/podman/v5/pkg/machine/define"
10
)
11

12
// AddSSHConnectionsToPodmanSocket adds SSH connections to the podman socket if
13
// no ignition path is provided
14
func AddSSHConnectionsToPodmanSocket(uid, port int, identityPath, name, remoteUsername string, opts define.InitOptions) error {
15
	if len(opts.IgnitionPath) > 0 {
16
		fmt.Println("An ignition path was provided.  No SSH connection was added to Podman")
17
		return nil
18
	}
19

20
	cons := createConnections(name, uid, port, remoteUsername)
21

22
	// The first connection defined when connections is empty will become the default
23
	// regardless of IsDefault, so order according to rootful
24
	if opts.Rootful {
25
		cons[0], cons[1] = cons[1], cons[0]
26
	}
27

28
	return addConnection(cons, identityPath, opts.IsDefault)
29
}
30

31
func createConnections(name string, uid, port int, remoteUsername string) []connection {
32
	uri := makeSSHURL(LocalhostIP, fmt.Sprintf("/run/user/%d/podman/podman.sock", uid), strconv.Itoa(port), remoteUsername)
33
	uriRoot := makeSSHURL(LocalhostIP, "/run/podman/podman.sock", strconv.Itoa(port), "root")
34

35
	return []connection{
36
		{
37
			name: name,
38
			uri:  uri,
39
		},
40
		{
41
			name: name + "-root",
42
			uri:  uriRoot,
43
		},
44
	}
45
}
46

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.