summaryrefslogtreecommitdiff
path: root/pkg/adapter/client_unix.go
blob: e0406567cec58b2ffa0d32b2741f320cf56b22f0 (plain)
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
// +build linux darwin
// +build remoteclient

package adapter

import (
	"fmt"

	"github.com/containers/libpod/cmd/podman/remoteclientconfig"
	"github.com/pkg/errors"
)

// newBridgeConnection creates a bridge type endpoint with username, destination, and log-level
func newBridgeConnection(formattedBridge string, remoteConn *remoteclientconfig.RemoteConnection, logLevel string) (*Endpoint, error) {
	endpoint := Endpoint{
		Type: BridgeConnection,
	}

	if len(formattedBridge) < 1 && remoteConn == nil {
		return nil, errors.New("bridge connections must either be created by string or remoteconnection")
	}
	if len(formattedBridge) > 0 {
		endpoint.Connection = formattedBridge
		return &endpoint, nil
	}
	endpoint.Connection = fmt.Sprintf(
		`ssh -T %s@%s -- /usr/bin/varlink -A \'/usr/bin/podman --log-level=%s varlink \\\$VARLINK_ADDRESS\' bridge`,
		remoteConn.Username, remoteConn.Destination, logLevel)
	return &endpoint, nil
}