| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- 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)
- }
|