forked from coop-cloud/abra
Compare commits
29 Commits
2da26852c6
...
a155fe1967
Author | SHA1 | Date |
---|---|---|
Moritz | a155fe1967 | |
Moritz | af4cb53c4c | |
Moritz | 6b4a108b90 | |
Moritz | 5a7fe9971a | |
Moritz | 9564673a10 | |
Moritz | cdb84b67c9 | |
Moritz | b32bc018f9 | |
Moritz | 5767eb0eda | |
Moritz | 75c5908dcd | |
Moritz | d22ed11aab | |
Moritz | 925cb3fe53 | |
Moritz | 844a902a0f | |
Moritz | b307bb6010 | |
Moritz | e02f4d1613 | |
Moritz | af0d15ef79 | |
Moritz | ee00823027 | |
Moritz | 7c27b72e35 | |
Moritz | af6e4285e8 | |
Moritz | 7dd32ddd25 | |
Moritz | 62daf78642 | |
Moritz | 352215dc83 | |
decentral1se | 29fa607190 | |
decentral1se | 7c541ffdfa | |
decentral1se | 7ccc4b4c08 | |
decentral1se | ef4df35995 | |
decentral1se | 71a9155042 | |
decentral1se | 2a88491d7c | |
decentral1se | bf79552204 | |
decentral1se | 0a7fa54759 |
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue