Closed lgrn closed 1 year ago
Here's some example code inspired by b72f202fccf0c3dda55772c748b4092f2ce88ca4 that I think shows the issue:
package main
import (
"fmt"
"strings"
"unicode"
)
func fixUnderscores(input string) string {
split := strings.Split(input, "_")
k := split[0]
if len(split) > 1 {
r2 := []rune(split[1])
r2[0] = unicode.ToUpper(r2[0])
k = k + string(r2)
}
return k
}
func main() {
fmt.Println("short_filter becomes: " + fixUnderscores("short_filter"))
fmt.Println("a_longer_filter becomes: " + fixUnderscores("a_longer_filter"))
}
Output:
short_filter becomes: shortFilter
a_longer_filter becomes: aLonger
Doing something like this with a for-loop instead of an if might fix it:
func fixUnderscores(input string) string {
split := strings.Split(input, "_")
k := split[0]
for i := 1; i < len(split); i++ {
r2 := []rune(split[i])
r2[0] = unicode.ToUpper(r2[0])
k = k + string(r2)
}
return k
}
short_filter becomes: shortFilter
a_longer_filter becomes: aLongerFilter
Hello,
Thanks for the report. You seems to have the fix so could you please open a PR ?
Thanks.
Summary
This is partly related to #209 that was fixed in #210. I am not sure, but looking at the code I think the fix might incorrectly assume that the filter names will only be
filter_name
but neverlong_filter_name
, i.e. have more than one underscore.I am encountering this issue when attempting to filter
netbox_json_virtualization_interfaces_list
onname = "virtual_machine_id"
. It works fine with thevirtual_machine
filter, but for the id I get this error:As before, I have verified that this call works against the API, i.e.
/api/virtualization/interfaces/?virtual_machine_id=1452
gives back the expected response.Version
Netbox version
Terraform version
Provider version
Issue details
Affected Data(s) / Resource(s)
Behaviors
Actual Behavior
Error message as above
Expected Behavior
Return interfaces with the provided vm id
Steps to Reproduce
Attempt to grab interfaces by vm id: