fix: generates monitoring resources for database
Generate the monitoring resources for database only if there is no external database defined
@@ -23,6 +23,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
+ "path/filepath"
"reflect"
"sort"
"strings"
@@ -131,6 +132,7 @@ func Render(filePath string, context interface{}) ([]unstructured.Unstructured,
// We can load plain yml files..
if strings.HasSuffix(filePath, ".yml") || strings.HasSuffix(filePath, ".yaml") {
+ if !skipFile(filePath, context) {
fileData, err := AssetAsBytes(filePath)
if err != nil {
return nil, err
@@ -141,6 +143,7 @@ func Render(filePath string, context interface{}) ([]unstructured.Unstructured,
return nil, errors.Errorf("%s:\n%s\n", err, string(fileData))
}
}
+ }
// We can process go lang templates.
if strings.HasSuffix(filePath, ".yml.tmpl") || strings.HasSuffix(filePath, ".yaml.tmpl") {
@@ -191,3 +194,18 @@ func Render(filePath string, context interface{}) ([]unstructured.Unstructured,
return response, nil
}
+
+// Skip file if conditions are met
+func skipFile(file string, config interface{}) bool {
+ if x, ok := config.(*configuration.Config); ok {
+ if x.Syndesis.Components.Database.ExternalDbURL != "" {
+ for _, wfile := range []string{"addon-ops-db-alerting-rules.yml", "addon-ops-db-dashboard.yml"} {
+ if wfile == filepath.Base(file) {
+ return true
+ }
+ }
+ }
+ }
+
+ return false
+}
