Skip to content

Commit 8f2aa37

Browse files
authored
Merge pull request #1580 from rackerlabs/nautobotopV3Update
feat: updating nautobot call for v3
2 parents 3341ec1 + f9eac64 commit 8f2aa37

File tree

13 files changed

+119
-96
lines changed

13 files changed

+119
-96
lines changed

go/nautobotop/.goreleaser.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,12 @@ docker_manifests:
7575

7676
signs:
7777
- cmd: cosign
78-
signature: "${artifact}.sig"
79-
certificate: "${artifact}.pem"
78+
signature: "${artifact}.sigstore.json"
8079
output: true
8180
artifacts: checksum
8281
args:
8382
- sign-blob
84-
- "--oidc-provider=github-actions"
85-
- "--output-certificate=${certificate}"
86-
- "--output-signature=${signature}"
83+
- "--bundle=${signature}"
8784
- "${artifact}"
8885
- --yes
8986

go/nautobotop/go.mod

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.24.0
44

55
require (
66
github.com/charmbracelet/log v0.4.2
7-
github.com/nautobot/go-nautobot/v2 v2.3.2-beta
7+
github.com/nautobot/go-nautobot/v3 v3.0.0-00010101000000-000000000000
88
github.com/onsi/ginkgo/v2 v2.22.0
99
github.com/onsi/gomega v1.36.1
1010
github.com/samber/lo v1.52.0
@@ -53,7 +53,6 @@ require (
5353
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5454
github.com/josharian/intern v1.0.0 // indirect
5555
github.com/json-iterator/go v1.1.12 // indirect
56-
github.com/klauspost/compress v1.18.2 // indirect
5756
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
5857
github.com/mailru/easyjson v0.7.7 // indirect
5958
github.com/mattn/go-isatty v0.0.20 // indirect
@@ -71,7 +70,6 @@ require (
7170
github.com/spf13/cobra v1.8.1 // indirect
7271
github.com/spf13/pflag v1.0.5 // indirect
7372
github.com/stoewer/go-strcase v1.3.0 // indirect
74-
github.com/stretchr/testify v1.11.1 // indirect
7573
github.com/x448/float16 v0.8.4 // indirect
7674
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
7775
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
@@ -86,14 +84,14 @@ require (
8684
go.uber.org/multierr v1.11.0 // indirect
8785
go.uber.org/zap v1.27.0 // indirect
8886
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
89-
golang.org/x/net v0.48.0 // indirect
87+
golang.org/x/net v0.38.0 // indirect
9088
golang.org/x/oauth2 v0.27.0 // indirect
91-
golang.org/x/sync v0.19.0 // indirect
92-
golang.org/x/sys v0.39.0 // indirect
93-
golang.org/x/term v0.38.0 // indirect
94-
golang.org/x/text v0.32.0 // indirect
95-
golang.org/x/time v0.12.0 // indirect
96-
golang.org/x/tools v0.39.0 // indirect
89+
golang.org/x/sync v0.12.0 // indirect
90+
golang.org/x/sys v0.31.0 // indirect
91+
golang.org/x/term v0.30.0 // indirect
92+
golang.org/x/text v0.23.0 // indirect
93+
golang.org/x/time v0.9.0 // indirect
94+
golang.org/x/tools v0.26.0 // indirect
9795
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
9896
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
9997
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
@@ -115,3 +113,5 @@ require (
115113
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
116114
sigs.k8s.io/yaml v1.4.0 // indirect
117115
)
116+
117+
replace github.com/nautobot/go-nautobot/v3 => github.com/abhimanyu003/go-nautobot/v3 v3.0.0-beta

go/nautobotop/go.sum

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cel.dev/expr v0.19.1 h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4=
22
cel.dev/expr v0.19.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw=
3+
github.com/abhimanyu003/go-nautobot/v3 v3.0.0-beta h1:lsRCn6JkSKHfedSpqt7MOgSkJHwEmjISSb2dg5Zs/ks=
4+
github.com/abhimanyu003/go-nautobot/v3 v3.0.0-beta/go.mod h1:syPUSxlp3KXMTLetxOBvWPz2+JHfQFaQUxYWmvw9Ljo=
35
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
46
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
57
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
@@ -90,8 +92,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
9092
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
9193
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
9294
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
93-
github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=
94-
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
95+
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
96+
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
9597
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
9698
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
9799
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
@@ -118,8 +120,6 @@ github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc
118120
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
119121
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
120122
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
121-
github.com/nautobot/go-nautobot/v2 v2.3.2-beta h1:w3sDcyt5CDSSWkKWUow08loxo6o72WjoDyclwkllotQ=
122-
github.com/nautobot/go-nautobot/v2 v2.3.2-beta/go.mod h1:T0emSo3w4TabGb4Wwb1o3NOEgbaVL1MLMDI9rFWaxtg=
123123
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
124124
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
125125
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
@@ -204,35 +204,35 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
204204
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
205205
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
206206
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
207-
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
208-
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
207+
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
208+
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
209209
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
210210
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
211211
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
212212
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
213213
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
214-
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
215-
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
214+
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
215+
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
216216
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
217217
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
218218
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
219219
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
220-
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
221-
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
222-
golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
223-
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
220+
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
221+
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
222+
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
223+
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
224224
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
225225
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
226-
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
227-
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
228-
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
229-
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
226+
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
227+
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
228+
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
229+
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
230230
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
231231
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
232232
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
233233
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
234-
golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=
235-
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
234+
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
235+
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
236236
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
237237
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
238238
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

go/nautobotop/internal/nautobot/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77

88
"github.com/charmbracelet/log"
9-
nb "github.com/nautobot/go-nautobot/v2"
9+
nb "github.com/nautobot/go-nautobot/v3"
1010
"github.com/samber/lo"
1111
)
1212

go/nautobotop/internal/nautobot/client/graphql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"k8s.io/apimachinery/pkg/util/json"
99

10-
nb "github.com/nautobot/go-nautobot/v2"
10+
nb "github.com/nautobot/go-nautobot/v3"
1111
)
1212

1313
type GraphQL struct {

go/nautobotop/internal/nautobot/dcim/devicetype.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/rackerlabs/understack/go/nautobotop/internal/nautobot/client"
77

88
"github.com/charmbracelet/log"
9-
nb "github.com/nautobot/go-nautobot/v2"
9+
nb "github.com/nautobot/go-nautobot/v3"
1010
"github.com/rackerlabs/understack/go/nautobotop/internal/nautobot/helpers"
1111
)
1212

@@ -38,7 +38,10 @@ func (s *DeviceTypeService) GetByName(ctx context.Context, name string) nb.Devic
3838
s.client.AddReport("GetDeviceTypeByName", "failed to get", "name", name, "error", err.Error(), "response_body", bodyString)
3939
return nb.DeviceType{}
4040
}
41-
if list == nil || len(list.Results) == 0 || list.Results[0].Id == "" {
41+
if list == nil || len(list.Results) == 0 {
42+
return nb.DeviceType{}
43+
}
44+
if list.Results[0].Id == nil {
4245
return nb.DeviceType{}
4346
}
4447
return list.Results[0]
@@ -52,7 +55,10 @@ func (s *DeviceTypeService) ListAll(ctx context.Context) []nb.DeviceType {
5255
s.client.AddReport("ListAllDeviceTypes", "failed to list", "error", err.Error(), "response_body", bodyString)
5356
return []nb.DeviceType{}
5457
}
55-
if list == nil || len(list.Results) == 0 || list.Results[0].Id == "" {
58+
if list == nil || len(list.Results) == 0 {
59+
return []nb.DeviceType{}
60+
}
61+
if list.Results[0].Id == nil {
5662
return []nb.DeviceType{}
5763
}
5864

go/nautobotop/internal/nautobot/dcim/manufacturer.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/charmbracelet/log"
88
"github.com/rackerlabs/understack/go/nautobotop/internal/nautobot/client"
99

10-
nb "github.com/nautobot/go-nautobot/v2"
10+
nb "github.com/nautobot/go-nautobot/v3"
1111
"github.com/rackerlabs/understack/go/nautobotop/internal/nautobot/helpers"
1212
)
1313

@@ -53,7 +53,10 @@ func (s *ManufacturerService) GetByName(ctx context.Context, name string) nb.Man
5353
s.client.AddReport("GetManufacturerByName", "failed to get manufacturer by name", "name", name, "error", err.Error(), "response_body", bodyString)
5454
return nb.Manufacturer{}
5555
}
56-
if list == nil || len(list.Results) == 0 || list.Results[0].Id == "" {
56+
if list == nil || len(list.Results) == 0 {
57+
return nb.Manufacturer{}
58+
}
59+
if list.Results[0].Id == nil {
5760
return nb.Manufacturer{}
5861
}
5962
return list.Results[0]

go/nautobotop/internal/nautobot/dcim/templates/console_port.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/rackerlabs/understack/go/nautobotop/internal/nautobot/client"
88

99
"github.com/charmbracelet/log"
10-
nb "github.com/nautobot/go-nautobot/v2"
10+
nb "github.com/nautobot/go-nautobot/v3"
1111
"github.com/rackerlabs/understack/go/nautobotop/internal/nautobot/helpers"
1212
)
1313

@@ -54,11 +54,15 @@ func (s *ConsolePortTemplateService) GetByName(ctx context.Context, name, device
5454
s.client.AddReport("GetConsolePortTemplateByName", "failed to get console port template by name", "name", name, "device_type_id", deviceTypeID, "error", err.Error(), "response_body", bodyString)
5555
return nb.ConsolePortTemplate{}
5656
}
57-
if list == nil || len(list.Results) == 0 || list.Results[0].Id == "" {
57+
if list == nil || len(list.Results) == 0 {
5858
log.Info("console port template not found", "name", name, "device_type_id", deviceTypeID)
5959
return nb.ConsolePortTemplate{}
6060
}
61-
log.Info("found console port template", "name", name, "device_type_id", deviceTypeID, "id", list.Results[0].Id)
61+
if list.Results[0].Id == nil {
62+
log.Info("console port template not found", "name", name, "device_type_id", deviceTypeID)
63+
return nb.ConsolePortTemplate{}
64+
}
65+
log.Info("found console port template", "name", name, "device_type_id", deviceTypeID, "id", *list.Results[0].Id)
6266
return list.Results[0]
6367
}
6468

go/nautobotop/internal/nautobot/dcim/templates/interface.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/rackerlabs/understack/go/nautobotop/internal/nautobot/client"
88

99
"github.com/charmbracelet/log"
10-
nb "github.com/nautobot/go-nautobot/v2"
10+
nb "github.com/nautobot/go-nautobot/v3"
1111
"github.com/rackerlabs/understack/go/nautobotop/internal/nautobot/helpers"
1212
)
1313

@@ -52,11 +52,15 @@ func (s *InterfaceTemplateService) GetByName(ctx context.Context, name, deviceTy
5252
s.client.AddReport("GetInterfaceTemplateByName", "failed to get interface template by name", "name", name, "device_type_id", deviceTypeID, "error", err.Error(), "response_body", bodyString)
5353
return nb.InterfaceTemplate{}
5454
}
55-
if list == nil || len(list.Results) == 0 || list.Results[0].Id == "" {
55+
if list == nil || len(list.Results) == 0 {
5656
log.Info("interface template not found", "name", name, "device_type_id", deviceTypeID)
5757
return nb.InterfaceTemplate{}
5858
}
59-
log.Info("found interface template", "name", name, "device_type_id", deviceTypeID, "id", list.Results[0].Id)
59+
if list.Results[0].Id == nil {
60+
log.Info("interface template not found", "name", name, "device_type_id", deviceTypeID)
61+
return nb.InterfaceTemplate{}
62+
}
63+
log.Info("found interface template", "name", name, "device_type_id", deviceTypeID, "id", *list.Results[0].Id)
6064
return list.Results[0]
6165
}
6266

go/nautobotop/internal/nautobot/dcim/templates/module_bay.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/rackerlabs/understack/go/nautobotop/internal/nautobot/client"
88

