mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
feat(push): stub for 'image push' command and Dialer interface for cluster connectors
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/psviderski/uncloud/internal/machine/api/pb"
|
||||
"github.com/psviderski/uncloud/internal/machine/docker"
|
||||
"github.com/psviderski/uncloud/pkg/api"
|
||||
"golang.org/x/net/proxy"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
@@ -31,9 +32,12 @@ type Client struct {
|
||||
|
||||
var _ api.Client = (*Client)(nil)
|
||||
|
||||
// Connector is an interface for establishing a connection to the machine API.
|
||||
// Connector is an interface for establishing a connection to the cluster.
|
||||
type Connector interface {
|
||||
// Connect establishes a gRPC client connection to the machine API.
|
||||
Connect(ctx context.Context) (*grpc.ClientConn, error)
|
||||
// Dialer returns a proxy dialer for establishing connections within the cluster if supported by the connector.
|
||||
Dialer() (proxy.ContextDialer, error)
|
||||
Close() error
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/psviderski/uncloud/internal/machine"
|
||||
"github.com/psviderski/uncloud/internal/sshexec"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"golang.org/x/net/proxy"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
@@ -79,6 +80,10 @@ func (c *SSHConnector) Connect(ctx context.Context) (*grpc.ClientConn, error) {
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func (c *SSHConnector) Dialer() (proxy.ContextDialer, error) {
|
||||
return nil, fmt.Errorf("dialer not implemented for SSHConnector yet")
|
||||
}
|
||||
|
||||
func (c *SSHConnector) Close() error {
|
||||
if c.client != nil {
|
||||
err := c.client.Close()
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net/netip"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
@@ -29,6 +30,10 @@ func (c *TCPConnector) Connect(_ context.Context) (*grpc.ClientConn, error) {
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func (c *TCPConnector) Dialer() (proxy.ContextDialer, error) {
|
||||
return nil, fmt.Errorf("proxy connections are not supported over a TCP connection")
|
||||
}
|
||||
|
||||
func (c *TCPConnector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/psviderski/uncloud/internal/machine/network"
|
||||
"github.com/psviderski/uncloud/internal/machine/network/tunnel"
|
||||
"github.com/psviderski/uncloud/pkg/client"
|
||||
"golang.org/x/net/proxy"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
@@ -75,6 +76,10 @@ func (c *WireGuardConnector) Connect(ctx context.Context) (*grpc.ClientConn, err
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func (c *WireGuardConnector) Dialer() (proxy.ContextDialer, error) {
|
||||
return nil, fmt.Errorf("proxy connections not implemented for WireGuard connector")
|
||||
}
|
||||
|
||||
func (c *WireGuardConnector) Close() error {
|
||||
if c.tun != nil {
|
||||
c.tun.Close()
|
||||
|
||||
Reference in New Issue
Block a user