mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-06 13:18:58 +00:00
add support for tcp cluster connections in uncloud config
This commit is contained in:
1 parent
6d1c3aa5b2
commit
3d5fe0a824
2 files changed
+16
-9
No files matched your search
+14
-9
@@ -88,16 +88,21 @@ func (cli *CLI) ConnectCluster(ctx context.Context, clusterName string) (*client
|
||||
|
||||
// TODO: iterate over all connections and try to connect to the cluster using the first successful connection.
|
||||
conn := cfg.Connections[0]
|
||||
user, host, port, err := conn.SSH.Parse()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse SSH connection %q: %w", conn.SSH, err)
|
||||
if conn.SSH != "" {
|
||||
user, host, port, err := conn.SSH.Parse()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse SSH connection %q: %w", conn.SSH, err)
|
||||
}
|
||||
sshConfig := &connector.SSHConnectorConfig{
|
||||
User: user,
|
||||
Host: host,
|
||||
Port: port,
|
||||
}
|
||||
return client.New(ctx, connector.NewSSHConnector(sshConfig))
|
||||
} else if conn.TCP.IsValid() {
|
||||
return client.New(ctx, connector.NewTCPConnector(conn.TCP))
|
||||
}
|
||||
sshConfig := &connector.SSHConnectorConfig{
|
||||
User: user,
|
||||
Host: host,
|
||||
Port: port,
|
||||
}
|
||||
return client.New(ctx, connector.NewSSHConnector(sshConfig))
|
||||
return nil, errors.New("no valid connection configuration found for the cluster")
|
||||
}
|
||||
|
||||
func (cli *CLI) InitCluster(
|
||||
|
||||
Reference in new issue
Block a user