Skip to content

Commit

Permalink
Merge pull request #12785 from MusicDin/feat/lts-flag
Browse files Browse the repository at this point in the history
Indicate LTS version in `lxc version`
  • Loading branch information
tomponline authored Jan 30, 2024
2 parents 0c38972 + ac92ecc commit 4c08b80
Show file tree
Hide file tree
Showing 50 changed files with 443 additions and 405 deletions.
5 changes: 5 additions & 0 deletions doc/api-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2351,3 +2351,8 @@ This field indicates which instance types are supported by the server.

Adds a `mounted` field to disk resources that LXD discovers on the system, reporting whether that disk or partition is
mounted.

## `server_version_lts`

The API extension adds indication whether the LXD version is an LTS release.
This is indicated when command `lxc version` is executed or when `/1.0` endpoint is queried.
5 changes: 5 additions & 0 deletions doc/rest-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5377,6 +5377,11 @@ definitions:
example: full-mesh
type: string
x-go-name: ServerEventMode
server_lts:
description: Whether the version is an LTS release
example: false
type: boolean
x-go-name: ServerLTS
server_name:
description: Server hostname
example: castiana
Expand Down
3 changes: 3 additions & 0 deletions lxc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ For help with any of those, simply call them with --help.`))
// Version handling
app.SetVersionTemplate("{{.Version}}\n")
app.Version = version.Version
if version.IsLTSVersion {
app.Version = fmt.Sprintf("%s LTS", version.Version)
}

// alias sub-command
aliasCmd := cmdAlias{global: &globalCmd}
Expand Down
16 changes: 12 additions & 4 deletions lxc/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ func (c *cmdVersion) Run(cmd *cobra.Command, args []string) error {
return err
}

fmt.Printf(i18n.G("Client version: %s\n"), version.Version)
// Client version
clientVersion := version.Version
if version.IsLTSVersion {
clientVersion = fmt.Sprintf("%s LTS", clientVersion)
}

// Remote version
remote := ""
Expand All @@ -45,17 +49,21 @@ func (c *cmdVersion) Run(cmd *cobra.Command, args []string) error {
}
}

version := i18n.G("unreachable")
serverVersion := i18n.G("unreachable")
resources, err := c.global.ParseServers(remote)
if err == nil {
resource := resources[0]
info, _, err := resource.server.GetServer()
if err == nil {
version = info.Environment.ServerVersion
serverVersion = info.Environment.ServerVersion
if info.Environment.ServerLTS {
serverVersion = fmt.Sprintf("%s LTS", serverVersion)
}
}
}

fmt.Printf(i18n.G("Server version: %s\n"), version)
fmt.Printf(i18n.G("Client version: %s\n"), clientVersion)
fmt.Printf(i18n.G("Server version: %s\n"), serverVersion)

return nil
}
1 change: 1 addition & 0 deletions lxd/api_1.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ func api10Get(d *Daemon, r *http.Request) response.Response {
Server: "lxd",
ServerPid: os.Getpid(),
ServerVersion: version.Version,
ServerLTS: version.IsLTSVersion,
ServerClustered: s.ServerClustered,
ServerEventMode: string(cluster.ServerEventMode()),
ServerName: serverName,
Expand Down
4 changes: 4 additions & 0 deletions lxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bufio"
"fmt"
"os"

"github.com/canonical/go-dqlite"
Expand Down Expand Up @@ -104,6 +105,9 @@ func main() {
// Version handling
app.SetVersionTemplate("{{.Version}}\n")
app.Version = version.Version
if version.IsLTSVersion {
app.Version = fmt.Sprintf("%s LTS", version.Version)
}

// activateifneeded sub-command
activateifneededCmd := cmdActivateifneeded{global: &globalCmd}
Expand Down
6 changes: 5 additions & 1 deletion lxd/main_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ func (c *cmdVersion) Command() *cobra.Command {
}

func (c *cmdVersion) Run(cmd *cobra.Command, args []string) error {
fmt.Println(version.Version)
if version.IsLTSVersion {
fmt.Println(version.Version, "LTS")
} else {
fmt.Println(version.Version)
}

return nil
}
20 changes: 10 additions & 10 deletions po/ar.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: lxd\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-01-24 18:09-0500\n"
"POT-Creation-Date: 2024-01-30 11:57+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
Expand Down Expand Up @@ -971,7 +971,7 @@ msgstr ""
msgid "Client certificate now trusted by server:"
msgstr ""

#: lxc/version.go:37
#: lxc/version.go:65
#, c-format
msgid "Client version: %s\n"
msgstr ""
Expand Down Expand Up @@ -2527,7 +2527,7 @@ msgstr ""
msgid "If the snapshot name already exists, delete and create a new one"
msgstr ""

#: lxc/main.go:390
#: lxc/main.go:393
msgid ""
"If this is your first time running LXD on this machine, you should also run: "
"lxd init"
Expand Down Expand Up @@ -2748,7 +2748,7 @@ msgstr ""
msgid "Invalid new snapshot name, parent volume must be the same as source"
msgstr ""

#: lxc/main.go:487
#: lxc/main.go:490
msgid "Invalid number of arguments"
msgstr ""

Expand Down Expand Up @@ -4048,7 +4048,7 @@ msgstr ""
msgid "Partitions:"
msgstr ""

#: lxc/main.go:353
#: lxc/main.go:356
#, c-format
msgid "Password for %s: "
msgstr ""
Expand Down Expand Up @@ -4735,7 +4735,7 @@ msgstr ""
msgid "Server protocol (lxd or simplestreams)"
msgstr ""

#: lxc/version.go:58
#: lxc/version.go:66
#, c-format
msgid "Server version: %s\n"
msgstr ""
Expand Down Expand Up @@ -5058,7 +5058,7 @@ msgstr ""
msgid "Show instance or server information"
msgstr ""

#: lxc/main.go:265 lxc/main.go:266
#: lxc/main.go:268 lxc/main.go:269
msgid "Show less common commands"
msgstr ""

Expand Down Expand Up @@ -5556,7 +5556,7 @@ msgstr ""
msgid "This LXD server is not available on the network"
msgstr ""

#: lxc/main.go:287
#: lxc/main.go:290
msgid ""
"This client hasn't been configured to use a remote LXD server yet.\n"
"As your platform can't run native Linux instances, you must connect to a "
Expand Down Expand Up @@ -5592,7 +5592,7 @@ msgstr ""
msgid "To detach from the console, press: <ctrl>+a q"
msgstr ""

#: lxc/main.go:395
#: lxc/main.go:398
msgid ""
"To start your first container, try: lxc launch ubuntu:22.04\n"
"Or for a virtual machine: lxc launch ubuntu:22.04 --vm"
Expand Down Expand Up @@ -6990,7 +6990,7 @@ msgstr ""
msgid "total space"
msgstr ""

#: lxc/version.go:48
#: lxc/version.go:52
msgid "unreachable"
msgstr ""

Expand Down
20 changes: 10 additions & 10 deletions po/ber.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: lxd\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-01-24 18:09-0500\n"
"POT-Creation-Date: 2024-01-30 11:57+0100\n"
"PO-Revision-Date: 2022-03-10 15:10+0000\n"
"Last-Translator: Anonymous <[email protected]>\n"
"Language-Team: Berber <https://hosted.weblate.org/projects/linux-containers/"
Expand Down Expand Up @@ -974,7 +974,7 @@ msgstr ""
msgid "Client certificate now trusted by server:"
msgstr ""

#: lxc/version.go:37
#: lxc/version.go:65
#, c-format
msgid "Client version: %s\n"
msgstr ""
Expand Down Expand Up @@ -2530,7 +2530,7 @@ msgstr ""
msgid "If the snapshot name already exists, delete and create a new one"
msgstr ""

#: lxc/main.go:390
#: lxc/main.go:393
msgid ""
"If this is your first time running LXD on this machine, you should also run: "
"lxd init"
Expand Down Expand Up @@ -2751,7 +2751,7 @@ msgstr ""
msgid "Invalid new snapshot name, parent volume must be the same as source"
msgstr ""

#: lxc/main.go:487
#: lxc/main.go:490
msgid "Invalid number of arguments"
msgstr ""

Expand Down Expand Up @@ -4051,7 +4051,7 @@ msgstr ""
msgid "Partitions:"
msgstr ""

#: lxc/main.go:353
#: lxc/main.go:356
#, c-format
msgid "Password for %s: "
msgstr ""
Expand Down Expand Up @@ -4738,7 +4738,7 @@ msgstr ""
msgid "Server protocol (lxd or simplestreams)"
msgstr ""

#: lxc/version.go:58
#: lxc/version.go:66
#, c-format
msgid "Server version: %s\n"
msgstr ""
Expand Down Expand Up @@ -5061,7 +5061,7 @@ msgstr ""
msgid "Show instance or server information"
msgstr ""

#: lxc/main.go:265 lxc/main.go:266
#: lxc/main.go:268 lxc/main.go:269
msgid "Show less common commands"
msgstr ""

Expand Down Expand Up @@ -5559,7 +5559,7 @@ msgstr ""
msgid "This LXD server is not available on the network"
msgstr ""

#: lxc/main.go:287
#: lxc/main.go:290
msgid ""
"This client hasn't been configured to use a remote LXD server yet.\n"
"As your platform can't run native Linux instances, you must connect to a "
Expand Down Expand Up @@ -5595,7 +5595,7 @@ msgstr ""
msgid "To detach from the console, press: <ctrl>+a q"
msgstr ""

#: lxc/main.go:395
#: lxc/main.go:398
msgid ""
"To start your first container, try: lxc launch ubuntu:22.04\n"
"Or for a virtual machine: lxc launch ubuntu:22.04 --vm"
Expand Down Expand Up @@ -6993,7 +6993,7 @@ msgstr ""
msgid "total space"
msgstr ""

#: lxc/version.go:48
#: lxc/version.go:52
msgid "unreachable"
msgstr ""

Expand Down
20 changes: 10 additions & 10 deletions po/bg.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: lxd\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2024-01-24 18:09-0500\n"
"POT-Creation-Date: 2024-01-30 11:57+0100\n"
"PO-Revision-Date: 2022-03-10 15:09+0000\n"
"Last-Translator: Anonymous <[email protected]>\n"
"Language-Team: Bulgarian <https://hosted.weblate.org/projects/linux-"
Expand Down Expand Up @@ -974,7 +974,7 @@ msgstr ""
msgid "Client certificate now trusted by server:"
msgstr ""

#: lxc/version.go:37
#: lxc/version.go:65
#, c-format
msgid "Client version: %s\n"
msgstr ""
Expand Down Expand Up @@ -2530,7 +2530,7 @@ msgstr ""
msgid "If the snapshot name already exists, delete and create a new one"
msgstr ""

#: lxc/main.go:390
#: lxc/main.go:393
msgid ""
"If this is your first time running LXD on this machine, you should also run: "
"lxd init"
Expand Down Expand Up @@ -2751,7 +2751,7 @@ msgstr ""
msgid "Invalid new snapshot name, parent volume must be the same as source"
msgstr ""

#: lxc/main.go:487
#: lxc/main.go:490
msgid "Invalid number of arguments"
msgstr ""

Expand Down Expand Up @@ -4051,7 +4051,7 @@ msgstr ""
msgid "Partitions:"
msgstr ""

#: lxc/main.go:353
#: lxc/main.go:356
#, c-format
msgid "Password for %s: "
msgstr ""
Expand Down Expand Up @@ -4738,7 +4738,7 @@ msgstr ""
msgid "Server protocol (lxd or simplestreams)"
msgstr ""

#: lxc/version.go:58
#: lxc/version.go:66
#, c-format
msgid "Server version: %s\n"
msgstr ""
Expand Down Expand Up @@ -5061,7 +5061,7 @@ msgstr ""
msgid "Show instance or server information"
msgstr ""

#: lxc/main.go:265 lxc/main.go:266
#: lxc/main.go:268 lxc/main.go:269
msgid "Show less common commands"
msgstr ""

Expand Down Expand Up @@ -5559,7 +5559,7 @@ msgstr ""
msgid "This LXD server is not available on the network"
msgstr ""

#: lxc/main.go:287
#: lxc/main.go:290
msgid ""
"This client hasn't been configured to use a remote LXD server yet.\n"
"As your platform can't run native Linux instances, you must connect to a "
Expand Down Expand Up @@ -5595,7 +5595,7 @@ msgstr ""
msgid "To detach from the console, press: <ctrl>+a q"
msgstr ""

#: lxc/main.go:395
#: lxc/main.go:398
msgid ""
"To start your first container, try: lxc launch ubuntu:22.04\n"
"Or for a virtual machine: lxc launch ubuntu:22.04 --vm"
Expand Down Expand Up @@ -6993,7 +6993,7 @@ msgstr ""
msgid "total space"
msgstr ""

#: lxc/version.go:48
#: lxc/version.go:52
msgid "unreachable"
msgstr ""

Expand Down
Loading

0 comments on commit 4c08b80

Please sign in to comment.