Commit afe9bfc0 authored by Yannik Dällenbach's avatar Yannik Dällenbach 🤼 Committed by Yannik Dällenbach
Browse files

Get information on how to connect to server

parent 325a8304
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -156,7 +156,26 @@ func (g *instanceGroup) Update(ctx context.Context, update func(instance string,

// ConnectInfo implements provider.InstanceGroup.
func (g *instanceGroup) ConnectInfo(ctx context.Context, instance string) (provider.ConnectInfo, error) {
	return provider.ConnectInfo{}, nil
	info := provider.ConnectInfo{ConnectorConfig: g.settings.ConnectorConfig}

	server, err := g.client.Servers.Get(ctx, instance)
	if err != nil {
		return provider.ConnectInfo{}, fmt.Errorf("failed to get server %s: %w", instance, err)
	}

	// General information
	info.ID = server.UUID
	info.OS = server.Image.OperatingSystem
	info.Arch = "amd64" // cloudscale.ch only provides amd64

	// Authentication
	info.Username = server.Image.DefaultUsername
	info.Key = g.settings.Key

	// Use the public address to access the instance
	info.ExternalAddr = server.Interfaces[0].Addresses[0].Address

	return info, nil
}

// Shutdown implements provider.InstanceGroup.