Merge branch 'fix-deploy-no-catalogue'
continuous-integration/drone/push Build was killed Details

This commit is contained in:
decentral1se 2023-08-02 10:48:54 +02:00
commit 5ae73f700e
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
1 changed files with 20 additions and 4 deletions

View File

@ -236,9 +236,10 @@ func Get(recipeName string, conf *runtime.Config) (Recipe, error) {
meta, err := GetRecipeMeta(recipeName, conf) meta, err := GetRecipeMeta(recipeName, conf)
if err != nil { if err != nil {
if strings.Contains(err.Error(), "does not exist") { switch err.(type) {
case RecipeMissingFromCatalogue:
meta = RecipeMeta{} meta = RecipeMeta{}
} else { default:
return Recipe{}, err return Recipe{}, err
} }
} }
@ -378,7 +379,12 @@ func EnsureLatest(recipeName string, conf *runtime.Config) error {
meta, err := GetRecipeMeta(recipeName, conf) meta, err := GetRecipeMeta(recipeName, conf)
if err != nil { if err != nil {
return err switch err.(type) {
case RecipeMissingFromCatalogue:
meta = RecipeMeta{}
default:
return err
}
} }
var branch plumbing.ReferenceName var branch plumbing.ReferenceName
@ -734,6 +740,14 @@ func VersionsOfService(recipe, serviceName string, conf *runtime.Config) ([]stri
return versions, nil 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. // GetRecipeMeta retrieves the recipe metadata from the recipe catalogue.
func GetRecipeMeta(recipeName string, conf *runtime.Config) (RecipeMeta, error) { func GetRecipeMeta(recipeName string, conf *runtime.Config) (RecipeMeta, error) {
catl, err := ReadRecipeCatalogue(conf) catl, err := ReadRecipeCatalogue(conf)
@ -743,7 +757,9 @@ func GetRecipeMeta(recipeName string, conf *runtime.Config) (RecipeMeta, error)
recipeMeta, ok := catl[recipeName] recipeMeta, ok := catl[recipeName]
if !ok { 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 { if err := EnsureExists(recipeName, conf); err != nil {