| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package preview
- import (
- "encoding/json"
- "fmt"
- "github.com/santhosh-tekuri/jsonschema/v5"
- _ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
- )
- func validateWebChartValues(values map[string]interface{}) error {
- compiler := jsonschema.NewCompiler()
- scm, err := compiler.Compile("https://raw.githubusercontent.com/porter-dev/porter-charts/master/applications/web/validate.json")
- if err != nil {
- return fmt.Errorf("error compiling job 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)
- }
- func validateWorkerChartValues(values map[string]interface{}) error {
- compiler := jsonschema.NewCompiler()
- scm, err := compiler.Compile("https://raw.githubusercontent.com/porter-dev/porter-charts/master/applications/worker/validate.json")
- if err != nil {
- return fmt.Errorf("error compiling job 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)
- }
- func validateJobChartValues(values map[string]interface{}) error {
- compiler := jsonschema.NewCompiler()
- scm, err := compiler.Compile("https://raw.githubusercontent.com/porter-dev/porter-charts/master/applications/job/validate.json")
- if err != nil {
- return fmt.Errorf("error compiling job 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)
- }
- 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)
- }
|