Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto update command #557

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,35 @@ See https://kairos.io/docs/upgrade/manual/ for documentation.
return nil
},
},
{
Name: "auto",
Action: func(c *cli.Context) error {
tags, err := agent.ListNewerReleases(c.Bool("pre"))
if err != nil {
return err
}
if len(tags) == 0 {
fmt.Println("No newer releases found")
return nil
}

if c.Bool("recovery") && c.String("boot-entry") != "" {
return fmt.Errorf("only one of '--recovery' and '--boot-entry' can be set")
}

upgradeEntry := ""
if c.Bool("recovery") {
upgradeEntry = constants.BootEntryRecovery
} else if c.String("boot-entry") != "" {
upgradeEntry = c.String("boot-entry")
}

return agent.Upgrade(fmt.Sprintf("oci:%s", tags[0]), c.Bool("force"),
c.Bool("strict-validation"), constants.GetConfigScanDirs(),
upgradeEntry, c.Bool("pre"),
)
},
},
},
Before: func(c *cli.Context) error {
if err := validateSource(c.String("source")); err != nil {
Expand Down
Loading