MCPcopy Create free account
hub / github.com/github/gh-aw / MarshalWithFieldOrder

Function MarshalWithFieldOrder

pkg/workflow/yaml.go:256–264  ·  view source on GitHub ↗

MarshalWithFieldOrder marshals a map to YAML with fields in a specific order. This function ensures deterministic field ordering in the generated YAML by using yaml.MapSlice internally. Priority fields are emitted first in the order specified, then remaining fields are emitted alphabetically. This

(data map[string]any, priorityFields []string)

Source from the content-addressed store, hash-verified

254// // permissions: ...
255// // jobs: ...
256func MarshalWithFieldOrder(data map[string]any, priorityFields []string) ([]byte, error) {
257 yamlLog.Printf("Marshaling YAML with field order: %d priority fields", len(priorityFields))
258
259 // Convert the map to an ordered MapSlice structure
260 orderedData := OrderMapFields(data, priorityFields)
261
262 // Marshal the ordered data with proper options for GitHub Actions
263 return yaml.MarshalWithOptions(orderedData, DefaultMarshalOptions...)
264}
265
266// OrderMapFields converts a map to yaml.MapSlice with fields in a specific order.
267//

Calls 2

OrderMapFieldsFunction · 0.85
PrintfMethod · 0.45