fix: ensure catalogue cloned for catalogue reliant commands
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
88f9796aaf
commit
7733637767
|
@ -94,12 +94,6 @@ keys configured on your account.
|
||||||
internal.ValidateRecipe(c)
|
internal.ValidateRecipe(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
|
||||||
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, "recipes")
|
|
||||||
if err := gitPkg.Clone(catalogueDir, url); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
repos, err := recipe.ReadReposMetadata()
|
repos, err := recipe.ReadReposMetadata()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
|
|
@ -2,14 +2,11 @@ package recipe
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"coopcloud.tech/abra/pkg/config"
|
|
||||||
"coopcloud.tech/abra/pkg/formatter"
|
"coopcloud.tech/abra/pkg/formatter"
|
||||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
|
||||||
"coopcloud.tech/abra/pkg/recipe"
|
"coopcloud.tech/abra/pkg/recipe"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
@ -32,12 +29,6 @@ var recipeListCommand = &cli.Command{
|
||||||
patternFlag,
|
patternFlag,
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
|
||||||
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, "recipes")
|
|
||||||
if err := gitPkg.Clone(catalogueDir, url); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
catl, err := recipe.ReadRecipeCatalogue()
|
catl, err := recipe.ReadRecipeCatalogue()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err.Error())
|
logrus.Fatal(err.Error())
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
package recipe
|
package recipe
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"path"
|
|
||||||
|
|
||||||
"coopcloud.tech/abra/cli/internal"
|
"coopcloud.tech/abra/cli/internal"
|
||||||
"coopcloud.tech/abra/pkg/autocomplete"
|
"coopcloud.tech/abra/pkg/autocomplete"
|
||||||
"coopcloud.tech/abra/pkg/config"
|
|
||||||
"coopcloud.tech/abra/pkg/formatter"
|
"coopcloud.tech/abra/pkg/formatter"
|
||||||
gitPkg "coopcloud.tech/abra/pkg/git"
|
|
||||||
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
recipePkg "coopcloud.tech/abra/pkg/recipe"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
@ -23,12 +18,6 @@ var recipeVersionCommand = &cli.Command{
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
recipe := internal.ValidateRecipe(c)
|
recipe := internal.ValidateRecipe(c)
|
||||||
|
|
||||||
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
|
||||||
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, "recipes")
|
|
||||||
if err := gitPkg.Clone(catalogueDir, url); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
catalogue, err := recipePkg.ReadRecipeCatalogue()
|
catalogue, err := recipePkg.ReadRecipeCatalogue()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
|
|
@ -698,6 +698,10 @@ func recipeCatalogueFSIsLatest() (bool, error) {
|
||||||
func ReadRecipeCatalogue() (RecipeCatalogue, error) {
|
func ReadRecipeCatalogue() (RecipeCatalogue, error) {
|
||||||
recipes := make(RecipeCatalogue)
|
recipes := make(RecipeCatalogue)
|
||||||
|
|
||||||
|
if err := EnsureCatalogue(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
recipeFSIsLatest, err := recipeCatalogueFSIsLatest()
|
recipeFSIsLatest, err := recipeCatalogueFSIsLatest()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1064,3 +1068,18 @@ func StripTagMeta(image string) string {
|
||||||
|
|
||||||
return image
|
return image
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnsureCatalogue ensures that the catalogue is cloned locally & present.
|
||||||
|
func EnsureCatalogue() error {
|
||||||
|
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
||||||
|
if _, err := os.Stat(catalogueDir); err != nil && os.IsNotExist(err) {
|
||||||
|
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, "recipes")
|
||||||
|
if err := gitPkg.Clone(catalogueDir, url); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logrus.Debugf("cloned catalogue repository to %s", catalogueDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue