Skip to content

Commit 1003b4f

Browse files
authored
Merge branch 'lxc:main' into nix-shell
2 parents f579dd3 + 6247aa7 commit 1003b4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+18635
-16533
lines changed

client/incus.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,11 @@ func (r *ProtocolIncus) rawWebsocket(url string) (*websocket.Conn, error) {
452452

453453
// Setup a new websocket dialer based on it
454454
dialer := websocket.Dialer{
455-
NetDialContext: httpTransport.DialContext,
456-
TLSClientConfig: httpTransport.TLSClientConfig,
457-
Proxy: httpTransport.Proxy,
458-
HandshakeTimeout: time.Second * 5,
455+
NetDialTLSContext: httpTransport.DialTLSContext,
456+
NetDialContext: httpTransport.DialContext,
457+
TLSClientConfig: httpTransport.TLSClientConfig,
458+
Proxy: httpTransport.Proxy,
459+
HandshakeTimeout: time.Second * 5,
459460
}
460461

461462
// Create temporary http.Request using the http url, not the ws one, so that we can add the client headers

client/incus_instances.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ func (r *ProtocolIncus) GetInstanceFileSFTP(instanceName string) (*sftp.Client,
16961696
}
16971697

16981698
// Get a SFTP client.
1699-
client, err := sftp.NewClientPipe(conn, conn)
1699+
client, err := sftp.NewClientPipe(conn, conn, sftp.MaxPacketUnchecked(128*1024))
17001700
if err != nil {
17011701
_ = conn.Close()
17021702
return nil, err
@@ -2528,6 +2528,10 @@ func (r *ProtocolIncus) ConsoleInstance(instanceName string, console api.Instanc
25282528
return nil, fmt.Errorf("The server is missing the required \"console_vga_type\" API extension")
25292529
}
25302530

2531+
if console.Force && !r.HasExtension("console_force") {
2532+
return nil, fmt.Errorf(`The server is missing the required "console_force" API extension`)
2533+
}
2534+
25312535
// Send the request
25322536
op, _, err := r.queryOperation("POST", fmt.Sprintf("%s/%s/console", path, url.PathEscape(instanceName)), console, "")
25332537
if err != nil {
@@ -2616,6 +2620,10 @@ func (r *ProtocolIncus) ConsoleInstanceDynamic(instanceName string, console api.
26162620
return nil, nil, fmt.Errorf("The server is missing the required \"console_vga_type\" API extension")
26172621
}
26182622

2623+
if console.Force && !r.HasExtension("console_force") {
2624+
return nil, nil, fmt.Errorf(`The server is missing the required "console_force" API extension`)
2625+
}
2626+
26192627
// Send the request.
26202628
op, _, err := r.queryOperation("POST", fmt.Sprintf("%s/%s/console", path, url.PathEscape(instanceName)), console, "")
26212629
if err != nil {

cmd/incus-simplestreams/main_list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"os"
45
"sort"
56

67
"github.com/spf13/cobra"
@@ -67,5 +68,5 @@ func (c *cmdList) Run(cmd *cobra.Command, args []string) error {
6768
"CREATED",
6869
}
6970

70-
return cli.RenderTable(c.flagFormat, header, data, images)
71+
return cli.RenderTable(os.Stdout, c.flagFormat, header, data, images)
7172
}

cmd/incus/admin_sql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,5 +166,5 @@ func (c *cmdAdminSQL) sqlPrintSelectResult(result internalSQL.SQLResult) error {
166166
data = append(data, rowData)
167167
}
168168

169-
return cli.RenderTable(c.flagFormat, result.Columns, data, result)
169+
return cli.RenderTable(os.Stdout, c.flagFormat, result.Columns, data, result)
170170
}

cmd/incus/alias.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"fmt"
5+
"os"
56
"sort"
67

78
"github.com/spf13/cobra"
@@ -149,7 +150,7 @@ func (c *cmdAliasList) Run(cmd *cobra.Command, args []string) error {
149150
i18n.G("TARGET"),
150151
}
151152

152-
return cli.RenderTable(c.flagFormat, header, data, conf.Aliases)
153+
return cli.RenderTable(os.Stdout, c.flagFormat, header, data, conf.Aliases)
153154
}
154155

155156
// Rename.

cmd/incus/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func (c *cmdClusterList) Run(cmd *cobra.Command, args []string) error {
302302
header = append(header, column.Name)
303303
}
304304

305-
return cli.RenderTable(c.flagFormat, header, data, members)
305+
return cli.RenderTable(os.Stdout, c.flagFormat, header, data, members)
306306
}
307307

308308
// Show.
@@ -1221,7 +1221,7 @@ func (c *cmdClusterListTokens) Run(cmd *cobra.Command, args []string) error {
12211221
header = append(header, column.Name)
12221222
}
12231223

1224-
return cli.RenderTable(c.flagFormat, header, data, joinTokens)
1224+
return cli.RenderTable(os.Stdout, c.flagFormat, header, data, joinTokens)
12251225
}
12261226

12271227
// Revoke Tokens.

cmd/incus/cluster_group.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ func (c *cmdClusterGroupAssign) Run(cmd *cobra.Command, args []string) error {
176176
type cmdClusterGroupCreate struct {
177177
global *cmdGlobal
178178
cluster *cmdCluster
179+
180+
flagDescription string
179181
}
180182

181183
// Creation of a new cluster group, defining its usage, short and long descriptions, and the RunE method.
@@ -191,6 +193,8 @@ func (c *cmdClusterGroupCreate) Command() *cobra.Command {
191193
incus cluster group create g1 < config.yaml
192194
Create a cluster group with configuration from config.yaml`))
193195

196+
cmd.Flags().StringVar(&c.flagDescription, "description", "", i18n.G("Cluster group description")+"``")
197+
194198
cmd.RunE = c.Run
195199

196200
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
@@ -245,6 +249,10 @@ func (c *cmdClusterGroupCreate) Run(cmd *cobra.Command, args []string) error {
245249
ClusterGroupPut: stdinData,
246250
}
247251

252+
if c.flagDescription != "" {
253+
group.Description = c.flagDescription
254+
}
255+
248256
err = resource.server.CreateClusterGroup(group)
249257
if err != nil {
250258
return err
@@ -592,7 +600,7 @@ func (c *cmdClusterGroupList) Run(cmd *cobra.Command, args []string) error {
592600
header = append(header, column.Name)
593601
}
594602

595-
return cli.RenderTable(c.flagFormat, header, data, groups)
603+
return cli.RenderTable(os.Stdout, c.flagFormat, header, data, groups)
596604
}
597605

598606
// Remove.

cmd/incus/config_template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func (c *cmdConfigTemplateList) Run(cmd *cobra.Command, args []string) error {
339339
i18n.G("FILENAME"),
340340
}
341341

342-
return cli.RenderTable(c.flagFormat, header, data, templates)
342+
return cli.RenderTable(os.Stdout, c.flagFormat, header, data, templates)
343343
}
344344

345345
// Show.

cmd/incus/config_trust.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,11 @@ type cmdConfigTrustAddCertificate struct {
158158
config *cmdConfig
159159
configTrust *cmdConfigTrust
160160

161-
flagProjects string
162-
flagRestricted bool
163-
flagName string
164-
flagType string
161+
flagProjects string
162+
flagRestricted bool
163+
flagName string
164+
flagType string
165+
flagDescription string
165166
}
166167

167168
func (c *cmdConfigTrustAddCertificate) Command() *cobra.Command {
@@ -180,6 +181,7 @@ The following certificate types are supported:
180181
cmd.Flags().StringVar(&c.flagProjects, "projects", "", i18n.G("List of projects to restrict the certificate to")+"``")
181182
cmd.Flags().StringVar(&c.flagName, "name", "", i18n.G("Alternative certificate name")+"``")
182183
cmd.Flags().StringVar(&c.flagType, "type", "client", i18n.G("Type of certificate")+"``")
184+
cmd.Flags().StringVar(&c.flagDescription, "description", "", i18n.G("Certificate description")+"``")
183185

184186
cmd.RunE = c.Run
185187

@@ -246,6 +248,7 @@ func (c *cmdConfigTrustAddCertificate) Run(cmd *cobra.Command, args []string) er
246248
cert := api.CertificatesPost{}
247249
cert.Certificate = base64.StdEncoding.EncodeToString(x509Cert.Raw)
248250
cert.Name = name
251+
cert.Description = c.flagDescription
249252

250253
if c.flagType == "client" {
251254
cert.Type = api.CertificateTypeClient
@@ -565,7 +568,7 @@ func (c *cmdConfigTrustList) Run(cmd *cobra.Command, args []string) error {
565568
headers = append(headers, column.Name)
566569
}
567570

568-
return cli.RenderTable(c.flagFormat, headers, data, trust)
571+
return cli.RenderTable(os.Stdout, c.flagFormat, headers, data, trust)
569572
}
570573

571574
// List tokens.
@@ -725,7 +728,7 @@ func (c *cmdConfigTrustListTokens) Run(cmd *cobra.Command, args []string) error
725728
header = append(header, column.Name)
726729
}
727730

728-
return cli.RenderTable(c.flagFormat, header, data, joinTokens)
731+
return cli.RenderTable(os.Stdout, c.flagFormat, header, data, joinTokens)
729732
}
730733

731734
// Remove.

cmd/incus/console.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
type cmdConsole struct {
2727
global *cmdGlobal
2828

29+
flagForce bool
2930
flagShowLog bool
3031
flagType string
3132
}
@@ -41,6 +42,7 @@ This command allows you to interact with the boot console of an instance
4142
as well as retrieve past log entries from it.`))
4243

