Skip to content

Commit

Permalink
use MapSlice
Browse files Browse the repository at this point in the history
  • Loading branch information
dogancanbakir committed Jul 20, 2023
1 parent e82e89a commit 72a464a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions v2/pkg/utils/insertion_ordered_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"encoding/json"
"fmt"
"strconv"

"github.com/goccy/go-yaml"
)

type InsertionOrderedStringMap struct {
Expand Down Expand Up @@ -32,13 +34,13 @@ func (insertionOrderedStringMap *InsertionOrderedStringMap) Len() int {
}

func (insertionOrderedStringMap *InsertionOrderedStringMap) UnmarshalYAML(unmarshal func(interface{}) error) error {
var data map[interface{}]interface{} //NOTE: this is a workaround. unmarshal func fails when using yaml.MapSlice
var data yaml.MapSlice
if err := unmarshal(&data); err != nil {
return err
}
insertionOrderedStringMap.values = make(map[string]interface{})
for k, v := range data {
insertionOrderedStringMap.Set(k.(string), toString(v))
for _, v := range data {
insertionOrderedStringMap.Set(v.Key.(string), toString(v.Value))
}
return nil
}
Expand Down

0 comments on commit 72a464a

Please sign in to comment.