Skip to content
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

Fix coverity scan errors #764

Merged
merged 2 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .changes/v3.5.0/738-features.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* **New Resource:** `vcd_nsxt_alb_edgegateway_service_engine_group` for managing NSX-T ALB Service Engine Groups
assignments to Edge Gateways [GH-738]
assignments to Edge Gateways [GH-738, GH-764]
* **New Data source:** `vcd_nsxt_alb_edgegateway_service_engine_group` for reading NSX-T ALB Service Engine Groups
assignments to Edge Gateways [GH-738]
assignments to Edge Gateways [GH-738, GH-764]
4 changes: 2 additions & 2 deletions .changes/v3.5.0/757-features.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* **New Resource:** `vcd_nsxt_alb_virtual_service` for managing NSX-T ALB Virtual Service on NSX-T Edge Gateways
[GH-757]
[GH-757, GH-764]
* **New Data source:** `vcd_nsxt_alb_virtual_service` for reading NSX-T ALB Virtual Service on NSX-T Edge Gateways
[GH-757]
[GH-757, GH-764]
11 changes: 6 additions & 5 deletions vcd/datasource_vcd_nsxt_alb_edgegateway_service_engine_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ func datasourceVcdAlbEdgeGatewayServiceEngineGroupRead(ctx context.Context, d *s
var err error
var edgeAlbServiceEngineAssignment *govcd.NsxtAlbServiceEngineGroupAssignment

switch {
// When `service_engine_group_name` lookup field is presented
if serviceEngineGroupName != "" {
case serviceEngineGroupName != "":
// This will filter service engine groups by assigned NSX-T Edge Gateway ID and additionally filter by Name on client
// side
queryParams := url.Values{}
Expand All @@ -95,10 +96,8 @@ func datasourceVcdAlbEdgeGatewayServiceEngineGroupRead(ctx context.Context, d *s
if err != nil {
return diag.Errorf("error retrieving Service Engine Group assignment to NSX-T Edge Gateway: %s", err)
}
}

// When `service_engine_group_id` lookup field is presented
if serviceEngineGroupId != "" {
// When `id` lookup field is presented
case serviceEngineGroupId != "":
queryParams := url.Values{}
queryParams.Add("filter", fmt.Sprintf("gatewayRef.id==%s;serviceEngineGroupRef.id==%s", edgeGatewayId, serviceEngineGroupId))

Expand All @@ -117,6 +116,8 @@ func datasourceVcdAlbEdgeGatewayServiceEngineGroupRead(ctx context.Context, d *s

// Exactly one Service Engine Group assignment is found
edgeAlbServiceEngineAssignment = edgeAlbServiceEngineAssignments[0]
default:
return diag.Errorf("Name or ID must be specified for Service Engine Group assignment data source")
}

setAlbServiceEngineGroupAssignmentData(d, edgeAlbServiceEngineAssignment.NsxtAlbServiceEngineGroupAssignment)
Expand Down
2 changes: 1 addition & 1 deletion vcd/resource_vcd_nsxt_alb_virtual_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func setNsxtAlbVirtualServicePortData(d *schema.ResourceData, ports []types.Nsxt
portMap["start_port"] = *port.PortStart
}

if port.PortEnd != nil && *port.PortStart != *port.PortEnd {
if port.PortEnd != nil && port.PortStart != nil && *port.PortStart != *port.PortEnd {
portMap["end_port"] = *port.PortEnd
}
if port.SslEnabled != nil {
Expand Down