Hi,
I’m trying to do something simple. List the allowed IP addresses/CIDR with the comment as a simple table.
However, the documentation on the go template integration is … not there.
I looked at the output from
atlas accessLists list -o json
which lead me to guess that I need to list the results array.
So I tried this:
atlas accessLists list -o go-template="{{range .results}} {{.ipAddress}} {{end}}"
The error is Error: template: output:1:8: executing "output" at <.results>: can't evaluate field results in type *admin.PaginatedNetworkAccess
So, I thought I’d try the simplest thing: atlas accessLists list -o go-template='{{.totalCount}}'
Error: template: output:1:2: executing "output" at <.totalCount>: can't evaluate field totalCount in type *admin.PaginatedNetworkAccess
I wonder, what’s the root object?
$ atlas accessLists list -o go-template='{{.}}'
{0xc000b082b8 0xc000b082d0 0xc000456e20}
Well, by Googling I found the source code for the formatting modules.
@MongoDB:
Guys, if you are going to advertise Golang formatting in the API, you really need to document somewhere where the models can be found and an example or two. I should not need to output in JSON and guess, or have to go grovelling around a git repo of source.
It turns out that:
The field names are capitalised in the Golang type. Who knew? They aren’t in the JSON output.
The output is an instance of PaginatedNetworkAccess
The Results array in that is an array of NetworkPermissionEntry.