Skip to content

Commit

Permalink
Add support for lb internal network type (#697)
Browse files Browse the repository at this point in the history
* Add support for lb internal network type

* Constant out network types
  • Loading branch information
asaha2 authored Jun 4, 2024
1 parent 65b6447 commit 333fbb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion load_balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ const (
loadBalancersBasePath = "/v2/load_balancers"
)

// Load Balancer types.
const (
// Load Balancer types
LoadBalancerTypeGlobal = "GLOBAL"
LoadBalancerTypeRegional = "REGIONAL"
LoadBalancerTypeRegionalNetwork = "REGIONAL_NETWORK"

// Load Balancer network types
LoadBalancerNetworkTypeExternal = "EXTERNAL"
LoadBalancerNetworkTypeInternal = "INTERNAL"
)

// LoadBalancersService is an interface for managing load balancers with the DigitalOcean API.
Expand Down Expand Up @@ -68,6 +72,7 @@ type LoadBalancer struct {
Domains []*LBDomain `json:"domains,omitempty"`
GLBSettings *GLBSettings `json:"glb_settings,omitempty"`
TargetLoadBalancerIDs []string `json:"target_load_balancer_ids,omitempty"`
Network string `json:"network,omitempty"`
}

// String creates a human-readable description of a LoadBalancer.
Expand Down Expand Up @@ -101,6 +106,7 @@ func (l LoadBalancer) AsRequest() *LoadBalancerRequest {
ProjectID: l.ProjectID,
HTTPIdleTimeoutSeconds: l.HTTPIdleTimeoutSeconds,
TargetLoadBalancerIDs: append([]string(nil), l.TargetLoadBalancerIDs...),
Network: l.Network,
}

if l.DisableLetsEncryptDNSRecords != nil {
Expand Down Expand Up @@ -238,6 +244,7 @@ type LoadBalancerRequest struct {
Domains []*LBDomain `json:"domains,omitempty"`
GLBSettings *GLBSettings `json:"glb_settings,omitempty"`
TargetLoadBalancerIDs []string `json:"target_load_balancer_ids,omitempty"`
Network string `json:"network,omitempty"`
}

// String creates a human-readable description of a LoadBalancerRequest.
Expand Down
5 changes: 4 additions & 1 deletion load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ var lbCreateJSONResponse = `
"target_load_balancer_ids": [
"8268a81c-fcf5-423e-a337-bbfe95817f24",
"8268a81c-fcf6-423e-a337-bbfe95817f24"
]
],
"network": "INTERNAL"
}
}
`
Expand Down Expand Up @@ -551,6 +552,7 @@ func TestLoadBalancers_Create(t *testing.T) {
FailoverThreshold: 10,
},
TargetLoadBalancerIDs: []string{"8268a81c-fcf5-423e-a337-bbfe95817f24", "8268a81c-fcf6-423e-a337-bbfe95817f24"},
Network: LoadBalancerNetworkTypeInternal,
}

path := "/v2/load_balancers"
Expand Down Expand Up @@ -638,6 +640,7 @@ func TestLoadBalancers_Create(t *testing.T) {
FailoverThreshold: 10,
},
TargetLoadBalancerIDs: []string{"8268a81c-fcf5-423e-a337-bbfe95817f24", "8268a81c-fcf6-423e-a337-bbfe95817f24"},
Network: LoadBalancerNetworkTypeInternal,
}

disableLetsEncryptDNSRecords := true
Expand Down

0 comments on commit 333fbb5

Please sign in to comment.