github.com/kubeflow/training-operator@v1.7.0/pkg/apis/kubeflow.org/v1/validation_test_utils.go (about) 1 package v1 2 3 import ( 4 "encoding/json" 5 "fmt" 6 7 log "github.com/sirupsen/logrus" 8 ) 9 10 const ( 11 testImage = "test-image:latest" 12 ) 13 14 // pformat returns a pretty format output of any value that can be marshaled to JSON. 15 func pformat(value interface{}) string { 16 if s, ok := value.(string); ok { 17 return s 18 } 19 valueJSON, err := json.MarshalIndent(value, "", " ") 20 if err != nil { 21 log.Warningf("Couldn't pretty format %v, error: %v", value, err) 22 return fmt.Sprintf("%v", value) 23 } 24 return string(valueJSON) 25 }