Closed jacobsalmela closed 7 months ago
If I try to use go-netbox to import any of the devicetypes defined here, it cannot unmarshal them
For example, on a dell switch, manufacturer: Dell is a string, but in go-netbox, the manufacturer is a NestedManufacturer, not a simple string.
manufacturer: Dell
manufacturer
NestedManufacturer
yaml: unmarshal errors: line 2: cannot unmarshal !!str `Dell` into netbox.NestedManufacturer exit status 1
Which is correct?
Here is some sample code where I see the issue:
package main import ( "bytes" "fmt" "os" "github.com/netbox-community/go-netbox/v3" "gopkg.in/yaml.v3" ) type MyType struct { netbox.DeviceType `yaml:",inline"` Custom MyCustomThing `yaml:"my-custom-thing"` } type MyCustomThing string func main() { // load yaml file f, err := os.ReadFile("../devicetype-library/device-types/Dell/PowerSwitch-S4048-ON.yaml") if err != nil { fmt.Printf("%+v\n", err) os.Exit(1) } r := bytes.NewReader(f) decoder := yaml.NewDecoder(r) mytype := MyType{} err = decoder.Decode(&mytype) if err != nil { fmt.Printf("%+v\n", err) os.Exit(1) } fmt.Printf("%+v\n", mytype.Manufacturer) }
This seems more go-netbox related: https://github.com/netbox-community/go-netbox/issues/168
If I try to use go-netbox to import any of the devicetypes defined here, it cannot unmarshal them
For example, on a dell switch,
manufacturer: Dell
is a string, but in go-netbox, themanufacturer
is aNestedManufacturer
, not a simple string.Which is correct?
Here is some sample code where I see the issue: