Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 15 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ require (
github.com/RangelReale/osincli v0.0.0-20160924135400-fababb0555f2
github.com/apparentlymart/go-cidr v1.1.0
github.com/aws/aws-sdk-go v1.55.8
github.com/aws/aws-sdk-go-v2 v1.41.5
github.com/aws/aws-sdk-go-v2/config v1.29.14
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.33.23
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.54.10
github.com/blang/semver/v4 v4.0.0
github.com/coreos/stream-metadata-go v0.4.9
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
Expand Down Expand Up @@ -170,6 +174,17 @@ require (
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
github.com/aws/smithy-go v1.24.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/campoy/embedmd v1.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
Expand Down
30 changes: 30 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,36 @@ github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3d
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/aws/aws-sdk-go v1.55.8 h1:JRmEUbU52aJQZ2AjX4q4Wu7t4uZjOu71uyNmaWlUkJQ=
github.com/aws/aws-sdk-go v1.55.8/go.mod h1:ZkViS9AqA6otK+JBBNH2++sx1sgxrPKcSzPPvQkUtXk=
github.com/aws/aws-sdk-go-v2 v1.41.5 h1:dj5kopbwUsVUVFgO4Fi5BIT3t4WyqIDjGKCangnV/yY=
github.com/aws/aws-sdk-go-v2 v1.41.5/go.mod h1:mwsPRE8ceUUpiTgF7QmQIJ7lgsKUPQOUl3o72QBrE1o=
github.com/aws/aws-sdk-go-v2/config v1.29.14 h1:f+eEi/2cKCg9pqKBoAIwRGzVb70MRKqWX4dg1BDcSJM=
github.com/aws/aws-sdk-go-v2/config v1.29.14/go.mod h1:wVPHWcIFv3WO89w0rE10gzf17ZYy+UVS1Geq8Iei34g=
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 h1:9KxtdcIA/5xPNQyZRgUSpYOE6j9Bc4+D7nZua0KGYOM=
github.com/aws/aws-sdk-go-v2/credentials v1.17.67/go.mod h1:p3C44m+cfnbv763s52gCqrjaqyPikj9Sg47kUVaNZQQ=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 h1:x793wxmUWVDhshP8WW2mlnXuFrO4cOd3HLBroh1paFw=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30/go.mod h1:Jpne2tDnYiFascUEs2AWHJL9Yp7A5ZVy3TNyxaAjD6M=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21 h1:Rgg6wvjjtX8bNHcvi9OnXWwcE0a2vGpbwmtICOsvcf4=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21/go.mod h1:A/kJFst/nm//cyqonihbdpQZwiUhhzpqTsdbhDdRF9c=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21 h1:PEgGVtPoB6NTpPrBgqSE5hE/o47Ij9qk/SEZFbUOe9A=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21/go.mod h1:p+hz+PRAYlY3zcpJhPwXlLC4C+kqn70WIHwnzAfs6ps=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d2KyU5X/BZxjOkRo=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.33.23 h1:sLj6B5YHp6RqyAf5lF5BxzyGxZIxXG1NW3mo0jtpDqo=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.33.23/go.mod h1:64UwjvWmvtc6HN/hbnZmLQbh+sFsqRUo8693mOu9LB4=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.54.10 h1:RRItb+JMcIGZSiNKLViw9fCYxQaahR+BaswSF3LkHEk=
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.54.10/go.mod h1:qogon7Vx0cwiCEkU3x9/42gzUZbHoAr+ADGdLVHRVks=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 h1:eAh2A4b5IzM/lum78bZ590jy36+d/aFLgKF/4Vd1xPE=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3/go.mod h1:0yKJC/kb8sAnmlYa6Zs3QVYqaC8ug2AbnNChv5Ox3uA=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 h1:dM9/92u2F1JbDaGooxTq18wmmFzbJRfXfVfy96/1CXM=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15/go.mod h1:SwFBy2vjtA0vZbjjaFtfN045boopadnoVPhu4Fv66vY=
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 h1:1Gw+9ajCV1jogloEv1RRnvfRFia2cL6c9cuKV2Ps+G8=
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 h1:hXmVKytPfTy5axZ+fYbR5d0cFmC3JvwLm5kM83luako=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs=
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 h1:1XuUZ8mYJw9B6lzAkXhqHlJd/XvaX32evhproijJEZY=
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4=
github.com/aws/smithy-go v1.24.2 h1:FzA3bu/nt/vDvmnkg+R8Xl46gmzEDam6mZ1hzmwXFng=
github.com/aws/smithy-go v1.24.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
Expand Down
4 changes: 2 additions & 2 deletions test/extended/cloud_controller_manager/ccm.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ spec:
healthCheckPath := "/healthz"
exutil.GetAwsCredentialFromCluster(oc)
region := exutil.GetClusterRegion(oc)
sess := exutil.InitAwsSession(region)
elbClient := exutil.NewELBClient(sess)
config := exutil.InitAwsConfig(region)
elbClient := exutil.NewELBClient(config)

expectedHealthCheck := fmt.Sprintf("HTTP:%s%s", healthCheckPort, healthCheckPath)
var healthCheck string
Expand Down
53 changes: 32 additions & 21 deletions test/extended/util/aws_client.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package util

import (
"context"
"encoding/base64"
"fmt"
"os"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
elb "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing"
elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
awsv1 "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/aws/aws-sdk-go/service/elbv2"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"
"github.com/tidwall/gjson"
Expand Down Expand Up @@ -39,36 +42,44 @@ func GetAwsCredentialFromCluster(oc *CLI) {
// InitAwsSession init session
func InitAwsSession(region string) *session.Session {
sess := session.Must(session.NewSessionWithOptions(session.Options{
Config: aws.Config{
Region: aws.String(region),
Config: awsv1.Config{
Region: awsv1.String(region),
},
}))

return sess
}

type ELBClient struct {
svc *elb.ELB
svcV2 *elbv2.ELBV2
svc *elb.Client
svcV2 *elbv2.Client
}

// NewELBClient creates an ECRClient
func NewELBClient(sess *session.Session) *ELBClient {
// InitAwsConfig init AWS config (AWS SDK v2)
func InitAwsConfig(region string) aws.Config {
cfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithRegion(region),
)
o.Expect(err).NotTo(o.HaveOccurred())

return cfg
}

// NewELBClient creates an ELBClient
func NewELBClient(cfg aws.Config) *ELBClient {
return &ELBClient{
svc: elb.New(sess),
svcV2: elbv2.New(sess),
svc: elb.NewFromConfig(cfg),
svcV2: elbv2.NewFromConfig(cfg),
}
}

// GetLBHealthCheckPortPath get load balance health check port and path for Classic Load Balancer
func (elbClient *ELBClient) GetCLBHealthCheckPortPath(lbName string) (string, error) {
input := &elb.DescribeLoadBalancersInput{
LoadBalancerNames: []*string{
aws.String(lbName),
},
LoadBalancerNames: []string{lbName},
}

result, err := elbClient.svc.DescribeLoadBalancers(input)
result, err := elbClient.svc.DescribeLoadBalancers(context.TODO(), input)
if err != nil {
e2e.Logf("Failed to describe classic load balancer: %v", err)
return "", err
Expand All @@ -89,9 +100,9 @@ func (elbClient *ELBClient) GetCLBHealthCheckPortPath(lbName string) (string, er
func (elbClient *ELBClient) GetNLBHealthCheckPortPath(lbName string) (string, error) {
// Describe the load balancer
input := &elbv2.DescribeLoadBalancersInput{
Names: []*string{aws.String(lbName)},
Names: []string{lbName},
}
result, err := elbClient.svcV2.DescribeLoadBalancers(input)
result, err := elbClient.svcV2.DescribeLoadBalancers(context.TODO(), input)
if err != nil {
e2e.Logf("Failed to describe NLB: %v", err)
return "", err
Expand All @@ -106,7 +117,7 @@ func (elbClient *ELBClient) GetNLBHealthCheckPortPath(lbName string) (string, er
tgInput := &elbv2.DescribeTargetGroupsInput{
LoadBalancerArn: result.LoadBalancers[0].LoadBalancerArn,
}
tgResult, err := elbClient.svcV2.DescribeTargetGroups(tgInput)
tgResult, err := elbClient.svcV2.DescribeTargetGroups(context.TODO(), tgInput)
if err != nil {
e2e.Logf("Failed to describe target groups: %v", err)
return "", err
Expand All @@ -119,9 +130,9 @@ func (elbClient *ELBClient) GetNLBHealthCheckPortPath(lbName string) (string, er

// Get health check configuration from the first target group
tg := tgResult.TargetGroups[0]
protocol := aws.StringValue(tg.HealthCheckProtocol)
path := aws.StringValue(tg.HealthCheckPath)
port := aws.StringValue(tg.HealthCheckPort)
protocol := string(tg.HealthCheckProtocol)
path := aws.ToString(tg.HealthCheckPath)
port := aws.ToString(tg.HealthCheckPort)

// Format: "HTTP:10256/healthz"
return fmt.Sprintf("%s:%s%s", protocol, port, path), nil
Expand Down
Loading