mercari/terraform-provider-spinnaker

Addressing go vet errors

dud225 opened this issue · 0 comments

Hello

running make vet on the current code yields:

go vet .
# github.com/mercari/terraform-provider-spinnaker/spinnaker
spinnaker/resource_canary_config.go:66:2: struct field id has json tag but is not exported
spinnaker/resource_canary_config.go:67:2: struct field name has json tag but is not exported
spinnaker/resource_canary_config.go:68:2: struct field description has json tag but is not exported
spinnaker/resource_canary_config.go:69:2: struct field configVersion has json tag but is not exported
spinnaker/resource_canary_config.go:70:2: struct field applications has json tag but is not exported
spinnaker/resource_canary_config.go:71:2: struct field judge has json tag but is not exported
spinnaker/resource_canary_config.go:72:2: struct field metrics has json tag but is not exported
spinnaker/resource_canary_config.go:73:2: struct field templates has json tag but is not exported
spinnaker/resource_canary_config.go:74:2: struct field classifier has json tag but is not exported
spinnaker/resource_canary_config.go:78:2: struct field name has json tag but is not exported
spinnaker/resource_canary_config.go:79:2: struct field judgeConfigurations has json tag but is not exported
spinnaker/resource_canary_config.go:93:2: struct field groupWeights has json tag but is not exported

but when looking closer at the code, it seems that those tags aren't really used anywhere since the data passed to or from the Spinnaker API is conveyed within a type interface{}:

And when looking at the rest of the code it's similar: data are exchanged either through a type interface{} or []interface{} or map[string]interface{} which means that in all cases the tags information is lost since it only applies to a struct.
Those tags only express some minor case adjustements, but AFAIU all the named structs defined by that package are not intended to be exported anyway, so all those fields could be simply renamed in lowercase.
The actual translation from an interface{} or similar to a named type is realised by calls to mapstructure.Decode which performs a case-insensitive mapping, that's why this all works even if the json tags are ignored.