Compare commits

..

29 Commits

Author SHA1 Message Date
Moritz a155fe1967 resolve some small issues 2023-02-08 19:39:03 +01:00
Moritz af4cb53c4c fix goreleaser.yml 2023-02-08 19:39:03 +01:00
Moritz 6b4a108b90 extract upgrade requirement checkings 2023-02-08 19:39:03 +01:00
Moritz 5a7fe9971a pass all errors to the Command function 2023-02-08 19:39:03 +01:00
Moritz 9564673a10 merge UpgradeApp and UpgradeAll using --all flag 2023-02-08 19:39:03 +01:00
Moritz cdb84b67c9 update command descriptions 2023-02-08 19:39:03 +01:00
Moritz b32bc018f9 Fix comments 2023-02-08 19:39:03 +01:00
Moritz 5767eb0eda use SERVER constant for setting the server address to localhost 2023-02-08 19:39:03 +01:00
Moritz 75c5908dcd fix dockerClient renaming 2023-02-08 19:39:03 +01:00
Moritz d22ed11aab fix Makefile alignment 2023-02-08 19:39:03 +01:00
Moritz 925cb3fe53 add kadabra to goreleaser 2023-02-08 19:39:03 +01:00
Moritz 844a902a0f fix: set updatelabel on upgrade, select latest instead of next release 2023-02-08 19:39:03 +01:00
Moritz b307bb6010 add notify command and --major flag 2023-02-08 19:39:03 +01:00
Moritz e02f4d1613 refactor: replace some functions with general getLabel function 2023-02-08 19:39:03 +01:00
Moritz af0d15ef79 evaluate if autoupdates are enabled 2023-02-08 19:39:03 +01:00
Moritz ee00823027 Refactor upgrade function: extract logical parts 2023-02-08 19:39:03 +01:00
Moritz 7c27b72e35 change .gitignore and add kadabras main.go 2023-02-08 19:39:03 +01:00
Moritz af6e4285e8 more verbose update info 2023-02-08 19:39:03 +01:00
Moritz 7dd32ddd25 pull recipe and lint it 2023-02-08 19:39:03 +01:00
Moritz 62daf78642 updater: read chaos deployment from docker label 2023-02-08 19:39:03 +01:00
Moritz 352215dc83 PoC auto updater 2023-02-08 19:39:03 +01:00
decentral1se 29fa607190
fix: restrict pulling to specific branch 2023-02-02 21:12:50 +01:00
decentral1se 7c541ffdfa
fix: better error handling in EnsureUpToDate 2023-02-02 21:12:24 +01:00
decentral1se 7ccc4b4c08
fix: woops, remove that print statement 2023-02-02 21:00:31 +01:00
decentral1se ef4df35995
fix: don't check twice (called in EnsureUpToDate) 2023-02-02 20:59:04 +01:00
decentral1se 71a9155042
fix: specify refs when fetching tags
See coop-cloud/organising#397
2023-02-02 20:58:38 +01:00
decentral1se 2a88491d7c
fix: catch errors here too
See coop-cloud/abra#266
2023-02-02 20:26:19 +01:00
decentral1se bf79552204
fix: improve permission denied message 2023-02-02 20:07:45 +01:00
decentral1se 0a7fa54759
fix: cant pass client here
Closes coop-cloud/organising#396
2023-02-02 20:06:49 +01:00
3 changed files with 25 additions and 18 deletions

View File

@ -8,6 +8,7 @@ import (
"path"
"strings"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/dns"
"coopcloud.tech/abra/pkg/formatter"
@ -16,15 +17,19 @@ import (
"coopcloud.tech/abra/pkg/recipe"
"coopcloud.tech/abra/pkg/upstream/stack"
"github.com/AlecAivazis/survey/v2"
dockerClient "github.com/docker/docker/client"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
// DeployAction is the main command-line action for this package
func DeployAction(c *cli.Context, cl *dockerClient.Client) error {
func DeployAction(c *cli.Context) error {
app := ValidateApp(c)
cl, err := client.New(app.Server)
if err != nil {
logrus.Fatal(err)
}
if !Chaos {
if err := recipe.EnsureUpToDate(app.Recipe); err != nil {
logrus.Fatal(err)

View File

@ -24,6 +24,7 @@ import (
composetypes "github.com/docker/cli/cli/compose/types"
"github.com/docker/distribution/reference"
"github.com/go-git/go-git/v5"
gitConfig "github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/sirupsen/logrus"
)
@ -582,7 +583,7 @@ func EnsureUpToDate(recipeName string) error {
isClean, err := gitPkg.IsClean(recipeDir)
if err != nil {
return err
return fmt.Errorf("unable to check git clean status in %s: %s", recipeDir, err)
}
if !isClean {
@ -592,12 +593,12 @@ func EnsureUpToDate(recipeName string) error {
repo, err := git.PlainOpen(recipeDir)
if err != nil {
return err
return fmt.Errorf("unable to open %s: %s", recipeDir, err)
}
remotes, err := repo.Remotes()
if err != nil {
return err
return fmt.Errorf("unable to read remotes in %s: %s", recipeDir, err)
}
if len(remotes) == 0 {
@ -607,27 +608,35 @@ func EnsureUpToDate(recipeName string) error {
worktree, err := repo.Worktree()
if err != nil {
return err
return fmt.Errorf("unable to open git work tree in %s: %s", recipeDir, err)
}
branch, err := gitPkg.CheckoutDefaultBranch(repo, recipeDir)
if err != nil {
return err
return fmt.Errorf("unable to check out default branch in %s: %s", recipeDir, err)
}
fetchOpts := &git.FetchOptions{
Tags: git.AllTags,
RefSpecs: []gitConfig.RefSpec{
gitConfig.RefSpec(fmt.Sprintf("%s:%s", branch, branch)),
},
}
if err := repo.Fetch(fetchOpts); err != nil {
if !strings.Contains(err.Error(), "already up-to-date") {
return fmt.Errorf("unable to fetch tags in %s: %s", recipeDir, err)
}
}
repo.Fetch(fetchOpts)
opts := &git.PullOptions{
Force: true,
ReferenceName: branch,
SingleBranch: true,
}
if err := worktree.Pull(opts); err != nil {
if !strings.Contains(err.Error(), "already up-to-date") {
return err
return fmt.Errorf("unable to git pull in %s: %s", recipeDir, err)
}
}
@ -1052,15 +1061,6 @@ func UpdateRepositories(repos RepoCatalogue, recipeName string) error {
logrus.Fatal(err)
}
isClean, err := gitPkg.IsClean(recipeDir)
if err != nil {
logrus.Fatal(err)
}
if !isClean {
logrus.Fatalf("%s has locally unstaged changes", rm.Name)
}
if err := EnsureUpToDate(rm.Name); err != nil {
logrus.Fatal(err)
}

View File

@ -75,6 +75,8 @@ func Fatal(hostname string, err error) error {
return fmt.Errorf("could not resolve hostname for %s", hostname)
} else if strings.Contains(out, "Connection timed out") {
return fmt.Errorf("connection timed out for %s", hostname)
} else if strings.Contains(out, "Permission denied") {
return fmt.Errorf("ssh auth: permission denied for %s", hostname)
} else {
return err
}