File tree Expand file tree Collapse file tree 3 files changed +8
-6
lines changed
Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import (
2121 "os"
2222 "path/filepath"
2323 "sort"
24+
25+ "github.com/containernetworking/cni/pkg/types"
2426)
2527
2628type NotFoundError struct {
@@ -41,8 +43,8 @@ func (e NoConfigsFoundError) Error() string {
4143}
4244
4345func ConfFromBytes (bytes []byte ) (* NetworkConfig , error ) {
44- conf := & NetworkConfig {Bytes : bytes }
45- if err := json .Unmarshal (bytes , & conf .Network ); err != nil {
46+ conf := & NetworkConfig {Bytes : bytes , Network : & types. NetConf {} }
47+ if err := json .Unmarshal (bytes , conf .Network ); err != nil {
4648 return nil , fmt .Errorf ("error parsing configuration: %w" , err )
4749 }
4850 if conf .Network .Type == "" {
Original file line number Diff line number Diff line change @@ -348,7 +348,7 @@ var _ = Describe("040 types operations", func() {
348348}` ))
349349
350350 recovered := & types040.IPConfig {}
351- Expect (json .Unmarshal (jsonBytes , & recovered )).To (Succeed ())
351+ Expect (json .Unmarshal (jsonBytes , recovered )).To (Succeed ())
352352 Expect (recovered ).To (Equal (ipc ))
353353 })
354354
@@ -363,7 +363,7 @@ var _ = Describe("040 types operations", func() {
363363 Context ("when unmarshalling json fails" , func () {
364364 It ("returns an error" , func () {
365365 recovered := & types040.IPConfig {}
366- err := json .Unmarshal ([]byte (`{"address": 5}` ), & recovered )
366+ err := json .Unmarshal ([]byte (`{"address": 5}` ), recovered )
367367 Expect (err ).To (MatchError (HavePrefix ("json: cannot unmarshal" )))
368368 })
369369 })
Original file line number Diff line number Diff line change @@ -295,14 +295,14 @@ var _ = Describe("Current types operations", func() {
295295}` ))
296296
297297 recovered := & current.IPConfig {}
298- Expect (json .Unmarshal (jsonBytes , & recovered )).To (Succeed ())
298+ Expect (json .Unmarshal (jsonBytes , recovered )).To (Succeed ())
299299 Expect (recovered ).To (Equal (ipc ))
300300 })
301301
302302 Context ("when unmarshalling json fails" , func () {
303303 It ("returns an error" , func () {
304304 recovered := & current.IPConfig {}
305- err := json .Unmarshal ([]byte (`{"address": 5}` ), & recovered )
305+ err := json .Unmarshal ([]byte (`{"address": 5}` ), recovered )
306306 Expect (err ).To (MatchError (HavePrefix ("json: cannot unmarshal" )))
307307 })
308308 })
You can’t perform that action at this time.
0 commit comments