model

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2025 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoerceToJsonMap

func CoerceToJsonMap(ymlData InterfaceOrBytes) (model map[string]interface{}, err error)

CoerceToJsonMap takes a yaml byte array and coerces it to a json interface{} This is necessary because the jsonschema library only accepts valid json data types that may not match yaml. Example: yaml allows for DateTimes to be time.Time, but json requires them to be strings This also allows for structs to be passed in, and they will be converted to map[string]interface{}

func FindValue

func FindValue(model map[string]interface{}, keys []string) interface{}

Finds the value of a key in a model in a map[string]interface{} given a slice of keys Returns nil if the key is not found or the model type is not supported Internal Recursive function so that the model can keep type safety

func GetModelType

func GetModelType(model map[string]interface{}) (modelType string, err error)

GetModelType returns the type of the model if the model is valid returns error if more than one model is found or no models are found (consistent with OSCAL spec)

func MarshalByExtension

func MarshalByExtension(model interface{}, outputFile string) (bytes []byte, err error)

MarshalByExtension takes a model and marshals it to json or yaml based on the extension of the output file

Types

type InterfaceOrBytes

type InterfaceOrBytes interface {
	interface{} | []byte
}

InterfaceOrBytes is an interface{} or []byte for generic functions that can support either type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL