Skip to content

Commit

Permalink
Merge pull request #63 from CMon/add-yaml-data-format
Browse files Browse the repository at this point in the history
add yaml as supported data format for data
  • Loading branch information
ezavgorodniy authored Apr 15, 2024
2 parents 22c400c + e056871 commit 2020ccc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pkg/security/types/data_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
Serialization
File
CSV
YAML
)

func DataFormatValues() []TypeEnum {
Expand All @@ -28,6 +29,7 @@ func DataFormatValues() []TypeEnum {
Serialization,
File,
CSV,
YAML,
}
}

Expand All @@ -37,6 +39,7 @@ var DataFormatTypeDescription = [...]TypeDescription{
{"serialization", "Serialized program objects"},
{"file", "Specific file types for data"},
{"csv", "CSV"},
{"yaml", "YAML"},
}

func ParseDataFormat(value string) (dataFormat DataFormat, err error) {
Expand All @@ -59,12 +62,12 @@ func (what DataFormat) Explain() string {
}

func (what DataFormat) Title() string {
return [...]string{"JSON", "XML", "Serialization", "File", "CSV"}[what]
return [...]string{"JSON", "XML", "Serialization", "File", "CSV", "YAML"}[what]
}

func (what DataFormat) Description() string {
return [...]string{"JSON marshalled object data", "XML structured data", "Serialization-based object graphs",
"File input/uploads", "CSV tabular data"}[what]
"File input/uploads", "CSV tabular data", "YAML structured configuration format"}[what]
}

type ByDataFormatAcceptedSort []DataFormat
Expand Down
4 changes: 4 additions & 0 deletions pkg/security/types/data_format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func TestParseDataFormat(t *testing.T) {
input: "csv",
expected: CSV,
},
"yaml": {
input: "yaml",
expected: YAML,
},
"unknown": {
input: "unknown",
expectedError: fmt.Errorf("unable to parse into type: unknown"),
Expand Down
3 changes: 2 additions & 1 deletion support/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@
"xml",
"serialization",
"file",
"csv"
"csv",
"yaml"
]
}
},
Expand Down

0 comments on commit 2020ccc

Please sign in to comment.