Documentation
¶
Index ¶
- func CoerceToJsonMap(ymlData InterfaceOrBytes) (model map[string]interface{}, err error)
- func CreateFileDirs(fullPath string) (err error)
- func FindValue(model map[string]interface{}, keys []string) interface{}
- func FormatOscalVersion(version string) (formattedVersion string)
- func FormatTags(cmdlineTags string) (tagList []string, err error)
- func GetLatestSupportedVersion() string
- func GetModelType(model map[string]interface{}) (modelType string, err error)
- func GetOscalVersionFromMap(model map[string]interface{}) (version string, err error)
- func GetTimestamp() time.Time
- func IsJson(path string) (err error)
- func IsJsonOrYaml(path string) (err error)
- func IsValidOscalVersion(version string) error
- func MarshalByExtension(model interface{}, outputFile string) (bytes []byte, err error)
- func RemoveTrailingWhitespace(bytes []byte) []byte
- func ReplaceOscalVersionInMap(model map[string]interface{}, version string) (upgradedModel map[string]interface{}, err error)
- func UpdateLastModified(metadata map[string]interface{})
- func VersionWarning(version string) error
- func WriteOutput(output []byte, outputFile string) (err error)
- type InterfaceOrBytes
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 CreateFileDirs ¶
CreateFileDirs creates the directories for a file path if they do not exist.
func FindValue ¶
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 FormatOscalVersion ¶
FormatOscalVersion takes a version string and returns a formatted version string
func FormatTags ¶
formatTags formats Go struct tags.
func GetLatestSupportedVersion ¶
func GetLatestSupportedVersion() string
GetLatestSupportedVersion returns the latest version of the OSCAL schema supported by the go-oscal release
func GetModelType ¶
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 GetOscalVersionFromMap ¶
GetOscalVersionFromMap returns formatted OSCAL version if valid version is passed, returns error if not.
func GetTimestamp ¶
func IsJsonOrYaml ¶
isJsonOrYaml returns error if the file is not a json or yaml file.
func IsValidOscalVersion ¶
IsValidOscalVersion returns true if the version is supported, false if not.
func MarshalByExtension ¶
MarshalByExtension takes a model and marshals it to json or yaml based on the extension of the output file
func RemoveTrailingWhitespace ¶ added in v0.3.1
RemoveTrailingWhitespace removes trailing whitespace from each line in a byte array. This is useful for removing trailing whitespace from a yaml file before it is marshalled into a struct. Prevents strings from being collapsed into a single line by yaml parser.
func ReplaceOscalVersionInMap ¶
func ReplaceOscalVersionInMap(model map[string]interface{}, version string) (upgradedModel map[string]interface{}, err error)
ReplaceOscalVersionInMap returns the model with the oscal version replaced
func UpdateLastModified ¶
func UpdateLastModified(metadata map[string]interface{})
UpdateLastModified updates the last-modified field in the metadata
func VersionWarning ¶
VersionWarning returns an warning as an error if there are any known issues with the current version or it isn't the latest.
func WriteOutput ¶
WriteOutput writes to the provided output file or to stdout by default.
Types ¶
type InterfaceOrBytes ¶
type InterfaceOrBytes interface {
interface{} | []byte
}
InterfaceOrBytes is an interface{} or []byte for generic functions that can support either type