99
"github.com/charmbracelet/log"
10-
nb "github.com/nautobot/go-nautobot/v2"
10+
nb "github.com/nautobot/go-nautobot/v3"
1111
"github.com/rackerlabs/understack/go/nautobotop/internal/nautobot/helpers"
1212
)
1313

@@ -54,11 +54,15 @@ func (s *ModuleBayTemplateService) GetByName(ctx context.Context, name, deviceTy
5454
s.client.AddReport("GetModuleBayTemplateByName", "failed to get module bay template by name", "name", name, "device_type_id", deviceTypeID, "error", err.Error(), "response_body", bodyString)
5555
return nb.ModuleBayTemplate{}
5656
}
57-
if list == nil || len(list.Results) == 0 || list.Results[0].Id == "" {
57+
if list == nil || len(list.Results) == 0 {
5858
log.Info("module bay template not found", "name", name, "device_type_id", deviceTypeID)
5959
return nb.ModuleBayTemplate{}
6060
}
61-
log.Info("found module bay template", "name", name, "device_type_id", deviceTypeID, "id", list.Results[0].Id)
61+
if list.Results[0].Id == nil {
62+
log.Info("module bay template not found", "name", name, "device_type_id", deviceTypeID)
63+
return nb.ModuleBayTemplate{}
64+
}
65+
log.Info("found module bay template", "name", name, "device_type_id", deviceTypeID, "id", *list.Results[0].Id)
6266
return list.Results[0]
6367
}
6468

0 commit comments

Comments
 (0)