Merge pull request #30760 from robertsirc/add-debuging-to-jsonschema

adding slog debug to a few points
pull/30766/head
Matt Farina 5 months ago committed by GitHub
commit 01590a59b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -19,6 +19,7 @@ package util
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"log/slog"
"strings" "strings"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -31,13 +32,14 @@ import (
func ValidateAgainstSchema(chrt *chart.Chart, values map[string]interface{}) error { func ValidateAgainstSchema(chrt *chart.Chart, values map[string]interface{}) error {
var sb strings.Builder var sb strings.Builder
if chrt.Schema != nil { if chrt.Schema != nil {
slog.Debug("chart name", "chart-name", chrt.Name())
err := ValidateAgainstSingleSchema(values, chrt.Schema) err := ValidateAgainstSingleSchema(values, chrt.Schema)
if err != nil { if err != nil {
sb.WriteString(fmt.Sprintf("%s:\n", chrt.Name())) sb.WriteString(fmt.Sprintf("%s:\n", chrt.Name()))
sb.WriteString(err.Error()) sb.WriteString(err.Error())
} }
} }
slog.Debug("number of dependencies in the chart", "dependencies", len(chrt.Dependencies()))
// For each dependency, recursively call this function with the coalesced values // For each dependency, recursively call this function with the coalesced values
for _, subchart := range chrt.Dependencies() { for _, subchart := range chrt.Dependencies() {
subchartValues := values[subchart.Name()].(map[string]interface{}) subchartValues := values[subchart.Name()].(map[string]interface{})
@ -67,6 +69,7 @@ func ValidateAgainstSingleSchema(values Values, schemaJSON []byte) (reterr error
if err != nil { if err != nil {
return err return err
} }
slog.Debug("unmarshalled JSON schema", "schema", schemaJSON)
compiler := jsonschema.NewCompiler() compiler := jsonschema.NewCompiler()
err = compiler.AddResource("file:///values.schema.json", schema) err = compiler.AddResource("file:///values.schema.json", schema)

Loading…
Cancel
Save