diff --git a/exampleoc/a/a-0.go b/exampleoc/a/a-0.go index cb9baf4..e8185cf 100644 --- a/exampleoc/a/a-0.go +++ b/exampleoc/a/a-0.go @@ -16,7 +16,7 @@ Package a is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../pathgen/testdata/yang/openconfig-simple.yang - ../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/exampleoc/enum.go b/exampleoc/enum.go index d1ef213..e462d67 100644 --- a/exampleoc/enum.go +++ b/exampleoc/enum.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../pathgen/testdata/yang/openconfig-simple.yang - ../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/exampleoc/enum_map.go b/exampleoc/enum_map.go index 63e224f..29ffb24 100644 --- a/exampleoc/enum_map.go +++ b/exampleoc/enum_map.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../pathgen/testdata/yang/openconfig-simple.yang - ../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/exampleoc/exampleocpath/exampleocpath.go b/exampleoc/exampleocpath/exampleocpath.go index bc02e3d..86c002f 100644 --- a/exampleoc/exampleocpath/exampleocpath.go +++ b/exampleoc/exampleocpath/exampleocpath.go @@ -16,7 +16,7 @@ Package exampleocpath is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../pathgen/testdata/yang/openconfig-simple.yang - ../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/exampleoc/modelb/modelb-0.go b/exampleoc/modelb/modelb-0.go index 7127f9c..793ba46 100644 --- a/exampleoc/modelb/modelb-0.go +++ b/exampleoc/modelb/modelb-0.go @@ -16,7 +16,7 @@ Package modelb is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../pathgen/testdata/yang/openconfig-simple.yang - ../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/exampleoc/schema.go b/exampleoc/schema.go index d892c59..871180b 100644 --- a/exampleoc/schema.go +++ b/exampleoc/schema.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../pathgen/testdata/yang/openconfig-simple.yang - ../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/exampleoc/structs-0.go b/exampleoc/structs-0.go index aa5b463..8eb7dcc 100644 --- a/exampleoc/structs-0.go +++ b/exampleoc/structs-0.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../pathgen/testdata/yang/openconfig-simple.yang - ../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/exampleoc/union.go b/exampleoc/union.go index a480d05..ea6e39d 100644 --- a/exampleoc/union.go +++ b/exampleoc/union.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../pathgen/testdata/yang/openconfig-simple.yang - ../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/go.mod b/go.mod index 1818cff..3db1066 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,8 @@ require ( github.com/google/go-cmp v0.6.0 github.com/openconfig/gnmi v0.10.0 github.com/openconfig/gocloser v0.0.0-20220310182203-c6c950ed3b0b - github.com/openconfig/goyang v1.4.3 - github.com/openconfig/ygot v0.29.16 + github.com/openconfig/goyang v1.4.4 + github.com/openconfig/ygot v0.29.17 github.com/pkg/errors v0.9.1 github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.15.0 diff --git a/go.sum b/go.sum index ea2552b..54210d3 100644 --- a/go.sum +++ b/go.sum @@ -40,7 +40,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/cenkalti/backoff/v4 v4.0.0/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= @@ -115,6 +114,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -130,7 +130,6 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/protobuf v3.11.4+incompatible/go.mod h1:lUQ9D1ePzbH2PrIS7ob/bjm9HXyH5WHB0Akwh7URreM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -159,22 +158,22 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/openconfig/gnmi v0.0.0-20200414194230-1597cc0f2600/go.mod h1:M/EcuapNQgvzxo1DDXHK4tx3QpYM/uG4l591v33jG2A= github.com/openconfig/gnmi v0.10.0 h1:kQEZ/9ek3Vp2Y5IVuV2L/ba8/77TgjdXg505QXvYmg8= github.com/openconfig/gnmi v0.10.0/go.mod h1:Y9os75GmSkhHw2wX8sMsxfI7qRGAEcDh8NTa5a8vj6E= github.com/openconfig/gocloser v0.0.0-20220310182203-c6c950ed3b0b h1:NSYuxdlOWLldNpid1dThR6Dci96juXioUguMho6aliI= github.com/openconfig/gocloser v0.0.0-20220310182203-c6c950ed3b0b/go.mod h1:uhC/ybmPapgeyAL2b9ZrUQ+DZE+DB+J+/7377PX+lek= github.com/openconfig/goyang v0.0.0-20200115183954-d0a48929f0ea/go.mod h1:dhXaV0JgHJzdrHi2l+w0fZrwArtXL7jEFoiqLEdmkvU= -github.com/openconfig/goyang v1.4.3 h1:9sr+l1vRbON0cMZxmogMhI8JiNqIf1uJoN8o4OdNqxI= -github.com/openconfig/goyang v1.4.3/go.mod h1:vX61x01Q46AzbZUzG617vWqh/cB+aisc+RrNkXRd3W8= +github.com/openconfig/goyang v1.4.4 h1:ee0bbD60eQIjqrzH5S8yjneA6kA36UdxitokeL3+SGg= +github.com/openconfig/goyang v1.4.4/go.mod h1:sdNZi/wdTZyLNBNfgLzmmbi7kISm7FskMDKKzMY+x1M= github.com/openconfig/grpctunnel v0.0.0-20220819142823-6f5422b8ca70 h1:t6SvvdfWCMlw0XPlsdxO8EgO+q/fXnTevDjdYREKFwU= github.com/openconfig/grpctunnel v0.0.0-20220819142823-6f5422b8ca70/go.mod h1:OmTWe7RyZj2CIzIgy4ovEBzCLBJzRvWSZmn7u02U9gU= github.com/openconfig/ygot v0.6.0/go.mod h1:o30svNf7O0xK+R35tlx95odkDmZWS9JyWWQSmIhqwAs= -github.com/openconfig/ygot v0.29.16 h1:nqSHTEHm2TtsoXVYM6BrgBilnxxFcOYF5Q19w7e6CmA= -github.com/openconfig/ygot v0.29.16/go.mod h1:GDi97RDhYa2MGyYQXSk/RbSV3OgtuOCXBPfeOKD5pQQ= -github.com/pborman/getopt v0.0.0-20190409184431-ee0cd42419d3/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= +github.com/openconfig/ygot v0.29.17 h1:o1r7jSsWdpuIk/mqrt0xZ/MfE8CRUsgIPUwWudnZqaY= +github.com/openconfig/ygot v0.29.17/go.mod h1:LeoQY1Ll4N20ccB33VjukrWJ6633V7jtg223GBfjHno= +github.com/pborman/getopt v1.1.0/go.mod h1:FxXoW1Re00sQG/+KIkuSqRL/LwQgSkv7uyac+STFsbk= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -183,6 +182,7 @@ github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qR github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/protocolbuffers/txtpbfmt v0.0.0-20220608084003-fc78c767cd6a/go.mod h1:KjY0wibdYKc4DYkerHSbguaf3JeIPGhNJBp2BNiFH78= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= @@ -229,7 +229,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -536,6 +535,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/exampleocconfig/a/a-0.go b/internal/exampleocconfig/a/a-0.go index 96a13ba..99bf821 100644 --- a/internal/exampleocconfig/a/a-0.go +++ b/internal/exampleocconfig/a/a-0.go @@ -16,7 +16,7 @@ Package a is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocconfig/enum.go b/internal/exampleocconfig/enum.go index c8009b8..1958371 100644 --- a/internal/exampleocconfig/enum.go +++ b/internal/exampleocconfig/enum.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocconfig/enum_map.go b/internal/exampleocconfig/enum_map.go index 8a916eb..20ea7ca 100644 --- a/internal/exampleocconfig/enum_map.go +++ b/internal/exampleocconfig/enum_map.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocconfig/exampleocconfigpath/exampleocconfigpath.go b/internal/exampleocconfig/exampleocconfigpath/exampleocconfigpath.go index a49574e..f2c6bfe 100644 --- a/internal/exampleocconfig/exampleocconfigpath/exampleocconfigpath.go +++ b/internal/exampleocconfig/exampleocconfigpath/exampleocconfigpath.go @@ -16,7 +16,7 @@ Package exampleocconfigpath is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocconfig/modelb/modelb-0.go b/internal/exampleocconfig/modelb/modelb-0.go index cc6185e..4452e5e 100644 --- a/internal/exampleocconfig/modelb/modelb-0.go +++ b/internal/exampleocconfig/modelb/modelb-0.go @@ -16,7 +16,7 @@ Package modelb is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocconfig/schema.go b/internal/exampleocconfig/schema.go index 7fa45f7..9850f51 100644 --- a/internal/exampleocconfig/schema.go +++ b/internal/exampleocconfig/schema.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocconfig/structs-0.go b/internal/exampleocconfig/structs-0.go index fea51ab..71bb06d 100644 --- a/internal/exampleocconfig/structs-0.go +++ b/internal/exampleocconfig/structs-0.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocconfig/union.go b/internal/exampleocconfig/union.go index 4e1ce42..03dbadf 100644 --- a/internal/exampleocconfig/union.go +++ b/internal/exampleocconfig/union.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocunordered/enum.go b/internal/exampleocunordered/enum.go index 61e8ebd..c27cd12 100644 --- a/internal/exampleocunordered/enum.go +++ b/internal/exampleocunordered/enum.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocunordered/enum_map.go b/internal/exampleocunordered/enum_map.go index 3567eec..34ede89 100644 --- a/internal/exampleocunordered/enum_map.go +++ b/internal/exampleocunordered/enum_map.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocunordered/exampleocunorderedpath/exampleocunorderedpath.go b/internal/exampleocunordered/exampleocunorderedpath/exampleocunorderedpath.go index 9277f90..e313bcd 100644 --- a/internal/exampleocunordered/exampleocunorderedpath/exampleocunorderedpath.go +++ b/internal/exampleocunordered/exampleocunorderedpath/exampleocunorderedpath.go @@ -16,7 +16,7 @@ Package exampleocunorderedpath is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocunordered/nested/nested-0.go b/internal/exampleocunordered/nested/nested-0.go index 676fe2e..aead55d 100644 --- a/internal/exampleocunordered/nested/nested-0.go +++ b/internal/exampleocunordered/nested/nested-0.go @@ -16,7 +16,7 @@ Package nested is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocunordered/schema.go b/internal/exampleocunordered/schema.go index 20748b5..237c8c6 100644 --- a/internal/exampleocunordered/schema.go +++ b/internal/exampleocunordered/schema.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocunordered/simple/simple-0.go b/internal/exampleocunordered/simple/simple-0.go index 9c304ad..c441505 100644 --- a/internal/exampleocunordered/simple/simple-0.go +++ b/internal/exampleocunordered/simple/simple-0.go @@ -16,7 +16,7 @@ Package simple is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocunordered/structs-0.go b/internal/exampleocunordered/structs-0.go index 4b2bd44..160cc66 100644 --- a/internal/exampleocunordered/structs-0.go +++ b/internal/exampleocunordered/structs-0.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocunordered/union.go b/internal/exampleocunordered/union.go index f38fbd3..3c75d08 100644 --- a/internal/exampleocunordered/union.go +++ b/internal/exampleocunordered/union.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was true in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/exampleocunordered/withlistval/withlistval-0.go b/internal/exampleocunordered/withlistval/withlistval-0.go index 86d90ae..22d25bd 100644 --- a/internal/exampleocunordered/withlistval/withlistval-0.go +++ b/internal/exampleocunordered/withlistval/withlistval-0.go @@ -16,7 +16,7 @@ Package withlistval is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/a/a-0.go b/internal/uexampleoc/a/a-0.go index 25123e9..78c3840 100644 --- a/internal/uexampleoc/a/a-0.go +++ b/internal/uexampleoc/a/a-0.go @@ -16,7 +16,7 @@ Package a is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/enum.go b/internal/uexampleoc/enum.go index 7106267..4823b62 100644 --- a/internal/uexampleoc/enum.go +++ b/internal/uexampleoc/enum.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was false in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/enum_map.go b/internal/uexampleoc/enum_map.go index 135b0b3..d892c5e 100644 --- a/internal/uexampleoc/enum_map.go +++ b/internal/uexampleoc/enum_map.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was false in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/modelb/modelb-0.go b/internal/uexampleoc/modelb/modelb-0.go index 9fd1db5..c2575d1 100644 --- a/internal/uexampleoc/modelb/modelb-0.go +++ b/internal/uexampleoc/modelb/modelb-0.go @@ -16,7 +16,7 @@ Package modelb is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/nested/nested-0.go b/internal/uexampleoc/nested/nested-0.go index 95e960b..2db6590 100644 --- a/internal/uexampleoc/nested/nested-0.go +++ b/internal/uexampleoc/nested/nested-0.go @@ -16,7 +16,7 @@ Package nested is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/schema.go b/internal/uexampleoc/schema.go index 2222362..6ffa9be 100644 --- a/internal/uexampleoc/schema.go +++ b/internal/uexampleoc/schema.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was false in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/simple/simple-0.go b/internal/uexampleoc/simple/simple-0.go index eee912e..6d2775d 100644 --- a/internal/uexampleoc/simple/simple-0.go +++ b/internal/uexampleoc/simple/simple-0.go @@ -16,7 +16,7 @@ Package simple is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/structs-0.go b/internal/uexampleoc/structs-0.go index 684c71e..e5beae9 100644 --- a/internal/uexampleoc/structs-0.go +++ b/internal/uexampleoc/structs-0.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was false in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/uexampleocpath/uexampleocpath.go b/internal/uexampleoc/uexampleocpath/uexampleocpath.go index 199bb35..7b49c68 100644 --- a/internal/uexampleoc/uexampleocpath/uexampleocpath.go +++ b/internal/uexampleoc/uexampleocpath/uexampleocpath.go @@ -16,7 +16,7 @@ Package uexampleocpath is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/union.go b/internal/uexampleoc/union.go index 2864c12..2824cae 100644 --- a/internal/uexampleoc/union.go +++ b/internal/uexampleoc/union.go @@ -18,7 +18,7 @@ of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was false in this case). -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/internal/uexampleoc/withlistval/withlistval-0.go b/internal/uexampleoc/withlistval/withlistval-0.go index e4247e9..01d766e 100644 --- a/internal/uexampleoc/withlistval/withlistval-0.go +++ b/internal/uexampleoc/withlistval/withlistval-0.go @@ -16,7 +16,7 @@ Package withlistval is a generated package which contains definitions of structs which generate gNMI paths for a YANG schema. -This package was generated by ygnmi version: (devel): (ygot: v0.29.16) +This package was generated by ygnmi version: (devel): (ygot: v0.29.17) using the following YANG input files: - ../../pathgen/testdata/yang/openconfig-simple.yang - ../../pathgen/testdata/yang/openconfig-withlistval.yang diff --git a/ygnmi/gnmi.go b/ygnmi/gnmi.go index 690e1eb..9d1979f 100644 --- a/ygnmi/gnmi.go +++ b/ygnmi/gnmi.go @@ -344,6 +344,9 @@ func removeRedundantModPrefix7951(v any, modName string) any { return newMap case []any: var newSlice []any + if v != nil { + newSlice = []any{} + } for _, v := range v { newSlice = append(newSlice, removeRedundantModPrefix7951(v, modName)) } @@ -356,6 +359,9 @@ func removeRedundantModPrefix7951(v any, modName string) any { // wrapJSONIETFSinglePath wraps a single layer of JSON-IETF for the given // JSON input. func wrapJSONIETFSinglePath(v any, modName, pathName string) any { + if v == nil { + return map[string]any{} + } return map[string]any{fmt.Sprintf("%s:%s", modName, pathName): removeRedundantModPrefix7951(v, modName)} } @@ -394,19 +400,12 @@ func set[T any](ctx context.Context, c *Client, q ConfigQuery[T], val T, op setO return nil, nil, err } - var modifyTypedValueFn func(*gpb.TypedValue) error - req := &gpb.SetRequest{} var setVal interface{} = val if q.isLeaf() && q.isScalar() { setVal = &val - } else if q.compressInfo() != nil && len(q.compressInfo().PostRelPath) > 0 { - // When the path struct points to a node that's compressed out, - // then we know that the type is a node lower than it should be - // as far as the JSON is concerned. - modifyTypedValueFn = func(tv *gpb.TypedValue) error { return wrapJSONIETF(tv, q.compressInfo().PostRelPath) } } - if err := populateSetRequest(req, path, setVal, op, q.isShadowPath(), modifyTypedValueFn, opts...); err != nil { + if err := populateSetRequest(req, path, setVal, op, q.isShadowPath(), q.isLeaf(), q.compressInfo(), opts...); err != nil { return nil, nil, err } @@ -432,7 +431,7 @@ const ( ) // populateSetRequest fills a SetResponse for a val and operation type. -func populateSetRequest(req *gpb.SetRequest, path *gpb.Path, val interface{}, op setOperation, preferShadowPath bool, modifyTypedValueFn func(*gpb.TypedValue) error, opts ...Option) error { +func populateSetRequest(req *gpb.SetRequest, path *gpb.Path, val interface{}, op setOperation, preferShadowPath, isLeaf bool, compressInfo *CompressionInfo, opts ...Option) error { if req == nil { return fmt.Errorf("cannot populate a nil SetRequest") } @@ -474,6 +473,14 @@ func populateSetRequest(req *gpb.SetRequest, path *gpb.Path, val interface{}, op } else if err != nil { return fmt.Errorf("failed to encode set request: %v", err) } + + var modifyTypedValueFn func(*gpb.TypedValue) error + if !isLeaf && compressInfo != nil && len(compressInfo.PostRelPath) > 0 { + // When the path struct points to a node that's compressed out, + // then we know that the type is a node lower than it should be + // as far as the JSON is concerned. + modifyTypedValueFn = func(tv *gpb.TypedValue) error { return wrapJSONIETF(tv, compressInfo.PostRelPath) } + } if modifyTypedValueFn != nil { if err := modifyTypedValueFn(typedVal); err != nil { return fmt.Errorf("failed to modify TypedValue: %v", err) diff --git a/ygnmi/gnmi_test.go b/ygnmi/gnmi_test.go index ffca4dc..ab02315 100644 --- a/ygnmi/gnmi_test.go +++ b/ygnmi/gnmi_test.go @@ -134,6 +134,18 @@ func TestWrapJSONIETF(t *testing.T) { ] } }`, + }, { + desc: "zero-length-list", + inQualifiedRelPath: []string{"openconfig-withlistval:ordered-list"}, + in: `[]`, + want: `{ + "openconfig-withlistval:ordered-list": [] +}`, + }, { + desc: "null-value", + inQualifiedRelPath: []string{"openconfig-withlistval:ordered-list"}, + in: `null`, + want: `{}`, }} for _, tt := range tests { diff --git a/ygnmi/ygnmi.go b/ygnmi/ygnmi.go index 8e5cc64..1b16b90 100644 --- a/ygnmi/ygnmi.go +++ b/ygnmi/ygnmi.go @@ -616,10 +616,12 @@ func Delete[T any](ctx context.Context, c *Client, q ConfigQuery[T], opts ...Opt } type batchOp struct { - path PathStruct - val interface{} - mode setOperation - shadowpath bool + path PathStruct + val interface{} + mode setOperation + shadowpath bool + isLeaf bool + compressInfo *CompressionInfo } // SetBatch allows multiple Set operations (Replace, Update, Delete) to be applied as part of a single Set transaction. @@ -636,7 +638,7 @@ func (sb *SetBatch) Set(ctx context.Context, c *Client, opts ...Option) (*Result if err != nil { return nil, err } - if err := populateSetRequest(req, path, op.val, op.mode, op.shadowpath, nil, opts...); err != nil { + if err := populateSetRequest(req, path, op.val, op.mode, op.shadowpath, op.isLeaf, op.compressInfo, opts...); err != nil { return nil, err } } @@ -656,10 +658,12 @@ func BatchUpdate[T any](sb *SetBatch, q ConfigQuery[T], val T) { setVal = &val } sb.ops = append(sb.ops, &batchOp{ - path: q.PathStruct(), - val: setVal, - mode: updatePath, - shadowpath: q.isShadowPath(), + path: q.PathStruct(), + val: setVal, + mode: updatePath, + shadowpath: q.isShadowPath(), + isLeaf: q.isLeaf(), + compressInfo: q.compressInfo(), }) } @@ -670,10 +674,12 @@ func BatchReplace[T any](sb *SetBatch, q ConfigQuery[T], val T) { setVal = &val } sb.ops = append(sb.ops, &batchOp{ - path: q.PathStruct(), - val: setVal, - mode: replacePath, - shadowpath: q.isShadowPath(), + path: q.PathStruct(), + val: setVal, + mode: replacePath, + shadowpath: q.isShadowPath(), + isLeaf: q.isLeaf(), + compressInfo: q.compressInfo(), }) } @@ -686,10 +692,12 @@ func BatchUnionReplace[T any](sb *SetBatch, q ConfigQuery[T], val T) { setVal = &val } sb.ops = append(sb.ops, &batchOp{ - path: q.PathStruct(), - val: setVal, - mode: unionreplacePath, - shadowpath: q.isShadowPath(), + path: q.PathStruct(), + val: setVal, + mode: unionreplacePath, + shadowpath: q.isShadowPath(), + isLeaf: q.isLeaf(), + compressInfo: q.compressInfo(), }) } @@ -705,19 +713,22 @@ func BatchUnionReplaceCLI(sb *SetBatch, nos, ascii string) { ps := NewDeviceRootBase() ps.PutCustomData(OriginOverride, nos+"_cli") sb.ops = append(sb.ops, &batchOp{ - path: ps, - val: ascii, - mode: unionreplacePath, - shadowpath: false, + path: ps, + val: ascii, + mode: unionreplacePath, + shadowpath: false, + compressInfo: nil, }) } // BatchDelete stores a delete operation in the SetBatch. func BatchDelete[T any](sb *SetBatch, q ConfigQuery[T]) { sb.ops = append(sb.ops, &batchOp{ - path: q.PathStruct(), - mode: deletePath, - shadowpath: q.isShadowPath(), + path: q.PathStruct(), + mode: deletePath, + shadowpath: q.isShadowPath(), + isLeaf: q.isLeaf(), + compressInfo: q.compressInfo(), }) } diff --git a/ygnmi/ygnmi_preferconfig_test.go b/ygnmi/ygnmi_preferconfig_test.go index c28966c..f77931f 100644 --- a/ygnmi/ygnmi_preferconfig_test.go +++ b/ygnmi/ygnmi_preferconfig_test.go @@ -4404,22 +4404,176 @@ func TestPreferConfigSetBatch(t *testing.T) { }, }, }, { - desc: "non leaf update delete", + desc: "non leaf update delete replace", addPaths: func(sb *ygnmi.SetBatch) { ygnmi.BatchUpdate(sb, exampleocconfigpath.Root().Parent().Child().Config(), &exampleocconfig.Parent_Child{One: ygot.String("foo")}) ygnmi.BatchDelete(sb, exampleocconfigpath.Root().Parent().Child().One().Config()) + + ygnmi.BatchReplace(sb, exampleocconfigpath.Root().Model().SingleKeyMap().Config(), getSamplePreferConfigSingleKeyedMap(t)) + ygnmi.BatchUpdate(sb, exampleocconfigpath.Root().Model().SingleKeyMap().Config(), getSamplePreferConfigSingleKeyedMap(t)) + ygnmi.BatchReplace(sb, exampleocconfigpath.Root().Model().SingleKey("foo").OrderedListMap().Config(), getSamplePreferConfigOrderedMap(t)) + ygnmi.BatchUpdate(sb, exampleocconfigpath.Root().Model().SingleKey("bar").OrderedListMap().Config(), getSamplePreferConfigOrderedMap(t)) + ygnmi.BatchDelete(sb, exampleocconfigpath.Root().Model().SingleKeyMap().Config()) + ygnmi.BatchDelete(sb, exampleocconfigpath.Root().Model().SingleKey("baz").OrderedListMap().Config()) }, wantRequest: &gpb.SetRequest{ Prefix: &gpb.Path{ Target: "dut", }, + Replace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:single-key": [ + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + }, + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + } + ] +}`))}}, + }, { + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:ordered-list": [ + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + }, + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + } + ] +}`))}}, + }}, Update: []*gpb.Update{{ Path: testutil.GNMIPath(t, "parent/child/"), Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("{\n \"openconfig-simple:config\": {\n \"one\": \"foo\"\n }\n}")}}, + }, { + Path: testutil.GNMIPath(t, "/model/a"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:single-key": [ + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + }, + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + } + ] +}`))}}, + }, { + Path: testutil.GNMIPath(t, "/model/a/single-key[key=bar]/ordered-lists"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:ordered-list": [ + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + }, + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + } + ] +}`))}}, }}, Delete: []*gpb.Path{ testutil.GNMIPath(t, "parent/child/config/one"), + testutil.GNMIPath(t, "/model/a"), + testutil.GNMIPath(t, "/model/a/single-key[key=baz]/ordered-lists"), + }, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "non leaf update delete replace nil objects", + addPaths: func(sb *ygnmi.SetBatch) { + ygnmi.BatchReplace(sb, exampleocconfigpath.Root().Model().SingleKeyMap().Config(), map[string]*exampleocconfig.Model_SingleKey{}) + ygnmi.BatchUpdate(sb, exampleocconfigpath.Root().Model().SingleKeyMap().Config(), nil) + ygnmi.BatchReplace(sb, exampleocconfigpath.Root().Model().SingleKey("foo").OrderedListMap().Config(), &exampleocconfig.Model_SingleKey_OrderedList_OrderedMap{}) + ygnmi.BatchUpdate(sb, exampleocconfigpath.Root().Model().SingleKey("bar").OrderedListMap().Config(), nil) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", }, + Replace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:single-key": [] +}`))}}, + }, { + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:ordered-list": [] +}`))}}, + }}, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{}`))}}, + }, { + Path: testutil.GNMIPath(t, "/model/a/single-key[key=bar]/ordered-lists"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{}`))}}, + }}, }, stubResponse: &gpb.SetResponse{ Prefix: &gpb.Path{ diff --git a/ygnmi/ygnmi_test.go b/ygnmi/ygnmi_test.go index debbab3..641fe08 100644 --- a/ygnmi/ygnmi_test.go +++ b/ygnmi/ygnmi_test.go @@ -4402,22 +4402,176 @@ func TestSetBatch(t *testing.T) { }, }, }, { - desc: "non leaf update delete", + desc: "non leaf update delete replace", addPaths: func(sb *ygnmi.SetBatch) { ygnmi.BatchUpdate(sb, exampleocpath.Root().Parent().Child().Config(), &exampleoc.Parent_Child{One: ygot.String("foo")}) ygnmi.BatchDelete(sb, exampleocpath.Root().Parent().Child().One().Config()) + + ygnmi.BatchReplace(sb, exampleocpath.Root().Model().SingleKeyMap().Config(), getSampleSingleKeyedMap(t)) + ygnmi.BatchUpdate(sb, exampleocpath.Root().Model().SingleKeyMap().Config(), getSampleSingleKeyedMap(t)) + ygnmi.BatchReplace(sb, exampleocpath.Root().Model().SingleKey("foo").OrderedListMap().Config(), getSampleOrderedMap(t)) + ygnmi.BatchUpdate(sb, exampleocpath.Root().Model().SingleKey("bar").OrderedListMap().Config(), getSampleOrderedMap(t)) + ygnmi.BatchDelete(sb, exampleocpath.Root().Model().SingleKeyMap().Config()) + ygnmi.BatchDelete(sb, exampleocpath.Root().Model().SingleKey("baz").OrderedListMap().Config()) }, wantRequest: &gpb.SetRequest{ Prefix: &gpb.Path{ Target: "dut", }, + Replace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:single-key": [ + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + }, + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + } + ] +}`))}}, + }, { + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:ordered-list": [ + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + }, + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + } + ] +}`))}}, + }}, Update: []*gpb.Update{{ Path: testutil.GNMIPath(t, "parent/child/"), Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte("{\n \"openconfig-simple:config\": {\n \"one\": \"foo\"\n }\n}")}}, + }, { + Path: testutil.GNMIPath(t, "/model/a"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:single-key": [ + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + }, + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + } + ] +}`))}}, + }, { + Path: testutil.GNMIPath(t, "/model/a/single-key[key=bar]/ordered-lists"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:ordered-list": [ + { + "config": { + "key": "foo", + "value": "42" + }, + "key": "foo" + }, + { + "config": { + "key": "bar", + "value": "43" + }, + "key": "bar" + }, + { + "config": { + "key": "baz", + "value": "44" + }, + "key": "baz" + } + ] +}`))}}, }}, Delete: []*gpb.Path{ testutil.GNMIPath(t, "parent/child/config/one"), + testutil.GNMIPath(t, "/model/a"), + testutil.GNMIPath(t, "/model/a/single-key[key=baz]/ordered-lists"), + }, + }, + stubResponse: &gpb.SetResponse{ + Prefix: &gpb.Path{ + Target: "dut", + }, + }, + }, { + desc: "non leaf update delete replace nil objects", + addPaths: func(sb *ygnmi.SetBatch) { + ygnmi.BatchReplace(sb, exampleocpath.Root().Model().SingleKeyMap().Config(), map[string]*exampleoc.Model_SingleKey{}) + ygnmi.BatchUpdate(sb, exampleocpath.Root().Model().SingleKeyMap().Config(), nil) + ygnmi.BatchReplace(sb, exampleocpath.Root().Model().SingleKey("foo").OrderedListMap().Config(), &exampleoc.Model_SingleKey_OrderedList_OrderedMap{}) + ygnmi.BatchUpdate(sb, exampleocpath.Root().Model().SingleKey("bar").OrderedListMap().Config(), nil) + }, + wantRequest: &gpb.SetRequest{ + Prefix: &gpb.Path{ + Target: "dut", }, + Replace: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:single-key": [] +}`))}}, + }, { + Path: testutil.GNMIPath(t, "/model/a/single-key[key=foo]/ordered-lists"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{ + "openconfig-withlistval:ordered-list": [] +}`))}}, + }}, + Update: []*gpb.Update{{ + Path: testutil.GNMIPath(t, "/model/a"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{}`))}}, + }, { + Path: testutil.GNMIPath(t, "/model/a/single-key[key=bar]/ordered-lists"), + Val: &gpb.TypedValue{Value: &gpb.TypedValue_JsonIetfVal{JsonIetfVal: []byte(removeWhitespace(`{}`))}}, + }}, }, stubResponse: &gpb.SetResponse{ Prefix: &gpb.Path{