forked from toolshed/abra
		
	fix: failover if no recipe meta available
This commit is contained in:
		@ -236,9 +236,10 @@ func Get(recipeName string, conf *runtime.Config) (Recipe, error) {
 | 
			
		||||
 | 
			
		||||
	meta, err := GetRecipeMeta(recipeName, conf)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if strings.Contains(err.Error(), "does not exist") {
 | 
			
		||||
		switch err.(type) {
 | 
			
		||||
		case RecipeMissingFromCatalogue:
 | 
			
		||||
			meta = RecipeMeta{}
 | 
			
		||||
		} else {
 | 
			
		||||
		default:
 | 
			
		||||
			return Recipe{}, err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@ -368,7 +369,12 @@ func EnsureLatest(recipeName string, conf *runtime.Config) error {
 | 
			
		||||
 | 
			
		||||
	meta, err := GetRecipeMeta(recipeName, conf)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
		switch err.(type) {
 | 
			
		||||
		case RecipeMissingFromCatalogue:
 | 
			
		||||
			meta = RecipeMeta{}
 | 
			
		||||
		default:
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var branch plumbing.ReferenceName
 | 
			
		||||
@ -719,6 +725,14 @@ func VersionsOfService(recipe, serviceName string, conf *runtime.Config) ([]stri
 | 
			
		||||
	return versions, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RecipeMissingFromCatalogue signifies a recipe is not present in the catalogue.
 | 
			
		||||
type RecipeMissingFromCatalogue struct{ err string }
 | 
			
		||||
 | 
			
		||||
// Error outputs the error message.
 | 
			
		||||
func (r RecipeMissingFromCatalogue) Error() string {
 | 
			
		||||
	return r.err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetRecipeMeta retrieves the recipe metadata from the recipe catalogue.
 | 
			
		||||
func GetRecipeMeta(recipeName string, conf *runtime.Config) (RecipeMeta, error) {
 | 
			
		||||
	catl, err := ReadRecipeCatalogue(conf)
 | 
			
		||||
@ -728,7 +742,9 @@ func GetRecipeMeta(recipeName string, conf *runtime.Config) (RecipeMeta, error)
 | 
			
		||||
 | 
			
		||||
	recipeMeta, ok := catl[recipeName]
 | 
			
		||||
	if !ok {
 | 
			
		||||
		return RecipeMeta{}, fmt.Errorf("recipe %s does not exist?", recipeName)
 | 
			
		||||
		return RecipeMeta{}, RecipeMissingFromCatalogue{
 | 
			
		||||
			err: fmt.Sprintf("recipe %s does not exist?", recipeName),
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if err := EnsureExists(recipeName, conf); err != nil {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user