Skip to content

Commit

Permalink
DOM: Remove deprecated ContainerFactory#FromAny() method
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com>
  • Loading branch information
rkosegi committed Aug 31, 2024
1 parent c0844c3 commit 02585e4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 26 deletions.
13 changes: 0 additions & 13 deletions dom/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package dom
import (
"fmt"
"github.com/rkosegi/yaml-toolkit/utils"
"gopkg.in/yaml.v3"
"io"
"regexp"
"strconv"
Expand Down Expand Up @@ -294,18 +293,6 @@ func (c *containerBuilderImpl) RemoveAt(path string) ContainerBuilder {
type containerFactory struct {
}

func (f *containerFactory) FromAny(v interface{}) ContainerBuilder {
var buff strings.Builder
if err := utils.NewYamlEncoder(&buff).Encode(v); err != nil {
panic(err)
}
var m map[string]interface{}
if err := yaml.Unmarshal([]byte(buff.String()), &m); err != nil {
panic(err)
}
return f.FromMap(m)
}

func (f *containerFactory) FromMap(in map[string]interface{}) ContainerBuilder {
return DefaultNodeDecoderFn(in).(ContainerBuilder)
}
Expand Down
9 changes: 0 additions & 9 deletions dom/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,6 @@ func TestAddListAt(t *testing.T) {
assert.Equal(t, "abc", root.Lookup("root.sub.sub2[5]").(Leaf).Value())
}

func TestFromAny(t *testing.T) {
type x struct {
A string
B int
}
r := b.FromAny(&x{A: "abc", B: 456}).Flatten()
assert.Equal(t, 2, len(r))
}

func TestCompact(t *testing.T) {
c, err := Builder().FromReader(strings.NewReader(`
root:
Expand Down
4 changes: 0 additions & 4 deletions dom/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ type ContainerFactory interface {
FromMap(in map[string]interface{}) ContainerBuilder
// FromProperties is similar to FromMap except that keys are parsed into path before inserting into ContainerBuilder
FromProperties(in map[string]interface{}) ContainerBuilder
// FromAny creates ContainerBuilder from any object. Any error encountered in process will result in panic.
// This method uses YAML codec internally to perform translation between raw interface and map.
// Deprecated, do not use. Same can be simply achieved by various ways by caller himself.
FromAny(v interface{}) ContainerBuilder
}

// Coordinate is address of Node within OverlayDocument
Expand Down

0 comments on commit 02585e4

Please sign in to comment.