fix: only check catalogue once
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
decentral1se 2021-11-19 15:50:29 +01:00
parent d821975aa2
commit 304b70639f
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
5 changed files with 25 additions and 10 deletions

View File

@ -101,6 +101,11 @@ can take some time.
canUpgradeCount int canUpgradeCount int
) )
catl, err := catalogue.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}
for _, app := range apps { for _, app := range apps {
var tableRow []string var tableRow []string
if app.Type == appType || appType == "" { if app.Type == appType || appType == "" {
@ -126,7 +131,8 @@ can take some time.
var newUpdates []string var newUpdates []string
if version != "unknown" { if version != "unknown" {
updates, err := catalogue.GetRecipeCatalogueVersions(app.Type)
updates, err := catalogue.GetRecipeCatalogueVersions(app.Type, catl)
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }

View File

@ -70,7 +70,12 @@ recipes.
logrus.Fatalf("'%s' is not deployed?", app.Name) logrus.Fatalf("'%s' is not deployed?", app.Name)
} }
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type) catl, err := catalogue.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type, catl)
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }

View File

@ -62,7 +62,12 @@ recipes.
logrus.Fatalf("'%s' is not deployed?", app.Name) logrus.Fatalf("'%s' is not deployed?", app.Name)
} }
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type) catl, err := catalogue.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type, catl)
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }

View File

@ -45,7 +45,11 @@ func DeployAction(c *cli.Context) error {
version := deployedVersion version := deployedVersion
if version == "" && !Chaos { if version == "" && !Chaos {
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type) catl, err := catalogue.ReadRecipeCatalogue()
if err != nil {
logrus.Fatal(err)
}
versions, err := catalogue.GetRecipeCatalogueVersions(app.Type, catl)
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }

View File

@ -480,14 +480,9 @@ func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
} }
// GetRecipeCatalogueVersions list the recipe versions listed in the recipe catalogue. // GetRecipeCatalogueVersions list the recipe versions listed in the recipe catalogue.
func GetRecipeCatalogueVersions(recipeName string) ([]string, error) { func GetRecipeCatalogueVersions(recipeName string, catl RecipeCatalogue) ([]string, error) {
var versions []string var versions []string
catl, err := ReadRecipeCatalogue()
if err != nil {
return versions, err
}
if recipeMeta, exists := catl[recipeName]; exists { if recipeMeta, exists := catl[recipeName]; exists {
for _, versionMeta := range recipeMeta.Versions { for _, versionMeta := range recipeMeta.Versions {
for tag := range versionMeta { for tag := range versionMeta {