fix: clone https url by default

Catalogue package had to be merged into the recipe package due to too
many circular import errors. Also, use https url for cloning, assume
folks don't have ssh setup by default (the whole reason for the
refactor).
This commit is contained in:
2021-12-27 16:40:59 +01:00
parent b1d9d9d858
commit 4c186678b8
16 changed files with 543 additions and 553 deletions

View File

@ -7,8 +7,8 @@ import (
abraFormatter "coopcloud.tech/abra/cli/formatter"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/catalogue"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/recipe"
"coopcloud.tech/abra/pkg/ssh"
"coopcloud.tech/tagcmp"
"github.com/sirupsen/logrus"
@ -92,7 +92,7 @@ can take some time.
sort.Sort(config.ByServerAndType(apps))
statuses := make(map[string]map[string]string)
var catl catalogue.RecipeCatalogue
var catl recipe.RecipeCatalogue
if status {
alreadySeen := make(map[string]bool)
for _, app := range apps {
@ -110,7 +110,7 @@ can take some time.
}
var err error
catl, err = catalogue.ReadRecipeCatalogue()
catl, err = recipe.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}
@ -153,7 +153,7 @@ can take some time.
var newUpdates []string
if version != "unknown" {
updates, err := catalogue.GetRecipeCatalogueVersions(app.Type, catl)
updates, err := recipe.GetRecipeCatalogueVersions(app.Type, catl)
if err != nil {
logrus.Fatal(err)
}

View File

@ -4,7 +4,6 @@ import (
"fmt"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/catalogue"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/lint"
"coopcloud.tech/abra/pkg/recipe"
@ -75,12 +74,12 @@ recipes.
logrus.Fatalf("%s is not deployed?", app.Name)
}
catl, err := catalogue.ReadRecipeCatalogue()
catl, err := recipe.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type, catl)
versions, err := recipe.GetRecipeCatalogueVersions(app.Type, catl)
if err != nil {
logrus.Fatal(err)
}

View File

@ -5,7 +5,6 @@ import (
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/catalogue"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/lint"
@ -79,12 +78,12 @@ recipes.
logrus.Fatalf("%s is not deployed?", app.Name)
}
catl, err := catalogue.ReadRecipeCatalogue()
catl, err := recipe.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type, catl)
versions, err := recipe.GetRecipeCatalogueVersions(app.Type, catl)
if err != nil {
logrus.Fatal(err)
}

View File

@ -6,8 +6,8 @@ import (
abraFormatter "coopcloud.tech/abra/cli/formatter"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/catalogue"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/recipe"
"coopcloud.tech/abra/pkg/upstream/stack"
"github.com/docker/distribution/reference"
"github.com/sirupsen/logrus"
@ -64,12 +64,12 @@ Cloud recipe version.
logrus.Fatalf("%s is not deployed?", app.Name)
}
recipeMeta, err := catalogue.GetRecipeMeta(app.Type)
recipeMeta, err := recipe.GetRecipeMeta(app.Type)
if err != nil {
logrus.Fatal(err)
}
versionsMeta := make(map[string]catalogue.ServiceMeta)
versionsMeta := make(map[string]recipe.ServiceMeta)
for _, recipeVersion := range recipeMeta.Versions {
if currentVersion, exists := recipeVersion[deployedVersion]; exists {
versionsMeta = currentVersion

View File

@ -9,7 +9,6 @@ import (
"coopcloud.tech/abra/cli/formatter"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/catalogue"
"coopcloud.tech/abra/pkg/config"
gitPkg "coopcloud.tech/abra/pkg/git"
"coopcloud.tech/abra/pkg/limit"
@ -103,7 +102,7 @@ If you have a Hub account you can have Abra log you in to avoid this. Pass
return err
}
repos, err := catalogue.ReadReposMetadata()
repos, err := recipe.ReadReposMetadata()
if err != nil {
logrus.Fatal(err)
}
@ -125,7 +124,7 @@ If you have a Hub account you can have Abra log you in to avoid this. Pass
}
}
catl := make(catalogue.RecipeCatalogue)
catl := make(recipe.RecipeCatalogue)
catlBar := formatter.CreateProgressbar(barLength, "generating catalogue metadata...")
for _, recipeMeta := range repos {
if recipeName != "" && recipeName != recipeMeta.Name {
@ -138,7 +137,7 @@ If you have a Hub account you can have Abra log you in to avoid this. Pass
continue
}
versions, err := catalogue.GetRecipeVersions(
versions, err := recipe.GetRecipeVersions(
recipeMeta.Name,
internal.RegistryUsername,
internal.RegistryPassword,
@ -152,7 +151,7 @@ If you have a Hub account you can have Abra log you in to avoid this. Pass
logrus.Warn(err)
}
catl[recipeMeta.Name] = catalogue.RecipeMeta{
catl[recipeMeta.Name] = recipe.RecipeMeta{
Name: recipeMeta.Name,
Repository: recipeMeta.CloneURL,
Icon: recipeMeta.AvatarURL,
@ -177,7 +176,7 @@ If you have a Hub account you can have Abra log you in to avoid this. Pass
logrus.Fatal(err)
}
} else {
catlFS, err := catalogue.ReadRecipeCatalogue()
catlFS, err := recipe.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}
@ -213,7 +212,7 @@ If you have a Hub account you can have Abra log you in to avoid this. Pass
}
if internal.Push {
if err := gitPkg.Push(cataloguePath); err != nil {
if err := gitPkg.Push(cataloguePath, false); err != nil {
logrus.Fatal(err)
}
}
@ -236,7 +235,7 @@ var CatalogueCommand = &cli.Command{
},
}
func updateRepositories(repos catalogue.RepoCatalogue, recipeName string) error {
func updateRepositories(repos recipe.RepoCatalogue, recipeName string) error {
var barLength int
if recipeName != "" {
barLength = 1
@ -246,10 +245,10 @@ func updateRepositories(repos catalogue.RepoCatalogue, recipeName string) error
cloneLimiter := limit.New(10)
retrieveBar := formatter.CreateProgressbar(barLength, "ensuring recipes are up-to-date...")
retrieveBar := formatter.CreateProgressbar(barLength, "ensuring recipes are cloned & up-to-date...")
ch := make(chan string, barLength)
for _, repoMeta := range repos {
go func(rm catalogue.RepoMeta) {
go func(rm recipe.RepoMeta) {
cloneLimiter.Begin()
defer cloneLimiter.End()
@ -266,7 +265,7 @@ func updateRepositories(repos catalogue.RepoCatalogue, recipeName string) error
recipeDir := path.Join(config.RECIPES_DIR, rm.Name)
if err := gitPkg.Clone(recipeDir, rm.SSHURL); err != nil {
if err := gitPkg.Clone(recipeDir, rm.CloneURL); err != nil {
logrus.Fatal(err)
}

View File

@ -5,7 +5,6 @@ import (
"strings"
abraFormatter "coopcloud.tech/abra/cli/formatter"
"coopcloud.tech/abra/pkg/catalogue"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/dns"
@ -58,11 +57,11 @@ func DeployAction(c *cli.Context) error {
version := deployedVersion
if version == "" && !Chaos {
catl, err := catalogue.ReadRecipeCatalogue()
catl, err := recipe.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type, catl)
versions, err := recipe.GetRecipeCatalogueVersions(app.Type, catl)
if err != nil {
logrus.Fatal(err)
}

View File

@ -5,7 +5,6 @@ import (
"strings"
"coopcloud.tech/abra/pkg/app"
"coopcloud.tech/abra/pkg/catalogue"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/recipe"
"coopcloud.tech/abra/pkg/ssh"
@ -50,7 +49,7 @@ func ValidateRecipeWithPrompt(c *cli.Context) recipe.Recipe {
if recipeName == "" && !NoInput {
var recipes []string
catl, err := catalogue.ReadRecipeCatalogue()
catl, err := recipe.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}

View File

@ -7,7 +7,7 @@ import (
"strings"
"coopcloud.tech/abra/cli/formatter"
"coopcloud.tech/abra/pkg/catalogue"
"coopcloud.tech/abra/pkg/recipe"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
@ -29,13 +29,13 @@ var recipeListCommand = &cli.Command{
patternFlag,
},
Action: func(c *cli.Context) error {
catl, err := catalogue.ReadRecipeCatalogue()
catl, err := recipe.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err.Error())
}
recipes := catl.Flatten()
sort.Sort(catalogue.ByRecipeName(recipes))
sort.Sort(recipe.ByRecipeName(recipes))
tableCol := []string{"name", "category", "status", "healthcheck", "backups", "email", "tests", "SSO"}
table := formatter.CreateTable(tableCol)

View File

@ -17,7 +17,6 @@ import (
"github.com/AlecAivazis/survey/v2"
"github.com/docker/distribution/reference"
"github.com/go-git/go-git/v5"
configPkg "github.com/go-git/go-git/v5/config"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
@ -214,7 +213,7 @@ func createReleaseFromTag(recipe recipe.Recipe, tagString, mainAppVersion string
logrus.Fatal(err)
}
if err := pushRelease(tagString, repo); err != nil {
if err := pushRelease(recipe.Dir()); err != nil {
logrus.Fatal(err)
}
@ -309,7 +308,7 @@ func tagRelease(tagString string, repo *git.Repository) error {
return nil
}
func pushRelease(tagString string, repo *git.Repository) error {
func pushRelease(recipeDir string) error {
if internal.Dry {
logrus.Info("dry run: no changes pushed")
return nil
@ -326,21 +325,9 @@ func pushRelease(tagString string, repo *git.Repository) error {
}
if internal.Push {
if err := repo.Push(&git.PushOptions{}); err != nil {
if err := gitPkg.Push(recipeDir, true); err != nil {
return err
}
tagRef := fmt.Sprintf("+refs/tags/%s:refs/tags/%s", tagString, tagString)
pushOpts := &git.PushOptions{
RefSpecs: []configPkg.RefSpec{
configPkg.RefSpec(tagRef),
},
}
if err := repo.Push(pushOpts); err != nil {
return err
}
logrus.Info(fmt.Sprintf("pushed tag %s to remote", tagString))
}
return nil
@ -416,7 +403,7 @@ func createReleaseFromPreviousTag(tagString, mainAppVersion string, recipe recip
logrus.Fatal(err)
}
if err := pushRelease(newTagString, repo); err != nil {
if err := pushRelease(recipe.Dir()); err != nil {
logrus.Fatal(err)
}

View File

@ -9,9 +9,9 @@ import (
"strings"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/catalogue"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/config"
recipePkg "coopcloud.tech/abra/pkg/recipe"
"coopcloud.tech/tagcmp"
"github.com/AlecAivazis/survey/v2"
"github.com/docker/distribution/reference"
@ -147,7 +147,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
continue // skip on to the next tag and don't update any compose files
}
catlVersions, err := catalogue.VersionsOfService(recipe.Name, service.Name)
catlVersions, err := recipePkg.VersionsOfService(recipe.Name, service.Name)
if err != nil {
logrus.Fatal(err)
}

View File

@ -4,7 +4,7 @@ import (
"coopcloud.tech/abra/cli/formatter"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/autocomplete"
"coopcloud.tech/abra/pkg/catalogue"
recipePkg "coopcloud.tech/abra/pkg/recipe"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
@ -18,7 +18,7 @@ var recipeVersionCommand = &cli.Command{
Action: func(c *cli.Context) error {
recipe := internal.ValidateRecipe(c)
catalogue, err := catalogue.ReadRecipeCatalogue()
catalogue, err := recipePkg.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}