Skip to content

Commit

Permalink
[build] add At method for loadbalancer
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongpiger committed Jun 22, 2024
1 parent 54e3b23 commit 0cde8bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/lb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestCreatePoolWithoutMembersSuccess(t *ltesting.T) {
func TestCreatePoolWithMembersSuccess(t *ltesting.T) {
vngcloud := validSdkConfig()
opt := lslbv2.NewCreatePoolRequest("cuongdm3-test-pool-3", lslbv2.PoolProtocolTCP).
WithLoadBalancerId("lb-96138e73-0864-4016-8db1-bae387002378").
WithLoadBalancerId("lb-8bd4ea07-ab40-483d-8387-124ed2f2cecb").
WithMembers(lslbv2.NewMember("cuongdm3-member-1", "10.84.0.32", 80, 80)).
WithHealthMonitor(lslbv2.NewHealthMonitor(lslbv2.HealthCheckProtocolTCP))

Expand Down
8 changes: 8 additions & 0 deletions vngcloud/entity/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ func (s *ListLoadBalancers) Empty() bool {
func (s *ListLoadBalancers) Add(item *LoadBalancer) {
s.Items = append(s.Items, item)
}

func (s *ListLoadBalancers) At(pidx int) *LoadBalancer {
if pidx < 0 || pidx >= s.Len() {
return nil
}

return s.Items[pidx]
}

0 comments on commit 0cde8bb

Please sign in to comment.