Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Item ¶
type Item struct { Properties map[string]extv1.JSONSchemaProps // contains filtered or unexported fields }
func buildOutputMap(groups []Item, propMap map[string]PropMap, chainedProps []string) ([]Item, map[string]extv1.JSONSchemaProps) { fmt.Printf("buildOutputMap: groups %d, chainedprops: %v\n", len(groups), chainedProps) sortedKeys := getSortedKeys(propMap) for _, prop := range sortedKeys { // idx is the last entry in the group -> we always append to the last entry of the group idx := len(groups) - 1 if groups[idx].tokens+propMap[prop].tokens < 3500 { groups[idx].tokens += propMap[prop].tokens groups[idx].Properties = addData( groups[idx].Properties, append(chainedProps, prop), propMap[prop].data, ) } else { // if we exceed the tokens we add a new item to the group groups = append(groups, Item{tokens: 0, Properties: map[string]extv1.JSONSchemaProps{}}) // append the group idx := len(groups) - 1 if groups[idx].tokens+propMap[prop].tokens < 3500 { groups[idx].tokens += propMap[prop].tokens groups[idx].Properties = addData( groups[idx].Properties, append(chainedProps, prop), propMap[prop].data, ) } else { // if a single item exceeds the token limit we need to split // add the initial element to the props w/o the properties groups[idx].Properties[prop] = propMap[prop].data for k := range groups[idx].Properties[prop].Properties { delete(groups[idx].Properties[prop].Properties, k) } groups, groups[idx].Properties = buildOutputMap( groups, propMap[prop].propMap, append(chainedProps, prop), // append the prop ) } } } idx := len(groups) - 1 return groups, groups[idx].Properties }
Click to show internal directories.
Click to hide internal directories.