mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
feat(dns): missed CLI changes
This commit is contained in:
+22
-3
@@ -112,17 +112,27 @@ func (cli *CLI) ConnectCluster(ctx context.Context, clusterName string) (*client
|
|||||||
// InitCluster initialises a new cluster on a remote machine and returns a client to interact with the cluster.
|
// InitCluster initialises a new cluster on a remote machine and returns a client to interact with the cluster.
|
||||||
// The client should be closed after use by the caller.
|
// The client should be closed after use by the caller.
|
||||||
func (cli *CLI) InitCluster(
|
func (cli *CLI) InitCluster(
|
||||||
ctx context.Context, remoteMachine *RemoteMachine, clusterName, machineName string, netPrefix netip.Prefix,
|
ctx context.Context,
|
||||||
|
remoteMachine *RemoteMachine,
|
||||||
|
clusterName,
|
||||||
|
machineName string,
|
||||||
|
netPrefix netip.Prefix,
|
||||||
|
publicIP *netip.Addr,
|
||||||
) (*client.Client, error) {
|
) (*client.Client, error) {
|
||||||
if remoteMachine != nil {
|
if remoteMachine != nil {
|
||||||
return cli.initRemoteMachine(ctx, *remoteMachine, clusterName, machineName, netPrefix)
|
return cli.initRemoteMachine(ctx, *remoteMachine, clusterName, machineName, netPrefix, publicIP)
|
||||||
}
|
}
|
||||||
// TODO: implement local machine initialisation
|
// TODO: implement local machine initialisation
|
||||||
return nil, fmt.Errorf("local machine initialisation is not implemented yet")
|
return nil, fmt.Errorf("local machine initialisation is not implemented yet")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *CLI) initRemoteMachine(
|
func (cli *CLI) initRemoteMachine(
|
||||||
ctx context.Context, remoteMachine RemoteMachine, clusterName, machineName string, netPrefix netip.Prefix,
|
ctx context.Context,
|
||||||
|
remoteMachine RemoteMachine,
|
||||||
|
clusterName,
|
||||||
|
machineName string,
|
||||||
|
netPrefix netip.Prefix,
|
||||||
|
publicIP *netip.Addr,
|
||||||
) (*client.Client, error) {
|
) (*client.Client, error) {
|
||||||
if clusterName == "" {
|
if clusterName == "" {
|
||||||
clusterName = defaultClusterName
|
clusterName = defaultClusterName
|
||||||
@@ -157,6 +167,15 @@ func (cli *CLI) initRemoteMachine(
|
|||||||
MachineName: machineName,
|
MachineName: machineName,
|
||||||
Network: pb.NewIPPrefix(netPrefix),
|
Network: pb.NewIPPrefix(netPrefix),
|
||||||
}
|
}
|
||||||
|
if publicIP != nil {
|
||||||
|
if publicIP.IsValid() {
|
||||||
|
req.PublicIpConfig = &pb.InitClusterRequest_PublicIp{PublicIp: pb.NewIP(*publicIP)}
|
||||||
|
} else {
|
||||||
|
// Invalid or in other words zero IP means to automatically detect the public IP.
|
||||||
|
req.PublicIpConfig = &pb.InitClusterRequest_PublicIpAuto{PublicIpAuto: true}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := machineClient.InitCluster(ctx, req)
|
resp, err := machineClient.InitCluster(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("init cluster: %w", err)
|
return nil, fmt.Errorf("init cluster: %w", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user