4344
cmd.RunE = c.Run
45+
cmd.Flags().BoolVarP(&c.flagForce, "force", "f", false, i18n.G("Forces a connection to the console, even if there is already an active session"))
4446
cmd.Flags().BoolVar(&c.flagShowLog, "show-log", false, i18n.G("Retrieve the instance's console log"))
4547
cmd.Flags().StringVarP(&c.flagType, "type", "t", "console", i18n.G("Type of connection to establish: 'console' for serial console, 'vga' for SPICE graphical output")+"``")
4648

@@ -188,6 +190,7 @@ func (c *cmdConsole) text(d incus.InstanceServer, name string) error {
188190
Width: width,
189191
Height: height,
190192
Type: "console",
193+
Force: c.flagForce,
191194
}
192195

193196
consoleDisconnect := make(chan bool)
@@ -210,6 +213,9 @@ func (c *cmdConsole) text(d incus.InstanceServer, name string) error {
210213
}
211214

212215
close(consoleDisconnect)
216+
217+
// Make sure we leave the user back to a clean prompt.
218+
fmt.Printf("\r\n")
213219
}()
214220

215221
// Attach to the instance console
@@ -243,7 +249,8 @@ func (c *cmdConsole) vga(d incus.InstanceServer, name string) error {
243249

244250
// Prepare the remote console.
245251
req := api.InstanceConsolePost{
246-
Type: "vga",
252+
Type: "vga",
253+
Force: c.flagForce,
247254
}
248255

249256
chDisconnect := make(chan bool)

cmd/incus/create.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type cmdCreate struct {
3434
flagNoProfiles bool
3535
flagEmpty bool
3636
flagVM bool
37+
flagDescription string
3738
}
3839

3940
func (c *cmdCreate) Command() *cobra.Command {
@@ -63,6 +64,7 @@ incus launch images:debian/12 v2 --vm -d root,size=50GiB -d root,io.bus=nvme
6364
cmd.Flags().BoolVar(&c.flagNoProfiles, "no-profiles", false, i18n.G("Create the instance with no profiles applied"))
6465
cmd.Flags().BoolVar(&c.flagEmpty, "empty", false, i18n.G("Create an empty instance"))
6566
cmd.Flags().BoolVar(&c.flagVM, "vm", false, i18n.G("Create a virtual machine"))
67+
cmd.Flags().StringVar(&c.flagDescription, "description", "", i18n.G("Instance description")+"``")
6668

6769
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
6870
if len(args) != 0 {
@@ -283,7 +285,12 @@ func (c *cmdCreate) create(conf *config.Config, args []string, launch bool) (inc
283285

284286
req.Config = configMap
285287
req.Ephemeral = c.flagEphemeral
286-
req.Description = stdinData.Description
288+
289+
if c.flagDescription != "" {
290+
req.Description = c.flagDescription
291+
} else {
292+
req.Description = stdinData.Description
293+
}
287294

288295
if !c.flagNoProfiles && len(profiles) == 0 {
289296
if len(stdinData.Profiles) > 0 {

cmd/incus/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ func (c *cmdImageList) Run(cmd *cobra.Command, args []string) error {
14011401
headers = append(headers, column.Name)
14021402
}
14031403

1404-
return cli.RenderTable(c.flagFormat, headers, data, rawData)
1404+
return cli.RenderTable(os.Stdout, c.flagFormat, headers, data, rawData)
14051405
}
14061406

14071407
// Refresh.

cmd/incus/image_alias.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"fmt"
5+
"os"
56
"sort"
67
"strings"
78

@@ -56,6 +57,8 @@ type cmdImageAliasCreate struct {
5657
global *cmdGlobal
5758
image *cmdImage
5859
imageAlias *cmdImageAlias
60+
61+
flagDescription string
5962
}
6063

6164
func (c *cmdImageAliasCreate) Command() *cobra.Command {
@@ -65,6 +68,8 @@ func (c *cmdImageAliasCreate) Command() *cobra.Command {
6568
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G(
6669
`Create aliases for existing images`))
6770

71+
cmd.Flags().StringVar(&c.flagDescription, "description", "", i18n.G("Image alias description")+"``")
72+
6873
cmd.RunE = c.Run
6974

7075
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
@@ -110,6 +115,7 @@ func (c *cmdImageAliasCreate) Run(cmd *cobra.Command, args []string) error {
110115
alias := api.ImageAliasesPost{}
111116
alias.Name = resource.name
112117
alias.Target = args[1]
118+
alias.Description = c.flagDescription
113119

114120
return resource.server.CreateImageAlias(alias)
115121
}
@@ -349,7 +355,7 @@ func (c *cmdImageAliasList) Run(cmd *cobra.Command, args []string) error {
349355
header = append(header, column.Name)
350356
}
351357

352-
return cli.RenderTable(c.flagFormat, header, data, aliases)
358+
return cli.RenderTable(os.Stdout, c.flagFormat, header, data, aliases)
353359
}
354360

355361
// Rename.

cmd/incus/info.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"io"
6+
"os"
67
"sort"
78
"strings"
89

@@ -631,7 +632,7 @@ func (c *cmdInfo) instanceInfo(d incus.InstanceServer, remote config.Remote, nam
631632
}
632633

633634
fmt.Printf(i18n.G("Name: %s")+"\n", inst.Name)
634-
635+
fmt.Printf(i18n.G("Description: %s")+"\n", inst.Description)
635636
fmt.Printf(i18n.G("Status: %s")+"\n", strings.ToUpper(inst.Status))
636637

637638
instType := inst.Type
@@ -831,7 +832,7 @@ func (c *cmdInfo) instanceInfo(d incus.InstanceServer, remote config.Remote, nam
831832
i18n.G("Stateful"),
832833
}
833834

834-
_ = cli.RenderTable(cli.TableFormatTable, snapHeader, snapData, inst.Snapshots)
835+
_ = cli.RenderTable(os.Stdout, cli.TableFormatTable, snapHeader, snapData, inst.Snapshots)
835836
}
836837

837838
// List backups
@@ -883,7 +884,7 @@ func (c *cmdInfo) instanceInfo(d incus.InstanceServer, remote config.Remote, nam
883884
i18n.G("Optimized Storage"),
884885
}
885886

886-
_ = cli.RenderTable(cli.TableFormatTable, backupHeader, backupData, inst.Backups)
887+
_ = cli.RenderTable(os.Stdout, cli.TableFormatTable, backupHeader, backupData, inst.Backups)
887888
}
888889

889890
if showLog {

cmd/incus/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"net"
6+
"os"
67
"regexp"
78
"slices"
89
"sort"
@@ -453,7 +454,7 @@ func (c *cmdList) showInstances(instances []api.InstanceFull, filters []string,
453454
headers = append(headers, column.Name)
454455
}
455456

456-
return cli.RenderTable(c.flagFormat, headers, data, instancesFiltered)
457+
return cli.RenderTable(os.Stdout, c.flagFormat, headers, data, instancesFiltered)
457458
}
458459

459460
func (c *cmdList) Run(cmd *cobra.Command, args []string) error {

cmd/incus/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func (c *cmdGlobal) PreRun(cmd *cobra.Command, args []string) error {
417417

418418
// Setup password helper
419419
c.conf.PromptPassword = func(filename string) (string, error) {
420-
return ask.AskPasswordOnce(fmt.Sprintf(i18n.G("Password for %s: "), filename)), nil
420+
return c.asker.AskPasswordOnce(fmt.Sprintf(i18n.G("Password for %s: "), filename)), nil
421421
}
422422

423423
// If the user is running a command that may attempt to connect to the local daemon

0 commit comments

Comments
 (0)