fix: find local only apps
This commit is contained in:
parent
cb2bb3f532
commit
8d499c0810
|
@ -48,14 +48,33 @@ func ValidateRecipeWithPrompt(c *cli.Context) recipe.Recipe {
|
||||||
recipeName := c.Args().First()
|
recipeName := c.Args().First()
|
||||||
|
|
||||||
if recipeName == "" && !NoInput {
|
if recipeName == "" && !NoInput {
|
||||||
|
var recipes []string
|
||||||
|
|
||||||
catl, err := catalogue.ReadRecipeCatalogue()
|
catl, err := catalogue.ReadRecipeCatalogue()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
var recipes []string
|
|
||||||
|
knownRecipes := make(map[string]bool)
|
||||||
for name := range catl {
|
for name := range catl {
|
||||||
recipes = append(recipes, name)
|
knownRecipes[name] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
localRecipes, err := recipe.GetRecipesLocal()
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, recipeLocal := range localRecipes {
|
||||||
|
if _, ok := knownRecipes[recipeLocal]; !ok {
|
||||||
|
knownRecipes[recipeLocal] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for recipeName := range knownRecipes {
|
||||||
|
recipes = append(recipes, recipeName)
|
||||||
|
}
|
||||||
|
|
||||||
prompt := &survey.Select{
|
prompt := &survey.Select{
|
||||||
Message: "Select recipe",
|
Message: "Select recipe",
|
||||||
Options: recipes,
|
Options: recipes,
|
||||||
|
|
|
@ -97,11 +97,6 @@ You may invoke this command in "wizard" mode and be prompted for input:
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, service := range recipe.Config.Services {
|
for _, service := range recipe.Config.Services {
|
||||||
catlVersions, err := catalogue.VersionsOfService(recipe.Name, service.Name)
|
|
||||||
if err != nil {
|
|
||||||
logrus.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
img, err := reference.ParseNormalizedNamed(service.Image)
|
img, err := reference.ParseNormalizedNamed(service.Image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
@ -152,6 +147,11 @@ 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
|
continue // skip on to the next tag and don't update any compose files
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catlVersions, err := catalogue.VersionsOfService(recipe.Name, service.Name)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
var compatibleStrings []string
|
var compatibleStrings []string
|
||||||
for _, compat := range compatible {
|
for _, compat := range compatible {
|
||||||
skip := false
|
skip := false
|
||||||
|
|
|
@ -220,6 +220,8 @@ func readRecipeCatalogueWeb(target interface{}) error {
|
||||||
|
|
||||||
// VersionsOfService lists the version of a service.
|
// VersionsOfService lists the version of a service.
|
||||||
func VersionsOfService(recipe, serviceName string) ([]string, error) {
|
func VersionsOfService(recipe, serviceName string) ([]string, error) {
|
||||||
|
var versions []string
|
||||||
|
|
||||||
catalogue, err := ReadRecipeCatalogue()
|
catalogue, err := ReadRecipeCatalogue()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -227,10 +229,9 @@ func VersionsOfService(recipe, serviceName string) ([]string, error) {
|
||||||
|
|
||||||
rec, ok := catalogue[recipe]
|
rec, ok := catalogue[recipe]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("recipe '%s' does not exist?", recipe)
|
return versions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
versions := []string{}
|
|
||||||
alreadySeen := make(map[string]bool)
|
alreadySeen := make(map[string]bool)
|
||||||
for _, serviceVersion := range rec.Versions {
|
for _, serviceVersion := range rec.Versions {
|
||||||
for tag := range serviceVersion {
|
for tag := range serviceVersion {
|
||||||
|
|
|
@ -135,7 +135,7 @@ func LoadAppFiles(servers ...string) (AppFiles, error) {
|
||||||
if servers[0] == "" {
|
if servers[0] == "" {
|
||||||
// Empty servers flag, one string will always be passed
|
// Empty servers flag, one string will always be passed
|
||||||
var err error
|
var err error
|
||||||
servers, err = getAllFoldersInDirectory(ABRA_SERVER_FOLDER)
|
servers, err = GetAllFoldersInDirectory(ABRA_SERVER_FOLDER)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,8 +95,8 @@ func getAllFilesInDirectory(directory string) ([]fs.FileInfo, error) {
|
||||||
return realFiles, nil
|
return realFiles, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getAllFoldersInDirectory returns both folder and symlink paths
|
// GetAllFoldersInDirectory returns both folder and symlink paths
|
||||||
func getAllFoldersInDirectory(directory string) ([]string, error) {
|
func GetAllFoldersInDirectory(directory string) ([]string, error) {
|
||||||
var folders []string
|
var folders []string
|
||||||
|
|
||||||
files, err := ioutil.ReadDir(directory)
|
files, err := ioutil.ReadDir(directory)
|
||||||
|
|
|
@ -259,3 +259,15 @@ func ChaosVersion(recipeName string) (string, error) {
|
||||||
|
|
||||||
return version, nil
|
return version, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRecipesLocal retrieves all local recipe directories
|
||||||
|
func GetRecipesLocal() ([]string, error) {
|
||||||
|
var recipes []string
|
||||||
|
|
||||||
|
recipes, err := config.GetAllFoldersInDirectory(config.APPS_DIR)
|
||||||
|
if err != nil {
|
||||||
|
return recipes, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return recipes, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue