|
|
@@ -5,6 +5,7 @@ import (
|
|
|
"fmt"
|
|
|
|
|
|
"github.com/santhosh-tekuri/jsonschema/v5"
|
|
|
+ _ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
|
|
|
)
|
|
|
|
|
|
func validateWebChartValues(values map[string]interface{}) error {
|
|
|
@@ -90,3 +91,27 @@ func validateJobChartValues(values map[string]interface{}) error {
|
|
|
|
|
|
return scm.Validate(v)
|
|
|
}
|
|
|
+
|
|
|
+func validatePostgresChartValues(values map[string]interface{}) error {
|
|
|
+ compiler := jsonschema.NewCompiler()
|
|
|
+
|
|
|
+ scm, err := compiler.Compile("https://raw.githubusercontent.com/porter-dev/porter-charts/master/addons/postgresql/values.schema.json")
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("error compiling postgres chart values schema: %w", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ jsonBytes, err := json.Marshal(values)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("error marshalling values to JSON: %w", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ var v interface{}
|
|
|
+
|
|
|
+ if err := json.Unmarshal(jsonBytes, &v); err != nil {
|
|
|
+ return fmt.Errorf("error unmarshalling values JSON to interface: %w", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ return scm.Validate(v)
|
|
|
+}
|