-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
triton_network: Add data source for triton_networks #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
- Docs?
- How does this handle network pools?
triton/data_source_network.go
Outdated
|
||
var network *network.Network | ||
for _, found := range networks { | ||
if strings.Contains(found.Name, netName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strings.Contains()
vs a strict ==
comparison?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was providing a feature to search but, in hindsight, probably should be a direct one-to-one comparison. I'll change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use a direct comparison here and require the full name. It might also be worth adding a switch for whether the network is a fabric?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jen20 It's sort of bunk that the ListNetworks
endpoint of CloudAPI doesn't provide any filter or search capabilities. Neither do many other List
endpoints for that matter (can I haz cloudapi-go
). But I can certainly add this (or any other returned field) since the implementation pulls all networks.
This should be the existing behavior as the data source simply maps the network name to it's UUID. |
I think with respect to network pools we'll need to make upstream API changes, since it's effectively impossible to converge on a given network if there are multiple pools involved. |
I've updated according to what we last spoke about. Curious what filters everyone might want, I can certainly add more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of minor nits here - I think to make this substantially more useful we should also expose the address space.
# triton\_network | ||
|
||
The `triton_network` data source queries the Triton Network API for a network ID | ||
based on it's name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/it's name/the name of the network/ ?
|
||
* `name` - (string) | ||
The name of the network | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably wants an "Attribute Reference" section too. We probably want to expose the address space as well as the network, in order that it can be used as input into the various IP functions.
I rebased and fixed this up, merged it as ea8ad1f. Thanks @cheapRoc! |
We can add other attributes at a future point. |
This adds a new data source for pulling up network UUIDs by their name/label. Here's two examples of looking up
Joyent-SDC-Public
andJoyent-SDC-Private
. Any caps sensitive string part of the network name will match. The first match is used./cc @jen20 @sean-