fix: dont overwrite generated catalogue
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Closes coop-cloud/organising#190.
This commit is contained in:
parent
0140f96ca1
commit
b68547b2c2
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"coopcloud.tech/abra/cli/formatter"
|
"coopcloud.tech/abra/cli/formatter"
|
||||||
|
@ -143,8 +144,26 @@ var catalogueGenerateCommand = &cli.Command{
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile(config.APPS_JSON, recipesJSON, 0644); err != nil {
|
if _, err := os.Stat(config.APPS_JSON); err != nil && os.IsNotExist(err) {
|
||||||
logrus.Fatal(err)
|
if err := ioutil.WriteFile(config.APPS_JSON, recipesJSON, 0644); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if recipeName != "" {
|
||||||
|
catlFS, err := catalogue.ReadRecipeCatalogue()
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
catlFS[recipeName] = catl[recipeName]
|
||||||
|
|
||||||
|
updatedRecipesJSON, err := json.MarshalIndent(catlFS, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile(config.APPS_JSON, updatedRecipesJSON, 0644); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("generated new recipe catalogue in '%s'", config.APPS_JSON)
|
logrus.Infof("generated new recipe catalogue in '%s'", config.APPS_JSON)
|
||||||
|
|
Loading…
Reference in New Issue