mirror of
https://github.com/rancher/os.git
synced 2025-08-30 21:10:26 +00:00
Add latest and currently running os info to 'ros os list'
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
parent
e97ad03b99
commit
61f591f56e
@ -79,6 +79,7 @@ func osSubcommands() []cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: this and the getLatestImage should probably move to utils/network and be suitably cached.
|
||||
func getImages() (*Images, error) {
|
||||
upgradeUrl, err := getUpgradeUrl()
|
||||
if err != nil {
|
||||
@ -128,13 +129,30 @@ func osMetaDataGet(c *cli.Context) error {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for _, image := range images.Available {
|
||||
cfg := config.LoadConfig()
|
||||
runningName := cfg.Rancher.Upgrade.Image + ":" + config.VERSION
|
||||
|
||||
foundRunning := false
|
||||
for i := len(images.Available) - 1; i >= 0; i-- {
|
||||
image := images.Available[i]
|
||||
_, _, err := client.ImageInspectWithRaw(context.Background(), image, false)
|
||||
local := "local"
|
||||
if dockerClient.IsErrImageNotFound(err) {
|
||||
fmt.Println(image, "remote")
|
||||
} else {
|
||||
fmt.Println(image, "local")
|
||||
local = "remote"
|
||||
}
|
||||
available := "available"
|
||||
if image == images.Current {
|
||||
available = "latest"
|
||||
}
|
||||
var running string
|
||||
if image == runningName {
|
||||
foundRunning = true
|
||||
running = "running"
|
||||
}
|
||||
fmt.Println(image, local, available, running)
|
||||
}
|
||||
if !foundRunning {
|
||||
fmt.Println(config.VERSION, "running")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user