terraform-provider-jamfpro
terraform-provider-jamfpro copied to clipboard
add (back) hasSite check to comp group data validation
Intended to address the issue described here.
This restores a site check to computer groups validation. I've amended the logic so that we shouldn't see any list index exceptions when/if site
is entirely empty.
I'm not really sure of several things:
- Is this error solely due to these groups + my tf state having been created by a prior version of the provider (0.0.49)?
- Why are computers expected when
site
is not defined, anyways? Can't we just discard them? - Why aren't I seeing a populated computers array in state, if they exist in the schema diff? I'd been assuming that if the error didn't occur, they'd appear after an apply.
- Are we using CustomizeDiff correctly?
- Why was the 'fix' reverted in the first place (asked humbly)? My assumption is because of the exception I'm now trying to avoid*, but perhaps there's some other cause?
* That exception:
panic: runtime error: index out of range [0] with length 0
goroutine 430 [running]:
github.com/deploymenttheory/terraform-provider-jamfpro/internal/endpoints/computergroups.validateComputersNotAllowedWithSmart({0x0?, 0x0?}, 0x1400074c680, {0x0?, 0x0?})
/Users/w0de/src/terraform-provider-jamfpro-w0de/internal/endpoints/computergroups/computergroups_data_validation.go:27 +0x1b8
github.com/deploymenttheory/terraform-provider-jamfpro/internal/endpoints/computergroups.customDiffComputeGroups({0x101b86890, 0x14000eb1b90}, 0x1400074c680, {0x101924e60, 0x14000156620})
/Users/w0de/src/terraform-provider-jamfpro-w0de/internal/endpoints/computergroups/computergroups_data_validation.go:13 +0x30
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Diff(0x1400043c3c0, {0x101b86890, 0x14000eb1b90}, 0x1400079b6c0, 0x14000549130, 0x101b6d2d0, {0x101924e60, 0x14000156620}, 0x0)
/Users/w0de/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/schema.go:698 +0x3b8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).SimpleDiff(0x101b86af8?, {0x101b86890?, 0x14000eb1b90?}, 0x1400079b6c0, 0x14000eb1bc0?, {0x101924e60?, 0x14000156620?})
/Users/w0de/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:962 +0x9c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).PlanResourceChange(0x140003fe720, {0x101b86890?, 0x14000eb1ad0?}, 0x14000548af0)
/Users/w0de/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:798 +0x824
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).PlanResourceChange(0x140003fc0a0, {0x101b86890?, 0x14000eb12f0?}, 0x1400064c700)
/Users/w0de/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:811 +0x2b4
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_PlanResourceChange_Handler({0x101b326e0, 0x140003fc0a0}, {0x101b86890, 0x14000eb12f0}, 0x1400089a680, 0x0)
/Users/w0de/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:500 +0x1c0
google.golang.org/grpc.(*Server).processUnaryRPC(0x140001dd200, {0x101b86890, 0x14000eb1260}, {0x101b8c940, 0x14000427ba0}, 0x140009777a0, 0x1400043d7a0, 0x102424520, 0x0)
/Users/w0de/go/pkg/mod/google.golang.org/[email protected]/server.go:1385 +0xb40
google.golang.org/grpc.(*Server).handleStream(0x140001dd200, {0x101b8c940, 0x14000427ba0}, 0x140009777a0)
/Users/w0de/go/pkg/mod/google.golang.org/[email protected]/server.go:1796 +0xc00
google.golang.org/grpc.(*Server).serveStreams.func2.1()
/Users/w0de/go/pkg/mod/google.golang.org/[email protected]/server.go:1029 +0x8c
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 15
/Users/w0de/go/pkg/mod/google.golang.org/[email protected]/server.go:1040 +0x13c