Skip to content

Commit

Permalink
Add VPC data source
Browse files Browse the repository at this point in the history
Signed-off-by: Kobi Samoray <[email protected]>
  • Loading branch information
ksamoray committed May 15, 2024
1 parent a8cdeae commit 5b87688
Show file tree
Hide file tree
Showing 68 changed files with 325 additions and 111 deletions.
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_context_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyContextProfile() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_dhcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyDhcpServer() *schema.Resource {
"display_name": getDataSourceExtendedDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyDistributedFloodProtectionProfile() *schema.Resource {
"display_name": getDataSourceExtendedDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_gateway_dns_forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func dataSourceNsxtPolicyGatewayDNSForwarder() *schema.Resource {
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"gateway_path": getPolicyPathSchema(false, false, "Gateway path"),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyGatewayFloodProtectionProfile() *schema.Resource {
"display_name": getDataSourceExtendedDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func dataSourceNsxtPolicyGatewayInterfaceRealization() *schema.Resource {

Schema: map[string]*schema.Schema{
"id": getDataSourceIDSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
"gateway_path": {
Type: schema.TypeString,
Description: "The path for the gateway",
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_gateway_locale_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func dataSourceNsxtPolicyGatewayLocaleService() *schema.Resource {
Optional: true,
Computed: true,
},
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_gateway_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func dataSourceNsxtPolicyGatewayPolicy() *schema.Resource {
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"domain": getDataSourceDomainNameSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
"category": {
Type: schema.TypeString,
Description: "Category",
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_gateway_qos_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyGatewayQosProfile() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func dataSourceNsxtPolicyGroup() *schema.Resource {
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"domain": getDomainNameSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_intrusion_service_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyIntrusionServiceProfile() *schema.Resource {
"display_name": getDataSourceExtendedDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_ip_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func dataSourceNsxtPolicyIPBlock() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
12 changes: 6 additions & 6 deletions nsxt/data_source_nsxt_policy_ip_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func testAccDataSourceNsxtPolicyIPBlockBasic(t *testing.T, withContext bool, pre
Steps: []resource.TestStep{
{
PreConfig: func() {
if err := testAccDataSourceNsxtPolicyIPBlockCreate(name); err != nil {
if err := testAccDataSourceNsxtPolicyIPBlockCreate(name, newUUID(), "4001::/64", false); err != nil {
t.Error(err)
}
},
Expand All @@ -57,7 +57,7 @@ func testAccDataSourceNsxtPolicyIPBlockBasic(t *testing.T, withContext bool, pre
})
}

func testAccDataSourceNsxtPolicyIPBlockCreate(name string) error {
func testAccDataSourceNsxtPolicyIPBlockCreate(name, id, cidr string, isPrivate bool) error {
connector, err := testAccGetPolicyConnector()
if err != nil {
return fmt.Errorf("Error during test client initialization: %v", err)
Expand All @@ -66,15 +66,15 @@ func testAccDataSourceNsxtPolicyIPBlockCreate(name string) error {

displayName := name
description := name
cidr := "4001::/64"
obj := model.IpAddressBlock{
Description: &description,
DisplayName: &displayName,
Cidr: &cidr,
}

// Generate a random ID for the resource
id := newUUID()
if isPrivate {
visibility := model.IpAddressBlock_VISIBILITY_PRIVATE
obj.Visibility = &visibility
}

err = client.Patch(id, obj)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_ip_discovery_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyIPDiscoveryProfile() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_ip_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func dataSourceNsxtPolicyIPPool() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
"realized_id": {
Type: schema.TypeString,
Description: "The ID of the realized resource",
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_ipv6_dad_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyIpv6DadProfile() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_ipv6_ndra_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyIpv6NdraProfile() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_mac_discovery_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyMacDiscoveryProfile() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
41 changes: 22 additions & 19 deletions nsxt/data_source_nsxt_policy_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,7 @@ func dataSourceNsxtPolicyProject() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"site_info": {
Type: schema.TypeList,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"edge_cluster_paths": {
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Optional: true,
},
"site_path": {
Type: schema.TypeString,
Optional: true,
},
},
},
Optional: true,
},
"site_info": getSiteInfoSchema(),
"tier0_gateway_paths": {
Type: schema.TypeList,
Elem: &schema.Schema{
Expand All @@ -57,6 +39,27 @@ func dataSourceNsxtPolicyProject() *schema.Resource {
}
}

func getSiteInfoSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeList,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"edge_cluster_paths": {
Type: schema.TypeList,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Optional: true,
},
"site_path": {
Type: schema.TypeString,
Optional: true,
},
},
},
Optional: true,
}
}
func dataSourceNsxtPolicyProjectRead(d *schema.ResourceData, m interface{}) error {
connector := getPolicyConnector(m)
client := infra.NewProjectsClient(connector)
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_qos_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyQosProfile() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_realization_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func dataSourceNsxtPolicyRealizationInfo() *schema.Resource {
Required: true,
ValidateFunc: validatePolicyPath(),
},
"context": getContextSchema(),
"context": getContextSchema(false, false),
"entity_type": {
Type: schema.TypeString,
Description: "The entity type of the realized resource",
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_security_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func dataSourceNsxtPolicySecurityPolicy() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
"domain": getDataSourceDomainNameSchema(),
"is_default": {
Type: schema.TypeBool,
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicySegment() *schema.Resource {
"display_name": getDataSourceExtendedDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_segment_realization.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func dataSourceNsxtPolicySegmentRealization() *schema.Resource {

Schema: map[string]*schema.Schema{
"id": getDataSourceIDSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
"path": {
Type: schema.TypeString,
Description: "The path for the policy segment",
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_segment_security_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicySegmentSecurityProfile() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicyService() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_spoofguard_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func dataSourceNsxtPolicySpoofGuardProfile() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_tier1_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func dataSourceNsxtPolicyTier1Gateway() *schema.Resource {
Optional: true,
Computed: true,
},
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func dataSourceNsxtPolicyVM() *schema.Resource {
"external_id": getDataSourceStringSchema("External ID of the Virtual Machine"),
"bios_id": getDataSourceStringSchema("BIOS UUID of the Virtual Machine"),
"instance_id": getDataSourceStringSchema("Instance UUID of the Virtual Machine"),
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsxt/data_source_nsxt_policy_vms.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func dataSourceNsxtPolicyVMs() *schema.Resource {
Type: schema.TypeString,
},
},
"context": getContextSchema(),
"context": getContextSchema(false, false),
},
}
}
Expand Down
Loading

0 comments on commit 5b87688

Please sign in to comment.