-
Notifications
You must be signed in to change notification settings - Fork 85
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
Add VPC data source #1207
Add VPC data source #1207
Conversation
/test-all |
cddacce
to
9cb2338
Compare
/test-all |
nsxt/data_source_nsxt_policy_vpc.go
Outdated
return fmt.Errorf("error obtaining VPC ID or name during read") | ||
} else { | ||
// Get by full name/prefix | ||
objList, err := client.List(defaultOrgID, ctx.ProjectID, nil, nil, nil, nil, nil, nil) |
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.
Search - to the best of my knowledge - should be working across orgs and projects.
Can we use it here instead of iterating over the list?
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've tried to implement the project datasource with search API at the time, which didn't work. So I didn't even try with this one - maybe it's worthwhile trying.
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.
Should this support pagination?
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.
Replaced logic with search API
nsxt/data_source_nsxt_policy_vpc.go
Outdated
} | ||
} | ||
if len(perfectMatch) > 0 { | ||
if len(perfectMatch) > 1 { |
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.
For VPC objects perhaps uniqueness should be defined within a project.
Perhaps we should filter by ctx.projectId and display 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.
client.List() call (L55) takes a project parameter, so uniqueness is only checked at the scope of these query results.
nsxt/data_source_policy_vpc_test.go
Outdated
resource.TestCheckResourceAttr(testResourceName, "display_name", name), | ||
resource.TestCheckResourceAttr(testResourceName, "description", name), | ||
resource.TestCheckResourceAttrSet(testResourceName, "path"), | ||
//resource.TestCheckResourceAttrSet(testResourceName, "default_gateway_path"), |
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.
Why is this attribute commented? Is it giving you troubles?
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 didn't set the DGW path parameter in Create() (L84), I intended to remove this as although I could gather the T0 id, I had to create a path from it as I do with IP block. It's quite ugly... If you think that there's some importance to this, I can add it.
TBH I'd rather rewrite this once we have a resource for VPC.
nsxt/data_source_nsxt_policy_vpc.go
Outdated
"display_name": getDataSourceDisplayNameSchema(), | ||
"description": getDataSourceDescriptionSchema(), | ||
"path": getPathSchema(), | ||
"context": getContextSchema(), |
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.
Should project be required here?
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.
Indeed
/test-all |
* `site_info` - Information related to sites applicable for given Project. | ||
* `edge_cluster_paths` - The edge cluster on which the networking elements for the Org will be created. | ||
* `site_path` - This represents the path of the site which is managed by Global Manager. For the local manager, if set, this needs to point to 'default'. | ||
* `default_gateway_path` - The tier 0 has to be pre-created before Project is created. |
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 description does not seem relevant to data source
* `path` - The NSX path of the policy resource. | ||
* `short_id` - Defaults to id if id is less than equal to 8 characters or defaults to random generated id if not set. | ||
* `site_info` - Information related to sites applicable for given Project. | ||
* `edge_cluster_paths` - The edge cluster on which the networking elements for the Org will be created. |
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.
Org
=> VPC
?
* `short_id` - Defaults to id if id is less than equal to 8 characters or defaults to random generated id if not set. | ||
* `site_info` - Information related to sites applicable for given Project. | ||
* `edge_cluster_paths` - The edge cluster on which the networking elements for the Org will be created. | ||
* `site_path` - This represents the path of the site which is managed by Global Manager. For the local manager, if set, this needs to point to 'default'. |
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'm not sure this is relevant for VPC
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'm not sure either - I reused the SiteInfo from Project as these two use the same schema. Should I remove site_path entirely from this DS?
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.
@tvigneron could you please give your opinion?
|
||
* `id` - (Optional) The ID of VPC to retrieve. If ID is specified, no additional argument should be configured. | ||
* `display_name` - (Optional) The Display Name prefix of the VPC to retrieve. | ||
* `context` - (Optional) The context which the object belongs to |
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 should be Required
"default_gateway_path": getPathSchema(), | ||
"short_id": { | ||
Type: schema.TypeString, | ||
Optional: true, |
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.
According to the code this is fully computed, in which case Optional: true
should be removed, so that terraform does not allow user to specify it
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 value is assigned by NSX if not set by user, and therefore has to be computed. It can also be set by the user (it should be unique - NSX will enforce that).
The UI doesn't allow updating it (on create there's the text "This field can be set at VPC creation time and cannot be edited later. Max 8 characters allowed.").
BTW there's an open issue for this in the Project.
Signed-off-by: Kobi Samoray <[email protected]>
Signed-off-by: Kobi Samoray <[email protected]>
/test-all |
No description provided.