@@ -32,6 +32,7 @@ import (
3232 "github.com/aws/aws-sdk-go-v2/service/ec2"
3333 ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
3434 elb "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing"
35+ elbtypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/types"
3536 elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
3637 "github.com/aws/aws-sdk-go-v2/service/kms"
3738 "k8s.io/klog/v2"
@@ -280,7 +281,10 @@ func (ec2i *FakeEC2Impl) DescribeSecurityGroups(ctx context.Context, request *ec
280281// CreateSecurityGroup is not implemented but is required for interface
281282// conformance
282283func (ec2i * FakeEC2Impl ) CreateSecurityGroup (ctx context.Context , request * ec2.CreateSecurityGroupInput , optFns ... func (* ec2.Options )) (* ec2.CreateSecurityGroupOutput , error ) {
283- panic ("Not implemented" )
284+ // Mock implementation for testing
285+ return & ec2.CreateSecurityGroupOutput {
286+ GroupId : aws .String ("sg-123456" ),
287+ }, nil
284288}
285289
286290// DeleteSecurityGroup is not implemented but is required for interface
@@ -292,7 +296,11 @@ func (ec2i *FakeEC2Impl) DeleteSecurityGroup(ctx context.Context, request *ec2.D
292296// AuthorizeSecurityGroupIngress is not implemented but is required for
293297// interface conformance
294298func (ec2i * FakeEC2Impl ) AuthorizeSecurityGroupIngress (ctx context.Context , request * ec2.AuthorizeSecurityGroupIngressInput , optFns ... func (* ec2.Options )) (* ec2.AuthorizeSecurityGroupIngressOutput , error ) {
295- panic ("Not implemented" )
299+ // Mock implementation for testing
300+ if request .GroupId == nil || len (request .IpPermissions ) == 0 {
301+ return nil , errors .New ("Invalid input: GroupId or IpPermissions missing" )
302+ }
303+ return & ec2.AuthorizeSecurityGroupIngressOutput {}, nil
296304}
297305
298306// RevokeSecurityGroupIngress is not implemented but is required for interface
@@ -530,10 +538,14 @@ type FakeELB struct {
530538 aws * FakeAWSServices
531539}
532540
533- // CreateLoadBalancer is not implemented but is required for interface
534- // conformance
541+ // CreateLoadBalancer is a mock implementation for testing
535542func (e * FakeELB ) CreateLoadBalancer (ctx context.Context , input * elb.CreateLoadBalancerInput , opts ... func (* elb.Options )) (* elb.CreateLoadBalancerOutput , error ) {
536- panic ("Not implemented" )
543+ if input == nil || input .LoadBalancerName == nil {
544+ return nil , errors .New ("Invalid input: LoadBalancerName missing" )
545+ }
546+ return & elb.CreateLoadBalancerOutput {
547+ DNSName : aws .String ("mock-dns-name" ),
548+ }, nil
537549}
538550
539551// DeleteLoadBalancer is not implemented but is required for interface
@@ -542,21 +554,33 @@ func (e *FakeELB) DeleteLoadBalancer(ctx context.Context, input *elb.DeleteLoadB
542554 return & elb.DeleteLoadBalancerOutput {}, nil
543555}
544556
545- // DescribeLoadBalancers is not implemented but is required for interface
546- // conformance
557+ // DescribeLoadBalancers is a mock implementation for testing
547558func (e * FakeELB ) DescribeLoadBalancers (ctx context.Context , input * elb.DescribeLoadBalancersInput , opts ... func (* elb.Options )) (* elb.DescribeLoadBalancersOutput , error ) {
548- panic ("Not implemented" )
559+ if input == nil || len (input .LoadBalancerNames ) == 0 {
560+ return nil , errors .New ("Invalid input: LoadBalancerNames missing" )
561+ }
562+ return & elb.DescribeLoadBalancersOutput {
563+ LoadBalancerDescriptions : []elbtypes.LoadBalancerDescription {
564+ {
565+ LoadBalancerName : aws .String (input .LoadBalancerNames [0 ]),
566+ DNSName : aws .String ("mock-dns-name" ),
567+ VPCId : aws .String ("mock-vpc-id" ),
568+ },
569+ },
570+ }, nil
549571}
550572
551573// AddTags is not implemented but is required for interface conformance
552574func (e * FakeELB ) AddTags (ctx context.Context , input * elb.AddTagsInput , opts ... func (* elb.Options )) (* elb.AddTagsOutput , error ) {
553575 panic ("Not implemented" )
554576}
555577
556- // RegisterInstancesWithLoadBalancer is not implemented but is required for
557- // interface conformance
578+ // RegisterInstancesWithLoadBalancer is a mock implementation for testing
558579func (e * FakeELB ) RegisterInstancesWithLoadBalancer (ctx context.Context , input * elb.RegisterInstancesWithLoadBalancerInput , opts ... func (* elb.Options )) (* elb.RegisterInstancesWithLoadBalancerOutput , error ) {
559- panic ("Not implemented" )
580+ if input == nil || len (input .Instances ) == 0 {
581+ return nil , errors .New ("Invalid input: Instances missing" )
582+ }
583+ return & elb.RegisterInstancesWithLoadBalancerOutput {}, nil
560584}
561585
562586// DeregisterInstancesFromLoadBalancer is not implemented but is required for
@@ -571,16 +595,20 @@ func (e *FakeELB) DetachLoadBalancerFromSubnets(ctx context.Context, input *elb.
571595 panic ("Not implemented" )
572596}
573597
574- // AttachLoadBalancerToSubnets is not implemented but is required for interface
575- // conformance
598+ // AttachLoadBalancerToSubnets is a mock implementation for testing
576599func (e * FakeELB ) AttachLoadBalancerToSubnets (ctx context.Context , input * elb.AttachLoadBalancerToSubnetsInput , opts ... func (* elb.Options )) (* elb.AttachLoadBalancerToSubnetsOutput , error ) {
577- panic ("Not implemented" )
600+ if input == nil || len (input .Subnets ) == 0 {
601+ return nil , errors .New ("Invalid input: Subnets missing" )
602+ }
603+ return & elb.AttachLoadBalancerToSubnetsOutput {}, nil
578604}
579605
580- // CreateLoadBalancerListeners is not implemented but is required for interface
581- // conformance
606+ // CreateLoadBalancerListeners is a mock implementation for testing
582607func (e * FakeELB ) CreateLoadBalancerListeners (ctx context.Context , input * elb.CreateLoadBalancerListenersInput , opts ... func (* elb.Options )) (* elb.CreateLoadBalancerListenersOutput , error ) {
583- panic ("Not implemented" )
608+ if input == nil || len (input .Listeners ) == 0 {
609+ return nil , errors .New ("Invalid input: Listeners missing" )
610+ }
611+ return & elb.CreateLoadBalancerListenersOutput {}, nil
584612}
585613
586614// DeleteLoadBalancerListeners is not implemented but is required for interface
@@ -589,10 +617,12 @@ func (e *FakeELB) DeleteLoadBalancerListeners(ctx context.Context, input *elb.De
589617 panic ("Not implemented" )
590618}
591619
592- // ApplySecurityGroupsToLoadBalancer is not implemented but is required for
593- // interface conformance
620+ // ApplySecurityGroupsToLoadBalancer is a mock implementation for testing
594621func (e * FakeELB ) ApplySecurityGroupsToLoadBalancer (ctx context.Context , input * elb.ApplySecurityGroupsToLoadBalancerInput , opts ... func (* elb.Options )) (* elb.ApplySecurityGroupsToLoadBalancerOutput , error ) {
595- panic ("Not implemented" )
622+ if input == nil || len (input .SecurityGroups ) == 0 {
623+ return nil , errors .New ("Invalid input: SecurityGroups missing" )
624+ }
625+ return & elb.ApplySecurityGroupsToLoadBalancerOutput {}, nil
596626}
597627
598628// ConfigureHealthCheck is not implemented but is required for interface
@@ -625,16 +655,22 @@ func (e *FakeELB) DescribeLoadBalancerPolicies(ctx context.Context, input *elb.D
625655 panic ("Not implemented" )
626656}
627657
628- // DescribeLoadBalancerAttributes is not implemented but is required for
629- // interface conformance
658+ // DescribeLoadBalancerAttributes is a mock implementation for testing
630659func (e * FakeELB ) DescribeLoadBalancerAttributes (ctx context.Context , input * elb.DescribeLoadBalancerAttributesInput , opts ... func (* elb.Options )) (* elb.DescribeLoadBalancerAttributesOutput , error ) {
631- panic ("Not implemented" )
660+ if input == nil || input .LoadBalancerName == nil {
661+ return nil , errors .New ("Invalid input: LoadBalancerName missing" )
662+ }
663+ return & elb.DescribeLoadBalancerAttributesOutput {
664+ LoadBalancerAttributes : & elbtypes.LoadBalancerAttributes {},
665+ }, nil
632666}
633667
634- // ModifyLoadBalancerAttributes is not implemented but is required for
635- // interface conformance
668+ // ModifyLoadBalancerAttributes is a mock implementation for testing
636669func (e * FakeELB ) ModifyLoadBalancerAttributes (ctx context.Context , input * elb.ModifyLoadBalancerAttributesInput , opts ... func (* elb.Options )) (* elb.ModifyLoadBalancerAttributesOutput , error ) {
637- panic ("Not implemented" )
670+ if input == nil || input .LoadBalancerName == nil {
671+ return nil , errors .New ("Invalid input: LoadBalancerName missing" )
672+ }
673+ return & elb.ModifyLoadBalancerAttributesOutput {}, nil
638674}
639675
640676// FakeELBV2 is a fake ELBV2 client used for testing
@@ -652,16 +688,27 @@ func (elb *FakeELBV2) CreateLoadBalancer(ctx context.Context, input *elbv2.Creat
652688 panic ("Not implemented" )
653689}
654690
655- // DescribeLoadBalancers is not implemented but is required for interface conformance
656- func (elb * FakeELBV2 ) DescribeLoadBalancers (ctx context.Context , input * elbv2.DescribeLoadBalancersInput , optFns ... func (* elbv2.Options )) (* elbv2.DescribeLoadBalancersOutput , error ) {
657- panic ("Not implemented" )
691+ // DescribeLoadBalancers is a mock implementation for testing
692+ func (elb * FakeELBV2 ) DescribeLoadBalancers (ctx context.Context , input * elbv2.DescribeLoadBalancersInput , opts ... func (* elbv2.Options )) (* elbv2.DescribeLoadBalancersOutput , error ) {
693+ if input == nil || len (input .Names ) == 0 {
694+ return nil , errors .New ("Invalid input: LoadBalancer names missing" )
695+ }
696+ if input .Names [0 ] == "aid" {
697+ return & elbv2.DescribeLoadBalancersOutput {}, nil
698+ }
699+ return nil , errors .New ("NLB 'aid' could not be found" )
658700}
659701
660702// DeleteLoadBalancer is not implemented but is required for interface conformance
661703func (elb * FakeELBV2 ) DeleteLoadBalancer (ctx context.Context , input * elbv2.DeleteLoadBalancerInput , optFns ... func (* elbv2.Options )) (* elbv2.DeleteLoadBalancerOutput , error ) {
662704 panic ("Not implemented" )
663705}
664706
707+ // SetSecurityGroups is not implemented but is required for interface conformance
708+ func (elb * FakeELBV2 ) SetSecurityGroups (ctx context.Context , input * elbv2.SetSecurityGroupsInput , optFns ... func (* elbv2.Options )) (* elbv2.SetSecurityGroupsOutput , error ) {
709+ panic ("Not implemented" )
710+ }
711+
665712// ModifyLoadBalancerAttributes is not implemented but is required for interface conformance
666713func (elb * FakeELBV2 ) ModifyLoadBalancerAttributes (ctx context.Context , input * elbv2.ModifyLoadBalancerAttributesInput , optFns ... func (* elbv2.Options )) (* elbv2.ModifyLoadBalancerAttributesOutput , error ) {
667714 panic ("Not implemented" )
@@ -707,9 +754,12 @@ func (elb *FakeELBV2) ModifyTargetGroupAttributes(ctx context.Context, input *el
707754 panic ("Not implemented" )
708755}
709756
710- // RegisterTargets is not implemented but is required for interface conformance
711- func (elb * FakeELBV2 ) RegisterTargets (ctx context.Context , input * elbv2.RegisterTargetsInput , optFns ... func (* elbv2.Options )) (* elbv2.RegisterTargetsOutput , error ) {
712- panic ("Not implemented" )
757+ // RegisterTargets is a mock implementation for testing
758+ func (elb * FakeELBV2 ) RegisterTargets (ctx context.Context , input * elbv2.RegisterTargetsInput , opts ... func (* elbv2.Options )) (* elbv2.RegisterTargetsOutput , error ) {
759+ if input == nil || len (input .Targets ) == 0 {
760+ return nil , errors .New ("Invalid input: Targets missing" )
761+ }
762+ return & elbv2.RegisterTargetsOutput {}, nil
713763}
714764
715765// DeregisterTargets is not implemented but is required for interface conformance
0 commit comments