From 676ffd84d4384596ecdc76672f19824c655a0582 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Tue, 10 Dec 2024 14:27:09 -0800 Subject: [PATCH 01/32] refactor: Update SOP to reflect current project implementation status --- ai/sop/spot.md | 58 +++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/ai/sop/spot.md b/ai/sop/spot.md index fd34f425..6784b173 100644 --- a/ai/sop/spot.md +++ b/ai/sop/spot.md @@ -1,37 +1,51 @@ # AWS Spot Instance Implementation Tasks -## Phase 1: Core Infrastructure Setup +## Phase 1: Core Infrastructure Setup (In Progress) ### Configuration & Types 1. Define spot instance configuration struct - - [ ] Add spot-specific fields to deployment config - - [ ] Create validation functions for spot configs - - [ ] Add price threshold configurations - - [ ] Add AZ validation requirements - - [ ] Create function to check minimum AZ count (>=2) - - [ ] Add early validation before deployment starts - - [ ] Implement clear error messaging for AZ validation failures - - [ ] Add AZ count validation to config validation pipeline + - [x] Add basic spot-specific fields to deployment config + - [x] Initial validation functions for deployment configs + - [ ] Enhance price threshold configurations + - [x] Implement AZ validation requirements + - [x] Create function to check minimum AZ count (>=2) + - [x] Add early validation before deployment starts + - [x] Implement clear error messaging for AZ validation failures + - [ ] Refine AZ count validation in config pipeline 2. Create spot instance type definitions - - [ ] Define SpotInstanceRequest struct - - [ ] Add spot pricing history types - - [ ] Create spot termination notice types - - [ ] Add AZ distribution configuration - - [ ] Define minimum AZ requirements - - [ ] Create AZ distribution strategy types - - [ ] Add AZ fallback configurations + - [x] Initial SpotInstanceRequest struct design + - [ ] Complete spot pricing history types + - [ ] Develop spot termination notice types + - [x] Initial AZ distribution configuration + - [x] Define basic AZ requirements + - [ ] Create advanced AZ distribution strategy types + - [ ] Implement comprehensive AZ fallback configurations ### Basic Operations 3. Implement spot price checking - - [ ] Create function to fetch current spot prices - - [ ] Add price history analysis - - [ ] Implement price threshold validation + - [x] Basic infrastructure for price checking + - [ ] Develop comprehensive price history analysis + - [ ] Implement advanced price threshold validation 4. Create spot request handling - - [ ] Implement spot instance request creation - - [ ] Add request status monitoring - - [ ] Create request cancellation logic + - [x] Initial spot instance request creation framework + - [ ] Enhance request status monitoring + - [ ] Develop robust request cancellation logic + +## Current Project Status +- Infrastructure creation is functional +- Basic AWS deployment workflow implemented +- SSH connectivity and machine provisioning working +- Bacalhau cluster deployment integrated +- Logging and error handling in place + +## Immediate Next Steps +- Implement spot instance specific features +- Enhance price and availability zone strategies +- Develop more granular fallback mechanisms +- Create comprehensive testing suite for spot instances +- Improve CLI and configuration management for spot deployments ## Phase 2: Instance Management From 61fcd5569015435dfb633aa811d0e2f975485a57 Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Tue, 10 Dec 2024 14:35:54 -0800 Subject: [PATCH 02/32] refactor: Rename createRegionalInfrastructure method to CreateRegionalResources --- pkg/providers/aws/provider.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 6645cf17..1d56de65 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -724,7 +724,7 @@ func (p *AWSProvider) initializeInfrastructureDisplay() error { } // Create infrastructure in all regions concurrently -func (p *AWSProvider) createRegionalInfrastructure( +func (p *AWSProvider) CreateRegionalResources( ctx context.Context, regions []string, ) error { From 29a347797b5f79a0bc60be0338d507a1159e340e Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Tue, 10 Dec 2024 14:35:56 -0800 Subject: [PATCH 03/32] refactor: Update getRegionAvailabilityZones to use regional EC2 client --- pkg/providers/aws/provider.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 1d56de65..a61d8697 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -822,6 +822,13 @@ func (p *AWSProvider) getRegionAvailabilityZones( ctx context.Context, region string, ) ([]ec2_types.AvailabilityZone, error) { + // Create a regional EC2 client + regionalCfg, err := awsconfig.LoadDefaultConfig(ctx, awsconfig.WithRegion(region)) + if err != nil { + return nil, fmt.Errorf("failed to load AWS config for region %s: %w", region, err) + } + regionalClient := ec2.NewFromConfig(regionalCfg) + azInput := &ec2.DescribeAvailabilityZonesInput{ Filters: []ec2_types.Filter{ { @@ -835,7 +842,7 @@ func (p *AWSProvider) getRegionAvailabilityZones( }, } - azOutput, err := p.EC2Client.DescribeAvailabilityZones(ctx, azInput) + azOutput, err := regionalClient.DescribeAvailabilityZones(ctx, azInput) if err != nil { return nil, fmt.Errorf("failed to get availability zones for region %s: %w", region, err) } From af3e2446ad7f53a61fef2439692fd20256812344 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Tue, 10 Dec 2024 16:52:54 -0800 Subject: [PATCH 04/32] refactor: Prevent automatic stdout logging in logger initialization --- pkg/logger/logger.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 8d58f5dd..ced45343 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -118,9 +118,9 @@ func InitProduction() { config.Level = zap.NewAtomicLevelAt(logLevel) var cores []zapcore.Core - // Add console core if enabled - if GlobalEnableConsoleLogger { - cores = append(cores, createConsoleCore(config.Level)) + // Add console core if enabled and not nil + if consoleCore := createConsoleCore(config.Level); consoleCore != nil { + cores = append(cores, consoleCore) } // Add file core if enabled @@ -147,12 +147,14 @@ func createConsoleCore(level zap.AtomicLevel) zapcore.Core { encoderConfig.EncodeTime = zapcore.TimeEncoderOfLayout("2006-01-02-15:04:05") encoderConfig.LineEnding = "\n" - // Create a custom writer that doesn't try to sync - stdoutWriter := zapcore.Lock(os.Stdout) + // Only create console core if explicitly enabled + if !GlobalEnableConsoleLogger { + return nil + } return zapcore.NewCore( zapcore.NewConsoleEncoder(encoderConfig), - stdoutWriter, + zapcore.AddSync(os.Stdout), level, ) } From 9179654c5a0a389d7d04aeeb4c758d8af17d707e Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Tue, 10 Dec 2024 19:30:43 -0800 Subject: [PATCH 05/32] refactor: Disable console logging by always returning nil in createConsoleCore --- pkg/logger/logger.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index ced45343..1bf9dc07 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -142,21 +142,8 @@ func InitProduction() { // Core creation helpers func createConsoleCore(level zap.AtomicLevel) zapcore.Core { - encoderConfig := zap.NewDevelopmentEncoderConfig() - encoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder - encoderConfig.EncodeTime = zapcore.TimeEncoderOfLayout("2006-01-02-15:04:05") - encoderConfig.LineEnding = "\n" - - // Only create console core if explicitly enabled - if !GlobalEnableConsoleLogger { - return nil - } - - return zapcore.NewCore( - zapcore.NewConsoleEncoder(encoderConfig), - zapcore.AddSync(os.Stdout), - level, - ) + // Always return nil to prevent console logging + return nil } func createFileCore(level zap.AtomicLevel) (zapcore.Core, error) { From 0797bfc314a62db137c56031b0ee93c8d9bde0ba Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Tue, 10 Dec 2024 19:33:49 -0800 Subject: [PATCH 06/32] refactor: Prevent console logging by disabling console core and caller options --- pkg/logger/logger.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 1bf9dc07..f0392033 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -118,10 +118,8 @@ func InitProduction() { config.Level = zap.NewAtomicLevelAt(logLevel) var cores []zapcore.Core - // Add console core if enabled and not nil - if consoleCore := createConsoleCore(config.Level); consoleCore != nil { - cores = append(cores, consoleCore) - } + // Explicitly skip console core + GlobalEnableConsoleLogger = false // Add file core if enabled if GlobalEnableFileLogger { @@ -136,13 +134,14 @@ func InitProduction() { } core := zapcore.NewTee(cores...) - globalLogger = zap.New(core, zap.AddCaller()).Named("andaime") + globalLogger = zap.New(core, zap.AddCaller(), zap.WithOptions(zap.WithCaller(false))).Named("andaime") }) } // Core creation helpers func createConsoleCore(level zap.AtomicLevel) zapcore.Core { - // Always return nil to prevent console logging + // Explicitly return nil to prevent any console logging + GlobalEnableConsoleLogger = false return nil } From 7a4b17e4071f591bc4b3fe699e672d07d2798856 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Tue, 10 Dec 2024 19:34:08 -0800 Subject: [PATCH 07/32] fix: Remove invalid zap.WithOptions() call in logger initialization --- pkg/logger/logger.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index f0392033..1a2c6a49 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -134,7 +134,7 @@ func InitProduction() { } core := zapcore.NewTee(cores...) - globalLogger = zap.New(core, zap.AddCaller(), zap.WithOptions(zap.WithCaller(false))).Named("andaime") + globalLogger = zap.New(core, zap.AddCaller()).Named("andaime") }) } From 9df7dfb838f7aaba8a5f9259c3eba4a682bf0469 Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Tue, 10 Dec 2024 21:01:03 -0800 Subject: [PATCH 08/32] refactor: Remove unused code and update regional resource handling --- pkg/providers/aws/provider.go | 269 +++++++++++----------------------- 1 file changed, 88 insertions(+), 181 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index a61d8697..ea0fb968 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -47,7 +47,6 @@ type VPCState struct { type RegionalVPCManager struct { states map[string]*VPCState // region -> state mu sync.RWMutex - viper *viper.Viper deployment *models.Deployment ec2Client aws_interface.EC2Clienter } @@ -223,21 +222,6 @@ func (p *AWSProvider) PrepareDeployment(ctx context.Context) error { regions[region] = struct{}{} } - // Create VPC and security group for each region - for region := range regions { - if vpc := deployment.AWS.RegionalResources.GetVPC(region); vpc != nil { - vpc, err := p.createVPCInfrastructure(ctx, region) - if err != nil { - return fmt.Errorf( - "failed to create VPC infrastructure in region %s: %w", - region, - err, - ) - } - deployment.AWS.RegionalResources.SetVPC(region, vpc) - } - } - return nil } @@ -703,26 +687,6 @@ func (p *AWSProvider) CreateInfrastructure(ctx context.Context) error { return nil } -// Initialize the display model for infrastructure creation -func (p *AWSProvider) initializeInfrastructureDisplay() error { - m := display.GetGlobalModelFunc() - if m == nil || m.Deployment == nil { - return fmt.Errorf("deployment model not initialized") - } - - for _, machine := range m.Deployment.GetMachines() { - m.QueueUpdate(display.UpdateAction{ - MachineName: machine.GetName(), - UpdateData: display.UpdateData{ - UpdateType: display.UpdateTypeResource, - ResourceType: "Infrastructure", - ResourceState: models.ResourceStatePending, - }, - }) - } - return nil -} - // Create infrastructure in all regions concurrently func (p *AWSProvider) CreateRegionalResources( ctx context.Context, @@ -790,7 +754,7 @@ func (p *AWSProvider) setupRegionalInfrastructure(ctx context.Context, region st return fmt.Errorf("VPC not found for region %s", region) } - sgID, err := p.createSecurityGroup(ctx, vpc.VPCID) + sgID, err := p.createSecurityGroup(ctx, region, vpc.VPCID) if err != nil { return fmt.Errorf("failed to create security groups: %w", err) } @@ -847,7 +811,7 @@ func (p *AWSProvider) getRegionAvailabilityZones( return nil, fmt.Errorf("failed to get availability zones for region %s: %w", region, err) } - if len(azOutput.AvailabilityZones) < 2 { + if len(azOutput.AvailabilityZones) < MinRequiredAZs { return nil, fmt.Errorf("region %s does not have at least 2 availability zones", region) } @@ -892,7 +856,7 @@ func (p *AWSProvider) createRegionalSubnets( for i, az := range azs { // Create public subnet l.Debugf("Creating public subnet in AZ %s", *az.ZoneName) - publicSubnet, err := p.createSubnet(ctx, vpc.VPCID, *az.ZoneName, i*2, "public") + publicSubnet, err := p.createSubnet(ctx, region, vpc.VPCID, *az.ZoneName, i*2, "public") if err != nil { return fmt.Errorf("failed to create public subnet: %w", err) } @@ -900,7 +864,14 @@ func (p *AWSProvider) createRegionalSubnets( // Create private subnet l.Debugf("Creating private subnet in AZ %s", *az.ZoneName) - privateSubnet, err := p.createSubnet(ctx, vpc.VPCID, *az.ZoneName, i*2+1, "private") + privateSubnet, err := p.createSubnet( + ctx, + region, + vpc.VPCID, + *az.ZoneName, + i*2+1, + "private", + ) if err != nil { return fmt.Errorf("failed to create private subnet: %w", err) } @@ -913,7 +884,9 @@ func (p *AWSProvider) createRegionalSubnets( // Create a single subnet func (p *AWSProvider) createSubnet( ctx context.Context, - vpcID, azName string, + region string, + vpcID string, + azName string, index int, subnetType string, ) (*ec2.CreateSubnetOutput, error) { @@ -935,7 +908,13 @@ func (p *AWSProvider) createSubnet( }, } - subnet, err := p.EC2Client.CreateSubnet(ctx, input) + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return nil, fmt.Errorf("global model or deployment is nil") + } + regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] + + subnet, err := regionalClient.CreateSubnet(ctx, input) if err != nil { return nil, fmt.Errorf("failed to create %s subnet in %s: %w", subnetType, azName, err) } @@ -966,7 +945,13 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error } // Create and attach Internet Gateway - igw, err := p.createInternetGateway(ctx) + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return fmt.Errorf("global model or deployment is nil") + } + regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] + + igw, err := regionalClient.CreateInternetGateway(ctx, &ec2.CreateInternetGatewayInput{}) if err != nil { return fmt.Errorf("failed to create internet gateway: %w", err) } @@ -974,30 +959,21 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error return p.vpcManager.UpdateVPC(region, func(vpc *models.AWSVPC) error { vpc.InternetGatewayID = *igw.InternetGateway.InternetGatewayId - if err := p.attachInternetGateway(ctx, vpc.InternetGatewayID, vpc.VPCID); err != nil { + if _, err := regionalClient.AttachInternetGateway( + ctx, + &ec2.AttachInternetGatewayInput{ + InternetGatewayId: aws.String(vpc.InternetGatewayID), + VpcId: aws.String(vpc.VPCID), + }, + ); err != nil { return fmt.Errorf("failed to attach internet gateway: %w", err) } // Setup routing - return p.setupRouting(ctx, vpc) + return p.setupRouting(ctx, region, vpc) }) } -func (p *AWSProvider) attachInternetGateway(ctx context.Context, igwID, vpcID string) error { - l := logger.Get() - l.Debugf("Attaching internet gateway %s to VPC %s", igwID, vpcID) - - if p.EC2Client == nil { - return fmt.Errorf("EC2 client not initialized") - } - - _, err := p.EC2Client.AttachInternetGateway(ctx, &ec2.AttachInternetGatewayInput{ - InternetGatewayId: aws.String(igwID), - VpcId: aws.String(vpcID), - }) - return err -} - // Update the infrastructure display state func (p *AWSProvider) updateInfrastructureDisplay(state models.MachineResourceState) { m := display.GetGlobalModelFunc() @@ -1015,22 +991,6 @@ func (p *AWSProvider) updateInfrastructureDisplay(state models.MachineResourceSt } } -// Helper functions for networking setup -func (p *AWSProvider) createInternetGateway( - ctx context.Context, -) (*ec2.CreateInternetGatewayOutput, error) { - return p.EC2Client.CreateInternetGateway(ctx, &ec2.CreateInternetGatewayInput{ - TagSpecifications: []ec2_types.TagSpecification{ - { - ResourceType: ec2_types.ResourceTypeInternetGateway, - Tags: []ec2_types.Tag{ - {Key: aws.String("Name"), Value: aws.String("andaime-igw")}, - }, - }, - }, - }) -} - // createVPCWithRetry handles VPC creation with cleanup retry logic func (p *AWSProvider) createVPCWithRetry(ctx context.Context, region string) error { l := logger.Get() @@ -1069,104 +1029,20 @@ func (p *AWSProvider) createVPCWithRetry(ctx context.Context, region string) err return nil } -// cleanupVPCResources handles the cleanup of a single VPC's resources -func (p *AWSProvider) cleanupVPCResources(ctx context.Context, vpcID string) error { +func (p *AWSProvider) createSecurityGroup(ctx context.Context, + region string, + vpcid string, +) (*string, error) { l := logger.Get() - l.Infof("Cleaning up resources for VPC %s", vpcID) - - // 1. Delete subnets - if err := p.cleanupSubnets(ctx, vpcID); err != nil { - return fmt.Errorf("failed to cleanup subnets: %w", err) - } - - // 2. Delete security groups - if err := p.cleanupSecurityGroups(ctx, vpcID); err != nil { - return fmt.Errorf("failed to cleanup security groups: %w", err) - } - - // 3. Delete route tables - if err := p.cleanupRouteTables(ctx, vpcID); err != nil { - return fmt.Errorf("failed to cleanup route tables: %w", err) - } - - // 4. Detach and delete internet gateways - if err := p.cleanupInternetGateways(ctx, vpcID); err != nil { - return fmt.Errorf("failed to cleanup internet gateways: %w", err) - } - - // Finally, delete the VPC - _, err := p.EC2Client.DeleteVpc(ctx, &ec2.DeleteVpcInput{ - VpcId: aws.String(vpcID), - }) - if err != nil { - return fmt.Errorf("failed to delete VPC: %w", err) - } - - l.Infof("Successfully cleaned up VPC %s", vpcID) - return nil -} - -// Helper functions for VPC cleanup -func (p *AWSProvider) cleanupSubnets(ctx context.Context, vpcID string) error { - subnets, err := p.EC2Client.DescribeSubnets(ctx, &ec2.DescribeSubnetsInput{ - Filters: []ec2_types.Filter{ - { - Name: aws.String("vpc-id"), - Values: []string{vpcID}, - }, - }, - }) - if err != nil { - return fmt.Errorf("failed to describe subnets: %w", err) - } - - for _, subnet := range subnets.Subnets { - _, err := p.EC2Client.DeleteSubnet(ctx, &ec2.DeleteSubnetInput{ - SubnetId: subnet.SubnetId, - }) - if err != nil { - return fmt.Errorf("failed to delete subnet %s: %w", aws.ToString(subnet.SubnetId), err) - } - } - - return nil -} - -func (p *AWSProvider) cleanupSecurityGroups(ctx context.Context, vpcID string) error { - sgs, err := p.EC2Client.DescribeSecurityGroups(ctx, &ec2.DescribeSecurityGroupsInput{ - Filters: []ec2_types.Filter{ - { - Name: aws.String("vpc-id"), - Values: []string{vpcID}, - }, - }, - }) - if err != nil { - return fmt.Errorf("failed to describe security groups: %w", err) + l.Info("Creating security groups...") + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return nil, fmt.Errorf("global model or deployment is nil") } - for _, sg := range sgs.SecurityGroups { - if aws.ToString(sg.GroupName) != DefaultName { - _, err := p.EC2Client.DeleteSecurityGroup(ctx, &ec2.DeleteSecurityGroupInput{ - GroupId: sg.GroupId, - }) - if err != nil { - return fmt.Errorf( - "failed to delete security group %s: %w", - aws.ToString(sg.GroupId), - err, - ) - } - } - } + regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] - return nil -} -func (p *AWSProvider) createSecurityGroup(ctx context.Context, - vpcid string) (*string, error) { - l := logger.Get() - l.Info("Creating security groups...") - sgOutput, err := p.GetEC2Client().CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{ + sgOutput, err := regionalClient.CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{ GroupName: aws.String("andaime-sg"), VpcId: aws.String(vpcid), Description: aws.String("Security group for Andaime deployments"), @@ -1198,11 +1074,13 @@ func (p *AWSProvider) createSecurityGroup(ctx context.Context, }) } - _, err = p.GetEC2Client(). - AuthorizeSecurityGroupIngress(ctx, &ec2.AuthorizeSecurityGroupIngressInput{ + _, err = regionalClient.AuthorizeSecurityGroupIngress( + ctx, + &ec2.AuthorizeSecurityGroupIngressInput{ GroupId: sgOutput.GroupId, IpPermissions: sgRules, - }) + }, + ) if err != nil { return nil, fmt.Errorf("failed to authorize security group ingress: %w", err) } @@ -1723,11 +1601,17 @@ func (p *AWSProvider) cleanupInternetGateways(ctx context.Context, vpcID string) } // Helper functions for VPC routing setup -func (p *AWSProvider) setupRouting(ctx context.Context, vpc *models.AWSVPC) error { +func (p *AWSProvider) setupRouting(ctx context.Context, region string, vpc *models.AWSVPC) error { l := logger.Get() // Create public route table + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return fmt.Errorf("global model or deployment is nil") + } + regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] + l.Debug("Creating public route table") - publicRT, err := p.EC2Client.CreateRouteTable(ctx, &ec2.CreateRouteTableInput{ + publicRT, err := regionalClient.CreateRouteTable(ctx, &ec2.CreateRouteTableInput{ VpcId: aws.String(vpc.VPCID), TagSpecifications: []ec2_types.TagSpecification{ { @@ -1744,18 +1628,28 @@ func (p *AWSProvider) setupRouting(ctx context.Context, vpc *models.AWSVPC) erro vpc.PublicRouteTableID = *publicRT.RouteTable.RouteTableId // Create route to Internet Gateway - if err := p.createInternetGatewayRoute(ctx, vpc); err != nil { + if err := p.createInternetGatewayRoute(ctx, region, vpc); err != nil { return err } // Associate public subnets with route table - return p.associatePublicSubnets(ctx, vpc) + return p.associatePublicSubnets(ctx, region, vpc) } -func (p *AWSProvider) createInternetGatewayRoute(ctx context.Context, vpc *models.AWSVPC) error { +func (p *AWSProvider) createInternetGatewayRoute( + ctx context.Context, + region string, + vpc *models.AWSVPC, +) error { l := logger.Get() l.Debugf("Creating internet gateway route for VPC %s", vpc.VPCID) - _, err := p.EC2Client.CreateRoute(ctx, &ec2.CreateRouteInput{ + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return fmt.Errorf("global model or deployment is nil") + } + regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] + + _, err := regionalClient.CreateRoute(ctx, &ec2.CreateRouteInput{ RouteTableId: aws.String(vpc.PublicRouteTableID), DestinationCidrBlock: aws.String("0.0.0.0/0"), GatewayId: aws.String(vpc.InternetGatewayID), @@ -1763,11 +1657,21 @@ func (p *AWSProvider) createInternetGatewayRoute(ctx context.Context, vpc *model return err } -func (p *AWSProvider) associatePublicSubnets(ctx context.Context, vpc *models.AWSVPC) error { +func (p *AWSProvider) associatePublicSubnets( + ctx context.Context, + region string, + vpc *models.AWSVPC, +) error { l := logger.Get() + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return fmt.Errorf("global model or deployment is nil") + } + regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] + for _, subnetID := range vpc.PublicSubnetIDs { l.Debugf("Associating subnet %s with route table %s", subnetID, vpc.PublicRouteTableID) - _, err := p.EC2Client.AssociateRouteTable(ctx, &ec2.AssociateRouteTableInput{ + _, err := regionalClient.AssociateRouteTable(ctx, &ec2.AssociateRouteTableInput{ RouteTableId: aws.String(vpc.PublicRouteTableID), SubnetId: aws.String(subnetID), }) @@ -1914,6 +1818,9 @@ func (p *AWSProvider) GetLatestUbuntuAMI( arch string, ) (string, error) { c := p.GetEC2Client() + if c == nil { + return "", fmt.Errorf("EC2 client not initialized") + } input := &ec2.DescribeImagesInput{ Filters: []ec2_types.Filter{ From 5c640d7027f7cb9d65a2443fb4be2893aaf11af9 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Tue, 10 Dec 2024 21:01:05 -0800 Subject: [PATCH 09/32] refactor: Modify setupNetworking to create Internet Gateway for all VPCs in a region --- pkg/providers/aws/provider.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index ea0fb968..cd1a5a65 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -2071,3 +2071,18 @@ func (rm *RegionalVPCManager) SaveVPCConfig(region string) error { return viper.WriteConfig() } + +// GetAllVPCStates returns all VPC states for a given region +func (rm *RegionalVPCManager) GetAllVPCStates(region string) []*VPCState { + rm.mu.RLock() + defer rm.mu.RUnlock() + + var states []*VPCState + for r, state := range rm.states { + if r == region { + states = append(states, state) + } + } + + return states +} From e946bdfd69640b1c2b533c9ef553459aa8976f0b Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Tue, 10 Dec 2024 21:01:38 -0800 Subject: [PATCH 10/32] refactor: Modify setupNetworking to create Internet Gateways for all VPCs in a region --- pkg/providers/aws/provider.go | 62 +++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index cd1a5a65..b52b28d3 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -937,41 +937,53 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error } state.mu.RLock() - vpc := state.vpc - state.mu.RUnlock() + // Get all VPCs for this region + vpcStates := p.vpcManager.GetAllVPCStates(region) - if vpc == nil { - return fmt.Errorf("VPC not found for region %s", region) - } + for _, state := range vpcStates { + state.mu.RLock() + vpc := state.vpc + state.mu.RUnlock() - // Create and attach Internet Gateway - m := display.GetGlobalModelFunc() - if m == nil || m.Deployment == nil { - return fmt.Errorf("global model or deployment is nil") - } - regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] - - igw, err := regionalClient.CreateInternetGateway(ctx, &ec2.CreateInternetGatewayInput{}) - if err != nil { - return fmt.Errorf("failed to create internet gateway: %w", err) - } + if vpc == nil { + continue + } - return p.vpcManager.UpdateVPC(region, func(vpc *models.AWSVPC) error { - vpc.InternetGatewayID = *igw.InternetGateway.InternetGatewayId + // Create Internet Gateway + igw, err := regionalClient.CreateInternetGateway(ctx, &ec2.CreateInternetGatewayInput{}) + if err != nil { + return fmt.Errorf("failed to create internet gateway for VPC %s: %w", vpc.VPCID, err) + } - if _, err := regionalClient.AttachInternetGateway( + // Attach Internet Gateway + _, err = regionalClient.AttachInternetGateway( ctx, &ec2.AttachInternetGatewayInput{ - InternetGatewayId: aws.String(vpc.InternetGatewayID), + InternetGatewayId: aws.String(*igw.InternetGateway.InternetGatewayId), VpcId: aws.String(vpc.VPCID), }, - ); err != nil { - return fmt.Errorf("failed to attach internet gateway: %w", err) + ) + if err != nil { + return fmt.Errorf("failed to attach internet gateway to VPC %s: %w", vpc.VPCID, err) } - // Setup routing - return p.setupRouting(ctx, region, vpc) - }) + // Update VPC state with Internet Gateway ID + if err := p.vpcManager.UpdateVPC(region, func(v *models.AWSVPC) error { + if v.VPCID == vpc.VPCID { + v.InternetGatewayID = *igw.InternetGateway.InternetGatewayId + } + return nil + }); err != nil { + return fmt.Errorf("failed to update VPC state: %w", err) + } + + // Setup routing for this VPC + if err := p.setupRouting(ctx, region, vpc); err != nil { + return fmt.Errorf("failed to setup routing for VPC %s: %w", vpc.VPCID, err) + } + } + + return nil } // Update the infrastructure display state From 11a3959155e522c6db1fa6983060e5deb70b99b8 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Tue, 10 Dec 2024 21:02:05 -0800 Subject: [PATCH 11/32] fix: Define regionalClient in AWS provider's setupNetworking method --- pkg/providers/aws/provider.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index b52b28d3..3189810d 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -940,6 +940,12 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error // Get all VPCs for this region vpcStates := p.vpcManager.GetAllVPCStates(region) + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return fmt.Errorf("global model or deployment is nil") + } + regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] + for _, state := range vpcStates { state.mu.RLock() vpc := state.vpc From b102f50ea112feedd0d3a428b9ad253dfea72474 Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Wed, 11 Dec 2024 07:48:27 -0800 Subject: [PATCH 12/32] refactor: Update VPC cleanup to use regional clients and modify function signature --- pkg/providers/aws/provider.go | 41 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 3189810d..33a3bb4a 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -675,15 +675,6 @@ func (p *AWSProvider) CreateInfrastructure(ctx context.Context) error { // Only proceed with infrastructure creation if all regions are validated l.Info("All regions validated successfully, proceeding with infrastructure creation") - // Create VPC and related resources for each region - for region := range regionsToValidate { - vpc, err := p.createVPCInfrastructure(ctx, region) - if err != nil { - return fmt.Errorf("failed to create infrastructure in region %s: %w", region, err) - } - m.Deployment.AWS.RegionalResources.VPCs[region] = vpc - } - return nil } @@ -1246,12 +1237,18 @@ func (p *AWSProvider) WaitForNetworkConnectivity(ctx context.Context) error { } // cleanupAbandonedVPCs attempts to find and remove any abandoned VPCs -func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { +func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context, region string) error { l := logger.Get() l.Info("Attempting to cleanup abandoned VPCs") + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return fmt.Errorf("global model or deployment is nil") + } + regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] + // List all VPCs - result, err := p.EC2Client.DescribeVpcs(ctx, &ec2.DescribeVpcsInput{}) + result, err := regionalClient.DescribeVpcs(ctx, &ec2.DescribeVpcsInput{}) if err != nil { return fmt.Errorf("failed to list VPCs: %w", err) } @@ -1276,7 +1273,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { l.Infof("Found abandoned VPC %s, cleaning up dependencies...", vpcID) // 1. Delete subnets - subnets, err := p.EC2Client.DescribeSubnets(ctx, &ec2.DescribeSubnetsInput{ + subnets, err := regionalClient.DescribeSubnets(ctx, &ec2.DescribeSubnetsInput{ Filters: []ec2_types.Filter{ { Name: aws.String("vpc-id"), @@ -1290,7 +1287,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { } for _, subnet := range subnets.Subnets { - _, err := p.EC2Client.DeleteSubnet(ctx, &ec2.DeleteSubnetInput{ + _, err := regionalClient.DeleteSubnet(ctx, &ec2.DeleteSubnetInput{ SubnetId: subnet.SubnetId, }) if err != nil { @@ -1299,7 +1296,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { } // 2. Delete security groups (except default) - sgs, err := p.EC2Client.DescribeSecurityGroups(ctx, &ec2.DescribeSecurityGroupsInput{ + sgs, err := regionalClient.DescribeSecurityGroups(ctx, &ec2.DescribeSecurityGroupsInput{ Filters: []ec2_types.Filter{ { Name: aws.String("vpc-id"), @@ -1314,7 +1311,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { for _, sg := range sgs.SecurityGroups { if aws.ToString(sg.GroupName) != DefaultName { - _, err := p.EC2Client.DeleteSecurityGroup(ctx, &ec2.DeleteSecurityGroupInput{ + _, err := regionalClient.DeleteSecurityGroup(ctx, &ec2.DeleteSecurityGroupInput{ GroupId: sg.GroupId, }) if err != nil { @@ -1328,7 +1325,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { } // 3. Delete route tables (except main) - rts, err := p.EC2Client.DescribeRouteTables(ctx, &ec2.DescribeRouteTablesInput{ + rts, err := regionalClient.DescribeRouteTables(ctx, &ec2.DescribeRouteTablesInput{ Filters: []ec2_types.Filter{ { Name: aws.String("vpc-id"), @@ -1357,7 +1354,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { // Delete route table associations first for _, assoc := range rt.Associations { if assoc.RouteTableAssociationId != nil { - _, err := p.EC2Client.DisassociateRouteTable( + _, err := regionalClient.DisassociateRouteTable( ctx, &ec2.DisassociateRouteTableInput{ AssociationId: assoc.RouteTableAssociationId, @@ -1373,7 +1370,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { } } - _, err := p.EC2Client.DeleteRouteTable(ctx, &ec2.DeleteRouteTableInput{ + _, err := regionalClient.DeleteRouteTable(ctx, &ec2.DeleteRouteTableInput{ RouteTableId: rt.RouteTableId, }) if err != nil { @@ -1386,7 +1383,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { } // 4. Detach and delete internet gateways - igws, err := p.EC2Client.DescribeInternetGateways( + igws, err := regionalClient.DescribeInternetGateways( ctx, &ec2.DescribeInternetGatewaysInput{ Filters: []ec2_types.Filter{ @@ -1404,7 +1401,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { for _, igw := range igws.InternetGateways { // Detach first - _, err := p.EC2Client.DetachInternetGateway(ctx, &ec2.DetachInternetGatewayInput{ + _, err := regionalClient.DetachInternetGateway(ctx, &ec2.DetachInternetGatewayInput{ InternetGatewayId: igw.InternetGatewayId, VpcId: aws.String(vpcID), }) @@ -1418,7 +1415,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { } // Then delete - _, err = p.EC2Client.DeleteInternetGateway(ctx, &ec2.DeleteInternetGatewayInput{ + _, err = regionalClient.DeleteInternetGateway(ctx, &ec2.DeleteInternetGatewayInput{ InternetGatewayId: igw.InternetGatewayId, }) if err != nil { @@ -1431,7 +1428,7 @@ func (p *AWSProvider) cleanupAbandonedVPCs(ctx context.Context) error { } // Finally, delete the VPC - _, err = p.EC2Client.DeleteVpc(ctx, &ec2.DeleteVpcInput{ + _, err = regionalClient.DeleteVpc(ctx, &ec2.DeleteVpcInput{ VpcId: aws.String(vpcID), }) if err != nil { From e7a4c625aa43e17dfefee5e9cfa4624c7480e2d0 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Wed, 11 Dec 2024 07:48:31 -0800 Subject: [PATCH 13/32] test: Fix AWS networking setup timeout and improve error handling This commit introduces several improvements to the AWS networking setup process: - Add a 15-minute timeout to prevent indefinite waiting - Use errgroup for parallel VPC networking setup - Implement retry mechanisms for internet gateway creation - Enhance logging for better debugging - Improve error handling to prevent blocking on single VPC failures --- pkg/providers/aws/provider.go | 100 ++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 34 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 33a3bb4a..2046c128 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -922,12 +922,15 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error return fmt.Errorf("VPC manager not initialized") } + // Create a context with a timeout to prevent indefinite waiting + ctx, cancel := context.WithTimeout(ctx, 15*time.Minute) + defer cancel() + state := p.vpcManager.GetOrCreateVPCState(region) if state == nil { return fmt.Errorf("failed to get VPC state for region %s", region) } - state.mu.RLock() // Get all VPCs for this region vpcStates := p.vpcManager.GetAllVPCStates(region) @@ -937,47 +940,76 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error } regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] + // Use errgroup to parallelize VPC networking setup with timeout + eg, ctx := errgroup.WithContext(ctx) + for _, state := range vpcStates { - state.mu.RLock() - vpc := state.vpc - state.mu.RUnlock() + state := state // capture loop variable + eg.Go(func() error { + state.mu.RLock() + vpc := state.vpc + state.mu.RUnlock() - if vpc == nil { - continue - } + if vpc == nil { + return nil + } - // Create Internet Gateway - igw, err := regionalClient.CreateInternetGateway(ctx, &ec2.CreateInternetGatewayInput{}) - if err != nil { - return fmt.Errorf("failed to create internet gateway for VPC %s: %w", vpc.VPCID, err) - } + l.Debugf("Setting up networking for VPC %s", vpc.VPCID) - // Attach Internet Gateway - _, err = regionalClient.AttachInternetGateway( - ctx, - &ec2.AttachInternetGatewayInput{ - InternetGatewayId: aws.String(*igw.InternetGateway.InternetGatewayId), - VpcId: aws.String(vpc.VPCID), - }, - ) - if err != nil { - return fmt.Errorf("failed to attach internet gateway to VPC %s: %w", vpc.VPCID, err) - } + // Create Internet Gateway with retry + var igw *ec2.CreateInternetGatewayOutput + err := backoff.Retry(func() error { + var err error + igw, err = regionalClient.CreateInternetGateway(ctx, &ec2.CreateInternetGatewayInput{}) + return err + }, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 3)) + if err != nil { + l.Errorf("Failed to create internet gateway for VPC %s: %v", vpc.VPCID, err) + return fmt.Errorf("failed to create internet gateway for VPC %s: %w", vpc.VPCID, err) + } + + // Attach Internet Gateway with retry + err = backoff.Retry(func() error { + _, err := regionalClient.AttachInternetGateway( + ctx, + &ec2.AttachInternetGatewayInput{ + InternetGatewayId: aws.String(*igw.InternetGateway.InternetGatewayId), + VpcId: aws.String(vpc.VPCID), + }, + ) + return err + }, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 3)) + if err != nil { + l.Errorf("Failed to attach internet gateway to VPC %s: %v", vpc.VPCID, err) + return fmt.Errorf("failed to attach internet gateway to VPC %s: %w", vpc.VPCID, err) + } - // Update VPC state with Internet Gateway ID - if err := p.vpcManager.UpdateVPC(region, func(v *models.AWSVPC) error { - if v.VPCID == vpc.VPCID { - v.InternetGatewayID = *igw.InternetGateway.InternetGatewayId + // Update VPC state with Internet Gateway ID + if err := p.vpcManager.UpdateVPC(region, func(v *models.AWSVPC) error { + if v.VPCID == vpc.VPCID { + v.InternetGatewayID = *igw.InternetGateway.InternetGatewayId + } + return nil + }); err != nil { + l.Errorf("Failed to update VPC state for VPC %s: %v", vpc.VPCID, err) + return fmt.Errorf("failed to update VPC state: %w", err) } + + // Setup routing for this VPC + if err := p.setupRouting(ctx, region, vpc); err != nil { + l.Errorf("Failed to setup routing for VPC %s: %v", vpc.VPCID, err) + return fmt.Errorf("failed to setup routing for VPC %s: %w", vpc.VPCID, err) + } + + l.Debugf("Successfully set up networking for VPC %s", vpc.VPCID) return nil - }); err != nil { - return fmt.Errorf("failed to update VPC state: %w", err) - } + }) + } - // Setup routing for this VPC - if err := p.setupRouting(ctx, region, vpc); err != nil { - return fmt.Errorf("failed to setup routing for VPC %s: %w", vpc.VPCID, err) - } + // Wait for all VPC networking setups to complete + if err := eg.Wait(); err != nil { + l.Errorf("Error setting up networking in region %s: %v", region, err) + return fmt.Errorf("failed to set up networking in region %s: %w", region, err) } return nil From 7ed638d0d521f4a3c56aefc88a15cee6861b7889 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Wed, 11 Dec 2024 08:18:26 -0800 Subject: [PATCH 14/32] style: Apply linter formatting to AWS provider code --- pkg/providers/aws/provider.go | 94 +++++------------------------------ 1 file changed, 13 insertions(+), 81 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 2046c128..c625b4e0 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -508,92 +508,17 @@ func (p *AWSProvider) CreateVpc(ctx context.Context, region string) error { return fmt.Errorf("failed to get EC2 client: %w", err) } - // Create VPC - err = p.vpcManager.UpdateVPC(region, func(vpc *models.AWSVPC) error { - createVpcInput := &ec2.CreateVpcInput{ - CidrBlock: aws.String("10.0.0.0/16"), - TagSpecifications: []ec2_types.TagSpecification{ - { - ResourceType: ec2_types.ResourceTypeVpc, - Tags: []ec2_types.Tag{ - { - Key: aws.String("Name"), - Value: aws.String("andaime-vpc"), - }, - { - Key: aws.String("andaime"), - Value: aws.String("true"), - }, - }, - }, - }, - } - - l.Debugf("Sending CreateVpc request with cidr_block %s", "10.0.0.0/16") - - createVpcOutput, err := regionalClient.CreateVpc(ctx, createVpcInput) - if err != nil { - l.Debugf("VPC creation failed: %v", err) - return fmt.Errorf("failed to create VPC: %w", err) - } - - vpc.VPCID = *createVpcOutput.Vpc.VpcId - l.Debugf("Created VPC with ID %s", vpc.VPCID) - return nil - }) - + vpc, err := p.createVPCInfrastructure(ctx, region) if err != nil { return err } - // Wait for VPC to become available - l.Info("Waiting for VPC to be available...") - state := p.vpcManager.GetOrCreateVPCState(region) - vpcID := state.vpc.VPCID - - b := backoff.NewExponentialBackOff() - b.MaxElapsedTime = 5 * time.Minute - b.InitialInterval = 2 * time.Second - b.MaxInterval = 30 * time.Second - - operation := func() error { - if err := ctx.Err(); err != nil { - return backoff.Permanent(err) - } - - input := &ec2.DescribeVpcsInput{ - VpcIds: []string{vpcID}, - } - - result, err := regionalClient.DescribeVpcs(ctx, input) - if err != nil { - l.Debugf("Failed to describe VPC with ID %s: %v", vpcID, err) - return fmt.Errorf("failed to describe VPC: %w", err) - } - - if len(result.Vpcs) > 0 { - l.Debugf("VPC status check with ID %s: %s", vpcID, string(result.Vpcs[0].State)) - - if result.Vpcs[0].State == ec2_types.VpcStateAvailable { - l.Debugf("VPC is now available with ID %s", vpcID) - return nil - } - } - - l.Debugf("VPC not yet available with ID %s", vpcID) - return fmt.Errorf("VPC not yet available") - } - - if err := backoff.Retry(operation, backoff.WithContext(b, ctx)); err != nil { - return fmt.Errorf("timeout waiting for VPC to become available: %w", err) - } - // Update display state to pending p.updateVPCDisplayState(m, models.ResourceStatePending) // Enable DNS hostnames modifyVpcAttributeInput := &ec2.ModifyVpcAttributeInput{ - VpcId: aws.String(vpcID), + VpcId: aws.String(vpc.VPCID), EnableDnsHostnames: &ec2_types.AttributeBooleanValue{Value: aws.Bool(true)}, } @@ -611,7 +536,7 @@ func (p *AWSProvider) CreateVpc(ctx context.Context, region string) error { } l.Debugf("Regional VPC (Region: %s) created successfully with ID %s", - region, vpcID) + region, vpc.VPCID) return nil } @@ -960,12 +885,19 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error var igw *ec2.CreateInternetGatewayOutput err := backoff.Retry(func() error { var err error - igw, err = regionalClient.CreateInternetGateway(ctx, &ec2.CreateInternetGatewayInput{}) + igw, err = regionalClient.CreateInternetGateway( + ctx, + &ec2.CreateInternetGatewayInput{}, + ) return err }, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 3)) if err != nil { l.Errorf("Failed to create internet gateway for VPC %s: %v", vpc.VPCID, err) - return fmt.Errorf("failed to create internet gateway for VPC %s: %w", vpc.VPCID, err) + return fmt.Errorf( + "failed to create internet gateway for VPC %s: %w", + vpc.VPCID, + err, + ) } // Attach Internet Gateway with retry @@ -1051,7 +983,7 @@ func (p *AWSProvider) createVPCWithRetry(ctx context.Context, region string) err l.Info("VPC limit exceeded, attempting to clean up abandoned VPCs...") // Try to find and clean up any abandoned VPCs - if cleanupErr := p.cleanupAbandonedVPCs(ctx); cleanupErr != nil { + if cleanupErr := p.cleanupAbandonedVPCs(ctx, region); cleanupErr != nil { return fmt.Errorf("failed to cleanup VPCs: %w", cleanupErr) } From 2c5c1a832b2c618c0aeb626010726ff7007becfd Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Wed, 11 Dec 2024 08:19:55 -0800 Subject: [PATCH 15/32] feat: Enhance VPC creation with logging, tagging, and resource management --- pkg/providers/aws/provider.go | 38 +++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index c625b4e0..26b0dcc9 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -229,6 +229,9 @@ func (p *AWSProvider) createVPCInfrastructure( ctx context.Context, region string, ) (*models.AWSVPC, error) { + l := logger.Get() + l.Debugf("Creating VPC infrastructure in region %s", region) + // Create EC2 client for the region ec2Client, err := p.getOrCreateEC2Client(ctx, region) if err != nil { @@ -246,6 +249,10 @@ func (p *AWSProvider) createVPCInfrastructure( Key: aws.String("Name"), Value: aws.String("andaime-vpc"), }, + { + Key: aws.String("andaime"), + Value: aws.String("true"), + }, }, }, }, @@ -267,6 +274,10 @@ func (p *AWSProvider) createVPCInfrastructure( Key: aws.String("Name"), Value: aws.String("andaime-sg"), }, + { + Key: aws.String("andaime"), + Value: aws.String("true"), + }, }, }, }, @@ -295,10 +306,33 @@ func (p *AWSProvider) createVPCInfrastructure( return nil, fmt.Errorf("failed to authorize security group ingress: %w", err) } - return &models.AWSVPC{ + // Create VPC object + vpc := &models.AWSVPC{ VPCID: *vpcOut.Vpc.VpcId, SecurityGroupID: *sgOut.GroupId, - }, nil + } + + // Initialize VPC manager if needed + if p.vpcManager == nil { + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return nil, fmt.Errorf("global model or deployment is nil") + } + p.vpcManager = NewRegionalVPCManager(m.Deployment, p.EC2Client) + } + + // Save VPC to regional resources + err = p.vpcManager.UpdateVPC(region, func(existingVPC *models.AWSVPC) error { + *existingVPC = *vpc + return nil + }) + if err != nil { + return nil, fmt.Errorf("failed to save VPC to regional resources: %w", err) + } + + l.Debugf("Successfully created VPC %s in region %s", vpc.VPCID, region) + + return vpc, nil } func (p *AWSProvider) ProcessMachinesConfig( From 21c80890051730ffd519eaf842ec35cc69d98c60 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Wed, 11 Dec 2024 08:21:03 -0800 Subject: [PATCH 16/32] feat: Enhance VPC infrastructure creation with improved logging and tagging --- pkg/providers/aws/provider.go | 41 ++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 26b0dcc9..bff76011 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -230,15 +230,19 @@ func (p *AWSProvider) createVPCInfrastructure( region string, ) (*models.AWSVPC, error) { l := logger.Get() - l.Debugf("Creating VPC infrastructure in region %s", region) + l.Infof("Creating VPC infrastructure in region %s", region) // Create EC2 client for the region ec2Client, err := p.getOrCreateEC2Client(ctx, region) if err != nil { + l.Errorf("Failed to create EC2 client for region %s: %v", region, err) return nil, fmt.Errorf("failed to create EC2 client for region %s: %w", region, err) } - // Create VPC with CIDR block + // Generate a unique deployment ID for tracking + deploymentID := fmt.Sprintf("andaime-%s", generateRandomString(8)) + + // Create VPC with CIDR block and enhanced tagging vpcOut, err := ec2Client.CreateVpc(ctx, &ec2.CreateVpcInput{ CidrBlock: aws.String("10.0.0.0/16"), TagSpecifications: []ec2_types.TagSpecification{ @@ -253,15 +257,26 @@ func (p *AWSProvider) createVPCInfrastructure( Key: aws.String("andaime"), Value: aws.String("true"), }, + { + Key: aws.String("andaime-deployment-id"), + Value: aws.String(deploymentID), + }, + { + Key: aws.String("andaime-region"), + Value: aws.String(region), + }, }, }, }, }) if err != nil { + l.Errorf("Failed to create VPC in region %s: %v", region, err) return nil, fmt.Errorf("failed to create VPC: %w", err) } - // Create security group + l.Infof("Created VPC %s in region %s", *vpcOut.Vpc.VpcId, region) + + // Create security group with enhanced tagging sgOut, err := ec2Client.CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{ GroupName: aws.String("andaime-sg"), Description: aws.String("Security group for Andaime deployment"), @@ -278,14 +293,25 @@ func (p *AWSProvider) createVPCInfrastructure( Key: aws.String("andaime"), Value: aws.String("true"), }, + { + Key: aws.String("andaime-deployment-id"), + Value: aws.String(deploymentID), + }, + { + Key: aws.String("andaime-region"), + Value: aws.String(region), + }, }, }, }, }) if err != nil { + l.Errorf("Failed to create security group in VPC %s: %v", *vpcOut.Vpc.VpcId, err) return nil, fmt.Errorf("failed to create security group: %w", err) } + l.Infof("Created security group %s in VPC %s", *sgOut.GroupId, *vpcOut.Vpc.VpcId) + // Allow inbound traffic _, err = ec2Client.AuthorizeSecurityGroupIngress(ctx, &ec2.AuthorizeSecurityGroupIngressInput{ GroupId: sgOut.GroupId, @@ -303,19 +329,23 @@ func (p *AWSProvider) createVPCInfrastructure( }, }) if err != nil { + l.Errorf("Failed to authorize security group ingress for group %s: %v", *sgOut.GroupId, err) return nil, fmt.Errorf("failed to authorize security group ingress: %w", err) } + l.Infof("Authorized security group ingress for %s", *sgOut.GroupId) + // Create VPC object vpc := &models.AWSVPC{ VPCID: *vpcOut.Vpc.VpcId, SecurityGroupID: *sgOut.GroupId, } - // Initialize VPC manager if needed + // Initialize VPC manager if not already done if p.vpcManager == nil { m := display.GetGlobalModelFunc() if m == nil || m.Deployment == nil { + l.Error("Global model or deployment is nil") return nil, fmt.Errorf("global model or deployment is nil") } p.vpcManager = NewRegionalVPCManager(m.Deployment, p.EC2Client) @@ -327,10 +357,11 @@ func (p *AWSProvider) createVPCInfrastructure( return nil }) if err != nil { + l.Errorf("Failed to save VPC %s to regional resources: %v", vpc.VPCID, err) return nil, fmt.Errorf("failed to save VPC to regional resources: %w", err) } - l.Debugf("Successfully created VPC %s in region %s", vpc.VPCID, region) + l.Infof("Successfully created and saved VPC %s in region %s", vpc.VPCID, region) return vpc, nil } From d823c5c31dc0019b5e4498e947801b81e70726c5 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Wed, 11 Dec 2024 08:30:32 -0800 Subject: [PATCH 17/32] refactor: Improve error handling and logging for multi-region AWS infrastructure setup --- pkg/providers/aws/provider.go | 63 +++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index bff76011..3d9b99f1 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -673,16 +673,30 @@ func (p *AWSProvider) CreateRegionalResources( ctx context.Context, regions []string, ) error { + l := logger.Get() + l.Infof("Creating regional resources for regions: %v", regions) + var eg errgroup.Group for _, region := range regions { region := region // capture for goroutine eg.Go(func() error { - return p.setupRegionalInfrastructure(ctx, region) + l.Debugf("Setting up infrastructure for region: %s", region) + err := p.setupRegionalInfrastructure(ctx, region) + if err != nil { + l.Errorf("Failed to setup infrastructure for region %s: %v", region, err) + return fmt.Errorf("failed to setup infrastructure for region %s: %w", region, err) + } + return nil }) } - return eg.Wait() + if err := eg.Wait(); err != nil { + l.Errorf("Error creating regional resources: %v", err) + return fmt.Errorf("failed to deploy VMs in parallel: %w", err) + } + + return nil } // Setup infrastructure for a single region @@ -695,6 +709,14 @@ func (p *AWSProvider) setupRegionalInfrastructure(ctx context.Context, region st return fmt.Errorf("global model or deployment is nil") } + // Ensure regional resources are initialized + if m.Deployment.AWS.RegionalResources == nil { + m.Deployment.AWS.RegionalResources = &models.RegionalResources{ + VPCs: make(map[string]*models.AWSVPC), + Clients: make(map[string]aws_interface.EC2Clienter), + } + } + // Debug current state l.Debugf("Current deployment state: %+v", m.Deployment.AWS) if m.Deployment.AWS.RegionalResources != nil { @@ -710,16 +732,16 @@ func (p *AWSProvider) setupRegionalInfrastructure(ctx context.Context, region st // Step 1: Get availability zones azs, err := p.getRegionAvailabilityZones(ctx, region) if err != nil { - l.Debugf("Failed to get availability zones: %v", err) - return err + l.Errorf("Failed to get availability zones for region %s: %v", region, err) + return fmt.Errorf("failed to get availability zones for region %s: %w", region, err) } - l.Debugf("Found %d availability zones", len(azs)) + l.Debugf("Found %d availability zones in region %s", len(azs), region) // Step 2: Create VPC and security groups - l.Debug("Creating VPC...") + l.Debugf("Creating VPC in region %s", region) if err := p.createVPCWithRetry(ctx, region); err != nil { - l.Debugf("Failed to create VPC: %v", err) - return fmt.Errorf("failed to create VPC: %w", err) + l.Errorf("Failed to create VPC in region %s: %v", region, err) + return fmt.Errorf("failed to create VPC in region %s: %w", region, err) } // Get VPC state @@ -728,37 +750,42 @@ func (p *AWSProvider) setupRegionalInfrastructure(ctx context.Context, region st vpc := state.vpc state.mu.RUnlock() - l.Debugf("VPC state after creation: %+v", vpc) + l.Debugf("VPC state after creation for region %s: %+v", region, vpc) if vpc == nil { - l.Debug("VPC is nil after creation!") + l.Error("VPC is nil after creation!") return fmt.Errorf("VPC not found for region %s", region) } + // Step 3: Create security group sgID, err := p.createSecurityGroup(ctx, region, vpc.VPCID) if err != nil { - return fmt.Errorf("failed to create security groups: %w", err) + l.Errorf("Failed to create security group in region %s: %v", region, err) + return fmt.Errorf("failed to create security groups in region %s: %w", region, err) } m.Deployment.AWS.RegionalResources.SetSGID(region, *sgID) - // Step 3: Create subnets + // Step 4: Create subnets if err := p.createRegionalSubnets(ctx, region, azs[:2]); err != nil { - return err + l.Errorf("Failed to create subnets in region %s: %v", region, err) + return fmt.Errorf("failed to create subnets in region %s: %w", region, err) } - // Step 4: Setup networking components + // Step 5: Setup networking components if err := p.setupNetworking(ctx, region); err != nil { - return err + l.Errorf("Failed to setup networking in region %s: %v", region, err) + return fmt.Errorf("failed to setup networking in region %s: %w", region, err) } - // Step 5: Save and update display + // Step 6: Save and update display if err := p.saveInfrastructureToConfig(); err != nil { - return fmt.Errorf("failed to save infrastructure IDs to config: %w", err) + l.Errorf("Failed to save infrastructure config for region %s: %v", region, err) + return fmt.Errorf("failed to save infrastructure IDs to config for region %s: %w", region, err) } p.updateInfrastructureDisplay(models.ResourceStateSucceeded) - l.Info("AWS infrastructure created successfully for region: " + region) + l.Infof("AWS infrastructure created successfully for region: %s", region) return nil } From 5a0e1acab1221cd4a14709415f153f046f20d011 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Wed, 11 Dec 2024 10:00:32 -0800 Subject: [PATCH 18/32] refactor: Improve VPC creation error handling and logging in AWS provider --- pkg/providers/aws/provider.go | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 3d9b99f1..eb27dbba 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -677,6 +677,8 @@ func (p *AWSProvider) CreateRegionalResources( l.Infof("Creating regional resources for regions: %v", regions) var eg errgroup.Group + var mu sync.Mutex + var errors []error for _, region := range regions { region := region // capture for goroutine @@ -685,7 +687,10 @@ func (p *AWSProvider) CreateRegionalResources( err := p.setupRegionalInfrastructure(ctx, region) if err != nil { l.Errorf("Failed to setup infrastructure for region %s: %v", region, err) - return fmt.Errorf("failed to setup infrastructure for region %s: %w", region, err) + mu.Lock() + errors = append(errors, fmt.Errorf("region %s: %w", region, err)) + mu.Unlock() + return err } return nil }) @@ -693,7 +698,20 @@ func (p *AWSProvider) CreateRegionalResources( if err := eg.Wait(); err != nil { l.Errorf("Error creating regional resources: %v", err) - return fmt.Errorf("failed to deploy VMs in parallel: %w", err) + + // Combine all errors + var combinedErr error + mu.Lock() + for _, e := range errors { + if combinedErr == nil { + combinedErr = e + } else { + combinedErr = fmt.Errorf("%v; %w", combinedErr, e) + } + } + mu.Unlock() + + return fmt.Errorf("failed to deploy VMs in parallel: %w", combinedErr) } return nil @@ -754,7 +772,13 @@ func (p *AWSProvider) setupRegionalInfrastructure(ctx context.Context, region st if vpc == nil { l.Error("VPC is nil after creation!") - return fmt.Errorf("VPC not found for region %s", region) + // Attempt to retrieve VPC from regional resources + vpc = m.Deployment.AWS.RegionalResources.GetVPC(region) + if vpc == nil { + l.Errorf("Could not find VPC in regional resources for region %s", region) + return fmt.Errorf("VPC not found for region %s", region) + } + l.Infof("Retrieved VPC %s from regional resources", vpc.VPCID) } // Step 3: Create security group From 8f3af6dbc403f5b51e60e897aa85286c71fcd945 Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Wed, 11 Dec 2024 17:12:11 -0800 Subject: [PATCH 19/32] fixing locations --- .cspell/custom-dictionary.txt | 2 + cmd/beta/aws/create_deployment.go | 21 ++++- cmd/beta/azure/create_deployment_test.go | 6 +- cmd/beta/gcp/create_deployment_test.go | 6 +- cmd/beta/gcp/create_vm.go | 8 +- cmd/beta/gcp/progress_test.go | 3 +- cmd/beta/provision/provisioner_test.go | 4 +- cmd/beta/testdisplay_test.go | 84 +++++++++--------- delete-vpcs.sh | 2 +- internal/clouds/azure/locations.go | 4 +- internal/clouds/azure/locations_test.go | 18 ++-- internal/clouds/gcp/locations.go | 10 +-- internal/clouds/gcp/locations_test.go | 30 +++---- internal/clouds/general/location.go | 89 +++++++++++++++++++ pkg/display/display_model.go | 8 +- pkg/display/rendering.go | 4 +- pkg/logger/logger.go | 26 +++--- pkg/models/aws.go | 5 -- pkg/models/deployment.go | 24 +++++- pkg/models/machine.go | 96 +++++++++++++-------- pkg/models/types.go | 10 +-- pkg/providers/aws/aws_compute_operations.go | 20 ++++- pkg/providers/aws/provider.go | 22 +++-- pkg/providers/azure/create_resource_test.go | 2 +- pkg/providers/azure/deploy.go | 21 +++-- pkg/providers/azure/deploy_bacalhau_test.go | 2 +- pkg/providers/azure/integration_test.go | 2 + pkg/providers/azure/resource_group.go | 2 +- pkg/providers/common/cluster_deployer.go | 2 +- pkg/providers/common/deployment.go | 21 ++++- pkg/providers/common/machine_config.go | 11 +++ pkg/providers/common/machines.go | 7 ++ pkg/providers/gcp/client_compute.go | 8 +- pkg/providers/gcp/gcp_cluster_deployer.go | 2 +- pkg/providers/gcp/integration_test.go | 2 + pkg/providers/gcp/machines.go | 2 +- pkg/providers/gcp/provider.go | 8 +- requirements.txt | 16 ++-- 38 files changed, 411 insertions(+), 199 deletions(-) create mode 100644 internal/clouds/general/location.go diff --git a/.cspell/custom-dictionary.txt b/.cspell/custom-dictionary.txt index c43fcc99..4d264958 100644 --- a/.cspell/custom-dictionary.txt +++ b/.cspell/custom-dictionary.txt @@ -237,6 +237,7 @@ mitchellh mktemp mmddhhmm mockprivatekey +Msgf nakedret nameprovider nanosec @@ -372,6 +373,7 @@ ukwest unbuffered unconvert UNIQID +unitedstates unmarshaling unmarshalling unpadded diff --git a/cmd/beta/aws/create_deployment.go b/cmd/beta/aws/create_deployment.go index 95d93a0e..3d1e6e28 100644 --- a/cmd/beta/aws/create_deployment.go +++ b/cmd/beta/aws/create_deployment.go @@ -41,7 +41,7 @@ func ExecuteCreateDeployment(cmd *cobra.Command, _ []string) error { FilePath: viper.GetString("general.log_path"), Format: viper.GetString("general.log_format"), WithTrace: true, - EnableConsole: true, + EnableConsole: false, EnableBuffer: true, BufferSize: 8192, InstantSync: true, @@ -181,6 +181,14 @@ func prepareDeployment( m.Deployment.SetMachines(machines) m.Deployment.SetLocations(locations) + for _, machine := range m.Deployment.GetMachines() { + region := machine.GetRegion() + if _, exists := m.Deployment.AWS.RegionalResources.VPCs[region]; !exists { + m.Deployment.AWS.RegionalResources.SetVPC(region, &models.AWSVPC{}) + m.Deployment.AWS.RegionalResources.SetClient(region, nil) + } + } + return m.Deployment, nil } @@ -268,6 +276,14 @@ func runDeployment(ctx context.Context, awsProvider *aws_provider.AWSProvider) e return fmt.Errorf("failed to create infrastructure: %w", err) } + l.Debug("Infrastructure created successfully") + l.Debug("Creating regional networking...") + if err := awsProvider.CreateRegionalResources(ctx, m.Deployment.AWS.RegionalResources.GetRegions()); err != nil { + return fmt.Errorf("failed to create regional networking: %w", err) + } + + l.Debug("Regional networking created successfully") + // Wait for network propagation and connectivity l.Info("Waiting for network propagation...") if err := awsProvider.WaitForNetworkConnectivity(ctx); err != nil { @@ -398,7 +414,8 @@ func writeConfig() { machines[name] = map[string]interface{}{ "public_ip": machine.GetPublicIP(), "private_ip": machine.GetPrivateIP(), - "location": machine.GetLocation(), + "region": machine.GetRegion(), + "zone": machine.GetZone(), } } diff --git a/cmd/beta/azure/create_deployment_test.go b/cmd/beta/azure/create_deployment_test.go index 41490b58..e383306d 100644 --- a/cmd/beta/azure/create_deployment_test.go +++ b/cmd/beta/azure/create_deployment_test.go @@ -224,12 +224,12 @@ func (suite *CmdBetaAzureCreateDeploymentSuite) TestPrepareDeployment() { // Check if machines were properly configured suite.Require().Len(deployment.Machines, 1) - var machine *models.Machine + var machine models.Machiner for _, m := range deployment.Machines { - machine = m.(*models.Machine) + machine = m break } - suite.Equal("eastus", machine.GetLocation()) + suite.Equal("eastus", machine.GetRegion()) suite.Equal("Standard_D2s_v3", machine.GetVMSize()) suite.True(machine.IsOrchestrator()) } diff --git a/cmd/beta/gcp/create_deployment_test.go b/cmd/beta/gcp/create_deployment_test.go index 01028bd6..3ce5e106 100644 --- a/cmd/beta/gcp/create_deployment_test.go +++ b/cmd/beta/gcp/create_deployment_test.go @@ -351,9 +351,9 @@ func (suite *CmdBetaGCPCreateDeploymentSuite) TestPrepareDeployment_CustomMachin // Verify custom machine configuration suite.Require().Len(deployment.Machines, 2, "Expected 2 machines to be created") for _, m := range deployment.Machines { - machine, ok := m.(*models.Machine) - suite.Require().True(ok, "Expected machine to be of type *models.Machine") - suite.Equal("us-west1-b", machine.GetLocation(), "Expected location to be us-west1-b") + machine := m + suite.Equal("us-west1", machine.GetRegion(), "Expected location to be us-west1") + suite.Equal("us-west1-b", machine.GetZone(), "Expected zone to be us-west1-b") suite.Equal( "n1-standard-4", machine.GetVMSize(), diff --git a/cmd/beta/gcp/create_vm.go b/cmd/beta/gcp/create_vm.go index 6530fea7..ba72ff76 100644 --- a/cmd/beta/gcp/create_vm.go +++ b/cmd/beta/gcp/create_vm.go @@ -103,15 +103,15 @@ func createVM(cmd *cobra.Command, args []string) error { m.Deployment.GCP.BillingAccountID = billingAccountID m.Deployment.GCP.DefaultRegion = getRegionFromZone(zone) m.Deployment.GCP.DefaultZone = zone + region := getRegionFromZone(zone) machine, err := models.NewMachine( models.DeploymentTypeGCP, vmName, machineType, diskSizeGB, - models.CloudSpecificInfo{ - Zone: zone, - Region: getRegionFromZone(zone), - }, + region, + zone, + models.CloudSpecificInfo{}, ) if err != nil { return err diff --git a/cmd/beta/gcp/progress_test.go b/cmd/beta/gcp/progress_test.go index de8e6610..75a42340 100644 --- a/cmd/beta/gcp/progress_test.go +++ b/cmd/beta/gcp/progress_test.go @@ -39,7 +39,8 @@ func (suite *GCPProgressTestSuite) SetupTest() { machine := &models.Machine{ ID: "test-machine", Name: "test-machine", - Location: "us-central1-a", + Region: "us-central1", + Zone: "us-central1-a", VMSize: "n1-standard-2", SSHPort: 22, SSHUser: "test-user", diff --git a/cmd/beta/provision/provisioner_test.go b/cmd/beta/provision/provisioner_test.go index 88c39a10..6949f004 100644 --- a/cmd/beta/provision/provisioner_test.go +++ b/cmd/beta/provision/provisioner_test.go @@ -417,9 +417,11 @@ func (cbpts *CmdBetaProvisionTestSuite) TestProvisionerLowLevelFailure() { testMachine, err := models.NewMachine( models.DeploymentTypeAWS, - "us-east-1", + "us-east-1a", "test", 1, + "us-east-1", + "us-east-1a", models.CloudSpecificInfo{}, ) testMachine.SetNodeType(models.BacalhauNodeTypeOrchestrator) diff --git a/cmd/beta/testdisplay_test.go b/cmd/beta/testdisplay_test.go index 21a9f08b..65d8e36d 100644 --- a/cmd/beta/testdisplay_test.go +++ b/cmd/beta/testdisplay_test.go @@ -28,49 +28,49 @@ func TestDisplayLayout(t *testing.T) { testMachines := make(map[string]models.Machiner) testMachines["test1"] = &models.Machine{ - Name: "test1", - CloudProvider: models.DeploymentTypeAzure, - Type: models.AzureResourceTypeVM, - Location: "us-west-2", - StatusMessage: "apple grape mango", - Orchestrator: true, - StartTime: time.Now().Add(-29 * time.Second), + Name: "test1", + CloudProvider: models.DeploymentTypeAzure, + Type: models.AzureResourceTypeVM, + DisplayLocation: "us-west-2", + StatusMessage: "apple grape mango", + Orchestrator: true, + StartTime: time.Now().Add(-29 * time.Second), } testMachines["test2"] = &models.Machine{ - Name: "test2", - CloudProvider: models.DeploymentTypeAzure, - Type: models.AzureResourceTypeVM, - Location: "us-west-2", - StatusMessage: "nectarine fig elderberry", - Orchestrator: true, - StartTime: time.Now().Add(-29 * time.Second), + Name: "test2", + CloudProvider: models.DeploymentTypeAzure, + Type: models.AzureResourceTypeVM, + DisplayLocation: "us-west-2", + StatusMessage: "nectarine fig elderberry", + Orchestrator: true, + StartTime: time.Now().Add(-29 * time.Second), } testMachines["test3"] = &models.Machine{ - Name: "test3", - CloudProvider: models.DeploymentTypeAzure, - Type: models.AzureResourceTypeVM, - Location: "us-west-2", - StatusMessage: "grape quince kiwi", - Orchestrator: true, - StartTime: time.Now().Add(-29 * time.Second), + Name: "test3", + CloudProvider: models.DeploymentTypeAzure, + Type: models.AzureResourceTypeVM, + DisplayLocation: "us-west-2", + StatusMessage: "grape quince kiwi", + Orchestrator: true, + StartTime: time.Now().Add(-29 * time.Second), } testMachines["test4"] = &models.Machine{ - Name: "test4", - CloudProvider: models.DeploymentTypeAzure, - Type: models.AzureResourceTypeVM, - Location: "us-west-2", - StatusMessage: "cherry orange quince", - Orchestrator: true, - StartTime: time.Now().Add(-29 * time.Second), + Name: "test4", + CloudProvider: models.DeploymentTypeAzure, + Type: models.AzureResourceTypeVM, + DisplayLocation: "us-west-2", + StatusMessage: "cherry orange quince", + Orchestrator: true, + StartTime: time.Now().Add(-29 * time.Second), } testMachines["test5"] = &models.Machine{ - Name: "test5", - CloudProvider: models.DeploymentTypeAzure, - Type: models.AzureResourceTypeVM, - Location: "us-west-2", - StatusMessage: "raspberry ugli kiwi", - Orchestrator: true, - StartTime: time.Now().Add(-29 * time.Second), + Name: "test5", + CloudProvider: models.DeploymentTypeAzure, + Type: models.AzureResourceTypeVM, + DisplayLocation: "us-west-2", + StatusMessage: "raspberry ugli kiwi", + Orchestrator: true, + StartTime: time.Now().Add(-29 * time.Second), } m.Deployment.SetMachines(testMachines) @@ -146,7 +146,7 @@ func TestDisplayLayout(t *testing.T) { expectedLineSprintfString, machine.GetName(), models.AzureResourceTypeVM.ShortResourceName, - machine.GetLocation(), + machine.GetDisplayLocation(), machine.GetStatusMessage(), "██████████████████", "29.0s", @@ -198,12 +198,12 @@ func TestProgressBar(t *testing.T) { viper.Set("general.project_prefix", "test-project") m := display.GetGlobalModelFunc() m.Deployment.SetMachine("test1", &models.Machine{ - Name: "test1", - CloudProvider: models.DeploymentTypeAzure, - Type: models.AzureResourceTypeVM, - Location: "us-west-2", - StatusMessage: "test", - Orchestrator: true, + Name: "test1", + CloudProvider: models.DeploymentTypeAzure, + Type: models.AzureResourceTypeVM, + DisplayLocation: "us-west-2", + StatusMessage: "test", + Orchestrator: true, }) for _, machine := range m.Deployment.GetMachines() { for _, resource := range machine.GetMachineResources() { diff --git a/delete-vpcs.sh b/delete-vpcs.sh index 4572f2cb..89c708ee 100755 --- a/delete-vpcs.sh +++ b/delete-vpcs.sh @@ -42,7 +42,7 @@ for region in $regions; do # Get VPC IDs for VPCs named "andaime-vpc" vpc_ids=$(aws ec2 describe-vpcs \ --region $region \ - --filters "Name=tag:Name,Values=andaime-vpc" \ + --filters "Name=tag:Name,Values=andaime-vpc*" \ --query 'Vpcs[*].VpcId' \ --output text) diff --git a/internal/clouds/azure/locations.go b/internal/clouds/azure/locations.go index c38398cf..af724b94 100644 --- a/internal/clouds/azure/locations.go +++ b/internal/clouds/azure/locations.go @@ -44,7 +44,7 @@ func getSortedAzureData() ([]byte, error) { return yaml.Marshal(sortedData) } -func IsValidAzureLocation(location string) bool { +func IsValidAzureRegion(region string) bool { l := logger.Get() data, err := getSortedAzureData() if err != nil { @@ -59,7 +59,7 @@ func IsValidAzureLocation(location string) bool { return false } - _, exists := azureData.Locations[strings.ToLower(location)] + _, exists := azureData.Locations[strings.ToLower(region)] return exists } diff --git a/internal/clouds/azure/locations_test.go b/internal/clouds/azure/locations_test.go index 6381801c..637cd55c 100644 --- a/internal/clouds/azure/locations_test.go +++ b/internal/clouds/azure/locations_test.go @@ -14,31 +14,31 @@ type InternalAzureTestSuite struct { func (suite *InternalAzureTestSuite) TestIsValidAzureLocation() { testCases := []struct { name string - location string + region string expectedValid bool expectedReason string }{ { name: "Valid location", - location: "polandcentral", + region: "polandcentral", expectedValid: true, expectedReason: "", }, { name: "Valid location with different case", - location: "polandCentral", + region: "polandCentral", expectedValid: true, expectedReason: "", }, { name: "Invalid location", - location: "invalidlocation", + region: "invalidlocation", expectedValid: false, - expectedReason: "invalidlocation is not a valid Azure location", + expectedReason: "invalidlocation is not a valid Azure region", }, { name: "Empty location", - location: "", + region: "", expectedValid: false, expectedReason: "location cannot be empty", }, @@ -46,13 +46,13 @@ func (suite *InternalAzureTestSuite) TestIsValidAzureLocation() { for _, tc := range testCases { suite.Run(tc.name, func() { - isValid := IsValidAzureLocation(tc.location) + isValid := IsValidAzureRegion(tc.region) suite.Equal( tc.expectedValid, isValid, fmt.Sprintf( - "Expected validity of location '%s' to be %v, but got %v", - tc.location, + "Expected validity of region '%s' to be %v, but got %v", + tc.region, tc.expectedValid, isValid, ), diff --git a/internal/clouds/gcp/locations.go b/internal/clouds/gcp/locations.go index c751df44..25339e4f 100644 --- a/internal/clouds/gcp/locations.go +++ b/internal/clouds/gcp/locations.go @@ -23,7 +23,7 @@ type DiskImage struct { Architecture string `yaml:"architecture"` } -func IsValidGCPLocation(location string) bool { +func IsValidGCPZone(zone string) bool { l := logger.Get() gcpDataRaw, err := GetGCPData() if err != nil { @@ -37,11 +37,11 @@ func IsValidGCPLocation(location string) bool { return false } - _, exists := gcpData.Locations[strings.ToLower(location)] + _, exists := gcpData.Locations[strings.ToLower(zone)] return exists } -func IsValidGCPMachineType(location, machineType string) bool { +func IsValidGCPMachineType(zone, machineType string) bool { l := logger.Get() gcpDataRaw, err := GetGCPData() if err != nil { @@ -53,7 +53,7 @@ func IsValidGCPMachineType(location, machineType string) bool { l.Warnf("Failed to unmarshal GCP data: %v", err) return false } - validMachineTypes, ok := gcpData.Locations[strings.ToLower(location)] + validMachineTypes, ok := gcpData.Locations[strings.ToLower(zone)] if !ok { return false } @@ -61,7 +61,7 @@ func IsValidGCPMachineType(location, machineType string) bool { } // Returns the name of the disk image, if the disk image family is valid, otherwise returns an empty string -func IsValidGCPDiskImageFamily(location, diskImageFamilyToCheck string) (string, error) { +func IsValidGCPDiskImageFamily(zone, diskImageFamilyToCheck string) (string, error) { l := logger.Get() gcpDataRaw, err := GetGCPData() if err != nil { diff --git a/internal/clouds/gcp/locations_test.go b/internal/clouds/gcp/locations_test.go index 94157b3a..15c50764 100644 --- a/internal/clouds/gcp/locations_test.go +++ b/internal/clouds/gcp/locations_test.go @@ -14,34 +14,34 @@ type InternalGCPTestSuite struct { func (suite *InternalGCPTestSuite) TestIsValidGCPLocation() { testCases := []struct { name string - location string + zone string expectedValid bool }{ { name: "Valid location", - location: "us-central1-a", + zone: "us-central1-a", expectedValid: true, }, { name: "Valid location with different case", - location: "US-CENTRAL1-A", + zone: "US-CENTRAL1-A", expectedValid: true, }, { name: "Invalid location", - location: "invalid-location", + zone: "invalid-location", expectedValid: false, }, { name: "Empty location", - location: "", + zone: "", expectedValid: false, }, } for _, tc := range testCases { suite.Run(tc.name, func() { - isValid := IsValidGCPLocation(tc.location) + isValid := IsValidGCPZone(tc.zone) assert.Equal(suite.T(), tc.expectedValid, isValid) }) } @@ -50,25 +50,25 @@ func (suite *InternalGCPTestSuite) TestIsValidGCPLocation() { func (suite *InternalGCPTestSuite) TestIsValidGCPMachineType() { testCases := []struct { name string - location string + zone string machineType string expectedValid bool }{ { name: "Valid machine type", - location: "us-central1-a", + zone: "us-central1-a", machineType: "n1-standard-1", expectedValid: true, }, { name: "Invalid machine type", - location: "us-central1-a", + zone: "us-central1-a", machineType: "invalid-machine-type", expectedValid: false, }, { name: "Invalid location", - location: "invalid-location", + zone: "invalid-location", machineType: "n1-standard-1", expectedValid: false, }, @@ -76,7 +76,7 @@ func (suite *InternalGCPTestSuite) TestIsValidGCPMachineType() { for _, tc := range testCases { suite.Run(tc.name, func() { - isValid := IsValidGCPMachineType(tc.location, tc.machineType) + isValid := IsValidGCPMachineType(tc.zone, tc.machineType) assert.Equal(suite.T(), tc.expectedValid, isValid) }) } @@ -85,19 +85,19 @@ func (suite *InternalGCPTestSuite) TestIsValidGCPMachineType() { func (suite *InternalGCPTestSuite) TestIsValidGCPDiskImageFamily() { testCases := []struct { name string - location string + zone string diskImageFamily string expectedValid bool }{ { name: "Valid disk image family", - location: "us-central1-a", + zone: "us-central1-a", diskImageFamily: "ubuntu-2004-lts", expectedValid: true, }, { name: "Invalid disk image family", - location: "us-central1-a", + zone: "us-central1-a", diskImageFamily: "invalid-family", expectedValid: false, }, @@ -105,7 +105,7 @@ func (suite *InternalGCPTestSuite) TestIsValidGCPDiskImageFamily() { for _, tc := range testCases { suite.Run(tc.name, func() { - imageURL, err := IsValidGCPDiskImageFamily(tc.location, tc.diskImageFamily) + imageURL, err := IsValidGCPDiskImageFamily(tc.zone, tc.diskImageFamily) if tc.expectedValid { assert.NoError(suite.T(), err) assert.NotEmpty(suite.T(), imageURL) diff --git a/internal/clouds/general/location.go b/internal/clouds/general/location.go new file mode 100644 index 00000000..ad2fd728 --- /dev/null +++ b/internal/clouds/general/location.go @@ -0,0 +1,89 @@ +package general + +import ( + "strings" + + "github.com/bacalhau-project/andaime/pkg/logger" +) + +func NormalizeLocation( + cloudProvider string, + location string, +) (string, string, error) { + l := logger.Get() + lowerCloudProvider := strings.ToLower(cloudProvider) + switch lowerCloudProvider { + case "aws": + // List of sample AWS locations: + // https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html + // us-east-1* N. Virginia us-east-1a us-east-1b us-east-1c us-east-1d us-east-1e + // us-east-2 Ohio us-east-2a us-east-2b us-east-2c + // us-west-1* N. California us-west-1a us-west-1b us-west-1c + // us-west-2 Oregon us-west-2a us-west-2b us-west-2c + // eu-west-1 Ireland eu-west-1a eu-west-1b eu-west-1c + // eu-central-1 Frankfurt eu-central-1a eu-central-1b + // ap-northeast-1* Tokyo ap-northeast-1a ap-northeast-1b ap-northeast-1c + // ap-northeast-2 Seoul ap-northeast-2a ap-northeast-2c + // ap-southeast-1 Singapore ap-southeast-1a ap-southeast-1b + // ap-southeast-2 Sydney ap-southeast-2a ap-southeast-2b ap-southeast-2c + // ap-south-1 Mumbai ap-south-1a ap-south-1b + // sa-east-1 Sao Paulo sa-east-1a sa-east-1b sa-east-1c + region, zone, err := ParseRegionZone(location) + if err != nil { + return "", "", err + } + + l.Debugf("Normalized AWS location: %s -> %s, %s", location, region, zone) + return region, zone, nil + case "azure": + // Azure locations are already normalized + // United Arab Emirates uae United Arab Emirates + // United Kingdom uk United Kingdom + // United States unitedstates United States + return location, location, nil + case "gcp": + // The GCP regions and zones are different from the AWS regions and zones. + // Sydney, Australia APAC australia-southeast1-a, australia-southeast1-b, australia-southeast1-c + // Tokyo, Japan APAC asia-northeast1-a, asia-northeast1-b, asia-northeast1-c + // Frankfurt, Germany Europe europe-west3-a, europe-west3-b, europe-west3-c + // Hamina, Finland Europe europe-north1-a, europe-north1-b, europe-north1-c + // London, England, UK Europe europe-west2-a, europe-west2-b, europe-west2-c + // Madrid, Spain Europe europe-southwest1-a, europe-southwest1-b, europe-southwest1-c + region, zone, err := ParseRegionZone(location) + if err != nil { + return "", "", err + } + l.Debugf("Normalized GCP location: %s -> %s, %s", location, region, zone) + return region, zone, nil + } + l.Warnf("Unknown cloud provider: %s", cloudProvider) + return location, location, nil +} + +// ParseRegionZone takes either a region (e.g., us-east-1) or zone (e.g., us-east-1a) +// and returns both the region and zone information. +// If a region is provided, the zone will be empty. +// If a zone is provided, both region and zone will be populated. +func ParseRegionZone(input string) (string, string, error) { + // Early return for empty input + if input == "" { + return "", "", nil + } + + // Handle GCP style zones (e.g., europe-west3-a) + if parts := strings.Split(input, "-"); len(parts) > 2 && parts[len(parts)-1][0] >= 'a' && + parts[len(parts)-1][0] <= 'z' { + // Input is a GCP zone, extract region by removing the last segment + region := strings.Join(parts[:len(parts)-1], "-") + return region, input, nil + } + + // Check if the input is an AWS-style zone (ends with a letter a-z) + if len(input) > 0 && input[len(input)-1] >= 'a' && input[len(input)-1] <= 'z' { + // Input is a zone, extract region by removing the last character + return input[:len(input)-1], input, nil + } + + // Input is a region + return input, input + "a", nil +} diff --git a/pkg/display/display_model.go b/pkg/display/display_model.go index 4f9f8a4b..8834521f 100644 --- a/pkg/display/display_model.go +++ b/pkg/display/display_model.go @@ -221,7 +221,7 @@ func (m *DisplayModel) updateLocation(machineName string, newStatus *models.Disp l := logger.Get() if newStatus.Location != "" { err := m.Deployment.UpdateMachine(machineName, func(mach models.Machiner) { - mach.SetLocation(newStatus.Location) + mach.SetDisplayLocation(newStatus.Location) }) if err != nil { l.Errorf("Error updating machine status: %v", err) @@ -283,8 +283,10 @@ func (m *DisplayModel) updateServiceStates(machineName string, newStatus *models } // Update SSH state if we have a public IP and the VM is running - if machine.GetPublicIP() != "" && - machine.GetMachineResourceState("compute.googleapis.com/Instance") == models.ResourceStateSucceeded { + if machine.GetPublicIP() != "" && + machine.GetMachineResourceState( + "compute.googleapis.com/Instance", + ) == models.ResourceStateSucceeded { machine.SetServiceState( models.ServiceTypeSSH.Name, models.ServiceStateSucceeded, diff --git a/pkg/display/rendering.go b/pkg/display/rendering.go index 4ff54a63..f9a14365 100644 --- a/pkg/display/rendering.go +++ b/pkg/display/rendering.go @@ -176,7 +176,7 @@ func (m *DisplayModel) getSortedMachineSlice() []struct { Location string Name string }{ - Location: machine.GetLocation(), + Location: machine.GetDisplayLocation(), Name: machine.GetName(), }) } @@ -209,7 +209,7 @@ func (m *DisplayModel) getMachineRowData(machine models.Machiner) []string { return []string{ machine.GetName(), machine.GetType().ShortResourceName, - utils.TruncateString(machine.GetLocation(), DisplayColumns[2].Width-2), + utils.TruncateString(machine.GetDisplayLocation(), DisplayColumns[2].Width-2), machine.GetStatusMessage(), progressBar, formatElapsedTime(elapsedTime), diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 1a2c6a49..3fcbbe87 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -22,6 +22,7 @@ const ( DebugFilePermissions = 0600 ProfileFilePermissions = 0600 InfoLogLevel = "info" + LastLogLines = 100 ) // Global variables @@ -138,19 +139,24 @@ func InitProduction() { }) } -// Core creation helpers -func createConsoleCore(level zap.AtomicLevel) zapcore.Core { - // Explicitly return nil to prevent any console logging - GlobalEnableConsoleLogger = false - return nil -} - func createFileCore(level zap.AtomicLevel) (zapcore.Core, error) { encoderConfig := zapcore.EncoderConfig{ - // ... encoder config ... + TimeKey: "time", + LevelKey: "level", + MessageKey: "msg", + StacktraceKey: "stacktrace", + EncodeLevel: zapcore.CapitalColorLevelEncoder, + LineEnding: zapcore.DefaultLineEnding, + EncodeTime: customTimeEncoder, + EncodeDuration: zapcore.SecondsDurationEncoder, + EncodeCaller: zapcore.ShortCallerEncoder, } - logFile, err := os.OpenFile(GlobalLogPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600) + logFile, err := os.OpenFile( + GlobalLogPath, + os.O_APPEND|os.O_CREATE|os.O_WRONLY, + 0600, //nolint:gosec,mnd + ) if err != nil { return nil, err } @@ -485,7 +491,7 @@ func (tl *TestLogger) PrintLogs(t *testing.T) { // PrintLogs prints all captured logs to the test output func (l *Logger) PrintLogs(t *testing.T) { t.Log("Captured logs:") - for i, log := range globalLogBuffer.GetLastLines(100) { + for i, log := range globalLogBuffer.GetLastLines(LastLogLines) { if log != "" { t.Logf("[%d] %s", i, log) } diff --git a/pkg/models/aws.go b/pkg/models/aws.go index 461d2ed0..28f3bb3b 100644 --- a/pkg/models/aws.go +++ b/pkg/models/aws.go @@ -1,9 +1,5 @@ package models -import ( - "sync" -) - // AWSDeployment represents AWS-specific deployment configuration type AWSDeployment struct { DefaultMachineType string `json:"default_machine_type,omitempty"` @@ -11,7 +7,6 @@ type AWSDeployment struct { DefaultCountPerRegion int32 `json:"default_count_per_zone,omitempty"` AccountID string `json:"account_id,omitempty"` RegionalResources *RegionalResources `json:"regional_resources,omitempty"` - mu sync.RWMutex } // AWSVPC represents AWS VPC and related resources diff --git a/pkg/models/deployment.go b/pkg/models/deployment.go index 0e6dfc04..774656d0 100644 --- a/pkg/models/deployment.go +++ b/pkg/models/deployment.go @@ -225,7 +225,7 @@ func (d *Deployment) UpdateViperConfig() error { // Group machines by region for _, machine := range d.Machines { - machineRegion := machine.GetLocation() + machineRegion := machine.GetRegion() if machineRegion == "" { continue } @@ -448,6 +448,18 @@ func (r *RegionalResources) SetVPC(region string, vpc *AWSVPC) { r.VPCs[region] = vpc } +func (r *RegionalResources) GetClient(region string) aws_interface.EC2Clienter { + r.RLock() + defer r.RUnlock() + return r.Clients[region] +} + +func (r *RegionalResources) SetClient(region string, client aws_interface.EC2Clienter) { + r.Lock() + defer r.Unlock() + r.Clients[region] = client +} + func (r *RegionalResources) SetSGID(region string, sgID string) { r.Lock() defer r.Unlock() @@ -460,6 +472,16 @@ func (r *RegionalResources) SetSGID(region string, sgID string) { r.VPCs[region].SecurityGroupID = sgID } +func (r *RegionalResources) GetRegions() []string { + r.RLock() + defer r.RUnlock() + regions := []string{} + for region := range r.VPCs { + regions = append(regions, region) + } + return regions +} + type RegionalVPC struct { VPCID string Region string diff --git a/pkg/models/machine.go b/pkg/models/machine.go index 477523c2..19ae5b35 100644 --- a/pkg/models/machine.go +++ b/pkg/models/machine.go @@ -38,10 +38,12 @@ type Machiner interface { SetDiskImageURL(url string) GetImageID() string SetImageID(id string) - GetLocation() string - SetLocation(location string) error + GetDisplayLocation() string + SetDisplayLocation(location string) error GetRegion() string + SetRegion(region string) GetZone() string + SetZone(zone string) GetPublicIP() string SetPublicIP(ip string) GetPrivateIP() string @@ -120,13 +122,13 @@ const ( ) type Machine struct { - ID string - Name string - Type ResourceType - Location string - Region string - Zone string - NodeType string + ID string + Name string + Type ResourceType + DisplayLocation string + Region string + Zone string + NodeType string StatusMessage string Parameters Parameters @@ -178,12 +180,6 @@ type CloudSpecificInfo struct { // Azure specific ResourceGroupName string - // GCP specific - Zone string - - // Both GCP and AWS - Region string - // AWS specific SpotMarketOptions *ec2Types.InstanceMarketOptionsRequest } @@ -193,6 +189,8 @@ func NewMachine( location string, vmSize string, diskSizeGB int, + region string, + zone string, cloudSpecificInfo CloudSpecificInfo, ) (Machiner, error) { newID := utils.CreateShortID() @@ -216,7 +214,7 @@ func NewMachine( } // There is some logic in SetLocation so we do this outside of the struct - err := returnMachine.SetLocation(location) + err := returnMachine.SetDisplayLocation(location) if err != nil { return nil, err } @@ -277,31 +275,37 @@ func (mach *Machine) SetOrchestrator(orchestrator bool) { mach.Orchestrator = orchestrator } -func (mach *Machine) SetLocation(location string) error { +func (mach *Machine) SetDisplayLocation(location string) error { + l := logger.Get() + region, zone, err := general.NormalizeLocation(string(mach.CloudProvider), location) + if err != nil { + return err + } + l.Debugf("Normalized location: %s -> %s, %s", location, region, zone) + switch mach.CloudProvider { case DeploymentTypeAzure: - if !internal_azure.IsValidAzureLocation(location) { + if !internal_azure.IsValidAzureRegion(region) { return fmt.Errorf("invalid Azure location: %s", location) } + mach.Region = region + mach.Zone = zone case DeploymentTypeGCP: - if !internal_gcp.IsValidGCPLocation(location) { - return fmt.Errorf("invalid GCP location: %s", location) - } - mach.CloudSpecific.Zone = location - region, err := internal_gcp.GetGCPRegionFromZone(location) - if err != nil { + if !internal_gcp.IsValidGCPZone(zone) { return fmt.Errorf("invalid GCP location: %s", location) } - mach.CloudSpecific.Region = region + mach.Region = region + mach.Zone = zone case DeploymentTypeAWS: - if !internal_aws.IsValidAWSRegion(location) { - return fmt.Errorf("invalid AWS region: %s", location) + if !internal_aws.IsValidAWSRegion(region) { + return fmt.Errorf("invalid AWS region: %s", region) } - mach.CloudSpecific.Region = location + mach.Region = region + mach.Zone = zone default: return fmt.Errorf("unknown deployment type: %s", mach.DeploymentType) } - mach.Location = location + mach.DisplayLocation = location return nil } @@ -683,15 +687,25 @@ func (mach *Machine) EnsureMachineServices() error { return nil } -// Add this new function +// For Azure, "location" is the region. +// For GCP, "location" is the zone. +// For AWS, "location" is the zone. func IsValidLocation(deploymentType DeploymentType, location string) bool { + region, zone, err := general.NormalizeLocation( + string(deploymentType), + location, + ) + if err != nil { + return false + } + switch deploymentType { case DeploymentTypeAzure: - return internal_azure.IsValidAzureLocation(location) + return internal_azure.IsValidAzureRegion(region) case DeploymentTypeGCP: - return internal_gcp.IsValidGCPLocation(location) + return internal_gcp.IsValidGCPZone(zone) case DeploymentTypeAWS: - return internal_aws.IsValidAWSRegion(location) + return internal_aws.IsValidAWSRegion(region) default: return false } @@ -729,15 +743,23 @@ func (mach *Machine) GetType() ResourceType { } func (mach *Machine) GetRegion() string { - return mach.CloudSpecific.Region + return mach.Region +} + +func (mach *Machine) SetRegion(region string) { + mach.Region = region } func (mach *Machine) GetZone() string { - return mach.CloudSpecific.Zone + return mach.Zone +} + +func (mach *Machine) SetZone(zone string) { + mach.Zone = zone } -func (mach *Machine) GetLocation() string { - return mach.Location +func (mach *Machine) GetDisplayLocation() string { + return mach.DisplayLocation } func (mach *Machine) GetPublicIP() string { diff --git a/pkg/models/types.go b/pkg/models/types.go index 9e764719..d23bf36e 100644 --- a/pkg/models/types.go +++ b/pkg/models/types.go @@ -277,7 +277,7 @@ func ConvertFromRawResourceToStatus( var statuses []DisplayStatus if location := GetLocationFromResourceName(resourceName); location != "" { - machinesNames, err := GetMachinesInLocation(location, deployment.GetMachines()) + machinesNames, err := GetMachinesInRegion(location, deployment.GetMachines()) if err != nil { return nil, err } @@ -360,17 +360,15 @@ func machineNeedsUpdating( return needsUpdate > 0 } -func GetMachinesInLocation(resourceName string, machines map[string]Machiner) ([]string, error) { - location := strings.Split(resourceName, "-")[0] - - if location == "" { +func GetMachinesInRegion(region string, machines map[string]Machiner) ([]string, error) { + if region == "" { return nil, fmt.Errorf("location is empty") } var machinesInLocation []string for _, machine := range machines { - if machine.GetLocation() == location { + if machine.GetRegion() == region { machinesInLocation = append(machinesInLocation, machine.GetName()) } } diff --git a/pkg/providers/aws/aws_compute_operations.go b/pkg/providers/aws/aws_compute_operations.go index 7316faf7..98322a5e 100644 --- a/pkg/providers/aws/aws_compute_operations.go +++ b/pkg/providers/aws/aws_compute_operations.go @@ -282,7 +282,7 @@ func (p *AWSProvider) DeployVMsInParallel( // Group machines by region machinesByRegion := make(map[string][]models.Machiner) for _, machine := range m.Deployment.GetMachines() { - region := machine.GetLocation() + region := machine.GetRegion() l.Debug(fmt.Sprintf("Processing machine %s in region %s", machine.GetName(), region)) if region == "" { l.Warn(fmt.Sprintf("Machine %s has no location specified", machine.GetName())) @@ -309,8 +309,8 @@ func (p *AWSProvider) DeployVMsInParallel( // Deploy machines in each region for region, machines := range machinesByRegion { - vpc, exists := m.Deployment.AWS.RegionalResources.VPCs[region] - if !exists { + vpc := m.Deployment.AWS.RegionalResources.GetVPC(region) + if vpc == nil { return fmt.Errorf("VPC not found for region %s", region) } @@ -454,7 +454,19 @@ func (p *AWSProvider) validateRegionZones(ctx context.Context, region string) er } // Describe all zones in the region, removing filters to get comprehensive data - result, err := ec2Client.DescribeAvailabilityZones(ctx, &ec2.DescribeAvailabilityZonesInput{}) + result, err := ec2Client.DescribeAvailabilityZones(ctx, &ec2.DescribeAvailabilityZonesInput{ + Filters: []ec2_types.Filter{ + { + Name: aws.String("region-name"), + Values: []string{region}, + }, + { + Name: aws.String("state"), + Values: []string{"available"}, + }, + }, + AllAvailabilityZones: aws.Bool(true), + }) if err != nil { l.Error(fmt.Sprintf("Failed to describe AZs: %v", err)) return fmt.Errorf("failed to describe availability zones: %w", err) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index eb27dbba..a913cdad 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -159,8 +159,8 @@ func (p *AWSProvider) getOrCreateEC2Client( m.Deployment.AWS.RegionalResources.Clients = make(map[string]aws_interface.EC2Clienter) } - if m.Deployment.AWS.RegionalResources.Clients[region] != nil { - return m.Deployment.AWS.RegionalResources.Clients[region], nil + if client := m.Deployment.AWS.RegionalResources.GetClient(region); client != nil { + return client, nil } cfg, err := awsconfig.LoadDefaultConfig(ctx, awsconfig.WithRegion(region)) @@ -170,8 +170,8 @@ func (p *AWSProvider) getOrCreateEC2Client( var ec2Client aws_interface.EC2Clienter p.ConfigMutex.Lock() - if m.Deployment.AWS.RegionalResources.Clients[region] != nil { - ec2Client = m.Deployment.AWS.RegionalResources.Clients[region] + if client := m.Deployment.AWS.RegionalResources.GetClient(region); client != nil { + ec2Client = client } else { ec2Client = &LiveEC2Client{client: ec2.NewFromConfig(cfg)} m.Deployment.AWS.RegionalResources.Clients[region] = ec2Client @@ -211,7 +211,7 @@ func (p *AWSProvider) PrepareDeployment(ctx context.Context) error { // Initialize regional resources regions := make(map[string]struct{}) for _, machine := range deployment.Machines { - region := machine.GetLocation() + region := machine.GetRegion() if region == "" { continue } @@ -619,7 +619,7 @@ func (p *AWSProvider) CreateInfrastructure(ctx context.Context) error { // Collect unique regions and validate them first for _, machine := range m.Deployment.GetMachines() { - region := machine.GetLocation() + region := machine.GetRegion() // Convert zone to region if necessary if len(region) > 0 && region[len(region)-1] >= 'a' && region[len(region)-1] <= 'z' { region = region[:len(region)-1] @@ -635,7 +635,7 @@ func (p *AWSProvider) CreateInfrastructure(ctx context.Context) error { // Update display for the first machine in this region for _, machine := range m.Deployment.GetMachines() { - machineRegion := machine.GetLocation() + machineRegion := machine.GetRegion() if len(machineRegion) > 0 && machineRegion[len(machineRegion)-1] >= 'a' && machineRegion[len(machineRegion)-1] <= 'z' { machineRegion = machineRegion[:len(machineRegion)-1] @@ -698,7 +698,7 @@ func (p *AWSProvider) CreateRegionalResources( if err := eg.Wait(); err != nil { l.Errorf("Error creating regional resources: %v", err) - + // Combine all errors var combinedErr error mu.Lock() @@ -804,7 +804,11 @@ func (p *AWSProvider) setupRegionalInfrastructure(ctx context.Context, region st // Step 6: Save and update display if err := p.saveInfrastructureToConfig(); err != nil { l.Errorf("Failed to save infrastructure config for region %s: %v", region, err) - return fmt.Errorf("failed to save infrastructure IDs to config for region %s: %w", region, err) + return fmt.Errorf( + "failed to save infrastructure IDs to config for region %s: %w", + region, + err, + ) } p.updateInfrastructureDisplay(models.ResourceStateSucceeded) diff --git a/pkg/providers/azure/create_resource_test.go b/pkg/providers/azure/create_resource_test.go index 2c338ded..26b552bb 100644 --- a/pkg/providers/azure/create_resource_test.go +++ b/pkg/providers/azure/create_resource_test.go @@ -152,7 +152,7 @@ func (suite *PkgProvidersAzureCreateResourceTestSuite) TestCreateResources() { machineName := fmt.Sprintf("machine-%s-%d", location, i) suite.deployment.SetMachine(machineName, &models.Machine{ Name: machineName, - Location: location, + Region: location, SSHPublicKeyPath: suite.testSSHPublicKeyPath, SSHPrivateKeyPath: suite.testSSHPrivateKeyPath, }) diff --git a/pkg/providers/azure/deploy.go b/pkg/providers/azure/deploy.go index a7f0eed8..4f240fdb 100644 --- a/pkg/providers/azure/deploy.go +++ b/pkg/providers/azure/deploy.go @@ -91,7 +91,7 @@ func (p *AzureProvider) PrepareResourceGroup( if len(m.Deployment.GetMachines()) > 0 { for _, machine := range m.Deployment.GetMachines() { // Break over the first machine - resourceGroupLocation = machine.GetLocation() + resourceGroupLocation = machine.GetRegion() break } } @@ -185,8 +185,8 @@ func (p *AzureProvider) CreateResources(ctx context.Context) error { // Group machines by location machinesByLocation := make(map[string][]models.Machiner) for _, machine := range m.Deployment.GetMachines() { - machinesByLocation[machine.GetLocation()] = append( - machinesByLocation[machine.GetLocation()], + machinesByLocation[machine.GetRegion()] = append( + machinesByLocation[machine.GetRegion()], machine, ) } @@ -410,7 +410,7 @@ func (p *AzureProvider) deployMachine( allMachines[machine.GetName()] = viperMachineStruct{ PublicIP: machine.GetPublicIP(), PrivateIP: machine.GetPrivateIP(), - Location: machine.GetLocation(), + Location: machine.GetRegion(), Size: machine.GetVMSize(), BacalhauProvisioned: machine.GetServiceState( models.ServiceTypeBacalhau.Name, @@ -455,10 +455,10 @@ func (p *AzureProvider) prepareDeploymentParams( ), "ubuntuOSVersion": "Ubuntu-2004", "vmSize": machine.GetVMSize(), - "virtualNetworkName": fmt.Sprintf("%s-vnet", machine.GetLocation()), - "subnetName": fmt.Sprintf("%s-subnet", machine.GetLocation()), - "networkSecurityGroupName": fmt.Sprintf("%s-nsg", machine.GetLocation()), - "location": machine.GetLocation(), + "virtualNetworkName": fmt.Sprintf("%s-vnet", machine.GetZone()), + "subnetName": fmt.Sprintf("%s-subnet", machine.GetZone()), + "networkSecurityGroupName": fmt.Sprintf("%s-nsg", machine.GetZone()), + "location": machine.GetZone(), "securityType": "TrustedLaunch", "allowedPorts": m.Deployment.AllowedPorts, } @@ -783,7 +783,10 @@ func (p *AzureProvider) DeployBacalhauWorkers(ctx context.Context) error { return p.DeployBacalhauWorkersWithCallback(ctx, func(*models.DisplayStatus) {}) } -func (p *AzureProvider) DeployBacalhauWorkersWithCallback(ctx context.Context, callback UpdateCallback) error { +func (p *AzureProvider) DeployBacalhauWorkersWithCallback( + ctx context.Context, + callback UpdateCallback, +) error { m := display.GetGlobalModelFunc() l := logger.Get() var workerMachines []models.Machiner diff --git a/pkg/providers/azure/deploy_bacalhau_test.go b/pkg/providers/azure/deploy_bacalhau_test.go index 8bdf6229..fab61815 100644 --- a/pkg/providers/azure/deploy_bacalhau_test.go +++ b/pkg/providers/azure/deploy_bacalhau_test.go @@ -306,7 +306,7 @@ func (s *PkgProvidersAzureDeployBacalhauTestSuite) TestSetupNodeConfigMetadata() "test": &models.Machine{ Name: "test", VMSize: "Standard_DS4_v2", - Location: "eastus2", + Region: "eastus2", NodeType: models.BacalhauNodeTypeOrchestrator, }, }) diff --git a/pkg/providers/azure/integration_test.go b/pkg/providers/azure/integration_test.go index 794fd5c5..7a083912 100644 --- a/pkg/providers/azure/integration_test.go +++ b/pkg/providers/azure/integration_test.go @@ -132,6 +132,8 @@ func (s *PkgProvidersAzureIntegrationTest) SetupTest() { machine.location, "Standard_D2s_v3", 30, + machine.location, + machine.location, models.CloudSpecificInfo{}, ) s.Require().NoError(err) diff --git a/pkg/providers/azure/resource_group.go b/pkg/providers/azure/resource_group.go index 62bfd3c9..9e1435f7 100644 --- a/pkg/providers/azure/resource_group.go +++ b/pkg/providers/azure/resource_group.go @@ -27,7 +27,7 @@ func (c *LiveAzureClient) GetOrCreateResourceGroup(ctx context.Context, return nil, fmt.Errorf("invalid resource group name: %s", rgName) } - if !internal.IsValidAzureLocation(rgLocation) { + if !internal.IsValidAzureRegion(rgLocation) { return nil, fmt.Errorf("invalid resource group location: %s", rgLocation) } diff --git a/pkg/providers/common/cluster_deployer.go b/pkg/providers/common/cluster_deployer.go index 2340bf22..21d82879 100644 --- a/pkg/providers/common/cluster_deployer.go +++ b/pkg/providers/common/cluster_deployer.go @@ -587,7 +587,7 @@ func (cd *ClusterDeployer) SetupNodeConfigMetadata( err = tmpl.ExecuteTemplate(&scriptBuffer, "getNodeMetadataScript", map[string]interface{}{ "MachineType": machine.GetVMSize(), "MachineName": machine.GetName(), - "Location": machine.GetLocation(), + "Location": machine.GetRegion(), "Orchestrators": strings.Join(orchestrators, ","), "IP": machine.GetPublicIP(), "Token": "", diff --git a/pkg/providers/common/deployment.go b/pkg/providers/common/deployment.go index a88e34c5..b465d591 100644 --- a/pkg/providers/common/deployment.go +++ b/pkg/providers/common/deployment.go @@ -8,11 +8,13 @@ import ( "strings" "time" + "github.com/bacalhau-project/andaime/internal/clouds/general" "github.com/bacalhau-project/andaime/pkg/globals" "github.com/bacalhau-project/andaime/pkg/logger" "github.com/bacalhau-project/andaime/pkg/models" "github.com/bacalhau-project/andaime/pkg/sshutils" "github.com/bacalhau-project/andaime/pkg/utils" + "github.com/spf13/viper" ) @@ -154,19 +156,29 @@ func PrepareDeployment( } else if provider == models.DeploymentTypeAWS { defaultCountPerLocation = int(deployment.AWS.DefaultCountPerRegion) defaultDiskSizeGB = int(deployment.AWS.DefaultDiskSizeGB) + } else { + return nil, fmt.Errorf("invalid provider: %s", provider) } orchestratorMachineName := "" - orchestratorLocation := "" orchestratorMessagePrinted := false for _, machineConfig := range machineConfigs { + region, zone, err := general.NormalizeLocation( + string(provider), + machineConfig["location"].(string), + ) + if err != nil { + return nil, fmt.Errorf("invalid location: %s", machineConfig["location"].(string)) + } machine := &models.Machine{ - Location: machineConfig["location"].(string), + DisplayLocation: machineConfig["location"].(string), VMSize: viper.GetString( fmt.Sprintf("%s.default_machine_type", strings.ToLower(string(provider))), ), DiskSizeGB: defaultDiskSizeGB, Orchestrator: false, + Region: region, + Zone: zone, } machine.SetNodeType(models.BacalhauNodeTypeCompute) @@ -206,11 +218,12 @@ func PrepareDeployment( machine.DiskSizeGB = diskSizeGB } + var orchestratorZone string if orchestrator, ok := params["orchestrator"].(bool); ok && orchestratorMachineName == "" { machine.Orchestrator = orchestrator orchestratorMachineName = machine.Name - orchestratorLocation = machine.Location + orchestratorZone = machine.Zone machine.SetNodeType(models.BacalhauNodeTypeOrchestrator) if count > 1 && !orchestratorMessagePrinted { l.Infof( @@ -220,7 +233,7 @@ func PrepareDeployment( } else if orchestratorMachineName != "" { l.Infof("Orchestrator flag must be set in a single location. Ignoring flag.") l.Infof("Orchestrator machine name: %s", orchestratorMachineName) - l.Infof("Orchestrator location: %s", orchestratorLocation) + l.Infof("Orchestrator location: %s", orchestratorZone) } for i := 0; i < count; i++ { machine.Name = fmt.Sprintf("%s-vm", utils.GenerateUniqueID()) diff --git a/pkg/providers/common/machine_config.go b/pkg/providers/common/machine_config.go index 6149654d..0a521cc2 100644 --- a/pkg/providers/common/machine_config.go +++ b/pkg/providers/common/machine_config.go @@ -7,6 +7,7 @@ import ( "strings" internal_gcp "github.com/bacalhau-project/andaime/internal/clouds/gcp" + "github.com/bacalhau-project/andaime/internal/clouds/general" "github.com/bacalhau-project/andaime/pkg/display" "github.com/bacalhau-project/andaime/pkg/logger" "github.com/bacalhau-project/andaime/pkg/models" @@ -147,6 +148,10 @@ func ProcessMachinesConfig( diskImageURL = rawMachine.Parameters.DiskImageURL } } + region, zone, err := general.NormalizeLocation( + string(providerType), + rawMachine.Location, + ) for i := 0; i < count; i++ { newMachine, err := createNewMachine( providerType, @@ -158,6 +163,8 @@ func ProcessMachinesConfig( publicKeyPath, publicKeyBytes, sshPort, + region, + zone, diskImageFamily, diskImageURL, ) @@ -226,6 +233,8 @@ func createNewMachine( publicKeyPath string, publicKeyBytes []byte, sshPort int, + region string, + zone string, diskImageFamily string, diskImageURL string, ) (models.Machiner, error) { @@ -235,6 +244,8 @@ func createNewMachine( location, vmSize, diskSizeGB, + region, + zone, models.CloudSpecificInfo{}, ) if err != nil { diff --git a/pkg/providers/common/machines.go b/pkg/providers/common/machines.go index 75817944..c6d9225f 100644 --- a/pkg/providers/common/machines.go +++ b/pkg/providers/common/machines.go @@ -3,6 +3,7 @@ package common import ( "fmt" + "github.com/bacalhau-project/andaime/internal/clouds/general" "github.com/bacalhau-project/andaime/pkg/logger" "github.com/bacalhau-project/andaime/pkg/models" "github.com/spf13/viper" @@ -20,10 +21,16 @@ func CreateNewMachine( publicKeyPath string, publicKeyBytes []byte, ) (models.Machiner, error) { + region, zone, err := general.NormalizeLocation( + string(deploymentType), + location, + ) newMachine, err := models.NewMachine(deploymentType, location, vmSize, diskSizeGB, + region, + zone, models.CloudSpecificInfo{}, ) if err != nil { diff --git a/pkg/providers/gcp/client_compute.go b/pkg/providers/gcp/client_compute.go index d1bcdc8d..12ecffce 100644 --- a/pkg/providers/gcp/client_compute.go +++ b/pkg/providers/gcp/client_compute.go @@ -572,7 +572,7 @@ func (c *LiveGCPClient) CreateVM( // Create the instance op, err := c.computeClient.Insert(ctx, &computepb.InsertInstanceRequest{ Project: projectID, - Zone: machine.GetLocation(), + Zone: machine.GetZone(), InstanceResource: instance, }) if err != nil { @@ -620,7 +620,7 @@ func (c *LiveGCPClient) validateCreateVMInput( return fmt.Errorf("projectID is not set in validateCreateVMInput") } - if err := c.validateZone(projectID, machine.GetLocation()); err != nil { + if err := c.validateZone(projectID, machine.GetZone()); err != nil { return fmt.Errorf("invalid zone: %w", err) } @@ -679,7 +679,7 @@ func (c *LiveGCPClient) prepareVMInstance( Name: proto.String(machine.GetName()), MachineType: proto.String(fmt.Sprintf( "zones/%s/machineTypes/%s", - machine.GetLocation(), + machine.GetZone(), machine.GetVMSize(), )), Tags: &computepb.Tags{ @@ -790,7 +790,7 @@ func (c *LiveGCPClient) validateZone(projectID, zone string) error { l := logger.Get() l.Debugf("Validating zone: %s in project: %s", zone, projectID) - isValid := internal_gcp.IsValidGCPLocation(zone) + isValid := internal_gcp.IsValidGCPZone(zone) if !isValid { return fmt.Errorf("zone %s is not valid", zone) } diff --git a/pkg/providers/gcp/gcp_cluster_deployer.go b/pkg/providers/gcp/gcp_cluster_deployer.go index 3989ccb4..977e9d69 100644 --- a/pkg/providers/gcp/gcp_cluster_deployer.go +++ b/pkg/providers/gcp/gcp_cluster_deployer.go @@ -129,7 +129,7 @@ func (p *GCPProvider) provisionMachine( l := logger.Get() // Create VM - l.Infof("Creating instance %s in zone %s", machine.GetName(), machine.GetLocation()) + l.Infof("Creating instance %s in zone %s", machine.GetName(), machine.GetZone()) if err := p.CreateAndConfigureVM(ctx, machine); err != nil { return fmt.Errorf("failed to create and configure VM: %w", err) } diff --git a/pkg/providers/gcp/integration_test.go b/pkg/providers/gcp/integration_test.go index 239c8766..5aaaca29 100644 --- a/pkg/providers/gcp/integration_test.go +++ b/pkg/providers/gcp/integration_test.go @@ -139,6 +139,8 @@ func (s *PkgProvidersGCPIntegrationTest) SetupTest() { machine.location, "n1-standard-2", 30, + machine.location, + machine.location, models.CloudSpecificInfo{}, ) s.Require().NoError(err) diff --git a/pkg/providers/gcp/machines.go b/pkg/providers/gcp/machines.go index f37e2c3f..30e119f2 100644 --- a/pkg/providers/gcp/machines.go +++ b/pkg/providers/gcp/machines.go @@ -19,7 +19,7 @@ func (p *GCPProvider) ValidateMachineType( ctx context.Context, location, machineType string, ) (bool, error) { - if !internal_gcp.IsValidGCPLocation(location) { + if !internal_gcp.IsValidGCPZone(location) { return false, fmt.Errorf("invalid location for GCP: %s", location) } if !internal_gcp.IsValidGCPMachineType(location, machineType) { diff --git a/pkg/providers/gcp/provider.go b/pkg/providers/gcp/provider.go index 46534b31..df647925 100644 --- a/pkg/providers/gcp/provider.go +++ b/pkg/providers/gcp/provider.go @@ -195,7 +195,7 @@ func (p *GCPProvider) DestroyProject( if err := p.GetGCPClient().DestroyProject(destroyCtx, projectID); err != nil { // Log specific error details l.Errorf("Failed to destroy GCP project %s: %v", projectID, err) - + // Check for specific error conditions if strings.Contains(err.Error(), "invalid project name") || strings.Contains(err.Error(), "Project not active") || @@ -203,7 +203,7 @@ func (p *GCPProvider) DestroyProject( l.Warnf("Project %s is invalid or not active, skipping", projectID) return nil } - + return fmt.Errorf("failed to destroy GCP project %s: %w", projectID, err) } @@ -784,7 +784,7 @@ func (p *GCPProvider) CreateAndConfigureVM( m := display.GetGlobalModelFunc() l.Infof("Starting VM creation process for %s in zone %s", - machine.GetName(), machine.GetLocation()) + machine.GetName(), machine.GetZone()) m.UpdateStatus(models.NewDisplayStatusWithText( machine.GetName(), @@ -794,7 +794,7 @@ func (p *GCPProvider) CreateAndConfigureVM( )) // Get region from zone - region := extractRegionFromZone(machine.GetLocation()) + region := extractRegionFromZone(machine.GetZone()) l.Infof("Determined region %s for VM %s", region, machine.GetName()) // Attempt IP allocation with retries diff --git a/requirements.txt b/requirements.txt index d7f8ce1f..acb5d35c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ # This file was autogenerated by uv via the following command: # uv pip compile - -o requirements.txt -aider-chat==0.67.0 +aider-chat==0.68.0 aiohappyeyeballs==2.4.4 # via # aider-chat # aiohttp -aiohttp==3.11.9 +aiohttp==3.11.10 # via # aider-chat # huggingface-hub @@ -20,7 +20,7 @@ annotated-types==0.7.0 # aider-chat # pydantic anthropic==0.34.1 -anyio==4.6.2.post1 +anyio==4.7.0 # via # aider-chat # anthropic @@ -138,7 +138,7 @@ httpx==0.27.2 # ollama # openai # tavily-python -huggingface-hub==0.26.3 +huggingface-hub==0.26.5 # via # aider-chat # llama-index-embeddings-huggingface @@ -186,7 +186,7 @@ jsonschema-specifications==2024.10.1 # via # aider-chat # jsonschema -litellm==1.53.5 +litellm==1.53.9 # via aider-chat llama-cloud==0.0.6 # via llama-index-core @@ -246,7 +246,7 @@ numpy==1.26.4 # sentence-transformers # transformers ollama==0.3.0 -openai==1.56.2 +openai==1.57.0 # via # aider-chat # litellm @@ -271,7 +271,8 @@ pillow==10.4.0 # aider-chat # llama-index-core # sentence-transformers -pip==24.2 +pip==24.3.1 + # via aider-chat playwright==1.45.0 posthog==3.7.4 # via aider-chat @@ -469,6 +470,7 @@ typing-extensions==4.12.2 # via # aider-chat # anthropic + # anyio # groq # huggingface-hub # llama-index-core From 5b81ffbe1f43a4bba1b1f6bd606fb50636f379af Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Wed, 11 Dec 2024 17:44:48 -0800 Subject: [PATCH 20/32] refactor: Improve AWS provider infrastructure setup and region handling --- pkg/providers/aws/provider.go | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index a913cdad..ea420f3a 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -233,7 +233,7 @@ func (p *AWSProvider) createVPCInfrastructure( l.Infof("Creating VPC infrastructure in region %s", region) // Create EC2 client for the region - ec2Client, err := p.getOrCreateEC2Client(ctx, region) + regionalClient, err := p.getOrCreateEC2Client(ctx, region) if err != nil { l.Errorf("Failed to create EC2 client for region %s: %v", region, err) return nil, fmt.Errorf("failed to create EC2 client for region %s: %w", region, err) @@ -243,7 +243,7 @@ func (p *AWSProvider) createVPCInfrastructure( deploymentID := fmt.Sprintf("andaime-%s", generateRandomString(8)) // Create VPC with CIDR block and enhanced tagging - vpcOut, err := ec2Client.CreateVpc(ctx, &ec2.CreateVpcInput{ + vpcOut, err := regionalClient.CreateVpc(ctx, &ec2.CreateVpcInput{ CidrBlock: aws.String("10.0.0.0/16"), TagSpecifications: []ec2_types.TagSpecification{ { @@ -277,7 +277,7 @@ func (p *AWSProvider) createVPCInfrastructure( l.Infof("Created VPC %s in region %s", *vpcOut.Vpc.VpcId, region) // Create security group with enhanced tagging - sgOut, err := ec2Client.CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{ + sgOut, err := regionalClient.CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{ GroupName: aws.String("andaime-sg"), Description: aws.String("Security group for Andaime deployment"), VpcId: vpcOut.Vpc.VpcId, @@ -313,21 +313,24 @@ func (p *AWSProvider) createVPCInfrastructure( l.Infof("Created security group %s in VPC %s", *sgOut.GroupId, *vpcOut.Vpc.VpcId) // Allow inbound traffic - _, err = ec2Client.AuthorizeSecurityGroupIngress(ctx, &ec2.AuthorizeSecurityGroupIngressInput{ - GroupId: sgOut.GroupId, - IpPermissions: []ec2_types.IpPermission{ - { - IpProtocol: aws.String("-1"), - FromPort: aws.Int32(-1), - ToPort: aws.Int32(-1), - IpRanges: []ec2_types.IpRange{ - { - CidrIp: aws.String("0.0.0.0/0"), + _, err = regionalClient.AuthorizeSecurityGroupIngress( + ctx, + &ec2.AuthorizeSecurityGroupIngressInput{ + GroupId: sgOut.GroupId, + IpPermissions: []ec2_types.IpPermission{ + { + IpProtocol: aws.String("-1"), + FromPort: aws.Int32(-1), + ToPort: aws.Int32(-1), + IpRanges: []ec2_types.IpRange{ + { + CidrIp: aws.String("0.0.0.0/0"), + }, }, }, }, }, - }) + ) if err != nil { l.Errorf("Failed to authorize security group ingress for group %s: %v", *sgOut.GroupId, err) return nil, fmt.Errorf("failed to authorize security group ingress: %w", err) @@ -680,7 +683,12 @@ func (p *AWSProvider) CreateRegionalResources( var mu sync.Mutex var errors []error + uniqueRegions := make(map[string]bool) for _, region := range regions { + uniqueRegions[region] = true + } + + for region := range uniqueRegions { region := region // capture for goroutine eg.Go(func() error { l.Debugf("Setting up infrastructure for region: %s", region) @@ -781,14 +789,6 @@ func (p *AWSProvider) setupRegionalInfrastructure(ctx context.Context, region st l.Infof("Retrieved VPC %s from regional resources", vpc.VPCID) } - // Step 3: Create security group - sgID, err := p.createSecurityGroup(ctx, region, vpc.VPCID) - if err != nil { - l.Errorf("Failed to create security group in region %s: %v", region, err) - return fmt.Errorf("failed to create security groups in region %s: %w", region, err) - } - m.Deployment.AWS.RegionalResources.SetSGID(region, *sgID) - // Step 4: Create subnets if err := p.createRegionalSubnets(ctx, region, azs[:2]); err != nil { l.Errorf("Failed to create subnets in region %s: %v", region, err) From 5ae3c135af07d93fe23594b02b44a7813a010773 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Wed, 11 Dec 2024 17:44:49 -0800 Subject: [PATCH 21/32] refactor: Enhance network connectivity logging with route table and internet gateway diagnostics --- pkg/providers/aws/provider.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index ea420f3a..434685e5 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -1282,6 +1282,14 @@ func (p *AWSProvider) WaitForNetworkConnectivity(ctx context.Context) error { l.Infof("Checking route table %d...", i+1) l.Infof("Route table ID: %s", *rt.RouteTableId) + // Log route table associations + l.Debugf("Route table associations for %s:", *rt.RouteTableId) + for _, assoc := range rt.Associations { + l.Debugf("- Association: SubnetID: %s, Main: %v", + aws.ToString(assoc.SubnetId), + aws.ToBool(assoc.Main)) + } + for _, route := range rt.Routes { if route.GatewayId != nil { l.Debugf( @@ -1302,6 +1310,25 @@ func (p *AWSProvider) WaitForNetworkConnectivity(ctx context.Context) error { if !hasInternetRoute { l.Warn("No internet gateway route found in any route table") + + // Additional diagnostic information + igws, err := p.EC2Client.DescribeInternetGateways(ctx, &ec2.DescribeInternetGatewaysInput{ + Filters: []ec2_types.Filter{ + { + Name: aws.String("attachment.vpc-id"), + Values: []string{vpcID}, + }, + }, + }) + if err != nil { + l.Errorf("Failed to describe internet gateways: %v", err) + } else { + l.Debugf("Internet Gateways for VPC %s: %d", vpcID, len(igws.InternetGateways)) + for _, igw := range igws.InternetGateways { + l.Debugf("IGW ID: %s", aws.ToString(igw.InternetGatewayId)) + } + } + return fmt.Errorf("internet gateway route not found") } From 3625a2a973ab8844e3f1c1493a0f5d7c002ee0ce Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Wed, 11 Dec 2024 18:52:05 -0800 Subject: [PATCH 22/32] feat: Add comprehensive VPC infrastructure creation method with detailed error handling --- pkg/providers/aws/provider.go | 526 +++++++++++++++++++++------------- 1 file changed, 332 insertions(+), 194 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 434685e5..0c7bf93f 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -28,18 +28,18 @@ import ( ) const ( - ResourcePollingInterval = 30 * time.Second - UpdateQueueSize = 1000 // Increased from 100 to prevent dropping updates - UpdatePollingInterval = 100 * time.Millisecond - DefaultStackTimeout = 30 * time.Minute - TestStackTimeout = 30 * time.Second - UbuntuAMIOwner = "099720109477" // Canonical's AWS account ID + ResourcePollingInterval = 30 * time.Second + UpdateQueueSize = 1000 // Increased from 100 to prevent dropping updates + UpdatePollingInterval = 100 * time.Millisecond + DefaultStackTimeout = 30 * time.Minute + TestStackTimeout = 30 * time.Second + UbuntuAMIOwner = "099720109477" // Canonical's AWS account ID + LengthOfDeploymentIDSuffix = 8 ) type VPCState struct { mu sync.RWMutex vpc *models.AWSVPC - status string lastUpdated time.Time } @@ -225,6 +225,310 @@ func (p *AWSProvider) PrepareDeployment(ctx context.Context) error { return nil } +// CreateVPCInfrastructure creates a complete VPC infrastructure in a given region +func (p *AWSProvider) CreateVPCInfrastructure( + ctx context.Context, + region string, +) (*models.AWSVPC, error) { + l := logger.Get() + l.Infof("Creating VPC infrastructure in region %s", region) + + // Create EC2 client for region + ec2Client, err := p.getOrCreateEC2Client(ctx, region) + if err != nil { + return nil, fmt.Errorf("failed to create EC2 client: %w", err) + } + + // Create VPC + vpc, err := p.createVPC(ctx, region, ec2Client) + if err != nil { + return nil, fmt.Errorf("failed to create VPC: %w", err) + } + + // Create Internet Gateway and attach to VPC + igwID, err := p.createAndAttachInternetGateway(ctx, region, vpc.VPCID, ec2Client) + if err != nil { + return nil, fmt.Errorf("failed to create and attach internet gateway: %w", err) + } + vpc.InternetGatewayID = igwID + + // Create subnets + err = p.createVPCSubnets(ctx, region, vpc, ec2Client) + if err != nil { + return nil, fmt.Errorf("failed to create subnets: %w", err) + } + + // Create and configure route table + err = p.configureVPCRouting(ctx, region, vpc, ec2Client) + if err != nil { + return nil, fmt.Errorf("failed to configure routing: %w", err) + } + + // Create security group + sgID, err := p.createSecurityGroup(ctx, region, vpc.VPCID, ec2Client) + if err != nil { + return nil, fmt.Errorf("failed to create security group: %w", err) + } + vpc.SecurityGroupID = sgID + + l.Infof("Successfully created VPC infrastructure in region %s", region) + return vpc, nil +} + +// createVPC creates a new VPC with the specified CIDR block +func (p *AWSProvider) createVPC( + ctx context.Context, + region string, + ec2Client aws_interface.EC2Clienter, +) (*models.AWSVPC, error) { + vpcResult, err := ec2Client.CreateVpc(ctx, &ec2.CreateVpcInput{ + CidrBlock: aws.String(VPCCidrBlock), + TagSpecifications: []ec2_types.TagSpecification{ + { + ResourceType: ec2_types.ResourceTypeVpc, + Tags: []ec2_types.Tag{ + { + Key: aws.String("Name"), + Value: aws.String(fmt.Sprintf("andaime-vpc-%s", region)), + }, + }, + }, + }, + }) + if err != nil { + return nil, fmt.Errorf("failed to create VPC: %w", err) + } + + // Enable DNS hostnames + _, err = ec2Client.ModifyVpcAttribute(ctx, &ec2.ModifyVpcAttributeInput{ + VpcId: vpcResult.Vpc.VpcId, + EnableDnsHostnames: &ec2_types.AttributeBooleanValue{Value: aws.Bool(true)}, + }) + if err != nil { + return nil, fmt.Errorf("failed to enable DNS hostnames: %w", err) + } + + return &models.AWSVPC{ + VPCID: *vpcResult.Vpc.VpcId, + }, nil +} + +// createAndAttachInternetGateway creates an Internet Gateway and attaches it to the VPC +func (p *AWSProvider) createAndAttachInternetGateway( + ctx context.Context, + region, vpcID string, + ec2Client aws_interface.EC2Clienter, +) (string, error) { + // Create Internet Gateway + igwResult, err := ec2Client.CreateInternetGateway(ctx, &ec2.CreateInternetGatewayInput{ + TagSpecifications: []ec2_types.TagSpecification{ + { + ResourceType: ec2_types.ResourceTypeInternetGateway, + Tags: []ec2_types.Tag{ + { + Key: aws.String("Name"), + Value: aws.String(fmt.Sprintf("andaime-igw-%s", region)), + }, + }, + }, + }, + }) + if err != nil { + return "", fmt.Errorf("failed to create internet gateway: %w", err) + } + + // Attach Internet Gateway to VPC + _, err = ec2Client.AttachInternetGateway(ctx, &ec2.AttachInternetGatewayInput{ + InternetGatewayId: igwResult.InternetGateway.InternetGatewayId, + VpcId: aws.String(vpcID), + }) + if err != nil { + return "", fmt.Errorf("failed to attach internet gateway: %w", err) + } + + return *igwResult.InternetGateway.InternetGatewayId, nil +} + +// createVPCSubnets creates the public and private subnets in the VPC +func (p *AWSProvider) createVPCSubnets( + ctx context.Context, + region string, + vpc *models.AWSVPC, + ec2Client aws_interface.EC2Clienter, +) error { + // Get available AZs + azResult, err := ec2Client.DescribeAvailabilityZones(ctx, &ec2.DescribeAvailabilityZonesInput{ + Filters: []ec2_types.Filter{ + { + Name: aws.String("region-name"), + Values: []string{region}, + }, + { + Name: aws.String("state"), + Values: []string{"available"}, + }, + }, + }) + if err != nil { + return fmt.Errorf("failed to get availability zones: %w", err) + } + + if len(azResult.AvailabilityZones) < MinRequiredAZs { + return fmt.Errorf("region %s does not have enough availability zones", region) + } + + // Create subnets + subnets := []struct { + cidr string + az string + name string + public bool + }{ + {PublicSubnet1CIDR, *azResult.AvailabilityZones[0].ZoneName, "public-1", true}, + {PublicSubnet2CIDR, *azResult.AvailabilityZones[1].ZoneName, "public-2", true}, + {PrivateSubnet1CIDR, *azResult.AvailabilityZones[0].ZoneName, "private-1", false}, + {PrivateSubnet2CIDR, *azResult.AvailabilityZones[1].ZoneName, "private-2", false}, + } + + for _, subnet := range subnets { + subnetResult, err := ec2Client.CreateSubnet(ctx, &ec2.CreateSubnetInput{ + VpcId: aws.String(vpc.VPCID), + CidrBlock: aws.String(subnet.cidr), + AvailabilityZone: aws.String(subnet.az), + TagSpecifications: []ec2_types.TagSpecification{ + { + ResourceType: ec2_types.ResourceTypeSubnet, + Tags: []ec2_types.Tag{ + { + Key: aws.String("Name"), + Value: aws.String(fmt.Sprintf("andaime-%s-%s", subnet.name, region)), + }, + }, + }, + }, + }) + if err != nil { + return fmt.Errorf("failed to create subnet %s: %w", subnet.name, err) + } + + if subnet.public { + vpc.PublicSubnetIDs = append(vpc.PublicSubnetIDs, *subnetResult.Subnet.SubnetId) + } else { + vpc.PrivateSubnetIDs = append(vpc.PrivateSubnetIDs, *subnetResult.Subnet.SubnetId) + } + } + + return nil +} + +// configureVPCRouting creates and configures the route table for the VPC +func (p *AWSProvider) configureVPCRouting( + ctx context.Context, + region string, + vpc *models.AWSVPC, + ec2Client aws_interface.EC2Clienter, +) error { + // Create route table + rtResult, err := ec2Client.CreateRouteTable(ctx, &ec2.CreateRouteTableInput{ + VpcId: aws.String(vpc.VPCID), + TagSpecifications: []ec2_types.TagSpecification{ + { + ResourceType: ec2_types.ResourceTypeRouteTable, + Tags: []ec2_types.Tag{ + { + Key: aws.String("Name"), + Value: aws.String(fmt.Sprintf("andaime-rt-%s", region)), + }, + }, + }, + }, + }) + if err != nil { + return fmt.Errorf("failed to create route table: %w", err) + } + + // Add route to Internet Gateway + _, err = ec2Client.CreateRoute(ctx, &ec2.CreateRouteInput{ + RouteTableId: rtResult.RouteTable.RouteTableId, + DestinationCidrBlock: aws.String("0.0.0.0/0"), + GatewayId: aws.String(vpc.InternetGatewayID), + }) + if err != nil { + return fmt.Errorf("failed to create route: %w", err) + } + + // Associate public subnets with route table + for _, subnetID := range vpc.PublicSubnetIDs { + _, err = ec2Client.AssociateRouteTable(ctx, &ec2.AssociateRouteTableInput{ + RouteTableId: rtResult.RouteTable.RouteTableId, + SubnetId: aws.String(subnetID), + }) + if err != nil { + return fmt.Errorf("failed to associate route table with subnet %s: %w", subnetID, err) + } + } + + vpc.PublicRouteTableID = *rtResult.RouteTable.RouteTableId + return nil +} + +// createSecurityGroup creates and configures the security group for the VPC +func (p *AWSProvider) createSecurityGroup( + ctx context.Context, + region, vpcID string, + ec2Client aws_interface.EC2Clienter, +) (string, error) { + sgResult, err := ec2Client.CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{ + GroupName: aws.String(fmt.Sprintf("andaime-sg-%s", region)), + Description: aws.String("Security group for Andaime instances"), + VpcId: aws.String(vpcID), + TagSpecifications: []ec2_types.TagSpecification{ + { + ResourceType: ec2_types.ResourceTypeSecurityGroup, + Tags: []ec2_types.Tag{ + { + Key: aws.String("Name"), + Value: aws.String(fmt.Sprintf("andaime-sg-%s", region)), + }, + }, + }, + }, + }) + if err != nil { + return "", fmt.Errorf("failed to create security group: %w", err) + } + + // Add security group rules + + ipPermissions := []ec2_types.IpPermission{} + for _, port := range p.vpcManager.deployment.AllowedPorts { + ipPermissions = append(ipPermissions, ec2_types.IpPermission{ + IpProtocol: aws.String("tcp"), + FromPort: aws.Int32(validatePort(port)), + ToPort: aws.Int32(validatePort(port)), + IpRanges: []ec2_types.IpRange{{CidrIp: aws.String("0.0.0.0/0")}}, + }) + } + + _, err = ec2Client.AuthorizeSecurityGroupIngress(ctx, &ec2.AuthorizeSecurityGroupIngressInput{ + GroupId: sgResult.GroupId, + IpPermissions: ipPermissions, + }) + if err != nil { + return "", fmt.Errorf("failed to authorize security group ingress: %w", err) + } + + return *sgResult.GroupId, nil +} + +// validatePort ensures port number is within valid int32 range +func validatePort(port int) int32 { + if port < 0 || port > 65535 { + return 0 // Or handle error appropriately + } + return int32(port) +} + func (p *AWSProvider) createVPCInfrastructure( ctx context.Context, region string, @@ -240,7 +544,7 @@ func (p *AWSProvider) createVPCInfrastructure( } // Generate a unique deployment ID for tracking - deploymentID := fmt.Sprintf("andaime-%s", generateRandomString(8)) + deploymentID := fmt.Sprintf("andaime-%s", generateRandomString(LengthOfDeploymentIDSuffix)) // Create VPC with CIDR block and enhanced tagging vpcOut, err := regionalClient.CreateVpc(ctx, &ec2.CreateVpcInput{ @@ -892,7 +1196,14 @@ func (p *AWSProvider) createRegionalSubnets( for i, az := range azs { // Create public subnet l.Debugf("Creating public subnet in AZ %s", *az.ZoneName) - publicSubnet, err := p.createSubnet(ctx, region, vpc.VPCID, *az.ZoneName, i*2, "public") + publicSubnet, err := p.createSubnet( + ctx, + region, + vpc.VPCID, + *az.ZoneName, + i*2, //nolint:mnd + "public", + ) if err != nil { return fmt.Errorf("failed to create public subnet: %w", err) } @@ -1122,65 +1433,6 @@ func (p *AWSProvider) createVPCWithRetry(ctx context.Context, region string) err return nil } -func (p *AWSProvider) createSecurityGroup(ctx context.Context, - region string, - vpcid string, -) (*string, error) { - l := logger.Get() - l.Info("Creating security groups...") - m := display.GetGlobalModelFunc() - if m == nil || m.Deployment == nil { - return nil, fmt.Errorf("global model or deployment is nil") - } - - regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] - - sgOutput, err := regionalClient.CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{ - GroupName: aws.String("andaime-sg"), - VpcId: aws.String(vpcid), - Description: aws.String("Security group for Andaime deployments"), - TagSpecifications: []ec2_types.TagSpecification{ - { - ResourceType: ec2_types.ResourceTypeSecurityGroup, - Tags: []ec2_types.Tag{ - {Key: aws.String("Name"), Value: aws.String("andaime-sg")}, - }, - }, - }, - }) - if err != nil { - return nil, fmt.Errorf("failed to create security group: %w", err) - } - - sgRules := []ec2_types.IpPermission{} - allowedPorts := []int{22, 1234, 1235, 4222} - for _, port := range allowedPorts { - sgRules = append(sgRules, ec2_types.IpPermission{ - IpProtocol: aws.String("tcp"), - FromPort: aws.Int32(int32(port)), - ToPort: aws.Int32(int32(port)), - IpRanges: []ec2_types.IpRange{ - { - CidrIp: aws.String("0.0.0.0/0"), - }, - }, - }) - } - - _, err = regionalClient.AuthorizeSecurityGroupIngress( - ctx, - &ec2.AuthorizeSecurityGroupIngressInput{ - GroupId: sgOutput.GroupId, - IpPermissions: sgRules, - }, - ) - if err != nil { - return nil, fmt.Errorf("failed to authorize security group ingress: %w", err) - } - - return sgOutput.GroupId, nil -} - func (p *AWSProvider) importSSHKeyPair( _ context.Context, sshPublicKeyPath string, @@ -1285,8 +1537,8 @@ func (p *AWSProvider) WaitForNetworkConnectivity(ctx context.Context) error { // Log route table associations l.Debugf("Route table associations for %s:", *rt.RouteTableId) for _, assoc := range rt.Associations { - l.Debugf("- Association: SubnetID: %s, Main: %v", - aws.ToString(assoc.SubnetId), + l.Debugf("- Association: SubnetID: %s, Main: %v", + aws.ToString(assoc.SubnetId), aws.ToBool(assoc.Main)) } @@ -1310,16 +1562,19 @@ func (p *AWSProvider) WaitForNetworkConnectivity(ctx context.Context) error { if !hasInternetRoute { l.Warn("No internet gateway route found in any route table") - + // Additional diagnostic information - igws, err := p.EC2Client.DescribeInternetGateways(ctx, &ec2.DescribeInternetGatewaysInput{ - Filters: []ec2_types.Filter{ - { - Name: aws.String("attachment.vpc-id"), - Values: []string{vpcID}, + igws, err := p.EC2Client.DescribeInternetGateways( + ctx, + &ec2.DescribeInternetGatewaysInput{ + Filters: []ec2_types.Filter{ + { + Name: aws.String("attachment.vpc-id"), + Values: []string{vpcID}, + }, }, }, - }) + ) if err != nil { l.Errorf("Failed to describe internet gateways: %v", err) } else { @@ -1609,123 +1864,6 @@ func (p *AWSProvider) GetVMExternalIP(ctx context.Context, instanceID string) (s return *instance.PublicIpAddress, nil } -func (p *AWSProvider) removeDeploymentFromConfig(stackName string) error { - deployments := viper.GetStringMap("deployments") - for uniqueID, details := range deployments { - deploymentDetails, ok := details.(map[string]interface{}) - if !ok { - continue - } - awsDetails, ok := deploymentDetails["aws"].(map[string]interface{}) - if !ok { - continue - } - if _, exists := awsDetails[stackName]; exists { - delete(awsDetails, stackName) - if len(awsDetails) == 0 { - delete(deploymentDetails, "aws") - } - if len(deploymentDetails) == 0 { - delete(deployments, uniqueID) - } - viper.Set("deployments", deployments) - return viper.WriteConfig() - } - } - return nil -} - -func (p *AWSProvider) cleanupRouteTables(ctx context.Context, vpcID string) error { - l := logger.Get() - rts, err := p.EC2Client.DescribeRouteTables(ctx, &ec2.DescribeRouteTablesInput{ - Filters: []ec2_types.Filter{ - { - Name: aws.String("vpc-id"), - Values: []string{vpcID}, - }, - }, - }) - if err != nil { - return fmt.Errorf("failed to describe route tables: %w", err) - } - - for _, rt := range rts.RouteTables { - // Skip the main route table - isMain := false - for _, assoc := range rt.Associations { - if aws.ToBool(assoc.Main) { - isMain = true - break - } - } - if isMain { - l.Debugf("Skipping main route table %s", *rt.RouteTableId) - continue - } - - // Delete route table associations first - for _, assoc := range rt.Associations { - if assoc.RouteTableAssociationId != nil { - l.Debugf("Disassociating route table %s", *assoc.RouteTableAssociationId) - _, err := p.EC2Client.DisassociateRouteTable(ctx, &ec2.DisassociateRouteTableInput{ - AssociationId: assoc.RouteTableAssociationId, - }) - if err != nil { - return fmt.Errorf("failed to disassociate route table: %w", err) - } - } - } - - l.Debugf("Deleting route table %s", *rt.RouteTableId) - _, err := p.EC2Client.DeleteRouteTable(ctx, &ec2.DeleteRouteTableInput{ - RouteTableId: rt.RouteTableId, - }) - if err != nil { - return fmt.Errorf("failed to delete route table: %w", err) - } - } - - return nil -} - -func (p *AWSProvider) cleanupInternetGateways(ctx context.Context, vpcID string) error { - l := logger.Get() - igws, err := p.EC2Client.DescribeInternetGateways(ctx, &ec2.DescribeInternetGatewaysInput{ - Filters: []ec2_types.Filter{ - { - Name: aws.String("attachment.vpc-id"), - Values: []string{vpcID}, - }, - }, - }) - if err != nil { - return fmt.Errorf("failed to describe internet gateways: %w", err) - } - - for _, igw := range igws.InternetGateways { - // Detach first - l.Debugf("Detaching internet gateway %s from VPC %s", *igw.InternetGatewayId, vpcID) - _, err := p.EC2Client.DetachInternetGateway(ctx, &ec2.DetachInternetGatewayInput{ - InternetGatewayId: igw.InternetGatewayId, - VpcId: aws.String(vpcID), - }) - if err != nil { - return fmt.Errorf("failed to detach internet gateway: %w", err) - } - - // Then delete - l.Debugf("Deleting internet gateway %s", *igw.InternetGatewayId) - _, err = p.EC2Client.DeleteInternetGateway(ctx, &ec2.DeleteInternetGatewayInput{ - InternetGatewayId: igw.InternetGatewayId, - }) - if err != nil { - return fmt.Errorf("failed to delete internet gateway: %w", err) - } - } - - return nil -} - // Helper functions for VPC routing setup func (p *AWSProvider) setupRouting(ctx context.Context, region string, vpc *models.AWSVPC) error { l := logger.Get() From 30b802c739744aeb9b67dc66b9b61c8c799fe1a1 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Wed, 11 Dec 2024 18:52:08 -0800 Subject: [PATCH 23/32] feat: Ensure unique internet gateway creation for each VPC --- pkg/providers/aws/provider.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 0c7bf93f..8169e998 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -1282,13 +1282,12 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error ctx, cancel := context.WithTimeout(ctx, 15*time.Minute) defer cancel() - state := p.vpcManager.GetOrCreateVPCState(region) - if state == nil { - return fmt.Errorf("failed to get VPC state for region %s", region) - } - // Get all VPCs for this region vpcStates := p.vpcManager.GetAllVPCStates(region) + if len(vpcStates) == 0 { + l.Warn("No VPC states found for region") + return fmt.Errorf("no VPC states found for region %s", region) + } m := display.GetGlobalModelFunc() if m == nil || m.Deployment == nil { @@ -1307,6 +1306,7 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error state.mu.RUnlock() if vpc == nil { + l.Warn("Skipping nil VPC in networking setup") return nil } @@ -1318,7 +1318,19 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error var err error igw, err = regionalClient.CreateInternetGateway( ctx, - &ec2.CreateInternetGatewayInput{}, + &ec2.CreateInternetGatewayInput{ + TagSpecifications: []ec2_types.TagSpecification{ + { + ResourceType: ec2_types.ResourceTypeInternetGateway, + Tags: []ec2_types.Tag{ + { + Key: aws.String("Name"), + Value: aws.String(fmt.Sprintf("andaime-igw-%s", vpc.VPCID)), + }, + }, + }, + }, + }, ) return err }, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 3)) From 2acd6cb10d231eebbe8eaa142df102db7110f511 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Wed, 11 Dec 2024 20:26:20 -0800 Subject: [PATCH 24/32] refactor: Enhance VPC networking setup with detailed logging and verification --- pkg/providers/aws/provider.go | 61 ++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 8169e998..35bc4c1f 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -1312,9 +1312,22 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error l.Debugf("Setting up networking for VPC %s", vpc.VPCID) + // Verify VPC exists and is in a valid state + vpcDesc, err := regionalClient.DescribeVpcs(ctx, &ec2.DescribeVpcsInput{ + VpcIds: []string{vpc.VPCID}, + }) + if err != nil { + l.Errorf("Failed to describe VPC %s: %v", vpc.VPCID, err) + return fmt.Errorf("failed to describe VPC %s: %w", vpc.VPCID, err) + } + if len(vpcDesc.Vpcs) == 0 { + l.Errorf("VPC %s not found", vpc.VPCID) + return fmt.Errorf("VPC %s not found", vpc.VPCID) + } + // Create Internet Gateway with retry var igw *ec2.CreateInternetGatewayOutput - err := backoff.Retry(func() error { + err = backoff.Retry(func() error { var err error igw, err = regionalClient.CreateInternetGateway( ctx, @@ -1327,6 +1340,10 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error Key: aws.String("Name"), Value: aws.String(fmt.Sprintf("andaime-igw-%s", vpc.VPCID)), }, + { + Key: aws.String("VPC"), + Value: aws.String(vpc.VPCID), + }, }, }, }, @@ -1376,6 +1393,48 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error return fmt.Errorf("failed to setup routing for VPC %s: %w", vpc.VPCID, err) } + // Verify Internet Gateway and Route Table + igws, err := regionalClient.DescribeInternetGateways(ctx, &ec2.DescribeInternetGatewaysInput{ + Filters: []ec2_types.Filter{ + { + Name: aws.String("attachment.vpc-id"), + Values: []string{vpc.VPCID}, + }, + }, + }) + if err != nil { + l.Errorf("Failed to describe internet gateways for VPC %s: %v", vpc.VPCID, err) + } else { + l.Debugf("Internet Gateways for VPC %s: %d", vpc.VPCID, len(igws.InternetGateways)) + for _, gateway := range igws.InternetGateways { + l.Debugf("IGW ID: %s", aws.ToString(gateway.InternetGatewayId)) + } + } + + rts, err := regionalClient.DescribeRouteTables(ctx, &ec2.DescribeRouteTablesInput{ + Filters: []ec2_types.Filter{ + { + Name: aws.String("vpc-id"), + Values: []string{vpc.VPCID}, + }, + }, + }) + if err != nil { + l.Errorf("Failed to describe route tables for VPC %s: %v", vpc.VPCID, err) + } else { + l.Debugf("Route tables for VPC %s: %d", vpc.VPCID, len(rts.RouteTables)) + for i, rt := range rts.RouteTables { + l.Debugf("Route table %d ID: %s", i+1, aws.ToString(rt.RouteTableId)) + for j, route := range rt.Routes { + l.Debugf("Route %d: Destination %s, Gateway %s", + j+1, + aws.ToString(route.DestinationCidrBlock), + aws.ToString(route.GatewayId), + ) + } + } + } + l.Debugf("Successfully set up networking for VPC %s", vpc.VPCID) return nil }) From 9736d9f315634e99f0a12d604da8663a9f3b1a18 Mon Sep 17 00:00:00 2001 From: "David Aronchick (aider)" Date: Thu, 12 Dec 2024 08:18:50 -0800 Subject: [PATCH 25/32] test: Add network diagnostics to AWS provider This commit enhances the AWS provider's network error handling by: - Adding comprehensive DNS and network diagnostics - Implementing retry mechanisms with exponential backoff - Providing more detailed error logging - Configuring HTTP client with longer timeouts - Logging system nameserver information The changes aim to improve visibility into network-related issues when interacting with AWS EC2 endpoints and provide more robust error handling. --- pkg/providers/aws/provider.go | 61 ++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 35bc4c1f..9218dc20 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -4,6 +4,8 @@ import ( "context" "fmt" "math/rand" + "net" + "net/http" "os" "sort" "strings" @@ -1126,10 +1128,34 @@ func (p *AWSProvider) getRegionAvailabilityZones( ctx context.Context, region string, ) ([]ec2_types.AvailabilityZone, error) { - // Create a regional EC2 client - regionalCfg, err := awsconfig.LoadDefaultConfig(ctx, awsconfig.WithRegion(region)) + l := logger.Get() + l.Debugf("Attempting to get availability zones for region %s", region) + + // Diagnostic logging for network configuration + addrs, err := net.LookupHost("ec2." + region + ".amazonaws.com") if err != nil { - return nil, fmt.Errorf("failed to load AWS config for region %s: %w", region, err) + l.Errorf("DNS resolution failed for ec2.%s.amazonaws.com: %v", region, err) + l.Warn("Attempting to use default AWS configuration with fallback mechanisms") + } else { + l.Debugf("Resolved EC2 endpoint addresses: %v", addrs) + } + + // Create a regional EC2 client with extended timeout and retry configuration + regionalCfg, err := awsconfig.LoadDefaultConfig( + ctx, + awsconfig.WithRegion(region), + awsconfig.WithHTTPClient(&http.Client{ + Timeout: 30 * time.Second, + Transport: &http.Transport{ + MaxIdleConns: 10, + IdleConnTimeout: 30 * time.Second, + DisableCompression: true, + TLSHandshakeTimeout: 10 * time.Second, + }, + }), + ) + if err != nil { + return nil, fmt.Errorf("failed to load AWS config for region %s: detailed network diagnostics - %w", region, err) } regionalClient := ec2.NewFromConfig(regionalCfg) @@ -1146,15 +1172,40 @@ func (p *AWSProvider) getRegionAvailabilityZones( }, } - azOutput, err := regionalClient.DescribeAvailabilityZones(ctx, azInput) + // Add retry mechanism with exponential backoff + b := backoff.NewExponentialBackOff() + b.MaxElapsedTime = 2 * time.Minute + + var azOutput *ec2.DescribeAvailabilityZonesOutput + err = backoff.Retry(func() error { + var retryErr error + azOutput, retryErr = regionalClient.DescribeAvailabilityZones(ctx, azInput) + if retryErr != nil { + l.Warnf("Retrying availability zones lookup for %s: %v", region, retryErr) + return retryErr + } + return nil + }, b) + if err != nil { - return nil, fmt.Errorf("failed to get availability zones for region %s: %w", region, err) + // Enhanced error logging with network diagnostics + netErr, ok := err.(net.Error) + if ok { + l.Errorf("Network error getting AZs: timeout=%v, temporary=%v", netErr.Timeout(), netErr.Temporary()) + } + + // Attempt to get system DNS configuration + nsAddrs, _ := net.LookupNS(".") + l.Debugf("System nameservers: %v", nsAddrs) + + return nil, fmt.Errorf("comprehensive failure getting availability zones for region %s: network diagnostics included - %w", region, err) } if len(azOutput.AvailabilityZones) < MinRequiredAZs { return nil, fmt.Errorf("region %s does not have at least 2 availability zones", region) } + l.Debugf("Successfully retrieved %d availability zones for region %s", len(azOutput.AvailabilityZones), region) return azOutput.AvailabilityZones, nil } From 2e306d4645b0c18cb27b688b7245075759f36ffd Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Sat, 14 Dec 2024 09:22:56 -0800 Subject: [PATCH 26/32] basic amazon now working --- .cspell/custom-dictionary.txt | 1 + .envrc | 10 +- cmd/andaime.go | 31 +- cmd/beta/aws/create_deployment.go | 30 +- delete-vpcs.sh | 341 ++++++--- internal/testdata/aws.go | 10 + mocks/aws/mock_EC2Clienter.go | 148 ++++ pkg/models/deployment.go | 28 +- pkg/providers/aws/aws_compute_operations.go | 122 +++- pkg/providers/aws/integration_test.go | 67 -- pkg/providers/aws/provider.go | 739 +++++++++----------- pkg/providers/aws/provider_test.go | 65 +- pkg/providers/aws/utils.go | 7 +- pkg/sshutils/constants.go | 2 +- pkg/sshutils/ssh_config.go | 8 +- test/integration/create_deployment_test.go | 3 +- 16 files changed, 953 insertions(+), 659 deletions(-) diff --git a/.cspell/custom-dictionary.txt b/.cspell/custom-dictionary.txt index 4d264958..2eef2ee7 100644 --- a/.cspell/custom-dictionary.txt +++ b/.cspell/custom-dictionary.txt @@ -109,6 +109,7 @@ dryrun dupl eastasia eastus +enis errcheck Errf errgroup diff --git a/.envrc b/.envrc index d3097db0..0ecd928f 100644 --- a/.envrc +++ b/.envrc @@ -1,8 +1,8 @@ # shellcheck disable=SC1090 . <( flox activate; ); - unset GOROOT - export PATH=$PATH:$GOROOT/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin - export PATH=/Users/daaronch/.cache/flox/run/aronchick/andaime.19a05c92/bin:$PATH +unset GOROOT +export PATH=$PATH:$GOROOT/bin +export GOPATH=$HOME/go +export PATH=$PATH:$GOPATH/bin +export PATH=/Users/daaronch/.cache/flox/run/aronchick/andaime.19a05c92/bin:$PATH diff --git a/cmd/andaime.go b/cmd/andaime.go index 86230b21..e26872e0 100644 --- a/cmd/andaime.go +++ b/cmd/andaime.go @@ -192,7 +192,23 @@ func GetSession(region string) *session.Session { return sess } + +// getUbuntuAMIId retrieves the latest Ubuntu AMI ID from AWS for a given architecture. +// It specifically looks for Ubuntu 22.04 (Jammy) images from Canonical. +// +// Parameters: +// +// svc: AWS EC2 service client +// arch: Target architecture (e.g., "x86_64" or "arm64") +// +// Returns: +// +// string: AMI ID if found +// error: Error if any occurred during the operation func getUbuntuAMIId(svc *ec2.EC2, arch string) (string, error) { + const ubuntuVersion = "ubuntu-jammy-22.04" + const canonicalOwnerID = "099720109477" + describeImagesInput := &ec2.DescribeImagesInput{ Filters: []*ec2.Filter{ { @@ -208,25 +224,21 @@ func getUbuntuAMIId(svc *ec2.EC2, arch string) (string, error) { Values: aws.StringSlice([]string{"available"}), }, }, - Owners: aws.StringSlice([]string{"099720109477"}), // Canonical's owner ID + Owners: aws.StringSlice([]string{canonicalOwnerID}), } - // Call DescribeImages to find matching AMIs result, err := svc.DescribeImages(describeImagesInput) if err != nil { - fmt.Printf("Failed to describe images, %v\n", err) - return "", err + return "", fmt.Errorf("failed to describe images: %w", err) } if len(result.Images) == 0 { - fmt.Println("No Ubuntu AMIs found") - return "", err + return "", fmt.Errorf("no Ubuntu AMIs found") } - // Filter the results to find the latest image that matches the desired pattern var latestImage *ec2.Image for _, image := range result.Images { - if strings.Contains(*image.Name, "ubuntu-jammy-22.04") { + if strings.Contains(*image.Name, ubuntuVersion) { if latestImage == nil || *image.CreationDate > *latestImage.CreationDate { latestImage = image } @@ -234,8 +246,7 @@ func getUbuntuAMIId(svc *ec2.EC2, arch string) (string, error) { } if latestImage == nil { - fmt.Println("No matching Ubuntu 22.04 AMIs found") - return "", fmt.Errorf("no matching Ubuntu 22.04 AMIs found") + return "", fmt.Errorf("no matching %s AMIs found", ubuntuVersion) } if VerboseModeFlag { diff --git a/cmd/beta/aws/create_deployment.go b/cmd/beta/aws/create_deployment.go index 3d1e6e28..3bf329b2 100644 --- a/cmd/beta/aws/create_deployment.go +++ b/cmd/beta/aws/create_deployment.go @@ -5,7 +5,6 @@ import ( "fmt" "time" - "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/bacalhau-project/andaime/pkg/display" "github.com/bacalhau-project/andaime/pkg/logger" "github.com/bacalhau-project/andaime/pkg/models" @@ -103,13 +102,6 @@ func ExecuteCreateDeployment(cmd *cobra.Command, _ []string) error { return fmt.Errorf("failed to write VPC ID to config: %w", err) } - // Ensure EC2 client is initialized - ec2Client := awsProvider.GetEC2Client() - if ec2Client == nil { - ec2Client = ec2.NewFromConfig(*awsProvider.GetConfig()) - awsProvider.SetEC2Client(ec2Client) - } - m := display.NewDisplayModel(deployment) prog := display.GetGlobalProgramFunc() @@ -317,13 +309,35 @@ func runDeployment(ctx context.Context, awsProvider *aws_provider.AWSProvider) e ) } + machine.SetMachineResourceState( + models.ServiceTypeSSH.Name, + models.ResourceStatePending, + ) + if err := sshConfig.WaitForSSH(ctx, sshutils.SSHRetryAttempts, sshutils.GetAggregateSSHTimeout()); err != nil { + machine.SetMachineResourceState( + models.ServiceTypeSSH.Name, + models.ResourceStateFailed, + ) return fmt.Errorf( "failed to establish SSH connection to machine %s: %w", machine.GetName(), err, ) } + machine.SetMachineResourceState( + models.ServiceTypeSSH.Name, + models.ResourceStateSucceeded, + ) + + m.QueueUpdate(display.UpdateAction{ + MachineName: machine.GetName(), + UpdateData: display.UpdateData{ + UpdateType: display.UpdateTypeResource, + ResourceType: "SSH", + ResourceState: models.MachineResourceState(models.ServiceTypeSSH.State), + }, + }) l.Infof("Machine %s is accessible via SSH", machine.GetName()) } diff --git a/delete-vpcs.sh b/delete-vpcs.sh index 89c708ee..81f8007f 100755 --- a/delete-vpcs.sh +++ b/delete-vpcs.sh @@ -2,16 +2,20 @@ # Parse command line arguments DRY_RUN=false +FORCE=false +MAX_RETRIES=3 print_usage() { - echo "Usage: $0 [-d|--dry-run]" + echo "Usage: $0 [-d|--dry-run] [-f|--force]" echo " -d, --dry-run Run in dry-run mode (no actual deletions)" + echo " -f, --force Force deletion without confirmation" exit 1 } while [[ "$#" -gt 0 ]]; do case $1 in -d|--dry-run) DRY_RUN=true ;; + -f|--force) FORCE=true ;; -h|--help) print_usage ;; *) echo "Unknown parameter: $1"; print_usage ;; esac @@ -22,107 +26,270 @@ if $DRY_RUN; then echo "Running in DRY-RUN mode - no resources will be deleted" fi -# Function to execute AWS commands with dry-run support +# Function to execute AWS commands with dry-run support and retries execute_aws_command() { local cmd="$1" - if $DRY_RUN; then - echo "[DRY-RUN] Would execute: $cmd" - else - eval "$cmd" - fi + local retries=0 + + while [ $retries -lt $MAX_RETRIES ]; do + if $DRY_RUN; then + echo "[DRY-RUN] Would execute: $cmd" + return 0 + else + cmd="aws --no-cli-pager ${cmd#aws }" + output=$(eval "$cmd" 2>&1) + if [ $? -eq 0 ]; then + echo "$output" + return 0 + elif [[ $output == *"DependencyViolation"* ]] || [[ $output == *"InvalidParameterValue"* ]]; then + retries=$((retries + 1)) + if [ $retries -lt $MAX_RETRIES ]; then + echo "Dependency error, retrying in 10 seconds... (attempt $retries of $MAX_RETRIES)" + sleep 10 + else + echo "Failed after $MAX_RETRIES attempts: $output" + return 1 + fi + else + echo "$output" + return 1 + fi + fi + done } -# Get list of all AWS regions -regions=$(aws ec2 describe-regions --query 'Regions[*].RegionName' --output text) +# Function to wait for EC2 instances to terminate +wait_for_instances() { + local region="$1" + local instance_ids="$2" + local max_wait=60 # Maximum wait time in seconds + local waited=0 + + if [ -z "$instance_ids" ]; then + return 0 + fi + + echo "[$region] Waiting for instances to terminate: $instance_ids" + while [ $waited -lt $max_wait ]; do + local status=$(aws --no-cli-pager ec2 describe-instances \ + --region "$region" \ + --instance-ids $instance_ids \ + --query 'Reservations[].Instances[].State.Name' \ + --output text 2>/dev/null || echo "terminated") + + if [[ "$status" == "terminated" ]] || [ -z "$status" ]; then + echo "[$region] All instances terminated" + return 0 + fi + + echo "[$region] Instances still terminating... ($waited seconds)" + sleep 10 + waited=$((waited + 10)) + done + + echo "[$region] Warning: Timed out waiting for instances to terminate" + return 1 +} -# Loop through each region -for region in $regions; do - echo "Checking region: $region" +# Function to delete a VPC and its resources +delete_vpc() { + local region="$1" + local vpc_id="$2" - # Get VPC IDs for VPCs named "andaime-vpc" - vpc_ids=$(aws ec2 describe-vpcs \ + echo "[$region] Processing VPC: $vpc_id" + + if ! $FORCE; then + read -p "[$region] Are you sure you want to delete VPC $vpc_id and all its resources? (y/N) " confirm + if [[ $confirm != [yY] ]]; then + echo "[$region] Skipping VPC $vpc_id" + return + fi + fi + + # 1. Terminate all EC2 instances first and wait + instance_ids=$(aws --no-cli-pager ec2 describe-instances \ --region $region \ - --filters "Name=tag:Name,Values=andaime-vpc*" \ - --query 'Vpcs[*].VpcId' \ + --filters "Name=vpc-id,Values=$vpc_id" "Name=instance-state-name,Values=running,stopped,pending,stopping" \ + --query 'Reservations[].Instances[].InstanceId' \ --output text) - # If no VPCs found, continue to next region - if [ -z "$vpc_ids" ]; then - echo "No matching VPCs found in $region" - continue + if [ ! -z "$instance_ids" ]; then + echo "[$region] Terminating EC2 instances: $instance_ids" + execute_aws_command "aws ec2 terminate-instances --region $region --instance-ids $instance_ids" + wait_for_instances "$region" "$instance_ids" fi + + # 2. Delete ELBs + elb_names=$(aws --no-cli-pager elb describe-load-balancers \ + --region $region \ + --query "LoadBalancerDescriptions[?VPCId=='$vpc_id'].LoadBalancerName" \ + --output text) - # Process each VPC - for vpc_id in $vpc_ids; do - echo "Processing VPC: $vpc_id in region $region" - - # Delete all dependent resources first - - # 1. Delete NAT Gateways - nat_gateway_ids=$(aws ec2 describe-nat-gateways \ - --region $region \ - --filter "Name=vpc-id,Values=$vpc_id" \ - --query 'NatGateways[*].NatGatewayId' \ - --output text) - - for nat_id in $nat_gateway_ids; do - echo "Deleting NAT Gateway: $nat_id" - execute_aws_command "aws ec2 delete-nat-gateway --region $region --nat-gateway-id $nat_id" - done - - # 2. Delete Internet Gateways - igw_ids=$(aws ec2 describe-internet-gateways \ - --region $region \ - --filters "Name=attachment.vpc-id,Values=$vpc_id" \ - --query 'InternetGateways[*].InternetGatewayId' \ - --output text) - - for igw_id in $igw_ids; do - echo "Detaching and deleting Internet Gateway: $igw_id" - execute_aws_command "aws ec2 detach-internet-gateway --region $region --internet-gateway-id $igw_id --vpc-id $vpc_id" - execute_aws_command "aws ec2 delete-internet-gateway --region $region --internet-gateway-id $igw_id" - done - - # 3. Delete Subnets - subnet_ids=$(aws ec2 describe-subnets \ - --region $region \ - --filters "Name=vpc-id,Values=$vpc_id" \ - --query 'Subnets[*].SubnetId' \ - --output text) - - for subnet_id in $subnet_ids; do - echo "Deleting Subnet: $subnet_id" - execute_aws_command "aws ec2 delete-subnet --region $region --subnet-id $subnet_id" - done - - # 4. Delete Route Tables (except main) - rt_ids=$(aws ec2 describe-route-tables \ - --region $region \ - --filters "Name=vpc-id,Values=$vpc_id" \ - --query 'RouteTables[?Associations[0].Main != `true`].RouteTableId' \ - --output text) - - for rt_id in $rt_ids; do - echo "Deleting Route Table: $rt_id" - execute_aws_command "aws ec2 delete-route-table --region $region --route-table-id $rt_id" - done - - # 5. Delete Security Groups (except default) - sg_ids=$(aws ec2 describe-security-groups \ + for elb in $elb_names; do + echo "[$region] Deleting ELB: $elb" + execute_aws_command "aws elb delete-load-balancer --region $region --load-balancer-name $elb" + done + + # 3. Delete ALBs/NLBs + alb_arns=$(aws --no-cli-pager elbv2 describe-load-balancers \ + --region $region \ + --query "LoadBalancers[?VpcId=='$vpc_id'].LoadBalancerArn" \ + --output text) + + for alb in $alb_arns; do + echo "[$region] Deleting ALB/NLB: $alb" + execute_aws_command "aws elbv2 delete-load-balancer --region $region --load-balancer-arn $alb" + done + + # 4. Delete NAT Gateways + nat_gateway_ids=$(aws --no-cli-pager ec2 describe-nat-gateways \ + --region $region \ + --filter "Name=vpc-id,Values=$vpc_id" \ + --query 'NatGateways[*].NatGatewayId' \ + --output text) + + for nat_id in $nat_gateway_ids; do + echo "[$region] Deleting NAT Gateway: $nat_id" + execute_aws_command "aws ec2 delete-nat-gateway --region $region --nat-gateway-id $nat_id" + done + + # 5. Delete Network Interfaces + eni_ids=$(aws --no-cli-pager ec2 describe-network-interfaces \ + --region $region \ + --filters "Name=vpc-id,Values=$vpc_id" \ + --query 'NetworkInterfaces[*].NetworkInterfaceId' \ + --output text) + + for eni_id in $eni_ids; do + echo "[$region] Deleting Network Interface: $eni_id" + execute_aws_command "aws ec2 delete-network-interface --region $region --network-interface-id $eni_id" + done + + # 6. Detach and delete Internet Gateways + igw_ids=$(aws --no-cli-pager ec2 describe-internet-gateways \ + --region $region \ + --filters "Name=attachment.vpc-id,Values=$vpc_id" \ + --query 'InternetGateways[*].InternetGatewayId' \ + --output text) + + for igw_id in $igw_ids; do + echo "[$region] Detaching Internet Gateway: $igw_id" + execute_aws_command "aws ec2 detach-internet-gateway --region $region --internet-gateway-id $igw_id --vpc-id $vpc_id" + echo "[$region] Deleting Internet Gateway: $igw_id" + execute_aws_command "aws ec2 delete-internet-gateway --region $region --internet-gateway-id $igw_id" + done + + # 7. Delete Route Table associations and Routes + rt_ids=$(aws --no-cli-pager ec2 describe-route-tables \ + --region $region \ + --filters "Name=vpc-id,Values=$vpc_id" \ + --query 'RouteTables[?Associations[0].Main != `true`].RouteTableId' \ + --output text) + + for rt_id in $rt_ids; do + # Delete non-main route table associations + assoc_ids=$(aws --no-cli-pager ec2 describe-route-tables \ --region $region \ - --filters "Name=vpc-id,Values=$vpc_id" \ - --query 'SecurityGroups[?GroupName != `default`].GroupId' \ + --route-table-ids $rt_id \ + --query 'RouteTables[*].Associations[?!Main].RouteTableAssociationId' \ --output text) - for sg_id in $sg_ids; do - echo "Deleting Security Group: $sg_id" - execute_aws_command "aws ec2 delete-security-group --region $region --group-id $sg_id" + for assoc_id in $assoc_ids; do + echo "[$region] Deleting Route Table association: $assoc_id" + execute_aws_command "aws ec2 disassociate-route-table --region $region --association-id $assoc_id" done - - # Finally, delete the VPC - echo "Deleting VPC: $vpc_id" - execute_aws_command "aws ec2 delete-vpc --region $region --vpc-id $vpc_id" + + # Delete routes + echo "[$region] Deleting routes from Route Table: $rt_id" + execute_aws_command "aws ec2 delete-route --region $region --route-table-id $rt_id --destination-cidr-block 0.0.0.0/0" done + + # 8. Delete Subnets + subnet_ids=$(aws --no-cli-pager ec2 describe-subnets \ + --region $region \ + --filters "Name=vpc-id,Values=$vpc_id" \ + --query 'Subnets[*].SubnetId' \ + --output text) + + for subnet_id in $subnet_ids; do + echo "[$region] Deleting Subnet: $subnet_id" + execute_aws_command "aws ec2 delete-subnet --region $region --subnet-id $subnet_id" + done + + # 9. Delete Route Tables + for rt_id in $rt_ids; do + echo "[$region] Deleting Route Table: $rt_id" + execute_aws_command "aws ec2 delete-route-table --region $region --route-table-id $rt_id" + done + + # 10. Delete Security Groups + sg_ids=$(aws --no-cli-pager ec2 describe-security-groups \ + --region $region \ + --filters "Name=vpc-id,Values=$vpc_id" \ + --query 'SecurityGroups[?GroupName != `default`].GroupId' \ + --output text) + + for sg_id in $sg_ids; do + echo "[$region] Deleting Security Group: $sg_id" + execute_aws_command "aws ec2 delete-security-group --region $region --group-id $sg_id" + done + + # 11. Delete the VPC + echo "[$region] Deleting VPC: $vpc_id" + execute_aws_command "aws ec2 delete-vpc --region $region --vpc-id $vpc_id" + + echo "[$region] Initiated deletion of VPC $vpc_id and its dependencies" +} + +# Export variables and functions for parallel execution +export -f delete_vpc execute_aws_command wait_for_instances +export DRY_RUN FORCE MAX_RETRIES + +# Get list of all AWS regions +regions=$(aws --no-cli-pager ec2 describe-regions --query 'Regions[*].RegionName' --output text) + +# Create a temporary file to store region/VPC pairs +temp_file=$(mktemp) +trap 'rm -f $temp_file' EXIT + +# Collect all region/VPC pairs +for region in $regions; do + echo "Checking region: $region" + + # Get VPCs with either the Name tag or andaime tag + vpc_ids=$(aws --no-cli-pager ec2 describe-vpcs \ + --region $region \ + --filters \ + "Name=tag:andaime,Values=true" \ + --query 'Vpcs[*].VpcId' \ + --output text) + + if [ ! -z "$vpc_ids" ]; then + for vpc_id in $vpc_ids; do + echo "$region $vpc_id" >> $temp_file + done + fi done -echo "VPC deletion process completed" +# If no VPCs found, exit +if [ ! -s $temp_file ]; then + echo "No VPCs found to delete" + exit 0 +fi + +echo "Found the following VPCs to delete:" +cat $temp_file + +if ! $FORCE; then + read -p "Do you want to proceed with deletion? (y/N) " confirm + if [[ $confirm != [yY] ]]; then + echo "Aborting deletion" + exit 0 + fi +fi + +# Process all regions in parallel using xargs +echo "Starting parallel deletion across regions..." +cat $temp_file | xargs -P 8 -L 1 bash -c 'delete_vpc "$0" "$1"' + +echo "VPC deletion process initiated across all regions" diff --git a/internal/testdata/aws.go b/internal/testdata/aws.go index 27c60b84..19a82520 100644 --- a/internal/testdata/aws.go +++ b/internal/testdata/aws.go @@ -170,6 +170,16 @@ func FakeEC2CreateInternetGatewayOutput() *ec2.CreateInternetGatewayOutput { } } +func FakeEC2DescribeInternetGatewaysOutput() *ec2.DescribeInternetGatewaysOutput { + return &ec2.DescribeInternetGatewaysOutput{ + InternetGateways: []types.InternetGateway{ + { + InternetGatewayId: aws.String("igw-12345"), + }, + }, + } +} + func FakeEC2AttachInternetGatewayOutput() *ec2.AttachInternetGatewayOutput { return &ec2.AttachInternetGatewayOutput{} } diff --git a/mocks/aws/mock_EC2Clienter.go b/mocks/aws/mock_EC2Clienter.go index 94a6146f..14c9f43e 100644 --- a/mocks/aws/mock_EC2Clienter.go +++ b/mocks/aws/mock_EC2Clienter.go @@ -762,6 +762,80 @@ func (_c *MockEC2Clienter_DeleteInternetGateway_Call) RunAndReturn(run func(cont return _c } +// DeleteNetworkInterface provides a mock function with given fields: ctx, params, optFns +func (_m *MockEC2Clienter) DeleteNetworkInterface(ctx context.Context, params *ec2.DeleteNetworkInterfaceInput, optFns ...func(*ec2.Options)) (*ec2.DeleteNetworkInterfaceOutput, error) { + _va := make([]interface{}, len(optFns)) + for _i := range optFns { + _va[_i] = optFns[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DeleteNetworkInterface") + } + + var r0 *ec2.DeleteNetworkInterfaceOutput + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteNetworkInterfaceInput, ...func(*ec2.Options)) (*ec2.DeleteNetworkInterfaceOutput, error)); ok { + return rf(ctx, params, optFns...) + } + if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteNetworkInterfaceInput, ...func(*ec2.Options)) *ec2.DeleteNetworkInterfaceOutput); ok { + r0 = rf(ctx, params, optFns...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*ec2.DeleteNetworkInterfaceOutput) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *ec2.DeleteNetworkInterfaceInput, ...func(*ec2.Options)) error); ok { + r1 = rf(ctx, params, optFns...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockEC2Clienter_DeleteNetworkInterface_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteNetworkInterface' +type MockEC2Clienter_DeleteNetworkInterface_Call struct { + *mock.Call +} + +// DeleteNetworkInterface is a helper method to define mock.On call +// - ctx context.Context +// - params *ec2.DeleteNetworkInterfaceInput +// - optFns ...func(*ec2.Options) +func (_e *MockEC2Clienter_Expecter) DeleteNetworkInterface(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DeleteNetworkInterface_Call { + return &MockEC2Clienter_DeleteNetworkInterface_Call{Call: _e.mock.On("DeleteNetworkInterface", + append([]interface{}{ctx, params}, optFns...)...)} +} + +func (_c *MockEC2Clienter_DeleteNetworkInterface_Call) Run(run func(ctx context.Context, params *ec2.DeleteNetworkInterfaceInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DeleteNetworkInterface_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]func(*ec2.Options), len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(func(*ec2.Options)) + } + } + run(args[0].(context.Context), args[1].(*ec2.DeleteNetworkInterfaceInput), variadicArgs...) + }) + return _c +} + +func (_c *MockEC2Clienter_DeleteNetworkInterface_Call) Return(_a0 *ec2.DeleteNetworkInterfaceOutput, _a1 error) *MockEC2Clienter_DeleteNetworkInterface_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockEC2Clienter_DeleteNetworkInterface_Call) RunAndReturn(run func(context.Context, *ec2.DeleteNetworkInterfaceInput, ...func(*ec2.Options)) (*ec2.DeleteNetworkInterfaceOutput, error)) *MockEC2Clienter_DeleteNetworkInterface_Call { + _c.Call.Return(run) + return _c +} + // DeleteRouteTable provides a mock function with given fields: ctx, params, optFns func (_m *MockEC2Clienter) DeleteRouteTable(ctx context.Context, params *ec2.DeleteRouteTableInput, optFns ...func(*ec2.Options)) (*ec2.DeleteRouteTableOutput, error) { _va := make([]interface{}, len(optFns)) @@ -1354,6 +1428,80 @@ func (_c *MockEC2Clienter_DescribeInternetGateways_Call) RunAndReturn(run func(c return _c } +// DescribeNetworkInterfaces provides a mock function with given fields: ctx, params, optFns +func (_m *MockEC2Clienter) DescribeNetworkInterfaces(ctx context.Context, params *ec2.DescribeNetworkInterfacesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeNetworkInterfacesOutput, error) { + _va := make([]interface{}, len(optFns)) + for _i := range optFns { + _va[_i] = optFns[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, params) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for DescribeNetworkInterfaces") + } + + var r0 *ec2.DescribeNetworkInterfacesOutput + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeNetworkInterfacesInput, ...func(*ec2.Options)) (*ec2.DescribeNetworkInterfacesOutput, error)); ok { + return rf(ctx, params, optFns...) + } + if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeNetworkInterfacesInput, ...func(*ec2.Options)) *ec2.DescribeNetworkInterfacesOutput); ok { + r0 = rf(ctx, params, optFns...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*ec2.DescribeNetworkInterfacesOutput) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *ec2.DescribeNetworkInterfacesInput, ...func(*ec2.Options)) error); ok { + r1 = rf(ctx, params, optFns...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockEC2Clienter_DescribeNetworkInterfaces_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DescribeNetworkInterfaces' +type MockEC2Clienter_DescribeNetworkInterfaces_Call struct { + *mock.Call +} + +// DescribeNetworkInterfaces is a helper method to define mock.On call +// - ctx context.Context +// - params *ec2.DescribeNetworkInterfacesInput +// - optFns ...func(*ec2.Options) +func (_e *MockEC2Clienter_Expecter) DescribeNetworkInterfaces(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DescribeNetworkInterfaces_Call { + return &MockEC2Clienter_DescribeNetworkInterfaces_Call{Call: _e.mock.On("DescribeNetworkInterfaces", + append([]interface{}{ctx, params}, optFns...)...)} +} + +func (_c *MockEC2Clienter_DescribeNetworkInterfaces_Call) Run(run func(ctx context.Context, params *ec2.DescribeNetworkInterfacesInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DescribeNetworkInterfaces_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]func(*ec2.Options), len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(func(*ec2.Options)) + } + } + run(args[0].(context.Context), args[1].(*ec2.DescribeNetworkInterfacesInput), variadicArgs...) + }) + return _c +} + +func (_c *MockEC2Clienter_DescribeNetworkInterfaces_Call) Return(_a0 *ec2.DescribeNetworkInterfacesOutput, _a1 error) *MockEC2Clienter_DescribeNetworkInterfaces_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockEC2Clienter_DescribeNetworkInterfaces_Call) RunAndReturn(run func(context.Context, *ec2.DescribeNetworkInterfacesInput, ...func(*ec2.Options)) (*ec2.DescribeNetworkInterfacesOutput, error)) *MockEC2Clienter_DescribeNetworkInterfaces_Call { + _c.Call.Return(run) + return _c +} + // DescribeRegions provides a mock function with given fields: ctx, params, optFns func (_m *MockEC2Clienter) DescribeRegions(ctx context.Context, params *ec2.DescribeRegionsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeRegionsOutput, error) { _va := make([]interface{}, len(optFns)) diff --git a/pkg/models/deployment.go b/pkg/models/deployment.go index 774656d0..2658c013 100644 --- a/pkg/models/deployment.go +++ b/pkg/models/deployment.go @@ -431,14 +431,26 @@ func (r *RegionalResources) RUnlock() { } func (r *RegionalResources) GetVPC(region string) *AWSVPC { - r.Lock() - defer r.Unlock() + r.RLock() + defer r.RUnlock() if r.VPCs == nil { r.VPCs = make(map[string]*AWSVPC) } return r.VPCs[region] } +func (r *RegionalResources) UpdateVPC( + deployment *Deployment, + region string, + updateFn func(*AWSVPC) error, +) error { + vpc := r.GetVPC(region) + if vpc == nil { + return fmt.Errorf("VPC not found for region %s", region) + } + return updateFn(vpc) +} + func (r *RegionalResources) SetVPC(region string, vpc *AWSVPC) { r.Lock() defer r.Unlock() @@ -482,6 +494,18 @@ func (r *RegionalResources) GetRegions() []string { return regions } +// SaveVPCConfig saves VPC configuration to viper +func (rm *RegionalResources) SaveVPCConfig( + deployment *Deployment, + region string, + vpc *AWSVPC, +) error { + deploymentPath := fmt.Sprintf("deployments.%s", deployment.UniqueID) + viper.Set(fmt.Sprintf("%s.aws.regions.%s.vpc_id", deploymentPath, region), vpc.VPCID) + + return viper.WriteConfig() +} + type RegionalVPC struct { VPCID string Region string diff --git a/pkg/providers/aws/aws_compute_operations.go b/pkg/providers/aws/aws_compute_operations.go index 98322a5e..8f6a9404 100644 --- a/pkg/providers/aws/aws_compute_operations.go +++ b/pkg/providers/aws/aws_compute_operations.go @@ -2,6 +2,7 @@ package aws import ( "context" + "encoding/base64" "fmt" "time" @@ -16,11 +17,22 @@ import ( "golang.org/x/sync/errgroup" ) -const MinRequiredAZs = 2 - // UNKNOWN represents an unknown value in AWS responses const UNKNOWN = "unknown" +// Network configuration constants +const ( + VPCCidrBlock = "10.0.0.0/16" + PublicSubnet1CIDR = "10.0.0.0/24" + PublicSubnet2CIDR = "10.0.1.0/24" + PrivateSubnet1CIDR = "10.0.2.0/24" + PrivateSubnet2CIDR = "10.0.3.0/24" + MinRequiredAZs = 2 + SSHRetryInterval = 10 * time.Second + MaxRetries = 30 + TimeToWaitForInstance = 5 * time.Minute +) + // LiveEC2Client implements the EC2Clienter interface type LiveEC2Client struct { client *ec2.Client @@ -259,11 +271,6 @@ func (c *LiveEC2Client) DeleteInternetGateway( return c.client.DeleteInternetGateway(ctx, params, optFns...) } -const ( - SSHRetryInterval = 10 * time.Second - MaxRetries = 30 -) - func (p *AWSProvider) DeployVMsInParallel( ctx context.Context, ) error { @@ -315,7 +322,7 @@ func (p *AWSProvider) DeployVMsInParallel( } // Create EC2 client for the region - ec2Client, err := p.getOrCreateEC2Client(ctx, region) + regionalClient, err := p.getOrCreateEC2Client(ctx, region) if err != nil { return fmt.Errorf("failed to create EC2 client for region %s: %w", region, err) } @@ -323,7 +330,7 @@ func (p *AWSProvider) DeployVMsInParallel( // Deploy machines in parallel within each region for _, machine := range machines { eg.Go(func() error { - if err := p.deployVM(ctx, ec2Client, machine, vpc); err != nil { + if err := p.deployVM(ctx, regionalClient, machine, vpc); err != nil { return fmt.Errorf( "failed to deploy VM %s in region %s: %w", machine.GetName(), @@ -349,37 +356,104 @@ func (p *AWSProvider) deployVM( machine models.Machiner, vpc *models.AWSVPC, ) error { + l := logger.Get() + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return fmt.Errorf("global model or deployment is nil") + } + + // Validate VPC configuration + if vpc == nil { + return fmt.Errorf("vpc is nil") + } + if len(vpc.PublicSubnetIDs) == 0 { + return fmt.Errorf("no public subnets available in VPC %s", vpc.VPCID) + } + if vpc.SecurityGroupID == "" { + return fmt.Errorf("no security group ID set for VPC %s", vpc.VPCID) + } + // Get AMI ID for the region - amiID, err := p.getLatestAMI(ctx, ec2Client) + amiID, err := p.GetLatestUbuntuAMI(ctx, machine.GetRegion(), "x86_64") if err != nil { return fmt.Errorf("failed to get latest AMI: %w", err) } + // Use the first public subnet + subnetID := vpc.PublicSubnetIDs[0] + l.Debug(fmt.Sprintf("Using subnet %s for VM %s", subnetID, machine.GetName())) + + var tagSpecs []ec2_types.TagSpecification + for k, v := range m.Deployment.Tags { + tagSpecs = append(tagSpecs, ec2_types.TagSpecification{ + ResourceType: ec2_types.ResourceTypeInstance, + Tags: []ec2_types.Tag{{Key: aws.String(k), Value: aws.String(v)}}, + }) + } + + tagSpecs = append(tagSpecs, ec2_types.TagSpecification{ + ResourceType: ec2_types.ResourceTypeInstance, + Tags: []ec2_types.Tag{ + {Key: aws.String("Name"), Value: aws.String(machine.GetName())}, + }, + }) + + userData := fmt.Sprintf(`#!/bin/bash +SSH_USERNAME=%s +SSH_PUBLIC_KEY_MATERIAL="%s" + +useradd -m -s /bin/bash $SSH_USERNAME +passwd -l $SSH_USERNAME +mkdir -p /home/$SSH_USERNAME/.ssh +echo "$SSH_PUBLIC_KEY_MATERIAL" > /root/root.pub +cat /root/root.pub >> /home/$SSH_USERNAME/.ssh/authorized_keys + +chown -R $SSH_USERNAME:$SSH_USERNAME /home/$SSH_USERNAME/.ssh +chmod 700 /home/$SSH_USERNAME/.ssh +chmod 600 /home/$SSH_USERNAME/.ssh/authorized_keys +usermod -aG sudo $SSH_USERNAME + +# Add $SSH_USERNAME to the sudoers file +echo "$SSH_USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers`, + machine.GetSSHUser(), + machine.GetSSHPublicKeyMaterial(), + ) + + // Encode the script in base64 + encodedUserData := base64.StdEncoding.EncodeToString([]byte(userData)) + + // runResult, err := c.ec2Client.RunInstances(ctx, &ec2.RunInstancesInput{ + // ImageId: aws.String(c.cfg.ImageID), + // InstanceType: types.InstanceType(quote.InstanceType.Name), + // MinCount: aws.Int32(1), + // MaxCount: aws.Int32(1), + // SubnetId: aws.String(c.cfg.SubnetID), + // KeyName: aws.String(c.cfg.SSHKeyName), + // InstanceMarketOptions: &types.InstanceMarketOptionsRequest{ + // MarketType: types.MarketTypeSpot, + // SpotOptions: &types.SpotMarketOptions{ + // InstanceInterruptionBehavior: types.InstanceInterruptionBehaviorTerminate, + // SpotInstanceType: types.SpotInstanceTypeOneTime, + // }, + // }, + // UserData: aws.String(encodedUserData), + // Create instance runResult, err := ec2Client.RunInstances(ctx, &ec2.RunInstancesInput{ ImageId: aws.String(amiID), - InstanceType: ec2_types.InstanceTypeT2Micro, + InstanceType: ec2_types.InstanceTypeT2Medium, MinCount: aws.Int32(1), MaxCount: aws.Int32(1), NetworkInterfaces: []ec2_types.InstanceNetworkInterfaceSpecification{ { DeviceIndex: aws.Int32(0), - SubnetId: aws.String(vpc.SubnetID), + SubnetId: aws.String(subnetID), Groups: []string{vpc.SecurityGroupID}, AssociatePublicIpAddress: aws.Bool(true), }, }, - TagSpecifications: []ec2_types.TagSpecification{ - { - ResourceType: ec2_types.ResourceTypeInstance, - Tags: []ec2_types.Tag{ - { - Key: aws.String("Name"), - Value: aws.String(machine.GetName()), - }, - }, - }, - }, + TagSpecifications: tagSpecs, + UserData: aws.String(encodedUserData), }) if err != nil { return fmt.Errorf("failed to run instance: %w", err) @@ -389,7 +463,7 @@ func (p *AWSProvider) deployVM( waiter := ec2.NewInstanceRunningWaiter(ec2Client) if err := waiter.Wait(ctx, &ec2.DescribeInstancesInput{ InstanceIds: []string{*runResult.Instances[0].InstanceId}, - }, 5*time.Minute); err != nil { + }, TimeToWaitForInstance); err != nil { return fmt.Errorf("failed waiting for instance to be running: %w", err) } diff --git a/pkg/providers/aws/integration_test.go b/pkg/providers/aws/integration_test.go index a08ba7d6..e1d0f5e1 100644 --- a/pkg/providers/aws/integration_test.go +++ b/pkg/providers/aws/integration_test.go @@ -42,24 +42,6 @@ mockEC2Client.On("DescribeAvailabilityZones", mock.Anything, mock.Anything).Retu RegionName: aws.String("us-east-1"), State: types.AvailabilityZoneStateAvailable, }, - { - ZoneName: aws.String("us-west-1a"), - ZoneType: aws.String("availability-zone"), - RegionName: aws.String("us-west-1"), - State: types.AvailabilityZoneStateAvailable, - }, - { - ZoneName: aws.String("us-west-1b"), - ZoneType: aws.String("availability-zone"), - RegionName: aws.String("us-west-1"), - State: types.AvailabilityZoneStateAvailable, - }, - { - ZoneName: aws.String("us-west-1c"), - ZoneType: aws.String("availability-zone"), - RegionName: aws.String("us-west-1"), - State: types.AvailabilityZoneStateAvailable, - }, }, }, nil) @@ -97,52 +79,3 @@ func TestIntegrationCreateAndDestroyInfrastructure(t *testing.T) { assert.NoError(t, err) assert.False(t, vpcExists) } - -func verifyVPCExists(ctx context.Context, provider *AWSProvider) (bool, error) { - if provider.EC2Client == nil { - return false, nil - } - - input := &ec2.DescribeVpcsInput{ - VpcIds: []string{provider.VPCID}, - } - - result, err := provider.EC2Client.DescribeVpcs(ctx, input) - if err != nil { - return false, err - } - - return len(result.Vpcs) > 0, nil -} - -func verifyNetworkConnectivity(ctx context.Context, provider *AWSProvider) (bool, error) { - if provider.EC2Client == nil { - return false, nil - } - - // Verify subnets can route to internet gateway - input := &ec2.DescribeRouteTablesInput{ - Filters: []types.Filter{ - { - Name: aws.String("vpc-id"), - Value: []string{provider.VPCID}, - }, - }, - } - - result, err := provider.EC2Client.DescribeRouteTables(ctx, input) - if err != nil { - return false, err - } - - // Check if route table has internet gateway route - for _, rt := range result.RouteTables { - for _, route := range rt.Routes { - if route.GatewayId != nil && *route.GatewayId != "" { - return true, nil - } - } - } - - return false, nil -} diff --git a/pkg/providers/aws/provider.go b/pkg/providers/aws/provider.go index 9218dc20..6b4b95e6 100644 --- a/pkg/providers/aws/provider.go +++ b/pkg/providers/aws/provider.go @@ -39,32 +39,6 @@ const ( LengthOfDeploymentIDSuffix = 8 ) -type VPCState struct { - mu sync.RWMutex - vpc *models.AWSVPC - lastUpdated time.Time -} - -// RegionalVPCManager handles VPC operations across regions -type RegionalVPCManager struct { - states map[string]*VPCState // region -> state - mu sync.RWMutex - deployment *models.Deployment - ec2Client aws_interface.EC2Clienter -} - -// NewRegionalVPCManager creates a new VPC manager -func NewRegionalVPCManager( - deployment *models.Deployment, - ec2Client aws_interface.EC2Clienter, -) *RegionalVPCManager { - return &RegionalVPCManager{ - states: make(map[string]*VPCState), - deployment: deployment, - ec2Client: ec2Client, - } -} - type DeploymentInfo struct { ID string Region string @@ -97,7 +71,6 @@ type AWSProvider struct { EC2Client aws_interface.EC2Clienter STSClient *sts.Client ConfigMutex sync.RWMutex - vpcManager *RegionalVPCManager } var NewAWSProviderFunc = NewAWSProvider @@ -480,6 +453,11 @@ func (p *AWSProvider) createSecurityGroup( region, vpcID string, ec2Client aws_interface.EC2Clienter, ) (string, error) { + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return "", fmt.Errorf("global model or deployment is nil") + } + sgResult, err := ec2Client.CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{ GroupName: aws.String(fmt.Sprintf("andaime-sg-%s", region)), Description: aws.String("Security group for Andaime instances"), @@ -501,17 +479,36 @@ func (p *AWSProvider) createSecurityGroup( } // Add security group rules - ipPermissions := []ec2_types.IpPermission{} - for _, port := range p.vpcManager.deployment.AllowedPorts { + for _, port := range m.Deployment.AllowedPorts { ipPermissions = append(ipPermissions, ec2_types.IpPermission{ IpProtocol: aws.String("tcp"), FromPort: aws.Int32(validatePort(port)), ToPort: aws.Int32(validatePort(port)), - IpRanges: []ec2_types.IpRange{{CidrIp: aws.String("0.0.0.0/0")}}, + IpRanges: []ec2_types.IpRange{ + { + CidrIp: aws.String("0.0.0.0/0"), + Description: aws.String( + fmt.Sprintf("Allow inbound TCP traffic on port %d", port), + ), + }, + }, }) } + // Also allow all outbound traffic + ipPermissions = append(ipPermissions, ec2_types.IpPermission{ + IpProtocol: aws.String("-1"), // All protocols + FromPort: aws.Int32(-1), // All ports + ToPort: aws.Int32(-1), // All ports + IpRanges: []ec2_types.IpRange{ + { + CidrIp: aws.String("0.0.0.0/0"), + Description: aws.String("Allow all outbound traffic"), + }, + }, + }) + _, err = ec2Client.AuthorizeSecurityGroupIngress(ctx, &ec2.AuthorizeSecurityGroupIngressInput{ GroupId: sgResult.GroupId, IpPermissions: ipPermissions, @@ -536,7 +533,12 @@ func (p *AWSProvider) createVPCInfrastructure( region string, ) (*models.AWSVPC, error) { l := logger.Get() - l.Infof("Creating VPC infrastructure in region %s", region) + l.Debugf("Creating VPC infrastructure in region %s", region) + + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return nil, fmt.Errorf("global model or deployment is nil") + } // Create EC2 client for the region regionalClient, err := p.getOrCreateEC2Client(ctx, region) @@ -546,7 +548,7 @@ func (p *AWSProvider) createVPCInfrastructure( } // Generate a unique deployment ID for tracking - deploymentID := fmt.Sprintf("andaime-%s", generateRandomString(LengthOfDeploymentIDSuffix)) + deploymentID := m.Deployment.UniqueID // Create VPC with CIDR block and enhanced tagging vpcOut, err := regionalClient.CreateVpc(ctx, &ec2.CreateVpcInput{ @@ -557,7 +559,7 @@ func (p *AWSProvider) createVPCInfrastructure( Tags: []ec2_types.Tag{ { Key: aws.String("Name"), - Value: aws.String("andaime-vpc"), + Value: aws.String(fmt.Sprintf("andaime-vpc-%s", region)), }, { Key: aws.String("andaime"), @@ -582,18 +584,23 @@ func (p *AWSProvider) createVPCInfrastructure( l.Infof("Created VPC %s in region %s", *vpcOut.Vpc.VpcId, region) - // Create security group with enhanced tagging - sgOut, err := regionalClient.CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{ - GroupName: aws.String("andaime-sg"), - Description: aws.String("Security group for Andaime deployment"), - VpcId: vpcOut.Vpc.VpcId, + // Create VPC object + vpc := &models.AWSVPC{ + VPCID: *vpcOut.Vpc.VpcId, + } + + // Create security group + sgResult, err := regionalClient.CreateSecurityGroup(ctx, &ec2.CreateSecurityGroupInput{ + GroupName: aws.String(fmt.Sprintf("andaime-sg-%s", region)), + Description: aws.String("Security group for Andaime instances"), + VpcId: aws.String(vpc.VPCID), TagSpecifications: []ec2_types.TagSpecification{ { ResourceType: ec2_types.ResourceTypeSecurityGroup, Tags: []ec2_types.Tag{ { Key: aws.String("Name"), - Value: aws.String("andaime-sg"), + Value: aws.String(fmt.Sprintf("andaime-sg-%s", region)), }, { Key: aws.String("andaime"), @@ -603,75 +610,89 @@ func (p *AWSProvider) createVPCInfrastructure( Key: aws.String("andaime-deployment-id"), Value: aws.String(deploymentID), }, - { - Key: aws.String("andaime-region"), - Value: aws.String(region), - }, }, }, }, }) if err != nil { - l.Errorf("Failed to create security group in VPC %s: %v", *vpcOut.Vpc.VpcId, err) + l.Errorf("Failed to create security group in region %s: %v", region, err) return nil, fmt.Errorf("failed to create security group: %w", err) } - l.Infof("Created security group %s in VPC %s", *sgOut.GroupId, *vpcOut.Vpc.VpcId) + // Add security group rules for allowed ports + ipPermissions := []ec2_types.IpPermission{} + for _, port := range m.Deployment.AllowedPorts { + ipPermissions = append(ipPermissions, ec2_types.IpPermission{ + IpProtocol: aws.String("tcp"), + FromPort: aws.Int32(validatePort(port)), + ToPort: aws.Int32(validatePort(port)), + IpRanges: []ec2_types.IpRange{ + { + CidrIp: aws.String("0.0.0.0/0"), + Description: aws.String( + fmt.Sprintf("Allow inbound TCP traffic on port %d", port), + ), + }, + }, + }) + } + + // Also allow all outbound traffic + ipPermissions = append(ipPermissions, ec2_types.IpPermission{ + IpProtocol: aws.String("-1"), // All protocols + FromPort: aws.Int32(-1), // All ports + ToPort: aws.Int32(-1), // All ports + IpRanges: []ec2_types.IpRange{ + { + CidrIp: aws.String("0.0.0.0/0"), + Description: aws.String("Allow all outbound traffic"), + }, + }, + }) - // Allow inbound traffic _, err = regionalClient.AuthorizeSecurityGroupIngress( ctx, &ec2.AuthorizeSecurityGroupIngressInput{ - GroupId: sgOut.GroupId, - IpPermissions: []ec2_types.IpPermission{ - { - IpProtocol: aws.String("-1"), - FromPort: aws.Int32(-1), - ToPort: aws.Int32(-1), - IpRanges: []ec2_types.IpRange{ - { - CidrIp: aws.String("0.0.0.0/0"), - }, - }, - }, - }, + GroupId: sgResult.GroupId, + IpPermissions: ipPermissions, }, ) if err != nil { - l.Errorf("Failed to authorize security group ingress for group %s: %v", *sgOut.GroupId, err) + l.Errorf("Failed to authorize security group ingress in region %s: %v", region, err) return nil, fmt.Errorf("failed to authorize security group ingress: %w", err) } - l.Infof("Authorized security group ingress for %s", *sgOut.GroupId) - - // Create VPC object - vpc := &models.AWSVPC{ - VPCID: *vpcOut.Vpc.VpcId, - SecurityGroupID: *sgOut.GroupId, - } - - // Initialize VPC manager if not already done - if p.vpcManager == nil { - m := display.GetGlobalModelFunc() - if m == nil || m.Deployment == nil { - l.Error("Global model or deployment is nil") - return nil, fmt.Errorf("global model or deployment is nil") - } - p.vpcManager = NewRegionalVPCManager(m.Deployment, p.EC2Client) - } + // Save security group ID to VPC object + vpc.SecurityGroupID = *sgResult.GroupId - // Save VPC to regional resources - err = p.vpcManager.UpdateVPC(region, func(existingVPC *models.AWSVPC) error { - *existingVPC = *vpc - return nil - }) + // Save VPC to regional resources and config + err = m.Deployment.AWS.RegionalResources.UpdateVPC( + m.Deployment, + region, + func(existingVPC *models.AWSVPC) error { + *existingVPC = *vpc + return nil + }, + ) if err != nil { l.Errorf("Failed to save VPC %s to regional resources: %v", vpc.VPCID, err) return nil, fmt.Errorf("failed to save VPC to regional resources: %w", err) } - l.Infof("Successfully created and saved VPC %s in region %s", vpc.VPCID, region) + // Save to viper config + configPath := fmt.Sprintf("deployments.%s.aws.regions.%s", deploymentID, region) + viper.Set(fmt.Sprintf("%s.vpc_id", configPath), vpc.VPCID) + viper.Set(fmt.Sprintf("%s.security_group_id", configPath), vpc.SecurityGroupID) + if err := viper.WriteConfig(); err != nil { + l.Warnf("Failed to write VPC and security group IDs to config: %v", err) + } + l.Infof( + "Successfully created and saved VPC %s with security group %s in region %s", + vpc.VPCID, + vpc.SecurityGroupID, + region, + ) return vpc, nil } @@ -870,12 +891,6 @@ func (p *AWSProvider) CreateVpc(ctx context.Context, region string) error { if m == nil || m.Deployment == nil { return fmt.Errorf("global model or deployment is nil") } - - // Initialize VPC manager if needed - if p.vpcManager == nil { - p.vpcManager = NewRegionalVPCManager(m.Deployment, p.EC2Client) - } - // Get or create EC2 client for this region regionalClient, err := p.getOrCreateEC2Client(ctx, region) if err != nil { @@ -905,7 +920,11 @@ func (p *AWSProvider) CreateVpc(ctx context.Context, region string) error { p.updateVPCDisplayState(m, models.ResourceStateRunning) // Save VPC configuration - if err := p.vpcManager.SaveVPCConfig(region); err != nil { + if err := m.Deployment.AWS.RegionalResources.SaveVPCConfig( + m.Deployment, + region, + vpc, + ); err != nil { l.Warnf("Failed to save VPC configuration: %v", err) } @@ -1055,12 +1074,6 @@ func (p *AWSProvider) setupRegionalInfrastructure(ctx context.Context, region st l.Debugf("Current VPCs: %+v", m.Deployment.AWS.RegionalResources.VPCs) } - // Initialize VPC manager if needed - if p.vpcManager == nil { - l.Debug("Initializing VPC manager") - p.vpcManager = NewRegionalVPCManager(m.Deployment, p.EC2Client) - } - // Step 1: Get availability zones azs, err := p.getRegionAvailabilityZones(ctx, region) if err != nil { @@ -1077,10 +1090,7 @@ func (p *AWSProvider) setupRegionalInfrastructure(ctx context.Context, region st } // Get VPC state - state := p.vpcManager.GetOrCreateVPCState(region) - state.mu.RLock() - vpc := state.vpc - state.mu.RUnlock() + vpc := m.Deployment.AWS.RegionalResources.GetVPC(region) l.Debugf("VPC state after creation for region %s: %+v", region, vpc) @@ -1142,7 +1152,7 @@ func (p *AWSProvider) getRegionAvailabilityZones( // Create a regional EC2 client with extended timeout and retry configuration regionalCfg, err := awsconfig.LoadDefaultConfig( - ctx, + ctx, awsconfig.WithRegion(region), awsconfig.WithHTTPClient(&http.Client{ Timeout: 30 * time.Second, @@ -1155,7 +1165,11 @@ func (p *AWSProvider) getRegionAvailabilityZones( }), ) if err != nil { - return nil, fmt.Errorf("failed to load AWS config for region %s: detailed network diagnostics - %w", region, err) + return nil, fmt.Errorf( + "failed to load AWS config for region %s: detailed network diagnostics - %w", + region, + err, + ) } regionalClient := ec2.NewFromConfig(regionalCfg) @@ -1191,21 +1205,33 @@ func (p *AWSProvider) getRegionAvailabilityZones( // Enhanced error logging with network diagnostics netErr, ok := err.(net.Error) if ok { - l.Errorf("Network error getting AZs: timeout=%v, temporary=%v", netErr.Timeout(), netErr.Temporary()) + l.Errorf( + "Network error getting AZs: timeout=%v, temporary=%v", + netErr.Timeout(), + netErr.Temporary(), + ) } // Attempt to get system DNS configuration nsAddrs, _ := net.LookupNS(".") l.Debugf("System nameservers: %v", nsAddrs) - return nil, fmt.Errorf("comprehensive failure getting availability zones for region %s: network diagnostics included - %w", region, err) + return nil, fmt.Errorf( + "comprehensive failure getting availability zones for region %s: network diagnostics included - %w", + region, + err, + ) } if len(azOutput.AvailabilityZones) < MinRequiredAZs { return nil, fmt.Errorf("region %s does not have at least 2 availability zones", region) } - l.Debugf("Successfully retrieved %d availability zones for region %s", len(azOutput.AvailabilityZones), region) + l.Debugf( + "Successfully retrieved %d availability zones for region %s", + len(azOutput.AvailabilityZones), + region, + ) return azOutput.AvailabilityZones, nil } @@ -1223,19 +1249,7 @@ func (p *AWSProvider) createRegionalSubnets( return fmt.Errorf("deployment model not properly initialized") } - // Initialize VPC manager if needed - if p.vpcManager == nil { - p.vpcManager = NewRegionalVPCManager(m.Deployment, p.EC2Client) - } - - state := p.vpcManager.GetOrCreateVPCState(region) - if state == nil { - return fmt.Errorf("failed to get VPC state for region %s", region) - } - - state.mu.RLock() - vpc := state.vpc - state.mu.RUnlock() + vpc := m.Deployment.AWS.RegionalResources.GetVPC(region) if vpc == nil { return fmt.Errorf("VPC not found for region %s", region) @@ -1243,40 +1257,44 @@ func (p *AWSProvider) createRegionalSubnets( l.Debugf("Creating subnets in VPC %s", vpc.VPCID) - return p.vpcManager.UpdateVPC(region, func(vpc *models.AWSVPC) error { - for i, az := range azs { - // Create public subnet - l.Debugf("Creating public subnet in AZ %s", *az.ZoneName) - publicSubnet, err := p.createSubnet( - ctx, - region, - vpc.VPCID, - *az.ZoneName, - i*2, //nolint:mnd - "public", - ) - if err != nil { - return fmt.Errorf("failed to create public subnet: %w", err) - } - vpc.PublicSubnetIDs = append(vpc.PublicSubnetIDs, *publicSubnet.Subnet.SubnetId) + return m.Deployment.AWS.RegionalResources.UpdateVPC( + m.Deployment, + region, + func(vpc *models.AWSVPC) error { + for i, az := range azs { + // Create public subnet + l.Debugf("Creating public subnet in AZ %s", *az.ZoneName) + publicSubnet, err := p.createSubnet( + ctx, + region, + vpc.VPCID, + *az.ZoneName, + i*2, //nolint:mnd + "public", + ) + if err != nil { + return fmt.Errorf("failed to create public subnet: %w", err) + } + vpc.PublicSubnetIDs = append(vpc.PublicSubnetIDs, *publicSubnet.Subnet.SubnetId) - // Create private subnet - l.Debugf("Creating private subnet in AZ %s", *az.ZoneName) - privateSubnet, err := p.createSubnet( - ctx, - region, - vpc.VPCID, - *az.ZoneName, - i*2+1, - "private", - ) - if err != nil { - return fmt.Errorf("failed to create private subnet: %w", err) + // Create private subnet + l.Debugf("Creating private subnet in AZ %s", *az.ZoneName) + privateSubnet, err := p.createSubnet( + ctx, + region, + vpc.VPCID, + *az.ZoneName, + i*2+1, + "private", + ) + if err != nil { + return fmt.Errorf("failed to create private subnet: %w", err) + } + vpc.PrivateSubnetIDs = append(vpc.PrivateSubnetIDs, *privateSubnet.Subnet.SubnetId) } - vpc.PrivateSubnetIDs = append(vpc.PrivateSubnetIDs, *privateSubnet.Subnet.SubnetId) - } - return nil - }) + return nil + }, + ) } // Create a single subnet @@ -1325,178 +1343,149 @@ func (p *AWSProvider) setupNetworking(ctx context.Context, region string) error l := logger.Get() l.Debugf("Setting up networking for region %s", region) - if p.vpcManager == nil { - return fmt.Errorf("VPC manager not initialized") - } - // Create a context with a timeout to prevent indefinite waiting ctx, cancel := context.WithTimeout(ctx, 15*time.Minute) defer cancel() - // Get all VPCs for this region - vpcStates := p.vpcManager.GetAllVPCStates(region) - if len(vpcStates) == 0 { - l.Warn("No VPC states found for region") - return fmt.Errorf("no VPC states found for region %s", region) - } - m := display.GetGlobalModelFunc() if m == nil || m.Deployment == nil { return fmt.Errorf("global model or deployment is nil") } regionalClient := m.Deployment.AWS.RegionalResources.Clients[region] + vpc := m.Deployment.AWS.RegionalResources.GetVPC(region) - // Use errgroup to parallelize VPC networking setup with timeout - eg, ctx := errgroup.WithContext(ctx) - - for _, state := range vpcStates { - state := state // capture loop variable - eg.Go(func() error { - state.mu.RLock() - vpc := state.vpc - state.mu.RUnlock() - - if vpc == nil { - l.Warn("Skipping nil VPC in networking setup") - return nil - } - - l.Debugf("Setting up networking for VPC %s", vpc.VPCID) + l.Debugf("Setting up networking for VPC %s", vpc.VPCID) - // Verify VPC exists and is in a valid state - vpcDesc, err := regionalClient.DescribeVpcs(ctx, &ec2.DescribeVpcsInput{ - VpcIds: []string{vpc.VPCID}, - }) - if err != nil { - l.Errorf("Failed to describe VPC %s: %v", vpc.VPCID, err) - return fmt.Errorf("failed to describe VPC %s: %w", vpc.VPCID, err) - } - if len(vpcDesc.Vpcs) == 0 { - l.Errorf("VPC %s not found", vpc.VPCID) - return fmt.Errorf("VPC %s not found", vpc.VPCID) - } + // Verify VPC exists and is in a valid state + vpcDesc, err := regionalClient.DescribeVpcs(ctx, &ec2.DescribeVpcsInput{ + VpcIds: []string{vpc.VPCID}, + }) + if err != nil { + l.Errorf("Failed to describe VPC %s: %v", vpc.VPCID, err) + return fmt.Errorf("failed to describe VPC %s: %w", vpc.VPCID, err) + } + if len(vpcDesc.Vpcs) == 0 { + l.Errorf("VPC %s not found", vpc.VPCID) + return fmt.Errorf("VPC %s not found", vpc.VPCID) + } - // Create Internet Gateway with retry - var igw *ec2.CreateInternetGatewayOutput - err = backoff.Retry(func() error { - var err error - igw, err = regionalClient.CreateInternetGateway( - ctx, - &ec2.CreateInternetGatewayInput{ - TagSpecifications: []ec2_types.TagSpecification{ + // Create Internet Gateway with retry + var igw *ec2.CreateInternetGatewayOutput + err = backoff.Retry(func() error { + var err error + igw, err = regionalClient.CreateInternetGateway( + ctx, + &ec2.CreateInternetGatewayInput{ + TagSpecifications: []ec2_types.TagSpecification{ + { + ResourceType: ec2_types.ResourceTypeInternetGateway, + Tags: []ec2_types.Tag{ { - ResourceType: ec2_types.ResourceTypeInternetGateway, - Tags: []ec2_types.Tag{ - { - Key: aws.String("Name"), - Value: aws.String(fmt.Sprintf("andaime-igw-%s", vpc.VPCID)), - }, - { - Key: aws.String("VPC"), - Value: aws.String(vpc.VPCID), - }, - }, + Key: aws.String("Name"), + Value: aws.String(fmt.Sprintf("andaime-igw-%s", vpc.VPCID)), + }, + { + Key: aws.String("VPC"), + Value: aws.String(vpc.VPCID), }, }, }, - ) - return err - }, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 3)) - if err != nil { - l.Errorf("Failed to create internet gateway for VPC %s: %v", vpc.VPCID, err) - return fmt.Errorf( - "failed to create internet gateway for VPC %s: %w", - vpc.VPCID, - err, - ) - } - - // Attach Internet Gateway with retry - err = backoff.Retry(func() error { - _, err := regionalClient.AttachInternetGateway( - ctx, - &ec2.AttachInternetGatewayInput{ - InternetGatewayId: aws.String(*igw.InternetGateway.InternetGatewayId), - VpcId: aws.String(vpc.VPCID), - }, - ) - return err - }, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 3)) - if err != nil { - l.Errorf("Failed to attach internet gateway to VPC %s: %v", vpc.VPCID, err) - return fmt.Errorf("failed to attach internet gateway to VPC %s: %w", vpc.VPCID, err) - } + }, + }, + ) + return err + }, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 3)) + if err != nil { + l.Errorf("Failed to create internet gateway for VPC %s: %v", vpc.VPCID, err) + return fmt.Errorf( + "failed to create internet gateway for VPC %s: %w", + vpc.VPCID, + err, + ) + } - // Update VPC state with Internet Gateway ID - if err := p.vpcManager.UpdateVPC(region, func(v *models.AWSVPC) error { - if v.VPCID == vpc.VPCID { - v.InternetGatewayID = *igw.InternetGateway.InternetGatewayId - } - return nil - }); err != nil { - l.Errorf("Failed to update VPC state for VPC %s: %v", vpc.VPCID, err) - return fmt.Errorf("failed to update VPC state: %w", err) - } + // Attach Internet Gateway with retry + err = backoff.Retry(func() error { + _, err := regionalClient.AttachInternetGateway( + ctx, + &ec2.AttachInternetGatewayInput{ + InternetGatewayId: aws.String(*igw.InternetGateway.InternetGatewayId), + VpcId: aws.String(vpc.VPCID), + }, + ) + return err + }, backoff.WithMaxRetries(backoff.NewExponentialBackOff(), 3)) + if err != nil { + l.Errorf("Failed to attach internet gateway to VPC %s: %v", vpc.VPCID, err) + return fmt.Errorf("failed to attach internet gateway to VPC %s: %w", vpc.VPCID, err) + } - // Setup routing for this VPC - if err := p.setupRouting(ctx, region, vpc); err != nil { - l.Errorf("Failed to setup routing for VPC %s: %v", vpc.VPCID, err) - return fmt.Errorf("failed to setup routing for VPC %s: %w", vpc.VPCID, err) + // Update VPC state with Internet Gateway ID + if err := m.Deployment.AWS.RegionalResources.UpdateVPC( + m.Deployment, + region, + func(v *models.AWSVPC) error { + if v.VPCID == vpc.VPCID { + v.InternetGatewayID = *igw.InternetGateway.InternetGatewayId } + return nil + }); err != nil { + l.Errorf("Failed to update VPC state for VPC %s: %v", vpc.VPCID, err) + return fmt.Errorf("failed to update VPC state: %w", err) + } - // Verify Internet Gateway and Route Table - igws, err := regionalClient.DescribeInternetGateways(ctx, &ec2.DescribeInternetGatewaysInput{ - Filters: []ec2_types.Filter{ - { - Name: aws.String("attachment.vpc-id"), - Values: []string{vpc.VPCID}, - }, - }, - }) - if err != nil { - l.Errorf("Failed to describe internet gateways for VPC %s: %v", vpc.VPCID, err) - } else { - l.Debugf("Internet Gateways for VPC %s: %d", vpc.VPCID, len(igws.InternetGateways)) - for _, gateway := range igws.InternetGateways { - l.Debugf("IGW ID: %s", aws.ToString(gateway.InternetGatewayId)) - } - } + // Setup routing for this VPC + if err := p.setupRouting(ctx, region, vpc); err != nil { + l.Errorf("Failed to setup routing for VPC %s: %v", vpc.VPCID, err) + return fmt.Errorf("failed to setup routing for VPC %s: %w", vpc.VPCID, err) + } - rts, err := regionalClient.DescribeRouteTables(ctx, &ec2.DescribeRouteTablesInput{ - Filters: []ec2_types.Filter{ - { - Name: aws.String("vpc-id"), - Values: []string{vpc.VPCID}, - }, + // Verify Internet Gateway and Route Table + igws, err := regionalClient.DescribeInternetGateways( + ctx, + &ec2.DescribeInternetGatewaysInput{ + Filters: []ec2_types.Filter{ + { + Name: aws.String("attachment.vpc-id"), + Values: []string{vpc.VPCID}, }, - }) - if err != nil { - l.Errorf("Failed to describe route tables for VPC %s: %v", vpc.VPCID, err) - } else { - l.Debugf("Route tables for VPC %s: %d", vpc.VPCID, len(rts.RouteTables)) - for i, rt := range rts.RouteTables { - l.Debugf("Route table %d ID: %s", i+1, aws.ToString(rt.RouteTableId)) - for j, route := range rt.Routes { - l.Debugf("Route %d: Destination %s, Gateway %s", - j+1, - aws.ToString(route.DestinationCidrBlock), - aws.ToString(route.GatewayId), - ) - } - } - } - - l.Debugf("Successfully set up networking for VPC %s", vpc.VPCID) - return nil - }) + }, + }, + ) + if err != nil { + l.Errorf("Failed to describe internet gateways for VPC %s: %v", vpc.VPCID, err) + } else { + l.Debugf("Internet Gateways for VPC %s: %d", vpc.VPCID, len(igws.InternetGateways)) + for _, gateway := range igws.InternetGateways { + l.Debugf("IGW ID: %s", aws.ToString(gateway.InternetGatewayId)) + } } - // Wait for all VPC networking setups to complete - if err := eg.Wait(); err != nil { - l.Errorf("Error setting up networking in region %s: %v", region, err) - return fmt.Errorf("failed to set up networking in region %s: %w", region, err) + rts, err := regionalClient.DescribeRouteTables(ctx, &ec2.DescribeRouteTablesInput{ + Filters: []ec2_types.Filter{ + { + Name: aws.String("vpc-id"), + Values: []string{vpc.VPCID}, + }, + }, + }) + if err != nil { + l.Errorf("Failed to describe route tables for VPC %s: %v", vpc.VPCID, err) + } else { + l.Debugf("Route tables for VPC %s: %d", vpc.VPCID, len(rts.RouteTables)) + for i, rt := range rts.RouteTables { + l.Debugf("Route table %d ID: %s", i+1, aws.ToString(rt.RouteTableId)) + for j, route := range rt.Routes { + l.Debugf("Route %d: Destination %s, Gateway %s", + j+1, + aws.ToString(route.DestinationCidrBlock), + aws.ToString(route.GatewayId), + ) + } + } } + l.Debugf("Successfully set up networking for VPC %s", vpc.VPCID) return nil } @@ -1525,11 +1514,6 @@ func (p *AWSProvider) createVPCWithRetry(ctx context.Context, region string) err return fmt.Errorf("global model or deployment is nil") } - // Initialize VPC manager if needed - if p.vpcManager == nil { - p.vpcManager = NewRegionalVPCManager(m.Deployment, p.EC2Client) - } - err := p.CreateVpc(ctx, region) if err != nil { if strings.Contains(err.Error(), "VpcLimitExceeded") { @@ -1642,7 +1626,10 @@ func (p *AWSProvider) WaitForNetworkConnectivity(ctx context.Context) error { l.Info("Attempting to describe route tables for VPC connectivity check...") l.Debugf("Looking for route tables in VPC %s with internet gateway routes", vpcID) - result, err := p.EC2Client.DescribeRouteTables(ctx, input) + result, err := m.Deployment.AWS.RegionalResources.Clients[region].DescribeRouteTables( + ctx, + input, + ) if err != nil { l.Debugf("Failed to describe route tables: %v", err) return fmt.Errorf("failed to describe route tables: %w", err) @@ -1686,7 +1673,7 @@ func (p *AWSProvider) WaitForNetworkConnectivity(ctx context.Context) error { l.Warn("No internet gateway route found in any route table") // Additional diagnostic information - igws, err := p.EC2Client.DescribeInternetGateways( + igws, err := m.Deployment.AWS.RegionalResources.Clients[region].DescribeInternetGateways( ctx, &ec2.DescribeInternetGatewaysInput{ Filters: []ec2_types.Filter{ @@ -1960,13 +1947,22 @@ func (p *AWSProvider) ValidateMachineType( ) } -func (p *AWSProvider) GetVMExternalIP(ctx context.Context, instanceID string) (string, error) { +func (p *AWSProvider) GetVMExternalIP( + ctx context.Context, + region string, + instanceID string, +) (string, error) { + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return "", fmt.Errorf("global model or deployment is nil") + } + // Describe the instance input := &ec2.DescribeInstancesInput{ InstanceIds: []string{instanceID}, } - result, err := p.EC2Client.DescribeInstances(ctx, input) + result, err := m.Deployment.AWS.RegionalResources.Clients[region].DescribeInstances(ctx, input) if err != nil { return "", fmt.Errorf("failed to describe instance: %w", err) } @@ -2091,30 +2087,6 @@ func (p *AWSProvider) updateVPCDisplayState( } } -// Additional VPC manager methods -func (p *AWSProvider) GetVPCState(region string) (*VPCState, error) { - if p.vpcManager == nil { - return nil, fmt.Errorf("VPC manager not initialized") - } - return p.vpcManager.GetOrCreateVPCState(region), nil -} - -func (p *AWSProvider) ValidateVPCState(region string) error { - state, err := p.GetVPCState(region) - if err != nil { - return err - } - - state.mu.RLock() - defer state.mu.RUnlock() - - if state.vpc == nil || state.vpc.VPCID == "" { - return fmt.Errorf("no valid VPC found for region %s", region) - } - - return nil -} - func (p *AWSProvider) ProvisionBacalhauCluster(ctx context.Context) error { if err := p.GetClusterDeployer().ProvisionBacalhauCluster(ctx); err != nil { return err @@ -2130,8 +2102,14 @@ func (p *AWSProvider) FinalizeDeployment(ctx context.Context) error { // WaitUntilInstanceRunning waits for an EC2 instance to reach the running state func (p *AWSProvider) WaitUntilInstanceRunning( ctx context.Context, + region string, input *ec2.DescribeInstancesInput, ) error { + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return fmt.Errorf("global model or deployment is nil") + } + l := logger.Get() b := backoff.NewExponentialBackOff() b.InitialInterval = 5 * time.Second @@ -2143,7 +2121,10 @@ func (p *AWSProvider) WaitUntilInstanceRunning( return backoff.Permanent(err) } - result, err := p.EC2Client.DescribeInstances(ctx, input) + result, err := m.Deployment.AWS.RegionalResources.Clients[region].DescribeInstances( + ctx, + input, + ) if err != nil { return fmt.Errorf("failed to describe instances: %w", err) } @@ -2176,14 +2157,6 @@ func (p *AWSProvider) WaitUntilInstanceRunning( return nil } -func (p *AWSProvider) SetEC2Client(client aws_interface.EC2Clienter) { - p.EC2Client = client -} - -func (p *AWSProvider) GetEC2Client() aws_interface.EC2Clienter { - return p.EC2Client -} - func (p *AWSProvider) GetPrimaryRegion() string { return p.Config.Region } @@ -2200,12 +2173,18 @@ func (p *AWSProvider) GetConfig() *aws.Config { // arch should be either "x86_64" or "arm64" func (p *AWSProvider) GetLatestUbuntuAMI( ctx context.Context, - loc string, + region string, arch string, ) (string, error) { - c := p.GetEC2Client() - if c == nil { - return "", fmt.Errorf("EC2 client not initialized") + m := display.GetGlobalModelFunc() + if m == nil || m.Deployment == nil { + return "", fmt.Errorf("global model or deployment is nil") + } + + // Get the EC2 client for the specific region + c, err := p.getOrCreateEC2Client(ctx, region) + if err != nil { + return "", fmt.Errorf("failed to get EC2 client for region %s: %w", region, err) } input := &ec2.DescribeImagesInput{ @@ -2228,20 +2207,21 @@ func (p *AWSProvider) GetLatestUbuntuAMI( }, { Name: aws.String("owner-id"), - Values: []string{"099720109477"}, // Canonical's AWS account ID + Values: []string{UbuntuAMIOwner}, // Canonical's AWS account ID }, }, } result, err := c.DescribeImages(ctx, input) if err != nil { - return "", fmt.Errorf("failed to describe images: %w", err) + return "", fmt.Errorf("failed to describe images in region %s: %w", region, err) } if len(result.Images) == 0 { return "", fmt.Errorf( - "no matching Ubuntu AMI found for location: '%s' and architecture: '%s'", - loc, arch, + "no matching Ubuntu AMI found in region %s for architecture: %s", + region, + arch, ) } @@ -2405,70 +2385,3 @@ func (p *AWSProvider) ListDeployments(ctx context.Context) ([]DeploymentInfo, er return deployments, nil } - -// GetOrCreateVPCState gets or creates a VPC state for a region -func (rm *RegionalVPCManager) GetOrCreateVPCState(region string) *VPCState { - rm.mu.Lock() - defer rm.mu.Unlock() - - if state, exists := rm.states[region]; exists { - return state - } - - state := &VPCState{ - vpc: rm.deployment.AWS.RegionalResources.GetVPC(region), - lastUpdated: time.Now(), - } - rm.states[region] = state - return state -} - -// UpdateVPC atomically updates a VPC's state -func (rm *RegionalVPCManager) UpdateVPC(region string, updateFn func(*models.AWSVPC) error) error { - state := rm.GetOrCreateVPCState(region) - state.mu.Lock() - defer state.mu.Unlock() - - if state.vpc == nil { - state.vpc = &models.AWSVPC{} - rm.deployment.AWS.RegionalResources.SetVPC(region, state.vpc) - } - - if err := updateFn(state.vpc); err != nil { - return fmt.Errorf("failed to update VPC state: %w", err) - } - - state.lastUpdated = time.Now() - return nil -} - -// SaveVPCConfig saves VPC configuration to viper -func (rm *RegionalVPCManager) SaveVPCConfig(region string) error { - state := rm.GetOrCreateVPCState(region) - state.mu.RLock() - defer state.mu.RUnlock() - - if state.vpc == nil { - return fmt.Errorf("no VPC found for region %s", region) - } - - deploymentPath := fmt.Sprintf("deployments.%s", rm.deployment.UniqueID) - viper.Set(fmt.Sprintf("%s.aws.regions.%s.vpc_id", deploymentPath, region), state.vpc.VPCID) - - return viper.WriteConfig() -} - -// GetAllVPCStates returns all VPC states for a given region -func (rm *RegionalVPCManager) GetAllVPCStates(region string) []*VPCState { - rm.mu.RLock() - defer rm.mu.RUnlock() - - var states []*VPCState - for r, state := range rm.states { - if r == region { - states = append(states, state) - } - } - - return states -} diff --git a/pkg/providers/aws/provider_test.go b/pkg/providers/aws/provider_test.go index a2e192ab..df4d4340 100644 --- a/pkg/providers/aws/provider_test.go +++ b/pkg/providers/aws/provider_test.go @@ -10,7 +10,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/bacalhau-project/andaime/internal/testdata" "github.com/bacalhau-project/andaime/internal/testutil" - aws_mocks "github.com/bacalhau-project/andaime/mocks/aws" + mocks "github.com/bacalhau-project/andaime/mocks/aws" ssh_mock "github.com/bacalhau-project/andaime/mocks/sshutils" "github.com/bacalhau-project/andaime/pkg/display" "github.com/bacalhau-project/andaime/pkg/logger" @@ -43,8 +43,8 @@ type PkgProvidersAWSProviderSuite struct { testSSHPrivateKeyPath string cleanupPublicKey func() cleanupPrivateKey func() - mockAWSClient *aws_mocks.MockEC2Clienter awsProvider *AWSProvider + deployment *models.Deployment origGetGlobalModelFunc func() *display.DisplayModel origNewSSHConfigFunc func(string, int, string, string) (sshutils_interface.SSHConfiger, error) mockSSHConfig *ssh_mock.MockSSHConfiger @@ -57,15 +57,6 @@ func (suite *PkgProvidersAWSProviderSuite) SetupSuite() { suite.testSSHPrivateKeyPath, suite.cleanupPrivateKey = testutil.CreateSSHPublicPrivateKeyPairOnDisk() - suite.origGetGlobalModelFunc = display.GetGlobalModelFunc - display.GetGlobalModelFunc = func() *display.DisplayModel { - deployment, err := models.NewDeployment() - suite.Require().NoError(err) - return &display.DisplayModel{ - Deployment: deployment, - } - } - suite.origLogger = logger.Get() logger.SetGlobalLogger(logger.NewTestLogger(suite.T())) } @@ -73,8 +64,6 @@ func (suite *PkgProvidersAWSProviderSuite) SetupSuite() { func (suite *PkgProvidersAWSProviderSuite) TearDownSuite() { suite.cleanupPublicKey() suite.cleanupPrivateKey() - display.GetGlobalModelFunc = suite.origGetGlobalModelFunc - sshutils.NewSSHConfigFunc = suite.origNewSSHConfigFunc logger.SetGlobalLogger(suite.origLogger) } @@ -97,6 +86,7 @@ func (suite *PkgProvidersAWSProviderSuite) SetupTest() { } // Set up the global model function + suite.origGetGlobalModelFunc = display.GetGlobalModelFunc display.GetGlobalModelFunc = func() *display.DisplayModel { return &display.DisplayModel{ Deployment: deployment, @@ -107,18 +97,14 @@ func (suite *PkgProvidersAWSProviderSuite) SetupTest() { provider, err := NewAWSProviderFunc(FAKE_ACCOUNT_ID) require.NoError(suite.T(), err) - // Set the mock client and ensure it's used for all regions - suite.mockAWSClient = new(aws_mocks.MockEC2Clienter) - provider.SetEC2Client(suite.mockAWSClient) - - // Pre-initialize VPC manager with the deployment - provider.vpcManager = NewRegionalVPCManager(deployment, suite.mockAWSClient) - // Initialize regional resources for the test region deployment.AWS.RegionalResources.VPCs[FAKE_REGION] = &models.AWSVPC{ VPCID: FAKE_VPC_ID, } - deployment.AWS.RegionalResources.Clients[FAKE_REGION] = suite.mockAWSClient + + mockAWSClient := new(mocks.MockEC2Clienter) + deployment.AWS.RegionalResources.Clients[FAKE_REGION] = mockAWSClient + suite.deployment = deployment // Mock all AWS API calls suite.setupAWSMocks() @@ -136,9 +122,15 @@ func (suite *PkgProvidersAWSProviderSuite) SetupTest() { suite.awsProvider = provider } +func (suite *PkgProvidersAWSProviderSuite) TearDownTest() { + display.GetGlobalModelFunc = suite.origGetGlobalModelFunc + sshutils.NewSSHConfigFunc = suite.origNewSSHConfigFunc +} + func (suite *PkgProvidersAWSProviderSuite) setupAWSMocks() { // Mock DescribeRegions - suite.mockAWSClient.On("DescribeRegions", mock.Anything, mock.Anything). + mockRegionalClient := suite.deployment.AWS.RegionalResources.Clients[FAKE_REGION].(*mocks.MockEC2Clienter) + mockRegionalClient.On("DescribeRegions", mock.Anything, mock.Anything). Return(&ec2.DescribeRegionsOutput{ Regions: []types.Region{ {RegionName: aws.String(FAKE_REGION)}, @@ -146,7 +138,7 @@ func (suite *PkgProvidersAWSProviderSuite) setupAWSMocks() { }, nil) // Mock availability zones - suite.mockAWSClient.On("DescribeAvailabilityZones", mock.Anything, mock.Anything). + mockRegionalClient.On("DescribeAvailabilityZones", mock.Anything, mock.Anything). Return(&ec2.DescribeAvailabilityZonesOutput{ AvailabilityZones: []types.AvailabilityZone{ { @@ -163,12 +155,12 @@ func (suite *PkgProvidersAWSProviderSuite) setupAWSMocks() { }, nil) // Mock VPC-related operations - suite.mockAWSClient.On("CreateVpc", mock.Anything, mock.Anything). + mockRegionalClient.On("CreateVpc", mock.Anything, mock.Anything). Return(&ec2.CreateVpcOutput{ Vpc: &types.Vpc{VpcId: aws.String(FAKE_VPC_ID)}, }, nil) - suite.mockAWSClient.On("DescribeVpcs", mock.Anything, mock.Anything). + mockRegionalClient.On("DescribeVpcs", mock.Anything, mock.Anything). Return(&ec2.DescribeVpcsOutput{ Vpcs: []types.Vpc{ { @@ -178,38 +170,38 @@ func (suite *PkgProvidersAWSProviderSuite) setupAWSMocks() { }, }, nil) - suite.mockAWSClient.On("ModifyVpcAttribute", mock.Anything, mock.Anything). + mockRegionalClient.On("ModifyVpcAttribute", mock.Anything, mock.Anything). Return(&ec2.ModifyVpcAttributeOutput{}, nil) // Mock networking components - suite.mockAWSClient.On("CreateSubnet", mock.Anything, mock.Anything). + mockRegionalClient.On("CreateSubnet", mock.Anything, mock.Anything). Return(&ec2.CreateSubnetOutput{ Subnet: &types.Subnet{SubnetId: aws.String(FAKE_SUBNET_ID)}, }, nil) - suite.mockAWSClient.On("CreateInternetGateway", mock.Anything, mock.Anything). + mockRegionalClient.On("CreateInternetGateway", mock.Anything, mock.Anything). Return(&ec2.CreateInternetGatewayOutput{ InternetGateway: &types.InternetGateway{ InternetGatewayId: aws.String(FAKE_IGW_ID), }, }, nil) - suite.mockAWSClient.On("CreateRouteTable", mock.Anything, mock.Anything). + mockRegionalClient.On("CreateRouteTable", mock.Anything, mock.Anything). Return(&ec2.CreateRouteTableOutput{ RouteTable: &types.RouteTable{RouteTableId: aws.String(FAKE_RTB_ID)}, }, nil) // Mock security group operations - suite.mockAWSClient.On("CreateSecurityGroup", mock.Anything, mock.Anything). + mockRegionalClient.On("CreateSecurityGroup", mock.Anything, mock.Anything). Return(&ec2.CreateSecurityGroupOutput{ GroupId: aws.String("sg-12345"), }, nil) - suite.mockAWSClient.On("AuthorizeSecurityGroupIngress", mock.Anything, mock.Anything). + mockRegionalClient.On("AuthorizeSecurityGroupIngress", mock.Anything, mock.Anything). Return(&ec2.AuthorizeSecurityGroupIngressOutput{}, nil) // Mock network setup operations with logging - suite.mockAWSClient.On("AttachInternetGateway", mock.Anything, mock.Anything). + mockRegionalClient.On("AttachInternetGateway", mock.Anything, mock.Anything). Run(func(args mock.Arguments) { input := args.Get(1).(*ec2.AttachInternetGatewayInput) logger.Get().Debugf("Attaching Internet Gateway %s to VPC %s", @@ -217,7 +209,7 @@ func (suite *PkgProvidersAWSProviderSuite) setupAWSMocks() { }). Return(&ec2.AttachInternetGatewayOutput{}, nil) - suite.mockAWSClient.On("CreateRoute", mock.Anything, mock.Anything). + mockRegionalClient.On("CreateRoute", mock.Anything, mock.Anything). Run(func(args mock.Arguments) { input := args.Get(1).(*ec2.CreateRouteInput) logger.Get().Debugf("Creating route in route table %s with destination %s via IGW %s", @@ -225,7 +217,7 @@ func (suite *PkgProvidersAWSProviderSuite) setupAWSMocks() { }). Return(&ec2.CreateRouteOutput{}, nil) - suite.mockAWSClient.On("AssociateRouteTable", mock.Anything, mock.Anything). + mockRegionalClient.On("AssociateRouteTable", mock.Anything, mock.Anything). Run(func(args mock.Arguments) { input := args.Get(1).(*ec2.AssociateRouteTableInput) logger.Get().Debugf("Associating route table %s with subnet %s", @@ -299,7 +291,8 @@ func (suite *PkgProvidersAWSProviderSuite) TestProcessMachinesConfig() { } func (suite *PkgProvidersAWSProviderSuite) TestGetVMExternalIP() { - suite.mockAWSClient.On("DescribeInstances", mock.Anything, &ec2.DescribeInstancesInput{ + mockRegionalClient := suite.deployment.AWS.RegionalResources.Clients[FAKE_REGION].(*mocks.MockEC2Clienter) + mockRegionalClient.On("DescribeInstances", mock.Anything, &ec2.DescribeInstancesInput{ InstanceIds: []string{FAKE_INSTANCE_ID}, }).Return(&ec2.DescribeInstancesOutput{ Reservations: []types.Reservation{{ @@ -310,7 +303,7 @@ func (suite *PkgProvidersAWSProviderSuite) TestGetVMExternalIP() { }}, }, nil) - ip, err := suite.awsProvider.GetVMExternalIP(suite.ctx, FAKE_INSTANCE_ID) + ip, err := suite.awsProvider.GetVMExternalIP(suite.ctx, FAKE_REGION, FAKE_INSTANCE_ID) suite.Require().NoError(err) suite.Require().Equal("203.0.113.1", ip) } diff --git a/pkg/providers/aws/utils.go b/pkg/providers/aws/utils.go index 0f692096..f9559661 100644 --- a/pkg/providers/aws/utils.go +++ b/pkg/providers/aws/utils.go @@ -9,9 +9,12 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ec2" ) -func (p *AWSProvider) GetAllAWSRegions(ctx context.Context) ([]string, error) { +func (p *AWSProvider) GetAllAWSRegions( + ctx context.Context, + client ec2.Client, +) ([]string, error) { // Use the provider's EC2Client which can be mocked in tests - output, err := p.EC2Client.DescribeRegions(ctx, &ec2.DescribeRegionsInput{ + output, err := client.DescribeRegions(ctx, &ec2.DescribeRegionsInput{ AllRegions: aws.Bool(true), }) if err != nil { diff --git a/pkg/sshutils/constants.go b/pkg/sshutils/constants.go index 2489a6b8..01903d5f 100644 --- a/pkg/sshutils/constants.go +++ b/pkg/sshutils/constants.go @@ -8,7 +8,7 @@ var ( SSHRetryAttempts = 3 SSHDialTimeout = 10 * time.Second SSHClientConfigTimeout = 10 * time.Second - SSHRetryDelay = 3 * time.Second + SSHRetryDelay = 20 * time.Second ) func GetAggregateSSHTimeout() time.Duration { diff --git a/pkg/sshutils/ssh_config.go b/pkg/sshutils/ssh_config.go index 51257e86..88a51e21 100644 --- a/pkg/sshutils/ssh_config.go +++ b/pkg/sshutils/ssh_config.go @@ -586,6 +586,7 @@ func (c *SSHConfig) SetSSHClient(client *ssh.Client) { // WaitForSSH waits for SSH connection to be available func (c *SSHConfig) WaitForSSH(ctx context.Context, retry int, timeout time.Duration) error { + l := logger.Get() var lastErr error deadline := time.Now().Add(timeout) @@ -600,7 +601,8 @@ func (c *SSHConfig) WaitForSSH(ctx context.Context, retry int, timeout time.Dura return nil } else { lastErr = err - fmt.Printf("Could not connect: %v\nRetrying in %v seconds...\n", err, SSHRetryDelay.Seconds()) + l.Infof("Could not connect to (%s): %v\nRetrying in %v seconds...\n", + c.Host, err, SSHRetryDelay.Seconds()) } // If first attempt fails, start retrying with backoff @@ -626,8 +628,8 @@ func (c *SSHConfig) WaitForSSH(ctx context.Context, retry int, timeout time.Dura } else { lastErr = err attempts++ - fmt.Printf("Could not connect: %v\nRetrying in %v seconds... (attempt %d/%d)\n", - err, SSHRetryDelay.Seconds(), attempts, retry) + l.Infof("Could not connect to (%s): %v\nRetrying in %v seconds... (attempt %d/%d)\n", + c.Host, err, SSHRetryDelay.Seconds(), attempts, retry) } } } diff --git a/test/integration/create_deployment_test.go b/test/integration/create_deployment_test.go index 84a09b8b..6e991b0c 100644 --- a/test/integration/create_deployment_test.go +++ b/test/integration/create_deployment_test.go @@ -297,7 +297,6 @@ func (s *IntegrationTestSuite) setupAWSTest() (*cobra.Command, error) { // Create and configure mock EC2 client mockEC2Client := new(aws_mock.MockEC2Clienter) s.setupMockAWSResources(mockEC2Client) - s.awsProvider.SetEC2Client(mockEC2Client) // Set up the provider in the command aws_provider.NewAWSProviderFunc = func(accountID string) (*aws_provider.AWSProvider, error) { @@ -383,6 +382,8 @@ func (s *IntegrationTestSuite) setupMockAWSResources(mockEC2Client *aws_mock.Moc // Routing mocks mockEC2Client.On("CreateInternetGateway", mock.Anything, mock.AnythingOfType("*ec2.CreateInternetGatewayInput")). Return(testdata.FakeEC2CreateInternetGatewayOutput(), nil) + mockEC2Client.On("DescribeInternetGateways", mock.Anything, mock.AnythingOfType("*ec2.DescribeInternetGatewaysInput")). + Return(testdata.FakeEC2DescribeInternetGatewaysOutput(), nil) mockEC2Client.On("AttachInternetGateway", mock.Anything, mock.AnythingOfType("*ec2.AttachInternetGatewayInput")). Return(testdata.FakeEC2AttachInternetGatewayOutput(), nil) mockEC2Client.On("CreateRouteTable", mock.Anything, mock.AnythingOfType("*ec2.CreateRouteTableInput")). From 975d05e9b2b3d1071f795365011d291b322917bc Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Sat, 14 Dec 2024 10:15:45 -0800 Subject: [PATCH 27/32] Update internal/clouds/general/location.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- internal/clouds/general/location.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/clouds/general/location.go b/internal/clouds/general/location.go index ad2fd728..3c28327f 100644 --- a/internal/clouds/general/location.go +++ b/internal/clouds/general/location.go @@ -71,8 +71,8 @@ func ParseRegionZone(input string) (string, string, error) { } // Handle GCP style zones (e.g., europe-west3-a) - if parts := strings.Split(input, "-"); len(parts) > 2 && parts[len(parts)-1][0] >= 'a' && - parts[len(parts)-1][0] <= 'z' { + if parts := strings.Split(input, "-"); len(parts) > 2 && len(parts[len(parts)-1]) > 0 && + parts[len(parts)-1][0] >= 'a' && parts[len(parts)-1][0] <= 'z' { // Input is a GCP zone, extract region by removing the last segment region := strings.Join(parts[:len(parts)-1], "-") return region, input, nil From b37ef741e51fb34b604ef4f7ee4ef2e3020aa12f Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Sat, 14 Dec 2024 10:16:02 -0800 Subject: [PATCH 28/32] Update internal/clouds/general/location.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- internal/clouds/general/location.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/clouds/general/location.go b/internal/clouds/general/location.go index 3c28327f..51e83e6f 100644 --- a/internal/clouds/general/location.go +++ b/internal/clouds/general/location.go @@ -57,7 +57,7 @@ func NormalizeLocation( return region, zone, nil } l.Warnf("Unknown cloud provider: %s", cloudProvider) - return location, location, nil + return "", "", fmt.Errorf("unknown cloud provider: %s", cloudProvider) } // ParseRegionZone takes either a region (e.g., us-east-1) or zone (e.g., us-east-1a) From e3a39ea8d1d8d97a4a4866389cc1ed4c9c7239e9 Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Sat, 14 Dec 2024 10:16:24 -0800 Subject: [PATCH 29/32] Update cmd/beta/aws/create_deployment.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- cmd/beta/aws/create_deployment.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/beta/aws/create_deployment.go b/cmd/beta/aws/create_deployment.go index 3bf329b2..bfbab19d 100644 --- a/cmd/beta/aws/create_deployment.go +++ b/cmd/beta/aws/create_deployment.go @@ -173,6 +173,12 @@ func prepareDeployment( m.Deployment.SetMachines(machines) m.Deployment.SetLocations(locations) + if m.Deployment.AWS.RegionalResources.VPCs == nil { + m.Deployment.AWS.RegionalResources.VPCs = make(map[string]*models.AWSVPC) + } + if m.Deployment.AWS.RegionalResources.Clients == nil { + m.Deployment.AWS.RegionalResources.Clients = make(map[string]aws_interface.EC2Clienter) + } for _, machine := range m.Deployment.GetMachines() { region := machine.GetRegion() if _, exists := m.Deployment.AWS.RegionalResources.VPCs[region]; !exists { From bfa4b278951b93e0237f9562f2c33458c6218f48 Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Sat, 14 Dec 2024 11:30:52 -0800 Subject: [PATCH 30/32] merge from main --- .cspell/custom-dictionary.txt | 2 + cmd/beta/aws/create_deployment.go | 1 + internal/clouds/general/location.go | 1 + pkg/providers/aws/interfaces/ec2_clienter.go | 46 -------------------- 4 files changed, 4 insertions(+), 46 deletions(-) delete mode 100644 pkg/providers/aws/interfaces/ec2_clienter.go diff --git a/.cspell/custom-dictionary.txt b/.cspell/custom-dictionary.txt index 2eef2ee7..dcc12f2e 100644 --- a/.cspell/custom-dictionary.txt +++ b/.cspell/custom-dictionary.txt @@ -11,6 +11,7 @@ allowlistedlocalpaths Andaime andaimeconfig andaimeuser +APAC apitype apiv armcompute @@ -171,6 +172,7 @@ gosimple govet gserviceaccount Gtthi +Hamina heartbeatcheckfrequency heartbeatfrequency heartbeattopic diff --git a/cmd/beta/aws/create_deployment.go b/cmd/beta/aws/create_deployment.go index bfbab19d..ce914fbf 100644 --- a/cmd/beta/aws/create_deployment.go +++ b/cmd/beta/aws/create_deployment.go @@ -8,6 +8,7 @@ import ( "github.com/bacalhau-project/andaime/pkg/display" "github.com/bacalhau-project/andaime/pkg/logger" "github.com/bacalhau-project/andaime/pkg/models" + aws_interface "github.com/bacalhau-project/andaime/pkg/models/interfaces/aws" aws_provider "github.com/bacalhau-project/andaime/pkg/providers/aws" "github.com/bacalhau-project/andaime/pkg/sshutils" diff --git a/internal/clouds/general/location.go b/internal/clouds/general/location.go index 51e83e6f..1c15bb5d 100644 --- a/internal/clouds/general/location.go +++ b/internal/clouds/general/location.go @@ -1,6 +1,7 @@ package general import ( + "fmt" "strings" "github.com/bacalhau-project/andaime/pkg/logger" diff --git a/pkg/providers/aws/interfaces/ec2_clienter.go b/pkg/providers/aws/interfaces/ec2_clienter.go deleted file mode 100644 index 05b01e41..00000000 --- a/pkg/providers/aws/interfaces/ec2_clienter.go +++ /dev/null @@ -1,46 +0,0 @@ -package interfaces - -import ( - "context" - - "github.com/aws/aws-sdk-go-v2/service/ec2" -) - -// EC2Clienter defines the interface for EC2 client operations -type EC2Clienter interface { - CreateVpc( - ctx context.Context, - params *ec2.CreateVpcInput, - optFns ...func(*ec2.Options), - ) (*ec2.CreateVpcOutput, error) - CreateSecurityGroup( - ctx context.Context, - params *ec2.CreateSecurityGroupInput, - optFns ...func(*ec2.Options), - ) (*ec2.CreateSecurityGroupOutput, error) - AuthorizeSecurityGroupIngress( - ctx context.Context, - params *ec2.AuthorizeSecurityGroupIngressInput, - optFns ...func(*ec2.Options), - ) (*ec2.AuthorizeSecurityGroupIngressOutput, error) - RunInstances( - ctx context.Context, - params *ec2.RunInstancesInput, - optFns ...func(*ec2.Options), - ) (*ec2.RunInstancesOutput, error) - DescribeInstances( - ctx context.Context, - params *ec2.DescribeInstancesInput, - optFns ...func(*ec2.Options), - ) (*ec2.DescribeInstancesOutput, error) - DescribeImages( - ctx context.Context, - params *ec2.DescribeImagesInput, - optFns ...func(*ec2.Options), - ) (*ec2.DescribeImagesOutput, error) - ModifyVpcAttribute( - ctx context.Context, - params *ec2.ModifyVpcAttributeInput, - optFns ...func(*ec2.Options), - ) (*ec2.ModifyVpcAttributeOutput, error) -} From d5803f6e6e8427e8f93b262031cf2d17a612825e Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Sat, 14 Dec 2024 11:35:03 -0800 Subject: [PATCH 31/32] spelling fix --- .cspell/custom-dictionary.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.cspell/custom-dictionary.txt b/.cspell/custom-dictionary.txt index dcc12f2e..34185b80 100644 --- a/.cspell/custom-dictionary.txt +++ b/.cspell/custom-dictionary.txt @@ -185,6 +185,7 @@ housekeepingbackgroundtaskinterval housekeepinginterval housekeepingtimeout htmltemplate +iface ignorephysicalresourcelimits igws ineffassign From d7a529dac755b1d00d82fea6edd3e4983d383c1b Mon Sep 17 00:00:00 2001 From: David Aronchick Date: Sat, 14 Dec 2024 11:37:34 -0800 Subject: [PATCH 32/32] removing duplicate mocks --- .../aws/mocks/aws/mock_EC2Clienter.go | 2109 ----------------- .../aws/mocks/azure/mock_AzureClienter.go | 856 ------- .../aws/mocks/azure/mock_Pollerer.go | 313 --- .../aws/mocks/common/mock_Clienter.go | 32 - .../mocks/common/mock_ClusterDeployerer.go | 371 --- .../aws/mocks/gcp/mock_GCPClienter.go | 1463 ------------ .../mocks/sshutils/mock_SFTPClientCreator.go | 95 - .../aws/mocks/sshutils/mock_SFTPClienter.go | 291 --- .../aws/mocks/sshutils/mock_SFTPFile.go | 133 -- .../mocks/sshutils/mock_SSHClientCreator.go | 99 - .../aws/mocks/sshutils/mock_SSHClienter.go | 288 --- .../aws/mocks/sshutils/mock_SSHConfiger.go | 1067 --------- .../aws/mocks/sshutils/mock_SSHSessioner.go | 446 ---- 13 files changed, 7563 deletions(-) delete mode 100644 pkg/models/interfaces/aws/mocks/aws/mock_EC2Clienter.go delete mode 100644 pkg/models/interfaces/aws/mocks/azure/mock_AzureClienter.go delete mode 100644 pkg/models/interfaces/aws/mocks/azure/mock_Pollerer.go delete mode 100644 pkg/models/interfaces/aws/mocks/common/mock_Clienter.go delete mode 100644 pkg/models/interfaces/aws/mocks/common/mock_ClusterDeployerer.go delete mode 100644 pkg/models/interfaces/aws/mocks/gcp/mock_GCPClienter.go delete mode 100644 pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPClientCreator.go delete mode 100644 pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPClienter.go delete mode 100644 pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPFile.go delete mode 100644 pkg/models/interfaces/aws/mocks/sshutils/mock_SSHClientCreator.go delete mode 100644 pkg/models/interfaces/aws/mocks/sshutils/mock_SSHClienter.go delete mode 100644 pkg/models/interfaces/aws/mocks/sshutils/mock_SSHConfiger.go delete mode 100644 pkg/models/interfaces/aws/mocks/sshutils/mock_SSHSessioner.go diff --git a/pkg/models/interfaces/aws/mocks/aws/mock_EC2Clienter.go b/pkg/models/interfaces/aws/mocks/aws/mock_EC2Clienter.go deleted file mode 100644 index 45ad371c..00000000 --- a/pkg/models/interfaces/aws/mocks/aws/mock_EC2Clienter.go +++ /dev/null @@ -1,2109 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package aws - -import ( - context "context" - - ec2 "github.com/aws/aws-sdk-go-v2/service/ec2" - mock "github.com/stretchr/testify/mock" -) - -// MockEC2Clienter is an autogenerated mock type for the EC2Clienter type -type MockEC2Clienter struct { - mock.Mock -} - -type MockEC2Clienter_Expecter struct { - mock *mock.Mock -} - -func (_m *MockEC2Clienter) EXPECT() *MockEC2Clienter_Expecter { - return &MockEC2Clienter_Expecter{mock: &_m.Mock} -} - -// AssociateRouteTable provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) AssociateRouteTable(ctx context.Context, params *ec2.AssociateRouteTableInput, optFns ...func(*ec2.Options)) (*ec2.AssociateRouteTableOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for AssociateRouteTable") - } - - var r0 *ec2.AssociateRouteTableOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.AssociateRouteTableInput, ...func(*ec2.Options)) (*ec2.AssociateRouteTableOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.AssociateRouteTableInput, ...func(*ec2.Options)) *ec2.AssociateRouteTableOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.AssociateRouteTableOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.AssociateRouteTableInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_AssociateRouteTable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AssociateRouteTable' -type MockEC2Clienter_AssociateRouteTable_Call struct { - *mock.Call -} - -// AssociateRouteTable is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.AssociateRouteTableInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) AssociateRouteTable(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_AssociateRouteTable_Call { - return &MockEC2Clienter_AssociateRouteTable_Call{Call: _e.mock.On("AssociateRouteTable", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_AssociateRouteTable_Call) Run(run func(ctx context.Context, params *ec2.AssociateRouteTableInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_AssociateRouteTable_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.AssociateRouteTableInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_AssociateRouteTable_Call) Return(_a0 *ec2.AssociateRouteTableOutput, _a1 error) *MockEC2Clienter_AssociateRouteTable_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_AssociateRouteTable_Call) RunAndReturn(run func(context.Context, *ec2.AssociateRouteTableInput, ...func(*ec2.Options)) (*ec2.AssociateRouteTableOutput, error)) *MockEC2Clienter_AssociateRouteTable_Call { - _c.Call.Return(run) - return _c -} - -// AttachInternetGateway provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) AttachInternetGateway(ctx context.Context, params *ec2.AttachInternetGatewayInput, optFns ...func(*ec2.Options)) (*ec2.AttachInternetGatewayOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for AttachInternetGateway") - } - - var r0 *ec2.AttachInternetGatewayOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.AttachInternetGatewayInput, ...func(*ec2.Options)) (*ec2.AttachInternetGatewayOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.AttachInternetGatewayInput, ...func(*ec2.Options)) *ec2.AttachInternetGatewayOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.AttachInternetGatewayOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.AttachInternetGatewayInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_AttachInternetGateway_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AttachInternetGateway' -type MockEC2Clienter_AttachInternetGateway_Call struct { - *mock.Call -} - -// AttachInternetGateway is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.AttachInternetGatewayInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) AttachInternetGateway(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_AttachInternetGateway_Call { - return &MockEC2Clienter_AttachInternetGateway_Call{Call: _e.mock.On("AttachInternetGateway", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_AttachInternetGateway_Call) Run(run func(ctx context.Context, params *ec2.AttachInternetGatewayInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_AttachInternetGateway_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.AttachInternetGatewayInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_AttachInternetGateway_Call) Return(_a0 *ec2.AttachInternetGatewayOutput, _a1 error) *MockEC2Clienter_AttachInternetGateway_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_AttachInternetGateway_Call) RunAndReturn(run func(context.Context, *ec2.AttachInternetGatewayInput, ...func(*ec2.Options)) (*ec2.AttachInternetGatewayOutput, error)) *MockEC2Clienter_AttachInternetGateway_Call { - _c.Call.Return(run) - return _c -} - -// AuthorizeSecurityGroupIngress provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) AuthorizeSecurityGroupIngress(ctx context.Context, params *ec2.AuthorizeSecurityGroupIngressInput, optFns ...func(*ec2.Options)) (*ec2.AuthorizeSecurityGroupIngressOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for AuthorizeSecurityGroupIngress") - } - - var r0 *ec2.AuthorizeSecurityGroupIngressOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.AuthorizeSecurityGroupIngressInput, ...func(*ec2.Options)) (*ec2.AuthorizeSecurityGroupIngressOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.AuthorizeSecurityGroupIngressInput, ...func(*ec2.Options)) *ec2.AuthorizeSecurityGroupIngressOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.AuthorizeSecurityGroupIngressOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.AuthorizeSecurityGroupIngressInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_AuthorizeSecurityGroupIngress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuthorizeSecurityGroupIngress' -type MockEC2Clienter_AuthorizeSecurityGroupIngress_Call struct { - *mock.Call -} - -// AuthorizeSecurityGroupIngress is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.AuthorizeSecurityGroupIngressInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) AuthorizeSecurityGroupIngress(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_AuthorizeSecurityGroupIngress_Call { - return &MockEC2Clienter_AuthorizeSecurityGroupIngress_Call{Call: _e.mock.On("AuthorizeSecurityGroupIngress", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_AuthorizeSecurityGroupIngress_Call) Run(run func(ctx context.Context, params *ec2.AuthorizeSecurityGroupIngressInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_AuthorizeSecurityGroupIngress_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.AuthorizeSecurityGroupIngressInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_AuthorizeSecurityGroupIngress_Call) Return(_a0 *ec2.AuthorizeSecurityGroupIngressOutput, _a1 error) *MockEC2Clienter_AuthorizeSecurityGroupIngress_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_AuthorizeSecurityGroupIngress_Call) RunAndReturn(run func(context.Context, *ec2.AuthorizeSecurityGroupIngressInput, ...func(*ec2.Options)) (*ec2.AuthorizeSecurityGroupIngressOutput, error)) *MockEC2Clienter_AuthorizeSecurityGroupIngress_Call { - _c.Call.Return(run) - return _c -} - -// CreateInternetGateway provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) CreateInternetGateway(ctx context.Context, params *ec2.CreateInternetGatewayInput, optFns ...func(*ec2.Options)) (*ec2.CreateInternetGatewayOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for CreateInternetGateway") - } - - var r0 *ec2.CreateInternetGatewayOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateInternetGatewayInput, ...func(*ec2.Options)) (*ec2.CreateInternetGatewayOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateInternetGatewayInput, ...func(*ec2.Options)) *ec2.CreateInternetGatewayOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.CreateInternetGatewayOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.CreateInternetGatewayInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_CreateInternetGateway_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateInternetGateway' -type MockEC2Clienter_CreateInternetGateway_Call struct { - *mock.Call -} - -// CreateInternetGateway is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.CreateInternetGatewayInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) CreateInternetGateway(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_CreateInternetGateway_Call { - return &MockEC2Clienter_CreateInternetGateway_Call{Call: _e.mock.On("CreateInternetGateway", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_CreateInternetGateway_Call) Run(run func(ctx context.Context, params *ec2.CreateInternetGatewayInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_CreateInternetGateway_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.CreateInternetGatewayInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_CreateInternetGateway_Call) Return(_a0 *ec2.CreateInternetGatewayOutput, _a1 error) *MockEC2Clienter_CreateInternetGateway_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_CreateInternetGateway_Call) RunAndReturn(run func(context.Context, *ec2.CreateInternetGatewayInput, ...func(*ec2.Options)) (*ec2.CreateInternetGatewayOutput, error)) *MockEC2Clienter_CreateInternetGateway_Call { - _c.Call.Return(run) - return _c -} - -// CreateRoute provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) CreateRoute(ctx context.Context, params *ec2.CreateRouteInput, optFns ...func(*ec2.Options)) (*ec2.CreateRouteOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for CreateRoute") - } - - var r0 *ec2.CreateRouteOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateRouteInput, ...func(*ec2.Options)) (*ec2.CreateRouteOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateRouteInput, ...func(*ec2.Options)) *ec2.CreateRouteOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.CreateRouteOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.CreateRouteInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_CreateRoute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRoute' -type MockEC2Clienter_CreateRoute_Call struct { - *mock.Call -} - -// CreateRoute is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.CreateRouteInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) CreateRoute(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_CreateRoute_Call { - return &MockEC2Clienter_CreateRoute_Call{Call: _e.mock.On("CreateRoute", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_CreateRoute_Call) Run(run func(ctx context.Context, params *ec2.CreateRouteInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_CreateRoute_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.CreateRouteInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_CreateRoute_Call) Return(_a0 *ec2.CreateRouteOutput, _a1 error) *MockEC2Clienter_CreateRoute_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_CreateRoute_Call) RunAndReturn(run func(context.Context, *ec2.CreateRouteInput, ...func(*ec2.Options)) (*ec2.CreateRouteOutput, error)) *MockEC2Clienter_CreateRoute_Call { - _c.Call.Return(run) - return _c -} - -// CreateRouteTable provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) CreateRouteTable(ctx context.Context, params *ec2.CreateRouteTableInput, optFns ...func(*ec2.Options)) (*ec2.CreateRouteTableOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for CreateRouteTable") - } - - var r0 *ec2.CreateRouteTableOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateRouteTableInput, ...func(*ec2.Options)) (*ec2.CreateRouteTableOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateRouteTableInput, ...func(*ec2.Options)) *ec2.CreateRouteTableOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.CreateRouteTableOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.CreateRouteTableInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_CreateRouteTable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRouteTable' -type MockEC2Clienter_CreateRouteTable_Call struct { - *mock.Call -} - -// CreateRouteTable is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.CreateRouteTableInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) CreateRouteTable(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_CreateRouteTable_Call { - return &MockEC2Clienter_CreateRouteTable_Call{Call: _e.mock.On("CreateRouteTable", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_CreateRouteTable_Call) Run(run func(ctx context.Context, params *ec2.CreateRouteTableInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_CreateRouteTable_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.CreateRouteTableInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_CreateRouteTable_Call) Return(_a0 *ec2.CreateRouteTableOutput, _a1 error) *MockEC2Clienter_CreateRouteTable_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_CreateRouteTable_Call) RunAndReturn(run func(context.Context, *ec2.CreateRouteTableInput, ...func(*ec2.Options)) (*ec2.CreateRouteTableOutput, error)) *MockEC2Clienter_CreateRouteTable_Call { - _c.Call.Return(run) - return _c -} - -// CreateSecurityGroup provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) CreateSecurityGroup(ctx context.Context, params *ec2.CreateSecurityGroupInput, optFns ...func(*ec2.Options)) (*ec2.CreateSecurityGroupOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for CreateSecurityGroup") - } - - var r0 *ec2.CreateSecurityGroupOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateSecurityGroupInput, ...func(*ec2.Options)) (*ec2.CreateSecurityGroupOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateSecurityGroupInput, ...func(*ec2.Options)) *ec2.CreateSecurityGroupOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.CreateSecurityGroupOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.CreateSecurityGroupInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_CreateSecurityGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateSecurityGroup' -type MockEC2Clienter_CreateSecurityGroup_Call struct { - *mock.Call -} - -// CreateSecurityGroup is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.CreateSecurityGroupInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) CreateSecurityGroup(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_CreateSecurityGroup_Call { - return &MockEC2Clienter_CreateSecurityGroup_Call{Call: _e.mock.On("CreateSecurityGroup", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_CreateSecurityGroup_Call) Run(run func(ctx context.Context, params *ec2.CreateSecurityGroupInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_CreateSecurityGroup_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.CreateSecurityGroupInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_CreateSecurityGroup_Call) Return(_a0 *ec2.CreateSecurityGroupOutput, _a1 error) *MockEC2Clienter_CreateSecurityGroup_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_CreateSecurityGroup_Call) RunAndReturn(run func(context.Context, *ec2.CreateSecurityGroupInput, ...func(*ec2.Options)) (*ec2.CreateSecurityGroupOutput, error)) *MockEC2Clienter_CreateSecurityGroup_Call { - _c.Call.Return(run) - return _c -} - -// CreateSubnet provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) CreateSubnet(ctx context.Context, params *ec2.CreateSubnetInput, optFns ...func(*ec2.Options)) (*ec2.CreateSubnetOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for CreateSubnet") - } - - var r0 *ec2.CreateSubnetOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateSubnetInput, ...func(*ec2.Options)) (*ec2.CreateSubnetOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateSubnetInput, ...func(*ec2.Options)) *ec2.CreateSubnetOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.CreateSubnetOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.CreateSubnetInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_CreateSubnet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateSubnet' -type MockEC2Clienter_CreateSubnet_Call struct { - *mock.Call -} - -// CreateSubnet is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.CreateSubnetInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) CreateSubnet(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_CreateSubnet_Call { - return &MockEC2Clienter_CreateSubnet_Call{Call: _e.mock.On("CreateSubnet", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_CreateSubnet_Call) Run(run func(ctx context.Context, params *ec2.CreateSubnetInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_CreateSubnet_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.CreateSubnetInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_CreateSubnet_Call) Return(_a0 *ec2.CreateSubnetOutput, _a1 error) *MockEC2Clienter_CreateSubnet_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_CreateSubnet_Call) RunAndReturn(run func(context.Context, *ec2.CreateSubnetInput, ...func(*ec2.Options)) (*ec2.CreateSubnetOutput, error)) *MockEC2Clienter_CreateSubnet_Call { - _c.Call.Return(run) - return _c -} - -// CreateVpc provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) CreateVpc(ctx context.Context, params *ec2.CreateVpcInput, optFns ...func(*ec2.Options)) (*ec2.CreateVpcOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for CreateVpc") - } - - var r0 *ec2.CreateVpcOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateVpcInput, ...func(*ec2.Options)) (*ec2.CreateVpcOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.CreateVpcInput, ...func(*ec2.Options)) *ec2.CreateVpcOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.CreateVpcOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.CreateVpcInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_CreateVpc_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateVpc' -type MockEC2Clienter_CreateVpc_Call struct { - *mock.Call -} - -// CreateVpc is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.CreateVpcInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) CreateVpc(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_CreateVpc_Call { - return &MockEC2Clienter_CreateVpc_Call{Call: _e.mock.On("CreateVpc", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_CreateVpc_Call) Run(run func(ctx context.Context, params *ec2.CreateVpcInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_CreateVpc_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.CreateVpcInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_CreateVpc_Call) Return(_a0 *ec2.CreateVpcOutput, _a1 error) *MockEC2Clienter_CreateVpc_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_CreateVpc_Call) RunAndReturn(run func(context.Context, *ec2.CreateVpcInput, ...func(*ec2.Options)) (*ec2.CreateVpcOutput, error)) *MockEC2Clienter_CreateVpc_Call { - _c.Call.Return(run) - return _c -} - -// DeleteInternetGateway provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DeleteInternetGateway(ctx context.Context, params *ec2.DeleteInternetGatewayInput, optFns ...func(*ec2.Options)) (*ec2.DeleteInternetGatewayOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DeleteInternetGateway") - } - - var r0 *ec2.DeleteInternetGatewayOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteInternetGatewayInput, ...func(*ec2.Options)) (*ec2.DeleteInternetGatewayOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteInternetGatewayInput, ...func(*ec2.Options)) *ec2.DeleteInternetGatewayOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DeleteInternetGatewayOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DeleteInternetGatewayInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DeleteInternetGateway_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteInternetGateway' -type MockEC2Clienter_DeleteInternetGateway_Call struct { - *mock.Call -} - -// DeleteInternetGateway is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DeleteInternetGatewayInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DeleteInternetGateway(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DeleteInternetGateway_Call { - return &MockEC2Clienter_DeleteInternetGateway_Call{Call: _e.mock.On("DeleteInternetGateway", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DeleteInternetGateway_Call) Run(run func(ctx context.Context, params *ec2.DeleteInternetGatewayInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DeleteInternetGateway_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DeleteInternetGatewayInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DeleteInternetGateway_Call) Return(_a0 *ec2.DeleteInternetGatewayOutput, _a1 error) *MockEC2Clienter_DeleteInternetGateway_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DeleteInternetGateway_Call) RunAndReturn(run func(context.Context, *ec2.DeleteInternetGatewayInput, ...func(*ec2.Options)) (*ec2.DeleteInternetGatewayOutput, error)) *MockEC2Clienter_DeleteInternetGateway_Call { - _c.Call.Return(run) - return _c -} - -// DeleteRouteTable provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DeleteRouteTable(ctx context.Context, params *ec2.DeleteRouteTableInput, optFns ...func(*ec2.Options)) (*ec2.DeleteRouteTableOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DeleteRouteTable") - } - - var r0 *ec2.DeleteRouteTableOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteRouteTableInput, ...func(*ec2.Options)) (*ec2.DeleteRouteTableOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteRouteTableInput, ...func(*ec2.Options)) *ec2.DeleteRouteTableOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DeleteRouteTableOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DeleteRouteTableInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DeleteRouteTable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteRouteTable' -type MockEC2Clienter_DeleteRouteTable_Call struct { - *mock.Call -} - -// DeleteRouteTable is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DeleteRouteTableInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DeleteRouteTable(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DeleteRouteTable_Call { - return &MockEC2Clienter_DeleteRouteTable_Call{Call: _e.mock.On("DeleteRouteTable", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DeleteRouteTable_Call) Run(run func(ctx context.Context, params *ec2.DeleteRouteTableInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DeleteRouteTable_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DeleteRouteTableInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DeleteRouteTable_Call) Return(_a0 *ec2.DeleteRouteTableOutput, _a1 error) *MockEC2Clienter_DeleteRouteTable_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DeleteRouteTable_Call) RunAndReturn(run func(context.Context, *ec2.DeleteRouteTableInput, ...func(*ec2.Options)) (*ec2.DeleteRouteTableOutput, error)) *MockEC2Clienter_DeleteRouteTable_Call { - _c.Call.Return(run) - return _c -} - -// DeleteSecurityGroup provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DeleteSecurityGroup(ctx context.Context, params *ec2.DeleteSecurityGroupInput, optFns ...func(*ec2.Options)) (*ec2.DeleteSecurityGroupOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DeleteSecurityGroup") - } - - var r0 *ec2.DeleteSecurityGroupOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteSecurityGroupInput, ...func(*ec2.Options)) (*ec2.DeleteSecurityGroupOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteSecurityGroupInput, ...func(*ec2.Options)) *ec2.DeleteSecurityGroupOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DeleteSecurityGroupOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DeleteSecurityGroupInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DeleteSecurityGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteSecurityGroup' -type MockEC2Clienter_DeleteSecurityGroup_Call struct { - *mock.Call -} - -// DeleteSecurityGroup is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DeleteSecurityGroupInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DeleteSecurityGroup(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DeleteSecurityGroup_Call { - return &MockEC2Clienter_DeleteSecurityGroup_Call{Call: _e.mock.On("DeleteSecurityGroup", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DeleteSecurityGroup_Call) Run(run func(ctx context.Context, params *ec2.DeleteSecurityGroupInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DeleteSecurityGroup_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DeleteSecurityGroupInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DeleteSecurityGroup_Call) Return(_a0 *ec2.DeleteSecurityGroupOutput, _a1 error) *MockEC2Clienter_DeleteSecurityGroup_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DeleteSecurityGroup_Call) RunAndReturn(run func(context.Context, *ec2.DeleteSecurityGroupInput, ...func(*ec2.Options)) (*ec2.DeleteSecurityGroupOutput, error)) *MockEC2Clienter_DeleteSecurityGroup_Call { - _c.Call.Return(run) - return _c -} - -// DeleteSubnet provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DeleteSubnet(ctx context.Context, params *ec2.DeleteSubnetInput, optFns ...func(*ec2.Options)) (*ec2.DeleteSubnetOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DeleteSubnet") - } - - var r0 *ec2.DeleteSubnetOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteSubnetInput, ...func(*ec2.Options)) (*ec2.DeleteSubnetOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteSubnetInput, ...func(*ec2.Options)) *ec2.DeleteSubnetOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DeleteSubnetOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DeleteSubnetInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DeleteSubnet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteSubnet' -type MockEC2Clienter_DeleteSubnet_Call struct { - *mock.Call -} - -// DeleteSubnet is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DeleteSubnetInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DeleteSubnet(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DeleteSubnet_Call { - return &MockEC2Clienter_DeleteSubnet_Call{Call: _e.mock.On("DeleteSubnet", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DeleteSubnet_Call) Run(run func(ctx context.Context, params *ec2.DeleteSubnetInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DeleteSubnet_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DeleteSubnetInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DeleteSubnet_Call) Return(_a0 *ec2.DeleteSubnetOutput, _a1 error) *MockEC2Clienter_DeleteSubnet_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DeleteSubnet_Call) RunAndReturn(run func(context.Context, *ec2.DeleteSubnetInput, ...func(*ec2.Options)) (*ec2.DeleteSubnetOutput, error)) *MockEC2Clienter_DeleteSubnet_Call { - _c.Call.Return(run) - return _c -} - -// DeleteVpc provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DeleteVpc(ctx context.Context, params *ec2.DeleteVpcInput, optFns ...func(*ec2.Options)) (*ec2.DeleteVpcOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DeleteVpc") - } - - var r0 *ec2.DeleteVpcOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteVpcInput, ...func(*ec2.Options)) (*ec2.DeleteVpcOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DeleteVpcInput, ...func(*ec2.Options)) *ec2.DeleteVpcOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DeleteVpcOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DeleteVpcInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DeleteVpc_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteVpc' -type MockEC2Clienter_DeleteVpc_Call struct { - *mock.Call -} - -// DeleteVpc is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DeleteVpcInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DeleteVpc(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DeleteVpc_Call { - return &MockEC2Clienter_DeleteVpc_Call{Call: _e.mock.On("DeleteVpc", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DeleteVpc_Call) Run(run func(ctx context.Context, params *ec2.DeleteVpcInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DeleteVpc_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DeleteVpcInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DeleteVpc_Call) Return(_a0 *ec2.DeleteVpcOutput, _a1 error) *MockEC2Clienter_DeleteVpc_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DeleteVpc_Call) RunAndReturn(run func(context.Context, *ec2.DeleteVpcInput, ...func(*ec2.Options)) (*ec2.DeleteVpcOutput, error)) *MockEC2Clienter_DeleteVpc_Call { - _c.Call.Return(run) - return _c -} - -// DescribeAvailabilityZones provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DescribeAvailabilityZones(ctx context.Context, params *ec2.DescribeAvailabilityZonesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeAvailabilityZonesOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DescribeAvailabilityZones") - } - - var r0 *ec2.DescribeAvailabilityZonesOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeAvailabilityZonesInput, ...func(*ec2.Options)) (*ec2.DescribeAvailabilityZonesOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeAvailabilityZonesInput, ...func(*ec2.Options)) *ec2.DescribeAvailabilityZonesOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DescribeAvailabilityZonesOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DescribeAvailabilityZonesInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DescribeAvailabilityZones_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DescribeAvailabilityZones' -type MockEC2Clienter_DescribeAvailabilityZones_Call struct { - *mock.Call -} - -// DescribeAvailabilityZones is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DescribeAvailabilityZonesInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DescribeAvailabilityZones(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DescribeAvailabilityZones_Call { - return &MockEC2Clienter_DescribeAvailabilityZones_Call{Call: _e.mock.On("DescribeAvailabilityZones", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DescribeAvailabilityZones_Call) Run(run func(ctx context.Context, params *ec2.DescribeAvailabilityZonesInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DescribeAvailabilityZones_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DescribeAvailabilityZonesInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DescribeAvailabilityZones_Call) Return(_a0 *ec2.DescribeAvailabilityZonesOutput, _a1 error) *MockEC2Clienter_DescribeAvailabilityZones_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DescribeAvailabilityZones_Call) RunAndReturn(run func(context.Context, *ec2.DescribeAvailabilityZonesInput, ...func(*ec2.Options)) (*ec2.DescribeAvailabilityZonesOutput, error)) *MockEC2Clienter_DescribeAvailabilityZones_Call { - _c.Call.Return(run) - return _c -} - -// DescribeImages provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DescribeImages(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DescribeImages") - } - - var r0 *ec2.DescribeImagesOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeImagesInput, ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeImagesInput, ...func(*ec2.Options)) *ec2.DescribeImagesOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DescribeImagesOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DescribeImagesInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DescribeImages_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DescribeImages' -type MockEC2Clienter_DescribeImages_Call struct { - *mock.Call -} - -// DescribeImages is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DescribeImagesInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DescribeImages(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DescribeImages_Call { - return &MockEC2Clienter_DescribeImages_Call{Call: _e.mock.On("DescribeImages", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DescribeImages_Call) Run(run func(ctx context.Context, params *ec2.DescribeImagesInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DescribeImages_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DescribeImagesInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DescribeImages_Call) Return(_a0 *ec2.DescribeImagesOutput, _a1 error) *MockEC2Clienter_DescribeImages_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DescribeImages_Call) RunAndReturn(run func(context.Context, *ec2.DescribeImagesInput, ...func(*ec2.Options)) (*ec2.DescribeImagesOutput, error)) *MockEC2Clienter_DescribeImages_Call { - _c.Call.Return(run) - return _c -} - -// DescribeInstances provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DescribeInstances(ctx context.Context, params *ec2.DescribeInstancesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DescribeInstances") - } - - var r0 *ec2.DescribeInstancesOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeInstancesInput, ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeInstancesInput, ...func(*ec2.Options)) *ec2.DescribeInstancesOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DescribeInstancesOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DescribeInstancesInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DescribeInstances_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DescribeInstances' -type MockEC2Clienter_DescribeInstances_Call struct { - *mock.Call -} - -// DescribeInstances is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DescribeInstancesInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DescribeInstances(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DescribeInstances_Call { - return &MockEC2Clienter_DescribeInstances_Call{Call: _e.mock.On("DescribeInstances", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DescribeInstances_Call) Run(run func(ctx context.Context, params *ec2.DescribeInstancesInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DescribeInstances_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DescribeInstancesInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DescribeInstances_Call) Return(_a0 *ec2.DescribeInstancesOutput, _a1 error) *MockEC2Clienter_DescribeInstances_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DescribeInstances_Call) RunAndReturn(run func(context.Context, *ec2.DescribeInstancesInput, ...func(*ec2.Options)) (*ec2.DescribeInstancesOutput, error)) *MockEC2Clienter_DescribeInstances_Call { - _c.Call.Return(run) - return _c -} - -// DescribeInternetGateways provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DescribeInternetGateways(ctx context.Context, params *ec2.DescribeInternetGatewaysInput, optFns ...func(*ec2.Options)) (*ec2.DescribeInternetGatewaysOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DescribeInternetGateways") - } - - var r0 *ec2.DescribeInternetGatewaysOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeInternetGatewaysInput, ...func(*ec2.Options)) (*ec2.DescribeInternetGatewaysOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeInternetGatewaysInput, ...func(*ec2.Options)) *ec2.DescribeInternetGatewaysOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DescribeInternetGatewaysOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DescribeInternetGatewaysInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DescribeInternetGateways_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DescribeInternetGateways' -type MockEC2Clienter_DescribeInternetGateways_Call struct { - *mock.Call -} - -// DescribeInternetGateways is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DescribeInternetGatewaysInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DescribeInternetGateways(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DescribeInternetGateways_Call { - return &MockEC2Clienter_DescribeInternetGateways_Call{Call: _e.mock.On("DescribeInternetGateways", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DescribeInternetGateways_Call) Run(run func(ctx context.Context, params *ec2.DescribeInternetGatewaysInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DescribeInternetGateways_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DescribeInternetGatewaysInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DescribeInternetGateways_Call) Return(_a0 *ec2.DescribeInternetGatewaysOutput, _a1 error) *MockEC2Clienter_DescribeInternetGateways_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DescribeInternetGateways_Call) RunAndReturn(run func(context.Context, *ec2.DescribeInternetGatewaysInput, ...func(*ec2.Options)) (*ec2.DescribeInternetGatewaysOutput, error)) *MockEC2Clienter_DescribeInternetGateways_Call { - _c.Call.Return(run) - return _c -} - -// DescribeRegions provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DescribeRegions(ctx context.Context, params *ec2.DescribeRegionsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeRegionsOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DescribeRegions") - } - - var r0 *ec2.DescribeRegionsOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeRegionsInput, ...func(*ec2.Options)) (*ec2.DescribeRegionsOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeRegionsInput, ...func(*ec2.Options)) *ec2.DescribeRegionsOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DescribeRegionsOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DescribeRegionsInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DescribeRegions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DescribeRegions' -type MockEC2Clienter_DescribeRegions_Call struct { - *mock.Call -} - -// DescribeRegions is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DescribeRegionsInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DescribeRegions(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DescribeRegions_Call { - return &MockEC2Clienter_DescribeRegions_Call{Call: _e.mock.On("DescribeRegions", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DescribeRegions_Call) Run(run func(ctx context.Context, params *ec2.DescribeRegionsInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DescribeRegions_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DescribeRegionsInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DescribeRegions_Call) Return(_a0 *ec2.DescribeRegionsOutput, _a1 error) *MockEC2Clienter_DescribeRegions_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DescribeRegions_Call) RunAndReturn(run func(context.Context, *ec2.DescribeRegionsInput, ...func(*ec2.Options)) (*ec2.DescribeRegionsOutput, error)) *MockEC2Clienter_DescribeRegions_Call { - _c.Call.Return(run) - return _c -} - -// DescribeRouteTables provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DescribeRouteTables(ctx context.Context, params *ec2.DescribeRouteTablesInput, optFns ...func(*ec2.Options)) (*ec2.DescribeRouteTablesOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DescribeRouteTables") - } - - var r0 *ec2.DescribeRouteTablesOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeRouteTablesInput, ...func(*ec2.Options)) (*ec2.DescribeRouteTablesOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeRouteTablesInput, ...func(*ec2.Options)) *ec2.DescribeRouteTablesOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DescribeRouteTablesOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DescribeRouteTablesInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DescribeRouteTables_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DescribeRouteTables' -type MockEC2Clienter_DescribeRouteTables_Call struct { - *mock.Call -} - -// DescribeRouteTables is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DescribeRouteTablesInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DescribeRouteTables(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DescribeRouteTables_Call { - return &MockEC2Clienter_DescribeRouteTables_Call{Call: _e.mock.On("DescribeRouteTables", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DescribeRouteTables_Call) Run(run func(ctx context.Context, params *ec2.DescribeRouteTablesInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DescribeRouteTables_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DescribeRouteTablesInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DescribeRouteTables_Call) Return(_a0 *ec2.DescribeRouteTablesOutput, _a1 error) *MockEC2Clienter_DescribeRouteTables_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DescribeRouteTables_Call) RunAndReturn(run func(context.Context, *ec2.DescribeRouteTablesInput, ...func(*ec2.Options)) (*ec2.DescribeRouteTablesOutput, error)) *MockEC2Clienter_DescribeRouteTables_Call { - _c.Call.Return(run) - return _c -} - -// DescribeSecurityGroups provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DescribeSecurityGroups(ctx context.Context, params *ec2.DescribeSecurityGroupsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupsOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DescribeSecurityGroups") - } - - var r0 *ec2.DescribeSecurityGroupsOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeSecurityGroupsInput, ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupsOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeSecurityGroupsInput, ...func(*ec2.Options)) *ec2.DescribeSecurityGroupsOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DescribeSecurityGroupsOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DescribeSecurityGroupsInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DescribeSecurityGroups_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DescribeSecurityGroups' -type MockEC2Clienter_DescribeSecurityGroups_Call struct { - *mock.Call -} - -// DescribeSecurityGroups is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DescribeSecurityGroupsInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DescribeSecurityGroups(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DescribeSecurityGroups_Call { - return &MockEC2Clienter_DescribeSecurityGroups_Call{Call: _e.mock.On("DescribeSecurityGroups", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DescribeSecurityGroups_Call) Run(run func(ctx context.Context, params *ec2.DescribeSecurityGroupsInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DescribeSecurityGroups_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DescribeSecurityGroupsInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DescribeSecurityGroups_Call) Return(_a0 *ec2.DescribeSecurityGroupsOutput, _a1 error) *MockEC2Clienter_DescribeSecurityGroups_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DescribeSecurityGroups_Call) RunAndReturn(run func(context.Context, *ec2.DescribeSecurityGroupsInput, ...func(*ec2.Options)) (*ec2.DescribeSecurityGroupsOutput, error)) *MockEC2Clienter_DescribeSecurityGroups_Call { - _c.Call.Return(run) - return _c -} - -// DescribeSubnets provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DescribeSubnets(ctx context.Context, params *ec2.DescribeSubnetsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeSubnetsOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DescribeSubnets") - } - - var r0 *ec2.DescribeSubnetsOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeSubnetsInput, ...func(*ec2.Options)) (*ec2.DescribeSubnetsOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeSubnetsInput, ...func(*ec2.Options)) *ec2.DescribeSubnetsOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DescribeSubnetsOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DescribeSubnetsInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DescribeSubnets_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DescribeSubnets' -type MockEC2Clienter_DescribeSubnets_Call struct { - *mock.Call -} - -// DescribeSubnets is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DescribeSubnetsInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DescribeSubnets(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DescribeSubnets_Call { - return &MockEC2Clienter_DescribeSubnets_Call{Call: _e.mock.On("DescribeSubnets", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DescribeSubnets_Call) Run(run func(ctx context.Context, params *ec2.DescribeSubnetsInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DescribeSubnets_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DescribeSubnetsInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DescribeSubnets_Call) Return(_a0 *ec2.DescribeSubnetsOutput, _a1 error) *MockEC2Clienter_DescribeSubnets_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DescribeSubnets_Call) RunAndReturn(run func(context.Context, *ec2.DescribeSubnetsInput, ...func(*ec2.Options)) (*ec2.DescribeSubnetsOutput, error)) *MockEC2Clienter_DescribeSubnets_Call { - _c.Call.Return(run) - return _c -} - -// DescribeVpcs provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DescribeVpcs(ctx context.Context, params *ec2.DescribeVpcsInput, optFns ...func(*ec2.Options)) (*ec2.DescribeVpcsOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DescribeVpcs") - } - - var r0 *ec2.DescribeVpcsOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeVpcsInput, ...func(*ec2.Options)) (*ec2.DescribeVpcsOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DescribeVpcsInput, ...func(*ec2.Options)) *ec2.DescribeVpcsOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DescribeVpcsOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DescribeVpcsInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DescribeVpcs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DescribeVpcs' -type MockEC2Clienter_DescribeVpcs_Call struct { - *mock.Call -} - -// DescribeVpcs is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DescribeVpcsInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DescribeVpcs(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DescribeVpcs_Call { - return &MockEC2Clienter_DescribeVpcs_Call{Call: _e.mock.On("DescribeVpcs", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DescribeVpcs_Call) Run(run func(ctx context.Context, params *ec2.DescribeVpcsInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DescribeVpcs_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DescribeVpcsInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DescribeVpcs_Call) Return(_a0 *ec2.DescribeVpcsOutput, _a1 error) *MockEC2Clienter_DescribeVpcs_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DescribeVpcs_Call) RunAndReturn(run func(context.Context, *ec2.DescribeVpcsInput, ...func(*ec2.Options)) (*ec2.DescribeVpcsOutput, error)) *MockEC2Clienter_DescribeVpcs_Call { - _c.Call.Return(run) - return _c -} - -// DetachInternetGateway provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DetachInternetGateway(ctx context.Context, params *ec2.DetachInternetGatewayInput, optFns ...func(*ec2.Options)) (*ec2.DetachInternetGatewayOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DetachInternetGateway") - } - - var r0 *ec2.DetachInternetGatewayOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DetachInternetGatewayInput, ...func(*ec2.Options)) (*ec2.DetachInternetGatewayOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DetachInternetGatewayInput, ...func(*ec2.Options)) *ec2.DetachInternetGatewayOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DetachInternetGatewayOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DetachInternetGatewayInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DetachInternetGateway_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DetachInternetGateway' -type MockEC2Clienter_DetachInternetGateway_Call struct { - *mock.Call -} - -// DetachInternetGateway is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DetachInternetGatewayInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DetachInternetGateway(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DetachInternetGateway_Call { - return &MockEC2Clienter_DetachInternetGateway_Call{Call: _e.mock.On("DetachInternetGateway", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DetachInternetGateway_Call) Run(run func(ctx context.Context, params *ec2.DetachInternetGatewayInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DetachInternetGateway_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DetachInternetGatewayInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DetachInternetGateway_Call) Return(_a0 *ec2.DetachInternetGatewayOutput, _a1 error) *MockEC2Clienter_DetachInternetGateway_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DetachInternetGateway_Call) RunAndReturn(run func(context.Context, *ec2.DetachInternetGatewayInput, ...func(*ec2.Options)) (*ec2.DetachInternetGatewayOutput, error)) *MockEC2Clienter_DetachInternetGateway_Call { - _c.Call.Return(run) - return _c -} - -// DisassociateRouteTable provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) DisassociateRouteTable(ctx context.Context, params *ec2.DisassociateRouteTableInput, optFns ...func(*ec2.Options)) (*ec2.DisassociateRouteTableOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for DisassociateRouteTable") - } - - var r0 *ec2.DisassociateRouteTableOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DisassociateRouteTableInput, ...func(*ec2.Options)) (*ec2.DisassociateRouteTableOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.DisassociateRouteTableInput, ...func(*ec2.Options)) *ec2.DisassociateRouteTableOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.DisassociateRouteTableOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.DisassociateRouteTableInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_DisassociateRouteTable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DisassociateRouteTable' -type MockEC2Clienter_DisassociateRouteTable_Call struct { - *mock.Call -} - -// DisassociateRouteTable is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.DisassociateRouteTableInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) DisassociateRouteTable(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_DisassociateRouteTable_Call { - return &MockEC2Clienter_DisassociateRouteTable_Call{Call: _e.mock.On("DisassociateRouteTable", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_DisassociateRouteTable_Call) Run(run func(ctx context.Context, params *ec2.DisassociateRouteTableInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_DisassociateRouteTable_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.DisassociateRouteTableInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_DisassociateRouteTable_Call) Return(_a0 *ec2.DisassociateRouteTableOutput, _a1 error) *MockEC2Clienter_DisassociateRouteTable_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_DisassociateRouteTable_Call) RunAndReturn(run func(context.Context, *ec2.DisassociateRouteTableInput, ...func(*ec2.Options)) (*ec2.DisassociateRouteTableOutput, error)) *MockEC2Clienter_DisassociateRouteTable_Call { - _c.Call.Return(run) - return _c -} - -// ModifyVpcAttribute provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) ModifyVpcAttribute(ctx context.Context, params *ec2.ModifyVpcAttributeInput, optFns ...func(*ec2.Options)) (*ec2.ModifyVpcAttributeOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for ModifyVpcAttribute") - } - - var r0 *ec2.ModifyVpcAttributeOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.ModifyVpcAttributeInput, ...func(*ec2.Options)) (*ec2.ModifyVpcAttributeOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.ModifyVpcAttributeInput, ...func(*ec2.Options)) *ec2.ModifyVpcAttributeOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.ModifyVpcAttributeOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.ModifyVpcAttributeInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_ModifyVpcAttribute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ModifyVpcAttribute' -type MockEC2Clienter_ModifyVpcAttribute_Call struct { - *mock.Call -} - -// ModifyVpcAttribute is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.ModifyVpcAttributeInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) ModifyVpcAttribute(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_ModifyVpcAttribute_Call { - return &MockEC2Clienter_ModifyVpcAttribute_Call{Call: _e.mock.On("ModifyVpcAttribute", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_ModifyVpcAttribute_Call) Run(run func(ctx context.Context, params *ec2.ModifyVpcAttributeInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_ModifyVpcAttribute_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.ModifyVpcAttributeInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_ModifyVpcAttribute_Call) Return(_a0 *ec2.ModifyVpcAttributeOutput, _a1 error) *MockEC2Clienter_ModifyVpcAttribute_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_ModifyVpcAttribute_Call) RunAndReturn(run func(context.Context, *ec2.ModifyVpcAttributeInput, ...func(*ec2.Options)) (*ec2.ModifyVpcAttributeOutput, error)) *MockEC2Clienter_ModifyVpcAttribute_Call { - _c.Call.Return(run) - return _c -} - -// RunInstances provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) RunInstances(ctx context.Context, params *ec2.RunInstancesInput, optFns ...func(*ec2.Options)) (*ec2.RunInstancesOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for RunInstances") - } - - var r0 *ec2.RunInstancesOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.RunInstancesInput, ...func(*ec2.Options)) (*ec2.RunInstancesOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.RunInstancesInput, ...func(*ec2.Options)) *ec2.RunInstancesOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.RunInstancesOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.RunInstancesInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_RunInstances_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RunInstances' -type MockEC2Clienter_RunInstances_Call struct { - *mock.Call -} - -// RunInstances is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.RunInstancesInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) RunInstances(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_RunInstances_Call { - return &MockEC2Clienter_RunInstances_Call{Call: _e.mock.On("RunInstances", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_RunInstances_Call) Run(run func(ctx context.Context, params *ec2.RunInstancesInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_RunInstances_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.RunInstancesInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_RunInstances_Call) Return(_a0 *ec2.RunInstancesOutput, _a1 error) *MockEC2Clienter_RunInstances_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_RunInstances_Call) RunAndReturn(run func(context.Context, *ec2.RunInstancesInput, ...func(*ec2.Options)) (*ec2.RunInstancesOutput, error)) *MockEC2Clienter_RunInstances_Call { - _c.Call.Return(run) - return _c -} - -// TerminateInstances provides a mock function with given fields: ctx, params, optFns -func (_m *MockEC2Clienter) TerminateInstances(ctx context.Context, params *ec2.TerminateInstancesInput, optFns ...func(*ec2.Options)) (*ec2.TerminateInstancesOutput, error) { - _va := make([]interface{}, len(optFns)) - for _i := range optFns { - _va[_i] = optFns[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, params) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - if len(ret) == 0 { - panic("no return value specified for TerminateInstances") - } - - var r0 *ec2.TerminateInstancesOutput - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *ec2.TerminateInstancesInput, ...func(*ec2.Options)) (*ec2.TerminateInstancesOutput, error)); ok { - return rf(ctx, params, optFns...) - } - if rf, ok := ret.Get(0).(func(context.Context, *ec2.TerminateInstancesInput, ...func(*ec2.Options)) *ec2.TerminateInstancesOutput); ok { - r0 = rf(ctx, params, optFns...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ec2.TerminateInstancesOutput) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *ec2.TerminateInstancesInput, ...func(*ec2.Options)) error); ok { - r1 = rf(ctx, params, optFns...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockEC2Clienter_TerminateInstances_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TerminateInstances' -type MockEC2Clienter_TerminateInstances_Call struct { - *mock.Call -} - -// TerminateInstances is a helper method to define mock.On call -// - ctx context.Context -// - params *ec2.TerminateInstancesInput -// - optFns ...func(*ec2.Options) -func (_e *MockEC2Clienter_Expecter) TerminateInstances(ctx interface{}, params interface{}, optFns ...interface{}) *MockEC2Clienter_TerminateInstances_Call { - return &MockEC2Clienter_TerminateInstances_Call{Call: _e.mock.On("TerminateInstances", - append([]interface{}{ctx, params}, optFns...)...)} -} - -func (_c *MockEC2Clienter_TerminateInstances_Call) Run(run func(ctx context.Context, params *ec2.TerminateInstancesInput, optFns ...func(*ec2.Options))) *MockEC2Clienter_TerminateInstances_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]func(*ec2.Options), len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(func(*ec2.Options)) - } - } - run(args[0].(context.Context), args[1].(*ec2.TerminateInstancesInput), variadicArgs...) - }) - return _c -} - -func (_c *MockEC2Clienter_TerminateInstances_Call) Return(_a0 *ec2.TerminateInstancesOutput, _a1 error) *MockEC2Clienter_TerminateInstances_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockEC2Clienter_TerminateInstances_Call) RunAndReturn(run func(context.Context, *ec2.TerminateInstancesInput, ...func(*ec2.Options)) (*ec2.TerminateInstancesOutput, error)) *MockEC2Clienter_TerminateInstances_Call { - _c.Call.Return(run) - return _c -} - -// NewMockEC2Clienter creates a new instance of MockEC2Clienter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockEC2Clienter(t interface { - mock.TestingT - Cleanup(func()) -}) *MockEC2Clienter { - mock := &MockEC2Clienter{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/azure/mock_AzureClienter.go b/pkg/models/interfaces/aws/mocks/azure/mock_AzureClienter.go deleted file mode 100644 index 41afb75b..00000000 --- a/pkg/models/interfaces/aws/mocks/azure/mock_AzureClienter.go +++ /dev/null @@ -1,856 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package azure_interface - -import ( - armcompute "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute" - armnetwork "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork" - - armresources "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - - armsubscription "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/subscription/armsubscription" - - azure_interface "github.com/bacalhau-project/andaime/pkg/models/interfaces/azure" - - context "context" - - mock "github.com/stretchr/testify/mock" - - runtime "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" -) - -// MockAzureClienter is an autogenerated mock type for the AzureClienter type -type MockAzureClienter struct { - mock.Mock -} - -type MockAzureClienter_Expecter struct { - mock *mock.Mock -} - -func (_m *MockAzureClienter) EXPECT() *MockAzureClienter_Expecter { - return &MockAzureClienter_Expecter{mock: &_m.Mock} -} - -// DeployTemplate provides a mock function with given fields: ctx, resourceGroupName, deploymentName, template, params, tags -func (_m *MockAzureClienter) DeployTemplate(ctx context.Context, resourceGroupName string, deploymentName string, template map[string]interface{}, params map[string]interface{}, tags map[string]*string) (azure_interface.Pollerer, error) { - ret := _m.Called(ctx, resourceGroupName, deploymentName, template, params, tags) - - if len(ret) == 0 { - panic("no return value specified for DeployTemplate") - } - - var r0 azure_interface.Pollerer - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, map[string]interface{}, map[string]interface{}, map[string]*string) (azure_interface.Pollerer, error)); ok { - return rf(ctx, resourceGroupName, deploymentName, template, params, tags) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, map[string]interface{}, map[string]interface{}, map[string]*string) azure_interface.Pollerer); ok { - r0 = rf(ctx, resourceGroupName, deploymentName, template, params, tags) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(azure_interface.Pollerer) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, map[string]interface{}, map[string]interface{}, map[string]*string) error); ok { - r1 = rf(ctx, resourceGroupName, deploymentName, template, params, tags) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_DeployTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeployTemplate' -type MockAzureClienter_DeployTemplate_Call struct { - *mock.Call -} - -// DeployTemplate is a helper method to define mock.On call -// - ctx context.Context -// - resourceGroupName string -// - deploymentName string -// - template map[string]interface{} -// - params map[string]interface{} -// - tags map[string]*string -func (_e *MockAzureClienter_Expecter) DeployTemplate(ctx interface{}, resourceGroupName interface{}, deploymentName interface{}, template interface{}, params interface{}, tags interface{}) *MockAzureClienter_DeployTemplate_Call { - return &MockAzureClienter_DeployTemplate_Call{Call: _e.mock.On("DeployTemplate", ctx, resourceGroupName, deploymentName, template, params, tags)} -} - -func (_c *MockAzureClienter_DeployTemplate_Call) Run(run func(ctx context.Context, resourceGroupName string, deploymentName string, template map[string]interface{}, params map[string]interface{}, tags map[string]*string)) *MockAzureClienter_DeployTemplate_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(map[string]interface{}), args[4].(map[string]interface{}), args[5].(map[string]*string)) - }) - return _c -} - -func (_c *MockAzureClienter_DeployTemplate_Call) Return(_a0 azure_interface.Pollerer, _a1 error) *MockAzureClienter_DeployTemplate_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_DeployTemplate_Call) RunAndReturn(run func(context.Context, string, string, map[string]interface{}, map[string]interface{}, map[string]*string) (azure_interface.Pollerer, error)) *MockAzureClienter_DeployTemplate_Call { - _c.Call.Return(run) - return _c -} - -// DestroyResourceGroup provides a mock function with given fields: ctx, resourceGroupName -func (_m *MockAzureClienter) DestroyResourceGroup(ctx context.Context, resourceGroupName string) error { - ret := _m.Called(ctx, resourceGroupName) - - if len(ret) == 0 { - panic("no return value specified for DestroyResourceGroup") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { - r0 = rf(ctx, resourceGroupName) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockAzureClienter_DestroyResourceGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DestroyResourceGroup' -type MockAzureClienter_DestroyResourceGroup_Call struct { - *mock.Call -} - -// DestroyResourceGroup is a helper method to define mock.On call -// - ctx context.Context -// - resourceGroupName string -func (_e *MockAzureClienter_Expecter) DestroyResourceGroup(ctx interface{}, resourceGroupName interface{}) *MockAzureClienter_DestroyResourceGroup_Call { - return &MockAzureClienter_DestroyResourceGroup_Call{Call: _e.mock.On("DestroyResourceGroup", ctx, resourceGroupName)} -} - -func (_c *MockAzureClienter_DestroyResourceGroup_Call) Run(run func(ctx context.Context, resourceGroupName string)) *MockAzureClienter_DestroyResourceGroup_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockAzureClienter_DestroyResourceGroup_Call) Return(_a0 error) *MockAzureClienter_DestroyResourceGroup_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockAzureClienter_DestroyResourceGroup_Call) RunAndReturn(run func(context.Context, string) error) *MockAzureClienter_DestroyResourceGroup_Call { - _c.Call.Return(run) - return _c -} - -// GetNetworkInterface provides a mock function with given fields: ctx, resourceGroupName, networkInterfaceName -func (_m *MockAzureClienter) GetNetworkInterface(ctx context.Context, resourceGroupName string, networkInterfaceName string) (*armnetwork.Interface, error) { - ret := _m.Called(ctx, resourceGroupName, networkInterfaceName) - - if len(ret) == 0 { - panic("no return value specified for GetNetworkInterface") - } - - var r0 *armnetwork.Interface - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*armnetwork.Interface, error)); ok { - return rf(ctx, resourceGroupName, networkInterfaceName) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *armnetwork.Interface); ok { - r0 = rf(ctx, resourceGroupName, networkInterfaceName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*armnetwork.Interface) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, resourceGroupName, networkInterfaceName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_GetNetworkInterface_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetNetworkInterface' -type MockAzureClienter_GetNetworkInterface_Call struct { - *mock.Call -} - -// GetNetworkInterface is a helper method to define mock.On call -// - ctx context.Context -// - resourceGroupName string -// - networkInterfaceName string -func (_e *MockAzureClienter_Expecter) GetNetworkInterface(ctx interface{}, resourceGroupName interface{}, networkInterfaceName interface{}) *MockAzureClienter_GetNetworkInterface_Call { - return &MockAzureClienter_GetNetworkInterface_Call{Call: _e.mock.On("GetNetworkInterface", ctx, resourceGroupName, networkInterfaceName)} -} - -func (_c *MockAzureClienter_GetNetworkInterface_Call) Run(run func(ctx context.Context, resourceGroupName string, networkInterfaceName string)) *MockAzureClienter_GetNetworkInterface_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockAzureClienter_GetNetworkInterface_Call) Return(_a0 *armnetwork.Interface, _a1 error) *MockAzureClienter_GetNetworkInterface_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_GetNetworkInterface_Call) RunAndReturn(run func(context.Context, string, string) (*armnetwork.Interface, error)) *MockAzureClienter_GetNetworkInterface_Call { - _c.Call.Return(run) - return _c -} - -// GetOrCreateResourceGroup provides a mock function with given fields: ctx, resourceGroupName, location, tags -func (_m *MockAzureClienter) GetOrCreateResourceGroup(ctx context.Context, resourceGroupName string, location string, tags map[string]string) (*armresources.ResourceGroup, error) { - ret := _m.Called(ctx, resourceGroupName, location, tags) - - if len(ret) == 0 { - panic("no return value specified for GetOrCreateResourceGroup") - } - - var r0 *armresources.ResourceGroup - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, map[string]string) (*armresources.ResourceGroup, error)); ok { - return rf(ctx, resourceGroupName, location, tags) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, map[string]string) *armresources.ResourceGroup); ok { - r0 = rf(ctx, resourceGroupName, location, tags) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*armresources.ResourceGroup) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, map[string]string) error); ok { - r1 = rf(ctx, resourceGroupName, location, tags) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_GetOrCreateResourceGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrCreateResourceGroup' -type MockAzureClienter_GetOrCreateResourceGroup_Call struct { - *mock.Call -} - -// GetOrCreateResourceGroup is a helper method to define mock.On call -// - ctx context.Context -// - resourceGroupName string -// - location string -// - tags map[string]string -func (_e *MockAzureClienter_Expecter) GetOrCreateResourceGroup(ctx interface{}, resourceGroupName interface{}, location interface{}, tags interface{}) *MockAzureClienter_GetOrCreateResourceGroup_Call { - return &MockAzureClienter_GetOrCreateResourceGroup_Call{Call: _e.mock.On("GetOrCreateResourceGroup", ctx, resourceGroupName, location, tags)} -} - -func (_c *MockAzureClienter_GetOrCreateResourceGroup_Call) Run(run func(ctx context.Context, resourceGroupName string, location string, tags map[string]string)) *MockAzureClienter_GetOrCreateResourceGroup_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(map[string]string)) - }) - return _c -} - -func (_c *MockAzureClienter_GetOrCreateResourceGroup_Call) Return(_a0 *armresources.ResourceGroup, _a1 error) *MockAzureClienter_GetOrCreateResourceGroup_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_GetOrCreateResourceGroup_Call) RunAndReturn(run func(context.Context, string, string, map[string]string) (*armresources.ResourceGroup, error)) *MockAzureClienter_GetOrCreateResourceGroup_Call { - _c.Call.Return(run) - return _c -} - -// GetPublicIPAddress provides a mock function with given fields: ctx, resourceGroupName, publicIPAddress -func (_m *MockAzureClienter) GetPublicIPAddress(ctx context.Context, resourceGroupName string, publicIPAddress *armnetwork.PublicIPAddress) (string, error) { - ret := _m.Called(ctx, resourceGroupName, publicIPAddress) - - if len(ret) == 0 { - panic("no return value specified for GetPublicIPAddress") - } - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, *armnetwork.PublicIPAddress) (string, error)); ok { - return rf(ctx, resourceGroupName, publicIPAddress) - } - if rf, ok := ret.Get(0).(func(context.Context, string, *armnetwork.PublicIPAddress) string); ok { - r0 = rf(ctx, resourceGroupName, publicIPAddress) - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, *armnetwork.PublicIPAddress) error); ok { - r1 = rf(ctx, resourceGroupName, publicIPAddress) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_GetPublicIPAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPublicIPAddress' -type MockAzureClienter_GetPublicIPAddress_Call struct { - *mock.Call -} - -// GetPublicIPAddress is a helper method to define mock.On call -// - ctx context.Context -// - resourceGroupName string -// - publicIPAddress *armnetwork.PublicIPAddress -func (_e *MockAzureClienter_Expecter) GetPublicIPAddress(ctx interface{}, resourceGroupName interface{}, publicIPAddress interface{}) *MockAzureClienter_GetPublicIPAddress_Call { - return &MockAzureClienter_GetPublicIPAddress_Call{Call: _e.mock.On("GetPublicIPAddress", ctx, resourceGroupName, publicIPAddress)} -} - -func (_c *MockAzureClienter_GetPublicIPAddress_Call) Run(run func(ctx context.Context, resourceGroupName string, publicIPAddress *armnetwork.PublicIPAddress)) *MockAzureClienter_GetPublicIPAddress_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(*armnetwork.PublicIPAddress)) - }) - return _c -} - -func (_c *MockAzureClienter_GetPublicIPAddress_Call) Return(_a0 string, _a1 error) *MockAzureClienter_GetPublicIPAddress_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_GetPublicIPAddress_Call) RunAndReturn(run func(context.Context, string, *armnetwork.PublicIPAddress) (string, error)) *MockAzureClienter_GetPublicIPAddress_Call { - _c.Call.Return(run) - return _c -} - -// GetResources provides a mock function with given fields: ctx, subscriptionID, resourceGroupName, tags -func (_m *MockAzureClienter) GetResources(ctx context.Context, subscriptionID string, resourceGroupName string, tags map[string]*string) ([]interface{}, error) { - ret := _m.Called(ctx, subscriptionID, resourceGroupName, tags) - - if len(ret) == 0 { - panic("no return value specified for GetResources") - } - - var r0 []interface{} - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, map[string]*string) ([]interface{}, error)); ok { - return rf(ctx, subscriptionID, resourceGroupName, tags) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, map[string]*string) []interface{}); ok { - r0 = rf(ctx, subscriptionID, resourceGroupName, tags) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]interface{}) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, map[string]*string) error); ok { - r1 = rf(ctx, subscriptionID, resourceGroupName, tags) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_GetResources_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetResources' -type MockAzureClienter_GetResources_Call struct { - *mock.Call -} - -// GetResources is a helper method to define mock.On call -// - ctx context.Context -// - subscriptionID string -// - resourceGroupName string -// - tags map[string]*string -func (_e *MockAzureClienter_Expecter) GetResources(ctx interface{}, subscriptionID interface{}, resourceGroupName interface{}, tags interface{}) *MockAzureClienter_GetResources_Call { - return &MockAzureClienter_GetResources_Call{Call: _e.mock.On("GetResources", ctx, subscriptionID, resourceGroupName, tags)} -} - -func (_c *MockAzureClienter_GetResources_Call) Run(run func(ctx context.Context, subscriptionID string, resourceGroupName string, tags map[string]*string)) *MockAzureClienter_GetResources_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(map[string]*string)) - }) - return _c -} - -func (_c *MockAzureClienter_GetResources_Call) Return(_a0 []interface{}, _a1 error) *MockAzureClienter_GetResources_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_GetResources_Call) RunAndReturn(run func(context.Context, string, string, map[string]*string) ([]interface{}, error)) *MockAzureClienter_GetResources_Call { - _c.Call.Return(run) - return _c -} - -// GetSKUsByLocation provides a mock function with given fields: ctx, location -func (_m *MockAzureClienter) GetSKUsByLocation(ctx context.Context, location string) ([]armcompute.ResourceSKU, error) { - ret := _m.Called(ctx, location) - - if len(ret) == 0 { - panic("no return value specified for GetSKUsByLocation") - } - - var r0 []armcompute.ResourceSKU - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) ([]armcompute.ResourceSKU, error)); ok { - return rf(ctx, location) - } - if rf, ok := ret.Get(0).(func(context.Context, string) []armcompute.ResourceSKU); ok { - r0 = rf(ctx, location) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]armcompute.ResourceSKU) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, location) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_GetSKUsByLocation_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSKUsByLocation' -type MockAzureClienter_GetSKUsByLocation_Call struct { - *mock.Call -} - -// GetSKUsByLocation is a helper method to define mock.On call -// - ctx context.Context -// - location string -func (_e *MockAzureClienter_Expecter) GetSKUsByLocation(ctx interface{}, location interface{}) *MockAzureClienter_GetSKUsByLocation_Call { - return &MockAzureClienter_GetSKUsByLocation_Call{Call: _e.mock.On("GetSKUsByLocation", ctx, location)} -} - -func (_c *MockAzureClienter_GetSKUsByLocation_Call) Run(run func(ctx context.Context, location string)) *MockAzureClienter_GetSKUsByLocation_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockAzureClienter_GetSKUsByLocation_Call) Return(_a0 []armcompute.ResourceSKU, _a1 error) *MockAzureClienter_GetSKUsByLocation_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_GetSKUsByLocation_Call) RunAndReturn(run func(context.Context, string) ([]armcompute.ResourceSKU, error)) *MockAzureClienter_GetSKUsByLocation_Call { - _c.Call.Return(run) - return _c -} - -// GetVMExternalIP provides a mock function with given fields: ctx, vmName, locationData -func (_m *MockAzureClienter) GetVMExternalIP(ctx context.Context, vmName string, locationData map[string]string) (string, error) { - ret := _m.Called(ctx, vmName, locationData) - - if len(ret) == 0 { - panic("no return value specified for GetVMExternalIP") - } - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, map[string]string) (string, error)); ok { - return rf(ctx, vmName, locationData) - } - if rf, ok := ret.Get(0).(func(context.Context, string, map[string]string) string); ok { - r0 = rf(ctx, vmName, locationData) - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, map[string]string) error); ok { - r1 = rf(ctx, vmName, locationData) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_GetVMExternalIP_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetVMExternalIP' -type MockAzureClienter_GetVMExternalIP_Call struct { - *mock.Call -} - -// GetVMExternalIP is a helper method to define mock.On call -// - ctx context.Context -// - vmName string -// - locationData map[string]string -func (_e *MockAzureClienter_Expecter) GetVMExternalIP(ctx interface{}, vmName interface{}, locationData interface{}) *MockAzureClienter_GetVMExternalIP_Call { - return &MockAzureClienter_GetVMExternalIP_Call{Call: _e.mock.On("GetVMExternalIP", ctx, vmName, locationData)} -} - -func (_c *MockAzureClienter_GetVMExternalIP_Call) Run(run func(ctx context.Context, vmName string, locationData map[string]string)) *MockAzureClienter_GetVMExternalIP_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(map[string]string)) - }) - return _c -} - -func (_c *MockAzureClienter_GetVMExternalIP_Call) Return(_a0 string, _a1 error) *MockAzureClienter_GetVMExternalIP_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_GetVMExternalIP_Call) RunAndReturn(run func(context.Context, string, map[string]string) (string, error)) *MockAzureClienter_GetVMExternalIP_Call { - _c.Call.Return(run) - return _c -} - -// GetVirtualMachine provides a mock function with given fields: ctx, resourceGroupName, vmName -func (_m *MockAzureClienter) GetVirtualMachine(ctx context.Context, resourceGroupName string, vmName string) (*armcompute.VirtualMachine, error) { - ret := _m.Called(ctx, resourceGroupName, vmName) - - if len(ret) == 0 { - panic("no return value specified for GetVirtualMachine") - } - - var r0 *armcompute.VirtualMachine - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (*armcompute.VirtualMachine, error)); ok { - return rf(ctx, resourceGroupName, vmName) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) *armcompute.VirtualMachine); ok { - r0 = rf(ctx, resourceGroupName, vmName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*armcompute.VirtualMachine) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, resourceGroupName, vmName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_GetVirtualMachine_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetVirtualMachine' -type MockAzureClienter_GetVirtualMachine_Call struct { - *mock.Call -} - -// GetVirtualMachine is a helper method to define mock.On call -// - ctx context.Context -// - resourceGroupName string -// - vmName string -func (_e *MockAzureClienter_Expecter) GetVirtualMachine(ctx interface{}, resourceGroupName interface{}, vmName interface{}) *MockAzureClienter_GetVirtualMachine_Call { - return &MockAzureClienter_GetVirtualMachine_Call{Call: _e.mock.On("GetVirtualMachine", ctx, resourceGroupName, vmName)} -} - -func (_c *MockAzureClienter_GetVirtualMachine_Call) Run(run func(ctx context.Context, resourceGroupName string, vmName string)) *MockAzureClienter_GetVirtualMachine_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockAzureClienter_GetVirtualMachine_Call) Return(_a0 *armcompute.VirtualMachine, _a1 error) *MockAzureClienter_GetVirtualMachine_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_GetVirtualMachine_Call) RunAndReturn(run func(context.Context, string, string) (*armcompute.VirtualMachine, error)) *MockAzureClienter_GetVirtualMachine_Call { - _c.Call.Return(run) - return _c -} - -// ListAllResourceGroups provides a mock function with given fields: ctx -func (_m *MockAzureClienter) ListAllResourceGroups(ctx context.Context) ([]*armresources.ResourceGroup, error) { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for ListAllResourceGroups") - } - - var r0 []*armresources.ResourceGroup - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]*armresources.ResourceGroup, error)); ok { - return rf(ctx) - } - if rf, ok := ret.Get(0).(func(context.Context) []*armresources.ResourceGroup); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*armresources.ResourceGroup) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_ListAllResourceGroups_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAllResourceGroups' -type MockAzureClienter_ListAllResourceGroups_Call struct { - *mock.Call -} - -// ListAllResourceGroups is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockAzureClienter_Expecter) ListAllResourceGroups(ctx interface{}) *MockAzureClienter_ListAllResourceGroups_Call { - return &MockAzureClienter_ListAllResourceGroups_Call{Call: _e.mock.On("ListAllResourceGroups", ctx)} -} - -func (_c *MockAzureClienter_ListAllResourceGroups_Call) Run(run func(ctx context.Context)) *MockAzureClienter_ListAllResourceGroups_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockAzureClienter_ListAllResourceGroups_Call) Return(_a0 []*armresources.ResourceGroup, _a1 error) *MockAzureClienter_ListAllResourceGroups_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_ListAllResourceGroups_Call) RunAndReturn(run func(context.Context) ([]*armresources.ResourceGroup, error)) *MockAzureClienter_ListAllResourceGroups_Call { - _c.Call.Return(run) - return _c -} - -// ListAllResourcesInSubscription provides a mock function with given fields: ctx, subscriptionID, tags -func (_m *MockAzureClienter) ListAllResourcesInSubscription(ctx context.Context, subscriptionID string, tags map[string]*string) ([]interface{}, error) { - ret := _m.Called(ctx, subscriptionID, tags) - - if len(ret) == 0 { - panic("no return value specified for ListAllResourcesInSubscription") - } - - var r0 []interface{} - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, map[string]*string) ([]interface{}, error)); ok { - return rf(ctx, subscriptionID, tags) - } - if rf, ok := ret.Get(0).(func(context.Context, string, map[string]*string) []interface{}); ok { - r0 = rf(ctx, subscriptionID, tags) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]interface{}) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, map[string]*string) error); ok { - r1 = rf(ctx, subscriptionID, tags) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_ListAllResourcesInSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAllResourcesInSubscription' -type MockAzureClienter_ListAllResourcesInSubscription_Call struct { - *mock.Call -} - -// ListAllResourcesInSubscription is a helper method to define mock.On call -// - ctx context.Context -// - subscriptionID string -// - tags map[string]*string -func (_e *MockAzureClienter_Expecter) ListAllResourcesInSubscription(ctx interface{}, subscriptionID interface{}, tags interface{}) *MockAzureClienter_ListAllResourcesInSubscription_Call { - return &MockAzureClienter_ListAllResourcesInSubscription_Call{Call: _e.mock.On("ListAllResourcesInSubscription", ctx, subscriptionID, tags)} -} - -func (_c *MockAzureClienter_ListAllResourcesInSubscription_Call) Run(run func(ctx context.Context, subscriptionID string, tags map[string]*string)) *MockAzureClienter_ListAllResourcesInSubscription_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(map[string]*string)) - }) - return _c -} - -func (_c *MockAzureClienter_ListAllResourcesInSubscription_Call) Return(_a0 []interface{}, _a1 error) *MockAzureClienter_ListAllResourcesInSubscription_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_ListAllResourcesInSubscription_Call) RunAndReturn(run func(context.Context, string, map[string]*string) ([]interface{}, error)) *MockAzureClienter_ListAllResourcesInSubscription_Call { - _c.Call.Return(run) - return _c -} - -// NewSubscriptionListPager provides a mock function with given fields: ctx, options -func (_m *MockAzureClienter) NewSubscriptionListPager(ctx context.Context, options *armsubscription.SubscriptionsClientListOptions) *runtime.Pager[armsubscription.SubscriptionsClientListResponse] { - ret := _m.Called(ctx, options) - - if len(ret) == 0 { - panic("no return value specified for NewSubscriptionListPager") - } - - var r0 *runtime.Pager[armsubscription.SubscriptionsClientListResponse] - if rf, ok := ret.Get(0).(func(context.Context, *armsubscription.SubscriptionsClientListOptions) *runtime.Pager[armsubscription.SubscriptionsClientListResponse]); ok { - r0 = rf(ctx, options) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*runtime.Pager[armsubscription.SubscriptionsClientListResponse]) - } - } - - return r0 -} - -// MockAzureClienter_NewSubscriptionListPager_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewSubscriptionListPager' -type MockAzureClienter_NewSubscriptionListPager_Call struct { - *mock.Call -} - -// NewSubscriptionListPager is a helper method to define mock.On call -// - ctx context.Context -// - options *armsubscription.SubscriptionsClientListOptions -func (_e *MockAzureClienter_Expecter) NewSubscriptionListPager(ctx interface{}, options interface{}) *MockAzureClienter_NewSubscriptionListPager_Call { - return &MockAzureClienter_NewSubscriptionListPager_Call{Call: _e.mock.On("NewSubscriptionListPager", ctx, options)} -} - -func (_c *MockAzureClienter_NewSubscriptionListPager_Call) Run(run func(ctx context.Context, options *armsubscription.SubscriptionsClientListOptions)) *MockAzureClienter_NewSubscriptionListPager_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*armsubscription.SubscriptionsClientListOptions)) - }) - return _c -} - -func (_c *MockAzureClienter_NewSubscriptionListPager_Call) Return(_a0 *runtime.Pager[armsubscription.SubscriptionsClientListResponse]) *MockAzureClienter_NewSubscriptionListPager_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockAzureClienter_NewSubscriptionListPager_Call) RunAndReturn(run func(context.Context, *armsubscription.SubscriptionsClientListOptions) *runtime.Pager[armsubscription.SubscriptionsClientListResponse]) *MockAzureClienter_NewSubscriptionListPager_Call { - _c.Call.Return(run) - return _c -} - -// ResourceGroupExists provides a mock function with given fields: ctx, resourceGroupName -func (_m *MockAzureClienter) ResourceGroupExists(ctx context.Context, resourceGroupName string) (bool, error) { - ret := _m.Called(ctx, resourceGroupName) - - if len(ret) == 0 { - panic("no return value specified for ResourceGroupExists") - } - - var r0 bool - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (bool, error)); ok { - return rf(ctx, resourceGroupName) - } - if rf, ok := ret.Get(0).(func(context.Context, string) bool); ok { - r0 = rf(ctx, resourceGroupName) - } else { - r0 = ret.Get(0).(bool) - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, resourceGroupName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_ResourceGroupExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResourceGroupExists' -type MockAzureClienter_ResourceGroupExists_Call struct { - *mock.Call -} - -// ResourceGroupExists is a helper method to define mock.On call -// - ctx context.Context -// - resourceGroupName string -func (_e *MockAzureClienter_Expecter) ResourceGroupExists(ctx interface{}, resourceGroupName interface{}) *MockAzureClienter_ResourceGroupExists_Call { - return &MockAzureClienter_ResourceGroupExists_Call{Call: _e.mock.On("ResourceGroupExists", ctx, resourceGroupName)} -} - -func (_c *MockAzureClienter_ResourceGroupExists_Call) Run(run func(ctx context.Context, resourceGroupName string)) *MockAzureClienter_ResourceGroupExists_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockAzureClienter_ResourceGroupExists_Call) Return(_a0 bool, _a1 error) *MockAzureClienter_ResourceGroupExists_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_ResourceGroupExists_Call) RunAndReturn(run func(context.Context, string) (bool, error)) *MockAzureClienter_ResourceGroupExists_Call { - _c.Call.Return(run) - return _c -} - -// ValidateMachineType provides a mock function with given fields: ctx, location, vmSize -func (_m *MockAzureClienter) ValidateMachineType(ctx context.Context, location string, vmSize string) (bool, error) { - ret := _m.Called(ctx, location, vmSize) - - if len(ret) == 0 { - panic("no return value specified for ValidateMachineType") - } - - var r0 bool - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (bool, error)); ok { - return rf(ctx, location, vmSize) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) bool); ok { - r0 = rf(ctx, location, vmSize) - } else { - r0 = ret.Get(0).(bool) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, location, vmSize) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockAzureClienter_ValidateMachineType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ValidateMachineType' -type MockAzureClienter_ValidateMachineType_Call struct { - *mock.Call -} - -// ValidateMachineType is a helper method to define mock.On call -// - ctx context.Context -// - location string -// - vmSize string -func (_e *MockAzureClienter_Expecter) ValidateMachineType(ctx interface{}, location interface{}, vmSize interface{}) *MockAzureClienter_ValidateMachineType_Call { - return &MockAzureClienter_ValidateMachineType_Call{Call: _e.mock.On("ValidateMachineType", ctx, location, vmSize)} -} - -func (_c *MockAzureClienter_ValidateMachineType_Call) Run(run func(ctx context.Context, location string, vmSize string)) *MockAzureClienter_ValidateMachineType_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockAzureClienter_ValidateMachineType_Call) Return(_a0 bool, _a1 error) *MockAzureClienter_ValidateMachineType_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockAzureClienter_ValidateMachineType_Call) RunAndReturn(run func(context.Context, string, string) (bool, error)) *MockAzureClienter_ValidateMachineType_Call { - _c.Call.Return(run) - return _c -} - -// NewMockAzureClienter creates a new instance of MockAzureClienter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockAzureClienter(t interface { - mock.TestingT - Cleanup(func()) -}) *MockAzureClienter { - mock := &MockAzureClienter{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/azure/mock_Pollerer.go b/pkg/models/interfaces/aws/mocks/azure/mock_Pollerer.go deleted file mode 100644 index 40c2f5c6..00000000 --- a/pkg/models/interfaces/aws/mocks/azure/mock_Pollerer.go +++ /dev/null @@ -1,313 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package azure_interface - -import ( - armresources "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" - - context "context" - - http "net/http" - - mock "github.com/stretchr/testify/mock" - - runtime "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" -) - -// MockPollerer is an autogenerated mock type for the Pollerer type -type MockPollerer struct { - mock.Mock -} - -type MockPollerer_Expecter struct { - mock *mock.Mock -} - -func (_m *MockPollerer) EXPECT() *MockPollerer_Expecter { - return &MockPollerer_Expecter{mock: &_m.Mock} -} - -// Done provides a mock function with given fields: -func (_m *MockPollerer) Done() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Done") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// MockPollerer_Done_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Done' -type MockPollerer_Done_Call struct { - *mock.Call -} - -// Done is a helper method to define mock.On call -func (_e *MockPollerer_Expecter) Done() *MockPollerer_Done_Call { - return &MockPollerer_Done_Call{Call: _e.mock.On("Done")} -} - -func (_c *MockPollerer_Done_Call) Run(run func()) *MockPollerer_Done_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockPollerer_Done_Call) Return(_a0 bool) *MockPollerer_Done_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockPollerer_Done_Call) RunAndReturn(run func() bool) *MockPollerer_Done_Call { - _c.Call.Return(run) - return _c -} - -// Poll provides a mock function with given fields: ctx -func (_m *MockPollerer) Poll(ctx context.Context) (*http.Response, error) { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for Poll") - } - - var r0 *http.Response - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*http.Response, error)); ok { - return rf(ctx) - } - if rf, ok := ret.Get(0).(func(context.Context) *http.Response); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*http.Response) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockPollerer_Poll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Poll' -type MockPollerer_Poll_Call struct { - *mock.Call -} - -// Poll is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockPollerer_Expecter) Poll(ctx interface{}) *MockPollerer_Poll_Call { - return &MockPollerer_Poll_Call{Call: _e.mock.On("Poll", ctx)} -} - -func (_c *MockPollerer_Poll_Call) Run(run func(ctx context.Context)) *MockPollerer_Poll_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockPollerer_Poll_Call) Return(_a0 *http.Response, _a1 error) *MockPollerer_Poll_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockPollerer_Poll_Call) RunAndReturn(run func(context.Context) (*http.Response, error)) *MockPollerer_Poll_Call { - _c.Call.Return(run) - return _c -} - -// PollUntilDone provides a mock function with given fields: ctx, options -func (_m *MockPollerer) PollUntilDone(ctx context.Context, options *runtime.PollUntilDoneOptions) (armresources.DeploymentsClientCreateOrUpdateResponse, error) { - ret := _m.Called(ctx, options) - - if len(ret) == 0 { - panic("no return value specified for PollUntilDone") - } - - var r0 armresources.DeploymentsClientCreateOrUpdateResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *runtime.PollUntilDoneOptions) (armresources.DeploymentsClientCreateOrUpdateResponse, error)); ok { - return rf(ctx, options) - } - if rf, ok := ret.Get(0).(func(context.Context, *runtime.PollUntilDoneOptions) armresources.DeploymentsClientCreateOrUpdateResponse); ok { - r0 = rf(ctx, options) - } else { - r0 = ret.Get(0).(armresources.DeploymentsClientCreateOrUpdateResponse) - } - - if rf, ok := ret.Get(1).(func(context.Context, *runtime.PollUntilDoneOptions) error); ok { - r1 = rf(ctx, options) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockPollerer_PollUntilDone_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PollUntilDone' -type MockPollerer_PollUntilDone_Call struct { - *mock.Call -} - -// PollUntilDone is a helper method to define mock.On call -// - ctx context.Context -// - options *runtime.PollUntilDoneOptions -func (_e *MockPollerer_Expecter) PollUntilDone(ctx interface{}, options interface{}) *MockPollerer_PollUntilDone_Call { - return &MockPollerer_PollUntilDone_Call{Call: _e.mock.On("PollUntilDone", ctx, options)} -} - -func (_c *MockPollerer_PollUntilDone_Call) Run(run func(ctx context.Context, options *runtime.PollUntilDoneOptions)) *MockPollerer_PollUntilDone_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*runtime.PollUntilDoneOptions)) - }) - return _c -} - -func (_c *MockPollerer_PollUntilDone_Call) Return(_a0 armresources.DeploymentsClientCreateOrUpdateResponse, _a1 error) *MockPollerer_PollUntilDone_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockPollerer_PollUntilDone_Call) RunAndReturn(run func(context.Context, *runtime.PollUntilDoneOptions) (armresources.DeploymentsClientCreateOrUpdateResponse, error)) *MockPollerer_PollUntilDone_Call { - _c.Call.Return(run) - return _c -} - -// Result provides a mock function with given fields: ctx -func (_m *MockPollerer) Result(ctx context.Context) (armresources.DeploymentsClientCreateOrUpdateResponse, error) { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for Result") - } - - var r0 armresources.DeploymentsClientCreateOrUpdateResponse - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (armresources.DeploymentsClientCreateOrUpdateResponse, error)); ok { - return rf(ctx) - } - if rf, ok := ret.Get(0).(func(context.Context) armresources.DeploymentsClientCreateOrUpdateResponse); ok { - r0 = rf(ctx) - } else { - r0 = ret.Get(0).(armresources.DeploymentsClientCreateOrUpdateResponse) - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockPollerer_Result_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Result' -type MockPollerer_Result_Call struct { - *mock.Call -} - -// Result is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockPollerer_Expecter) Result(ctx interface{}) *MockPollerer_Result_Call { - return &MockPollerer_Result_Call{Call: _e.mock.On("Result", ctx)} -} - -func (_c *MockPollerer_Result_Call) Run(run func(ctx context.Context)) *MockPollerer_Result_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockPollerer_Result_Call) Return(_a0 armresources.DeploymentsClientCreateOrUpdateResponse, _a1 error) *MockPollerer_Result_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockPollerer_Result_Call) RunAndReturn(run func(context.Context) (armresources.DeploymentsClientCreateOrUpdateResponse, error)) *MockPollerer_Result_Call { - _c.Call.Return(run) - return _c -} - -// ResumeToken provides a mock function with given fields: -func (_m *MockPollerer) ResumeToken() (string, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for ResumeToken") - } - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func() (string, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockPollerer_ResumeToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResumeToken' -type MockPollerer_ResumeToken_Call struct { - *mock.Call -} - -// ResumeToken is a helper method to define mock.On call -func (_e *MockPollerer_Expecter) ResumeToken() *MockPollerer_ResumeToken_Call { - return &MockPollerer_ResumeToken_Call{Call: _e.mock.On("ResumeToken")} -} - -func (_c *MockPollerer_ResumeToken_Call) Run(run func()) *MockPollerer_ResumeToken_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockPollerer_ResumeToken_Call) Return(_a0 string, _a1 error) *MockPollerer_ResumeToken_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockPollerer_ResumeToken_Call) RunAndReturn(run func() (string, error)) *MockPollerer_ResumeToken_Call { - _c.Call.Return(run) - return _c -} - -// NewMockPollerer creates a new instance of MockPollerer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockPollerer(t interface { - mock.TestingT - Cleanup(func()) -}) *MockPollerer { - mock := &MockPollerer{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/common/mock_Clienter.go b/pkg/models/interfaces/aws/mocks/common/mock_Clienter.go deleted file mode 100644 index 7cc1d6de..00000000 --- a/pkg/models/interfaces/aws/mocks/common/mock_Clienter.go +++ /dev/null @@ -1,32 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package common_interface - -import mock "github.com/stretchr/testify/mock" - -// MockClienter is an autogenerated mock type for the Clienter type -type MockClienter struct { - mock.Mock -} - -type MockClienter_Expecter struct { - mock *mock.Mock -} - -func (_m *MockClienter) EXPECT() *MockClienter_Expecter { - return &MockClienter_Expecter{mock: &_m.Mock} -} - -// NewMockClienter creates a new instance of MockClienter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockClienter(t interface { - mock.TestingT - Cleanup(func()) -}) *MockClienter { - mock := &MockClienter{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/common/mock_ClusterDeployerer.go b/pkg/models/interfaces/aws/mocks/common/mock_ClusterDeployerer.go deleted file mode 100644 index 80a73774..00000000 --- a/pkg/models/interfaces/aws/mocks/common/mock_ClusterDeployerer.go +++ /dev/null @@ -1,371 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package common_interface - -import ( - context "context" - - models "github.com/bacalhau-project/andaime/pkg/models" - mock "github.com/stretchr/testify/mock" - - sshutils "github.com/bacalhau-project/andaime/pkg/models/interfaces/sshutils" -) - -// MockClusterDeployerer is an autogenerated mock type for the ClusterDeployerer type -type MockClusterDeployerer struct { - mock.Mock -} - -type MockClusterDeployerer_Expecter struct { - mock *mock.Mock -} - -func (_m *MockClusterDeployerer) EXPECT() *MockClusterDeployerer_Expecter { - return &MockClusterDeployerer_Expecter{mock: &_m.Mock} -} - -// ApplyBacalhauConfigs provides a mock function with given fields: ctx, sshConfig, bacalhauSettings -func (_m *MockClusterDeployerer) ApplyBacalhauConfigs(ctx context.Context, sshConfig sshutils.SSHConfiger, bacalhauSettings []models.BacalhauSettings) error { - ret := _m.Called(ctx, sshConfig, bacalhauSettings) - - if len(ret) == 0 { - panic("no return value specified for ApplyBacalhauConfigs") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sshutils.SSHConfiger, []models.BacalhauSettings) error); ok { - r0 = rf(ctx, sshConfig, bacalhauSettings) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClusterDeployerer_ApplyBacalhauConfigs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApplyBacalhauConfigs' -type MockClusterDeployerer_ApplyBacalhauConfigs_Call struct { - *mock.Call -} - -// ApplyBacalhauConfigs is a helper method to define mock.On call -// - ctx context.Context -// - sshConfig sshutils.SSHConfiger -// - bacalhauSettings []models.BacalhauSettings -func (_e *MockClusterDeployerer_Expecter) ApplyBacalhauConfigs(ctx interface{}, sshConfig interface{}, bacalhauSettings interface{}) *MockClusterDeployerer_ApplyBacalhauConfigs_Call { - return &MockClusterDeployerer_ApplyBacalhauConfigs_Call{Call: _e.mock.On("ApplyBacalhauConfigs", ctx, sshConfig, bacalhauSettings)} -} - -func (_c *MockClusterDeployerer_ApplyBacalhauConfigs_Call) Run(run func(ctx context.Context, sshConfig sshutils.SSHConfiger, bacalhauSettings []models.BacalhauSettings)) *MockClusterDeployerer_ApplyBacalhauConfigs_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sshutils.SSHConfiger), args[2].([]models.BacalhauSettings)) - }) - return _c -} - -func (_c *MockClusterDeployerer_ApplyBacalhauConfigs_Call) Return(_a0 error) *MockClusterDeployerer_ApplyBacalhauConfigs_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClusterDeployerer_ApplyBacalhauConfigs_Call) RunAndReturn(run func(context.Context, sshutils.SSHConfiger, []models.BacalhauSettings) error) *MockClusterDeployerer_ApplyBacalhauConfigs_Call { - _c.Call.Return(run) - return _c -} - -// ExecuteCustomScript provides a mock function with given fields: ctx, sshConfig, machine -func (_m *MockClusterDeployerer) ExecuteCustomScript(ctx context.Context, sshConfig sshutils.SSHConfiger, machine models.Machiner) error { - ret := _m.Called(ctx, sshConfig, machine) - - if len(ret) == 0 { - panic("no return value specified for ExecuteCustomScript") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sshutils.SSHConfiger, models.Machiner) error); ok { - r0 = rf(ctx, sshConfig, machine) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClusterDeployerer_ExecuteCustomScript_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExecuteCustomScript' -type MockClusterDeployerer_ExecuteCustomScript_Call struct { - *mock.Call -} - -// ExecuteCustomScript is a helper method to define mock.On call -// - ctx context.Context -// - sshConfig sshutils.SSHConfiger -// - machine models.Machiner -func (_e *MockClusterDeployerer_Expecter) ExecuteCustomScript(ctx interface{}, sshConfig interface{}, machine interface{}) *MockClusterDeployerer_ExecuteCustomScript_Call { - return &MockClusterDeployerer_ExecuteCustomScript_Call{Call: _e.mock.On("ExecuteCustomScript", ctx, sshConfig, machine)} -} - -func (_c *MockClusterDeployerer_ExecuteCustomScript_Call) Run(run func(ctx context.Context, sshConfig sshutils.SSHConfiger, machine models.Machiner)) *MockClusterDeployerer_ExecuteCustomScript_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sshutils.SSHConfiger), args[2].(models.Machiner)) - }) - return _c -} - -func (_c *MockClusterDeployerer_ExecuteCustomScript_Call) Return(_a0 error) *MockClusterDeployerer_ExecuteCustomScript_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClusterDeployerer_ExecuteCustomScript_Call) RunAndReturn(run func(context.Context, sshutils.SSHConfiger, models.Machiner) error) *MockClusterDeployerer_ExecuteCustomScript_Call { - _c.Call.Return(run) - return _c -} - -// ProvisionBacalhauCluster provides a mock function with given fields: ctx -func (_m *MockClusterDeployerer) ProvisionBacalhauCluster(ctx context.Context) error { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for ProvisionBacalhauCluster") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context) error); ok { - r0 = rf(ctx) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClusterDeployerer_ProvisionBacalhauCluster_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProvisionBacalhauCluster' -type MockClusterDeployerer_ProvisionBacalhauCluster_Call struct { - *mock.Call -} - -// ProvisionBacalhauCluster is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockClusterDeployerer_Expecter) ProvisionBacalhauCluster(ctx interface{}) *MockClusterDeployerer_ProvisionBacalhauCluster_Call { - return &MockClusterDeployerer_ProvisionBacalhauCluster_Call{Call: _e.mock.On("ProvisionBacalhauCluster", ctx)} -} - -func (_c *MockClusterDeployerer_ProvisionBacalhauCluster_Call) Run(run func(ctx context.Context)) *MockClusterDeployerer_ProvisionBacalhauCluster_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockClusterDeployerer_ProvisionBacalhauCluster_Call) Return(_a0 error) *MockClusterDeployerer_ProvisionBacalhauCluster_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClusterDeployerer_ProvisionBacalhauCluster_Call) RunAndReturn(run func(context.Context) error) *MockClusterDeployerer_ProvisionBacalhauCluster_Call { - _c.Call.Return(run) - return _c -} - -// ProvisionMachine provides a mock function with given fields: ctx, sshConfig, machine -func (_m *MockClusterDeployerer) ProvisionMachine(ctx context.Context, sshConfig sshutils.SSHConfiger, machine models.Machiner) error { - ret := _m.Called(ctx, sshConfig, machine) - - if len(ret) == 0 { - panic("no return value specified for ProvisionMachine") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sshutils.SSHConfiger, models.Machiner) error); ok { - r0 = rf(ctx, sshConfig, machine) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClusterDeployerer_ProvisionMachine_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProvisionMachine' -type MockClusterDeployerer_ProvisionMachine_Call struct { - *mock.Call -} - -// ProvisionMachine is a helper method to define mock.On call -// - ctx context.Context -// - sshConfig sshutils.SSHConfiger -// - machine models.Machiner -func (_e *MockClusterDeployerer_Expecter) ProvisionMachine(ctx interface{}, sshConfig interface{}, machine interface{}) *MockClusterDeployerer_ProvisionMachine_Call { - return &MockClusterDeployerer_ProvisionMachine_Call{Call: _e.mock.On("ProvisionMachine", ctx, sshConfig, machine)} -} - -func (_c *MockClusterDeployerer_ProvisionMachine_Call) Run(run func(ctx context.Context, sshConfig sshutils.SSHConfiger, machine models.Machiner)) *MockClusterDeployerer_ProvisionMachine_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sshutils.SSHConfiger), args[2].(models.Machiner)) - }) - return _c -} - -func (_c *MockClusterDeployerer_ProvisionMachine_Call) Return(_a0 error) *MockClusterDeployerer_ProvisionMachine_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClusterDeployerer_ProvisionMachine_Call) RunAndReturn(run func(context.Context, sshutils.SSHConfiger, models.Machiner) error) *MockClusterDeployerer_ProvisionMachine_Call { - _c.Call.Return(run) - return _c -} - -// ProvisionOrchestrator provides a mock function with given fields: ctx, machineName -func (_m *MockClusterDeployerer) ProvisionOrchestrator(ctx context.Context, machineName string) error { - ret := _m.Called(ctx, machineName) - - if len(ret) == 0 { - panic("no return value specified for ProvisionOrchestrator") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { - r0 = rf(ctx, machineName) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClusterDeployerer_ProvisionOrchestrator_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProvisionOrchestrator' -type MockClusterDeployerer_ProvisionOrchestrator_Call struct { - *mock.Call -} - -// ProvisionOrchestrator is a helper method to define mock.On call -// - ctx context.Context -// - machineName string -func (_e *MockClusterDeployerer_Expecter) ProvisionOrchestrator(ctx interface{}, machineName interface{}) *MockClusterDeployerer_ProvisionOrchestrator_Call { - return &MockClusterDeployerer_ProvisionOrchestrator_Call{Call: _e.mock.On("ProvisionOrchestrator", ctx, machineName)} -} - -func (_c *MockClusterDeployerer_ProvisionOrchestrator_Call) Run(run func(ctx context.Context, machineName string)) *MockClusterDeployerer_ProvisionOrchestrator_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockClusterDeployerer_ProvisionOrchestrator_Call) Return(_a0 error) *MockClusterDeployerer_ProvisionOrchestrator_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClusterDeployerer_ProvisionOrchestrator_Call) RunAndReturn(run func(context.Context, string) error) *MockClusterDeployerer_ProvisionOrchestrator_Call { - _c.Call.Return(run) - return _c -} - -// ProvisionWorker provides a mock function with given fields: ctx, machineName -func (_m *MockClusterDeployerer) ProvisionWorker(ctx context.Context, machineName string) error { - ret := _m.Called(ctx, machineName) - - if len(ret) == 0 { - panic("no return value specified for ProvisionWorker") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { - r0 = rf(ctx, machineName) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClusterDeployerer_ProvisionWorker_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProvisionWorker' -type MockClusterDeployerer_ProvisionWorker_Call struct { - *mock.Call -} - -// ProvisionWorker is a helper method to define mock.On call -// - ctx context.Context -// - machineName string -func (_e *MockClusterDeployerer_Expecter) ProvisionWorker(ctx interface{}, machineName interface{}) *MockClusterDeployerer_ProvisionWorker_Call { - return &MockClusterDeployerer_ProvisionWorker_Call{Call: _e.mock.On("ProvisionWorker", ctx, machineName)} -} - -func (_c *MockClusterDeployerer_ProvisionWorker_Call) Run(run func(ctx context.Context, machineName string)) *MockClusterDeployerer_ProvisionWorker_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockClusterDeployerer_ProvisionWorker_Call) Return(_a0 error) *MockClusterDeployerer_ProvisionWorker_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClusterDeployerer_ProvisionWorker_Call) RunAndReturn(run func(context.Context, string) error) *MockClusterDeployerer_ProvisionWorker_Call { - _c.Call.Return(run) - return _c -} - -// WaitForAllMachinesToReachState provides a mock function with given fields: ctx, resourceType, state -func (_m *MockClusterDeployerer) WaitForAllMachinesToReachState(ctx context.Context, resourceType string, state models.MachineResourceState) error { - ret := _m.Called(ctx, resourceType, state) - - if len(ret) == 0 { - panic("no return value specified for WaitForAllMachinesToReachState") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, models.MachineResourceState) error); ok { - r0 = rf(ctx, resourceType, state) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockClusterDeployerer_WaitForAllMachinesToReachState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitForAllMachinesToReachState' -type MockClusterDeployerer_WaitForAllMachinesToReachState_Call struct { - *mock.Call -} - -// WaitForAllMachinesToReachState is a helper method to define mock.On call -// - ctx context.Context -// - resourceType string -// - state models.MachineResourceState -func (_e *MockClusterDeployerer_Expecter) WaitForAllMachinesToReachState(ctx interface{}, resourceType interface{}, state interface{}) *MockClusterDeployerer_WaitForAllMachinesToReachState_Call { - return &MockClusterDeployerer_WaitForAllMachinesToReachState_Call{Call: _e.mock.On("WaitForAllMachinesToReachState", ctx, resourceType, state)} -} - -func (_c *MockClusterDeployerer_WaitForAllMachinesToReachState_Call) Run(run func(ctx context.Context, resourceType string, state models.MachineResourceState)) *MockClusterDeployerer_WaitForAllMachinesToReachState_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(models.MachineResourceState)) - }) - return _c -} - -func (_c *MockClusterDeployerer_WaitForAllMachinesToReachState_Call) Return(_a0 error) *MockClusterDeployerer_WaitForAllMachinesToReachState_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockClusterDeployerer_WaitForAllMachinesToReachState_Call) RunAndReturn(run func(context.Context, string, models.MachineResourceState) error) *MockClusterDeployerer_WaitForAllMachinesToReachState_Call { - _c.Call.Return(run) - return _c -} - -// NewMockClusterDeployerer creates a new instance of MockClusterDeployerer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockClusterDeployerer(t interface { - mock.TestingT - Cleanup(func()) -}) *MockClusterDeployerer { - mock := &MockClusterDeployerer{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/gcp/mock_GCPClienter.go b/pkg/models/interfaces/aws/mocks/gcp/mock_GCPClienter.go deleted file mode 100644 index f3293591..00000000 --- a/pkg/models/interfaces/aws/mocks/gcp/mock_GCPClienter.go +++ /dev/null @@ -1,1463 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package gcp_interface - -import ( - assetpb "cloud.google.com/go/asset/apiv1/assetpb" - computepb "cloud.google.com/go/compute/apiv1/computepb" - - context "context" - - iam "google.golang.org/api/iam/v1" - - mock "github.com/stretchr/testify/mock" - - models "github.com/bacalhau-project/andaime/pkg/models" - - resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb" -) - -// MockGCPClienter is an autogenerated mock type for the GCPClienter type -type MockGCPClienter struct { - mock.Mock -} - -type MockGCPClienter_Expecter struct { - mock *mock.Mock -} - -func (_m *MockGCPClienter) EXPECT() *MockGCPClienter_Expecter { - return &MockGCPClienter_Expecter{mock: &_m.Mock} -} - -// CheckAuthentication provides a mock function with given fields: ctx, projectID -func (_m *MockGCPClienter) CheckAuthentication(ctx context.Context, projectID string) error { - ret := _m.Called(ctx, projectID) - - if len(ret) == 0 { - panic("no return value specified for CheckAuthentication") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { - r0 = rf(ctx, projectID) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_CheckAuthentication_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckAuthentication' -type MockGCPClienter_CheckAuthentication_Call struct { - *mock.Call -} - -// CheckAuthentication is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -func (_e *MockGCPClienter_Expecter) CheckAuthentication(ctx interface{}, projectID interface{}) *MockGCPClienter_CheckAuthentication_Call { - return &MockGCPClienter_CheckAuthentication_Call{Call: _e.mock.On("CheckAuthentication", ctx, projectID)} -} - -func (_c *MockGCPClienter_CheckAuthentication_Call) Run(run func(ctx context.Context, projectID string)) *MockGCPClienter_CheckAuthentication_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_CheckAuthentication_Call) Return(_a0 error) *MockGCPClienter_CheckAuthentication_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_CheckAuthentication_Call) RunAndReturn(run func(context.Context, string) error) *MockGCPClienter_CheckAuthentication_Call { - _c.Call.Return(run) - return _c -} - -// CheckFirewallRuleExists provides a mock function with given fields: ctx, projectID, ruleName -func (_m *MockGCPClienter) CheckFirewallRuleExists(ctx context.Context, projectID string, ruleName string) error { - ret := _m.Called(ctx, projectID, ruleName) - - if len(ret) == 0 { - panic("no return value specified for CheckFirewallRuleExists") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = rf(ctx, projectID, ruleName) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_CheckFirewallRuleExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckFirewallRuleExists' -type MockGCPClienter_CheckFirewallRuleExists_Call struct { - *mock.Call -} - -// CheckFirewallRuleExists is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - ruleName string -func (_e *MockGCPClienter_Expecter) CheckFirewallRuleExists(ctx interface{}, projectID interface{}, ruleName interface{}) *MockGCPClienter_CheckFirewallRuleExists_Call { - return &MockGCPClienter_CheckFirewallRuleExists_Call{Call: _e.mock.On("CheckFirewallRuleExists", ctx, projectID, ruleName)} -} - -func (_c *MockGCPClienter_CheckFirewallRuleExists_Call) Run(run func(ctx context.Context, projectID string, ruleName string)) *MockGCPClienter_CheckFirewallRuleExists_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_CheckFirewallRuleExists_Call) Return(_a0 error) *MockGCPClienter_CheckFirewallRuleExists_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_CheckFirewallRuleExists_Call) RunAndReturn(run func(context.Context, string, string) error) *MockGCPClienter_CheckFirewallRuleExists_Call { - _c.Call.Return(run) - return _c -} - -// CheckPermissions provides a mock function with given fields: ctx, projectID -func (_m *MockGCPClienter) CheckPermissions(ctx context.Context, projectID string) error { - ret := _m.Called(ctx, projectID) - - if len(ret) == 0 { - panic("no return value specified for CheckPermissions") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { - r0 = rf(ctx, projectID) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_CheckPermissions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckPermissions' -type MockGCPClienter_CheckPermissions_Call struct { - *mock.Call -} - -// CheckPermissions is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -func (_e *MockGCPClienter_Expecter) CheckPermissions(ctx interface{}, projectID interface{}) *MockGCPClienter_CheckPermissions_Call { - return &MockGCPClienter_CheckPermissions_Call{Call: _e.mock.On("CheckPermissions", ctx, projectID)} -} - -func (_c *MockGCPClienter_CheckPermissions_Call) Run(run func(ctx context.Context, projectID string)) *MockGCPClienter_CheckPermissions_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_CheckPermissions_Call) Return(_a0 error) *MockGCPClienter_CheckPermissions_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_CheckPermissions_Call) RunAndReturn(run func(context.Context, string) error) *MockGCPClienter_CheckPermissions_Call { - _c.Call.Return(run) - return _c -} - -// CreateFirewallRules provides a mock function with given fields: ctx, projectID, networkName -func (_m *MockGCPClienter) CreateFirewallRules(ctx context.Context, projectID string, networkName string) error { - ret := _m.Called(ctx, projectID, networkName) - - if len(ret) == 0 { - panic("no return value specified for CreateFirewallRules") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = rf(ctx, projectID, networkName) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_CreateFirewallRules_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateFirewallRules' -type MockGCPClienter_CreateFirewallRules_Call struct { - *mock.Call -} - -// CreateFirewallRules is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - networkName string -func (_e *MockGCPClienter_Expecter) CreateFirewallRules(ctx interface{}, projectID interface{}, networkName interface{}) *MockGCPClienter_CreateFirewallRules_Call { - return &MockGCPClienter_CreateFirewallRules_Call{Call: _e.mock.On("CreateFirewallRules", ctx, projectID, networkName)} -} - -func (_c *MockGCPClienter_CreateFirewallRules_Call) Run(run func(ctx context.Context, projectID string, networkName string)) *MockGCPClienter_CreateFirewallRules_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_CreateFirewallRules_Call) Return(_a0 error) *MockGCPClienter_CreateFirewallRules_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_CreateFirewallRules_Call) RunAndReturn(run func(context.Context, string, string) error) *MockGCPClienter_CreateFirewallRules_Call { - _c.Call.Return(run) - return _c -} - -// CreateIP provides a mock function with given fields: ctx, projectID, location, address -func (_m *MockGCPClienter) CreateIP(ctx context.Context, projectID string, location string, address *computepb.Address) (*computepb.Address, error) { - ret := _m.Called(ctx, projectID, location, address) - - if len(ret) == 0 { - panic("no return value specified for CreateIP") - } - - var r0 *computepb.Address - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, *computepb.Address) (*computepb.Address, error)); ok { - return rf(ctx, projectID, location, address) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, *computepb.Address) *computepb.Address); ok { - r0 = rf(ctx, projectID, location, address) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*computepb.Address) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, *computepb.Address) error); ok { - r1 = rf(ctx, projectID, location, address) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_CreateIP_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateIP' -type MockGCPClienter_CreateIP_Call struct { - *mock.Call -} - -// CreateIP is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - location string -// - address *computepb.Address -func (_e *MockGCPClienter_Expecter) CreateIP(ctx interface{}, projectID interface{}, location interface{}, address interface{}) *MockGCPClienter_CreateIP_Call { - return &MockGCPClienter_CreateIP_Call{Call: _e.mock.On("CreateIP", ctx, projectID, location, address)} -} - -func (_c *MockGCPClienter_CreateIP_Call) Run(run func(ctx context.Context, projectID string, location string, address *computepb.Address)) *MockGCPClienter_CreateIP_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(*computepb.Address)) - }) - return _c -} - -func (_c *MockGCPClienter_CreateIP_Call) Return(_a0 *computepb.Address, _a1 error) *MockGCPClienter_CreateIP_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_CreateIP_Call) RunAndReturn(run func(context.Context, string, string, *computepb.Address) (*computepb.Address, error)) *MockGCPClienter_CreateIP_Call { - _c.Call.Return(run) - return _c -} - -// CreateServiceAccount provides a mock function with given fields: ctx, projectID -func (_m *MockGCPClienter) CreateServiceAccount(ctx context.Context, projectID string) (*iam.ServiceAccount, error) { - ret := _m.Called(ctx, projectID) - - if len(ret) == 0 { - panic("no return value specified for CreateServiceAccount") - } - - var r0 *iam.ServiceAccount - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*iam.ServiceAccount, error)); ok { - return rf(ctx, projectID) - } - if rf, ok := ret.Get(0).(func(context.Context, string) *iam.ServiceAccount); ok { - r0 = rf(ctx, projectID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*iam.ServiceAccount) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, projectID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_CreateServiceAccount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateServiceAccount' -type MockGCPClienter_CreateServiceAccount_Call struct { - *mock.Call -} - -// CreateServiceAccount is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -func (_e *MockGCPClienter_Expecter) CreateServiceAccount(ctx interface{}, projectID interface{}) *MockGCPClienter_CreateServiceAccount_Call { - return &MockGCPClienter_CreateServiceAccount_Call{Call: _e.mock.On("CreateServiceAccount", ctx, projectID)} -} - -func (_c *MockGCPClienter_CreateServiceAccount_Call) Run(run func(ctx context.Context, projectID string)) *MockGCPClienter_CreateServiceAccount_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_CreateServiceAccount_Call) Return(_a0 *iam.ServiceAccount, _a1 error) *MockGCPClienter_CreateServiceAccount_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_CreateServiceAccount_Call) RunAndReturn(run func(context.Context, string) (*iam.ServiceAccount, error)) *MockGCPClienter_CreateServiceAccount_Call { - _c.Call.Return(run) - return _c -} - -// CreateVM provides a mock function with given fields: ctx, projectID, machine, ip, networkName -func (_m *MockGCPClienter) CreateVM(ctx context.Context, projectID string, machine models.Machiner, ip *computepb.Address, networkName string) (*computepb.Instance, error) { - ret := _m.Called(ctx, projectID, machine, ip, networkName) - - if len(ret) == 0 { - panic("no return value specified for CreateVM") - } - - var r0 *computepb.Instance - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, models.Machiner, *computepb.Address, string) (*computepb.Instance, error)); ok { - return rf(ctx, projectID, machine, ip, networkName) - } - if rf, ok := ret.Get(0).(func(context.Context, string, models.Machiner, *computepb.Address, string) *computepb.Instance); ok { - r0 = rf(ctx, projectID, machine, ip, networkName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*computepb.Instance) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, models.Machiner, *computepb.Address, string) error); ok { - r1 = rf(ctx, projectID, machine, ip, networkName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_CreateVM_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateVM' -type MockGCPClienter_CreateVM_Call struct { - *mock.Call -} - -// CreateVM is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - machine models.Machiner -// - ip *computepb.Address -// - networkName string -func (_e *MockGCPClienter_Expecter) CreateVM(ctx interface{}, projectID interface{}, machine interface{}, ip interface{}, networkName interface{}) *MockGCPClienter_CreateVM_Call { - return &MockGCPClienter_CreateVM_Call{Call: _e.mock.On("CreateVM", ctx, projectID, machine, ip, networkName)} -} - -func (_c *MockGCPClienter_CreateVM_Call) Run(run func(ctx context.Context, projectID string, machine models.Machiner, ip *computepb.Address, networkName string)) *MockGCPClienter_CreateVM_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(models.Machiner), args[3].(*computepb.Address), args[4].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_CreateVM_Call) Return(_a0 *computepb.Instance, _a1 error) *MockGCPClienter_CreateVM_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_CreateVM_Call) RunAndReturn(run func(context.Context, string, models.Machiner, *computepb.Address, string) (*computepb.Instance, error)) *MockGCPClienter_CreateVM_Call { - _c.Call.Return(run) - return _c -} - -// CreateVPCNetwork provides a mock function with given fields: ctx, projectID, networkName -func (_m *MockGCPClienter) CreateVPCNetwork(ctx context.Context, projectID string, networkName string) error { - ret := _m.Called(ctx, projectID, networkName) - - if len(ret) == 0 { - panic("no return value specified for CreateVPCNetwork") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = rf(ctx, projectID, networkName) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_CreateVPCNetwork_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateVPCNetwork' -type MockGCPClienter_CreateVPCNetwork_Call struct { - *mock.Call -} - -// CreateVPCNetwork is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - networkName string -func (_e *MockGCPClienter_Expecter) CreateVPCNetwork(ctx interface{}, projectID interface{}, networkName interface{}) *MockGCPClienter_CreateVPCNetwork_Call { - return &MockGCPClienter_CreateVPCNetwork_Call{Call: _e.mock.On("CreateVPCNetwork", ctx, projectID, networkName)} -} - -func (_c *MockGCPClienter_CreateVPCNetwork_Call) Run(run func(ctx context.Context, projectID string, networkName string)) *MockGCPClienter_CreateVPCNetwork_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_CreateVPCNetwork_Call) Return(_a0 error) *MockGCPClienter_CreateVPCNetwork_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_CreateVPCNetwork_Call) RunAndReturn(run func(context.Context, string, string) error) *MockGCPClienter_CreateVPCNetwork_Call { - _c.Call.Return(run) - return _c -} - -// DeleteIP provides a mock function with given fields: ctx, projectID, location, addressName -func (_m *MockGCPClienter) DeleteIP(ctx context.Context, projectID string, location string, addressName string) error { - ret := _m.Called(ctx, projectID, location, addressName) - - if len(ret) == 0 { - panic("no return value specified for DeleteIP") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) error); ok { - r0 = rf(ctx, projectID, location, addressName) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_DeleteIP_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteIP' -type MockGCPClienter_DeleteIP_Call struct { - *mock.Call -} - -// DeleteIP is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - location string -// - addressName string -func (_e *MockGCPClienter_Expecter) DeleteIP(ctx interface{}, projectID interface{}, location interface{}, addressName interface{}) *MockGCPClienter_DeleteIP_Call { - return &MockGCPClienter_DeleteIP_Call{Call: _e.mock.On("DeleteIP", ctx, projectID, location, addressName)} -} - -func (_c *MockGCPClienter_DeleteIP_Call) Run(run func(ctx context.Context, projectID string, location string, addressName string)) *MockGCPClienter_DeleteIP_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_DeleteIP_Call) Return(_a0 error) *MockGCPClienter_DeleteIP_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_DeleteIP_Call) RunAndReturn(run func(context.Context, string, string, string) error) *MockGCPClienter_DeleteIP_Call { - _c.Call.Return(run) - return _c -} - -// DestroyProject provides a mock function with given fields: ctx, projectID -func (_m *MockGCPClienter) DestroyProject(ctx context.Context, projectID string) error { - ret := _m.Called(ctx, projectID) - - if len(ret) == 0 { - panic("no return value specified for DestroyProject") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { - r0 = rf(ctx, projectID) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_DestroyProject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DestroyProject' -type MockGCPClienter_DestroyProject_Call struct { - *mock.Call -} - -// DestroyProject is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -func (_e *MockGCPClienter_Expecter) DestroyProject(ctx interface{}, projectID interface{}) *MockGCPClienter_DestroyProject_Call { - return &MockGCPClienter_DestroyProject_Call{Call: _e.mock.On("DestroyProject", ctx, projectID)} -} - -func (_c *MockGCPClienter_DestroyProject_Call) Run(run func(ctx context.Context, projectID string)) *MockGCPClienter_DestroyProject_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_DestroyProject_Call) Return(_a0 error) *MockGCPClienter_DestroyProject_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_DestroyProject_Call) RunAndReturn(run func(context.Context, string) error) *MockGCPClienter_DestroyProject_Call { - _c.Call.Return(run) - return _c -} - -// EnableAPI provides a mock function with given fields: ctx, projectID, apiName -func (_m *MockGCPClienter) EnableAPI(ctx context.Context, projectID string, apiName string) error { - ret := _m.Called(ctx, projectID, apiName) - - if len(ret) == 0 { - panic("no return value specified for EnableAPI") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = rf(ctx, projectID, apiName) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_EnableAPI_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnableAPI' -type MockGCPClienter_EnableAPI_Call struct { - *mock.Call -} - -// EnableAPI is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - apiName string -func (_e *MockGCPClienter_Expecter) EnableAPI(ctx interface{}, projectID interface{}, apiName interface{}) *MockGCPClienter_EnableAPI_Call { - return &MockGCPClienter_EnableAPI_Call{Call: _e.mock.On("EnableAPI", ctx, projectID, apiName)} -} - -func (_c *MockGCPClienter_EnableAPI_Call) Run(run func(ctx context.Context, projectID string, apiName string)) *MockGCPClienter_EnableAPI_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_EnableAPI_Call) Return(_a0 error) *MockGCPClienter_EnableAPI_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_EnableAPI_Call) RunAndReturn(run func(context.Context, string, string) error) *MockGCPClienter_EnableAPI_Call { - _c.Call.Return(run) - return _c -} - -// EnsureFirewallRules provides a mock function with given fields: ctx, projectID, networkName, allowedPorts -func (_m *MockGCPClienter) EnsureFirewallRules(ctx context.Context, projectID string, networkName string, allowedPorts []int) error { - ret := _m.Called(ctx, projectID, networkName, allowedPorts) - - if len(ret) == 0 { - panic("no return value specified for EnsureFirewallRules") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, []int) error); ok { - r0 = rf(ctx, projectID, networkName, allowedPorts) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_EnsureFirewallRules_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnsureFirewallRules' -type MockGCPClienter_EnsureFirewallRules_Call struct { - *mock.Call -} - -// EnsureFirewallRules is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - networkName string -// - allowedPorts []int -func (_e *MockGCPClienter_Expecter) EnsureFirewallRules(ctx interface{}, projectID interface{}, networkName interface{}, allowedPorts interface{}) *MockGCPClienter_EnsureFirewallRules_Call { - return &MockGCPClienter_EnsureFirewallRules_Call{Call: _e.mock.On("EnsureFirewallRules", ctx, projectID, networkName, allowedPorts)} -} - -func (_c *MockGCPClienter_EnsureFirewallRules_Call) Run(run func(ctx context.Context, projectID string, networkName string, allowedPorts []int)) *MockGCPClienter_EnsureFirewallRules_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].([]int)) - }) - return _c -} - -func (_c *MockGCPClienter_EnsureFirewallRules_Call) Return(_a0 error) *MockGCPClienter_EnsureFirewallRules_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_EnsureFirewallRules_Call) RunAndReturn(run func(context.Context, string, string, []int) error) *MockGCPClienter_EnsureFirewallRules_Call { - _c.Call.Return(run) - return _c -} - -// EnsureProject provides a mock function with given fields: ctx, organizationID, projectID, billingAccountID -func (_m *MockGCPClienter) EnsureProject(ctx context.Context, organizationID string, projectID string, billingAccountID string) (string, error) { - ret := _m.Called(ctx, organizationID, projectID, billingAccountID) - - if len(ret) == 0 { - panic("no return value specified for EnsureProject") - } - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (string, error)); ok { - return rf(ctx, organizationID, projectID, billingAccountID) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) string); ok { - r0 = rf(ctx, organizationID, projectID, billingAccountID) - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, organizationID, projectID, billingAccountID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_EnsureProject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnsureProject' -type MockGCPClienter_EnsureProject_Call struct { - *mock.Call -} - -// EnsureProject is a helper method to define mock.On call -// - ctx context.Context -// - organizationID string -// - projectID string -// - billingAccountID string -func (_e *MockGCPClienter_Expecter) EnsureProject(ctx interface{}, organizationID interface{}, projectID interface{}, billingAccountID interface{}) *MockGCPClienter_EnsureProject_Call { - return &MockGCPClienter_EnsureProject_Call{Call: _e.mock.On("EnsureProject", ctx, organizationID, projectID, billingAccountID)} -} - -func (_c *MockGCPClienter_EnsureProject_Call) Run(run func(ctx context.Context, organizationID string, projectID string, billingAccountID string)) *MockGCPClienter_EnsureProject_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_EnsureProject_Call) Return(_a0 string, _a1 error) *MockGCPClienter_EnsureProject_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_EnsureProject_Call) RunAndReturn(run func(context.Context, string, string, string) (string, error)) *MockGCPClienter_EnsureProject_Call { - _c.Call.Return(run) - return _c -} - -// EnsureVPCNetwork provides a mock function with given fields: ctx, projectID, networkName -func (_m *MockGCPClienter) EnsureVPCNetwork(ctx context.Context, projectID string, networkName string) error { - ret := _m.Called(ctx, projectID, networkName) - - if len(ret) == 0 { - panic("no return value specified for EnsureVPCNetwork") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = rf(ctx, projectID, networkName) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_EnsureVPCNetwork_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnsureVPCNetwork' -type MockGCPClienter_EnsureVPCNetwork_Call struct { - *mock.Call -} - -// EnsureVPCNetwork is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - networkName string -func (_e *MockGCPClienter_Expecter) EnsureVPCNetwork(ctx interface{}, projectID interface{}, networkName interface{}) *MockGCPClienter_EnsureVPCNetwork_Call { - return &MockGCPClienter_EnsureVPCNetwork_Call{Call: _e.mock.On("EnsureVPCNetwork", ctx, projectID, networkName)} -} - -func (_c *MockGCPClienter_EnsureVPCNetwork_Call) Run(run func(ctx context.Context, projectID string, networkName string)) *MockGCPClienter_EnsureVPCNetwork_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_EnsureVPCNetwork_Call) Return(_a0 error) *MockGCPClienter_EnsureVPCNetwork_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_EnsureVPCNetwork_Call) RunAndReturn(run func(context.Context, string, string) error) *MockGCPClienter_EnsureVPCNetwork_Call { - _c.Call.Return(run) - return _c -} - -// GetParentString provides a mock function with given fields: -func (_m *MockGCPClienter) GetParentString() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetParentString") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockGCPClienter_GetParentString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetParentString' -type MockGCPClienter_GetParentString_Call struct { - *mock.Call -} - -// GetParentString is a helper method to define mock.On call -func (_e *MockGCPClienter_Expecter) GetParentString() *MockGCPClienter_GetParentString_Call { - return &MockGCPClienter_GetParentString_Call{Call: _e.mock.On("GetParentString")} -} - -func (_c *MockGCPClienter_GetParentString_Call) Run(run func()) *MockGCPClienter_GetParentString_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockGCPClienter_GetParentString_Call) Return(_a0 string) *MockGCPClienter_GetParentString_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_GetParentString_Call) RunAndReturn(run func() string) *MockGCPClienter_GetParentString_Call { - _c.Call.Return(run) - return _c -} - -// GetVMExternalIP provides a mock function with given fields: ctx, vmName, locationData -func (_m *MockGCPClienter) GetVMExternalIP(ctx context.Context, vmName string, locationData map[string]string) (string, error) { - ret := _m.Called(ctx, vmName, locationData) - - if len(ret) == 0 { - panic("no return value specified for GetVMExternalIP") - } - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, map[string]string) (string, error)); ok { - return rf(ctx, vmName, locationData) - } - if rf, ok := ret.Get(0).(func(context.Context, string, map[string]string) string); ok { - r0 = rf(ctx, vmName, locationData) - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, map[string]string) error); ok { - r1 = rf(ctx, vmName, locationData) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_GetVMExternalIP_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetVMExternalIP' -type MockGCPClienter_GetVMExternalIP_Call struct { - *mock.Call -} - -// GetVMExternalIP is a helper method to define mock.On call -// - ctx context.Context -// - vmName string -// - locationData map[string]string -func (_e *MockGCPClienter_Expecter) GetVMExternalIP(ctx interface{}, vmName interface{}, locationData interface{}) *MockGCPClienter_GetVMExternalIP_Call { - return &MockGCPClienter_GetVMExternalIP_Call{Call: _e.mock.On("GetVMExternalIP", ctx, vmName, locationData)} -} - -func (_c *MockGCPClienter_GetVMExternalIP_Call) Run(run func(ctx context.Context, vmName string, locationData map[string]string)) *MockGCPClienter_GetVMExternalIP_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(map[string]string)) - }) - return _c -} - -func (_c *MockGCPClienter_GetVMExternalIP_Call) Return(_a0 string, _a1 error) *MockGCPClienter_GetVMExternalIP_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_GetVMExternalIP_Call) RunAndReturn(run func(context.Context, string, map[string]string) (string, error)) *MockGCPClienter_GetVMExternalIP_Call { - _c.Call.Return(run) - return _c -} - -// GetVMZone provides a mock function with given fields: ctx, projectID, vmName -func (_m *MockGCPClienter) GetVMZone(ctx context.Context, projectID string, vmName string) (string, error) { - ret := _m.Called(ctx, projectID, vmName) - - if len(ret) == 0 { - panic("no return value specified for GetVMZone") - } - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (string, error)); ok { - return rf(ctx, projectID, vmName) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) string); ok { - r0 = rf(ctx, projectID, vmName) - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, projectID, vmName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_GetVMZone_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetVMZone' -type MockGCPClienter_GetVMZone_Call struct { - *mock.Call -} - -// GetVMZone is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - vmName string -func (_e *MockGCPClienter_Expecter) GetVMZone(ctx interface{}, projectID interface{}, vmName interface{}) *MockGCPClienter_GetVMZone_Call { - return &MockGCPClienter_GetVMZone_Call{Call: _e.mock.On("GetVMZone", ctx, projectID, vmName)} -} - -func (_c *MockGCPClienter_GetVMZone_Call) Run(run func(ctx context.Context, projectID string, vmName string)) *MockGCPClienter_GetVMZone_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_GetVMZone_Call) Return(_a0 string, _a1 error) *MockGCPClienter_GetVMZone_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_GetVMZone_Call) RunAndReturn(run func(context.Context, string, string) (string, error)) *MockGCPClienter_GetVMZone_Call { - _c.Call.Return(run) - return _c -} - -// IsAPIEnabled provides a mock function with given fields: ctx, projectID, apiName -func (_m *MockGCPClienter) IsAPIEnabled(ctx context.Context, projectID string, apiName string) (bool, error) { - ret := _m.Called(ctx, projectID, apiName) - - if len(ret) == 0 { - panic("no return value specified for IsAPIEnabled") - } - - var r0 bool - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) (bool, error)); ok { - return rf(ctx, projectID, apiName) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) bool); ok { - r0 = rf(ctx, projectID, apiName) - } else { - r0 = ret.Get(0).(bool) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, projectID, apiName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_IsAPIEnabled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsAPIEnabled' -type MockGCPClienter_IsAPIEnabled_Call struct { - *mock.Call -} - -// IsAPIEnabled is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - apiName string -func (_e *MockGCPClienter_Expecter) IsAPIEnabled(ctx interface{}, projectID interface{}, apiName interface{}) *MockGCPClienter_IsAPIEnabled_Call { - return &MockGCPClienter_IsAPIEnabled_Call{Call: _e.mock.On("IsAPIEnabled", ctx, projectID, apiName)} -} - -func (_c *MockGCPClienter_IsAPIEnabled_Call) Run(run func(ctx context.Context, projectID string, apiName string)) *MockGCPClienter_IsAPIEnabled_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_IsAPIEnabled_Call) Return(_a0 bool, _a1 error) *MockGCPClienter_IsAPIEnabled_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_IsAPIEnabled_Call) RunAndReturn(run func(context.Context, string, string) (bool, error)) *MockGCPClienter_IsAPIEnabled_Call { - _c.Call.Return(run) - return _c -} - -// ListAddresses provides a mock function with given fields: ctx, projectID, region -func (_m *MockGCPClienter) ListAddresses(ctx context.Context, projectID string, region string) ([]*computepb.Address, error) { - ret := _m.Called(ctx, projectID, region) - - if len(ret) == 0 { - panic("no return value specified for ListAddresses") - } - - var r0 []*computepb.Address - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) ([]*computepb.Address, error)); ok { - return rf(ctx, projectID, region) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string) []*computepb.Address); ok { - r0 = rf(ctx, projectID, region) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*computepb.Address) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { - r1 = rf(ctx, projectID, region) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_ListAddresses_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAddresses' -type MockGCPClienter_ListAddresses_Call struct { - *mock.Call -} - -// ListAddresses is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - region string -func (_e *MockGCPClienter_Expecter) ListAddresses(ctx interface{}, projectID interface{}, region interface{}) *MockGCPClienter_ListAddresses_Call { - return &MockGCPClienter_ListAddresses_Call{Call: _e.mock.On("ListAddresses", ctx, projectID, region)} -} - -func (_c *MockGCPClienter_ListAddresses_Call) Run(run func(ctx context.Context, projectID string, region string)) *MockGCPClienter_ListAddresses_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_ListAddresses_Call) Return(_a0 []*computepb.Address, _a1 error) *MockGCPClienter_ListAddresses_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_ListAddresses_Call) RunAndReturn(run func(context.Context, string, string) ([]*computepb.Address, error)) *MockGCPClienter_ListAddresses_Call { - _c.Call.Return(run) - return _c -} - -// ListAllAssetsInProject provides a mock function with given fields: ctx, projectID -func (_m *MockGCPClienter) ListAllAssetsInProject(ctx context.Context, projectID string) ([]*assetpb.Asset, error) { - ret := _m.Called(ctx, projectID) - - if len(ret) == 0 { - panic("no return value specified for ListAllAssetsInProject") - } - - var r0 []*assetpb.Asset - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) ([]*assetpb.Asset, error)); ok { - return rf(ctx, projectID) - } - if rf, ok := ret.Get(0).(func(context.Context, string) []*assetpb.Asset); ok { - r0 = rf(ctx, projectID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*assetpb.Asset) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, projectID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_ListAllAssetsInProject_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAllAssetsInProject' -type MockGCPClienter_ListAllAssetsInProject_Call struct { - *mock.Call -} - -// ListAllAssetsInProject is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -func (_e *MockGCPClienter_Expecter) ListAllAssetsInProject(ctx interface{}, projectID interface{}) *MockGCPClienter_ListAllAssetsInProject_Call { - return &MockGCPClienter_ListAllAssetsInProject_Call{Call: _e.mock.On("ListAllAssetsInProject", ctx, projectID)} -} - -func (_c *MockGCPClienter_ListAllAssetsInProject_Call) Run(run func(ctx context.Context, projectID string)) *MockGCPClienter_ListAllAssetsInProject_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_ListAllAssetsInProject_Call) Return(_a0 []*assetpb.Asset, _a1 error) *MockGCPClienter_ListAllAssetsInProject_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_ListAllAssetsInProject_Call) RunAndReturn(run func(context.Context, string) ([]*assetpb.Asset, error)) *MockGCPClienter_ListAllAssetsInProject_Call { - _c.Call.Return(run) - return _c -} - -// ListBillingAccounts provides a mock function with given fields: ctx -func (_m *MockGCPClienter) ListBillingAccounts(ctx context.Context) ([]string, error) { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for ListBillingAccounts") - } - - var r0 []string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context) ([]string, error)); ok { - return rf(ctx) - } - if rf, ok := ret.Get(0).(func(context.Context) []string); ok { - r0 = rf(ctx) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]string) - } - } - - if rf, ok := ret.Get(1).(func(context.Context) error); ok { - r1 = rf(ctx) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_ListBillingAccounts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListBillingAccounts' -type MockGCPClienter_ListBillingAccounts_Call struct { - *mock.Call -} - -// ListBillingAccounts is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockGCPClienter_Expecter) ListBillingAccounts(ctx interface{}) *MockGCPClienter_ListBillingAccounts_Call { - return &MockGCPClienter_ListBillingAccounts_Call{Call: _e.mock.On("ListBillingAccounts", ctx)} -} - -func (_c *MockGCPClienter_ListBillingAccounts_Call) Run(run func(ctx context.Context)) *MockGCPClienter_ListBillingAccounts_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockGCPClienter_ListBillingAccounts_Call) Return(_a0 []string, _a1 error) *MockGCPClienter_ListBillingAccounts_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_ListBillingAccounts_Call) RunAndReturn(run func(context.Context) ([]string, error)) *MockGCPClienter_ListBillingAccounts_Call { - _c.Call.Return(run) - return _c -} - -// ListProjects provides a mock function with given fields: ctx, req -func (_m *MockGCPClienter) ListProjects(ctx context.Context, req *resourcemanagerpb.ListProjectsRequest) ([]*resourcemanagerpb.Project, error) { - ret := _m.Called(ctx, req) - - if len(ret) == 0 { - panic("no return value specified for ListProjects") - } - - var r0 []*resourcemanagerpb.Project - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *resourcemanagerpb.ListProjectsRequest) ([]*resourcemanagerpb.Project, error)); ok { - return rf(ctx, req) - } - if rf, ok := ret.Get(0).(func(context.Context, *resourcemanagerpb.ListProjectsRequest) []*resourcemanagerpb.Project); ok { - r0 = rf(ctx, req) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*resourcemanagerpb.Project) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *resourcemanagerpb.ListProjectsRequest) error); ok { - r1 = rf(ctx, req) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_ListProjects_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListProjects' -type MockGCPClienter_ListProjects_Call struct { - *mock.Call -} - -// ListProjects is a helper method to define mock.On call -// - ctx context.Context -// - req *resourcemanagerpb.ListProjectsRequest -func (_e *MockGCPClienter_Expecter) ListProjects(ctx interface{}, req interface{}) *MockGCPClienter_ListProjects_Call { - return &MockGCPClienter_ListProjects_Call{Call: _e.mock.On("ListProjects", ctx, req)} -} - -func (_c *MockGCPClienter_ListProjects_Call) Run(run func(ctx context.Context, req *resourcemanagerpb.ListProjectsRequest)) *MockGCPClienter_ListProjects_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*resourcemanagerpb.ListProjectsRequest)) - }) - return _c -} - -func (_c *MockGCPClienter_ListProjects_Call) Return(_a0 []*resourcemanagerpb.Project, _a1 error) *MockGCPClienter_ListProjects_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_ListProjects_Call) RunAndReturn(run func(context.Context, *resourcemanagerpb.ListProjectsRequest) ([]*resourcemanagerpb.Project, error)) *MockGCPClienter_ListProjects_Call { - _c.Call.Return(run) - return _c -} - -// ProjectExists provides a mock function with given fields: ctx, projectID -func (_m *MockGCPClienter) ProjectExists(ctx context.Context, projectID string) (bool, error) { - ret := _m.Called(ctx, projectID) - - if len(ret) == 0 { - panic("no return value specified for ProjectExists") - } - - var r0 bool - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (bool, error)); ok { - return rf(ctx, projectID) - } - if rf, ok := ret.Get(0).(func(context.Context, string) bool); ok { - r0 = rf(ctx, projectID) - } else { - r0 = ret.Get(0).(bool) - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, projectID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_ProjectExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProjectExists' -type MockGCPClienter_ProjectExists_Call struct { - *mock.Call -} - -// ProjectExists is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -func (_e *MockGCPClienter_Expecter) ProjectExists(ctx interface{}, projectID interface{}) *MockGCPClienter_ProjectExists_Call { - return &MockGCPClienter_ProjectExists_Call{Call: _e.mock.On("ProjectExists", ctx, projectID)} -} - -func (_c *MockGCPClienter_ProjectExists_Call) Run(run func(ctx context.Context, projectID string)) *MockGCPClienter_ProjectExists_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_ProjectExists_Call) Return(_a0 bool, _a1 error) *MockGCPClienter_ProjectExists_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_ProjectExists_Call) RunAndReturn(run func(context.Context, string) (bool, error)) *MockGCPClienter_ProjectExists_Call { - _c.Call.Return(run) - return _c -} - -// SetBillingAccount provides a mock function with given fields: ctx, projectID, billingAccountID -func (_m *MockGCPClienter) SetBillingAccount(ctx context.Context, projectID string, billingAccountID string) error { - ret := _m.Called(ctx, projectID, billingAccountID) - - if len(ret) == 0 { - panic("no return value specified for SetBillingAccount") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = rf(ctx, projectID, billingAccountID) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_SetBillingAccount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetBillingAccount' -type MockGCPClienter_SetBillingAccount_Call struct { - *mock.Call -} - -// SetBillingAccount is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - billingAccountID string -func (_e *MockGCPClienter_Expecter) SetBillingAccount(ctx interface{}, projectID interface{}, billingAccountID interface{}) *MockGCPClienter_SetBillingAccount_Call { - return &MockGCPClienter_SetBillingAccount_Call{Call: _e.mock.On("SetBillingAccount", ctx, projectID, billingAccountID)} -} - -func (_c *MockGCPClienter_SetBillingAccount_Call) Run(run func(ctx context.Context, projectID string, billingAccountID string)) *MockGCPClienter_SetBillingAccount_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_SetBillingAccount_Call) Return(_a0 error) *MockGCPClienter_SetBillingAccount_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_SetBillingAccount_Call) RunAndReturn(run func(context.Context, string, string) error) *MockGCPClienter_SetBillingAccount_Call { - _c.Call.Return(run) - return _c -} - -// SetParentString provides a mock function with given fields: organizationID -func (_m *MockGCPClienter) SetParentString(organizationID string) { - _m.Called(organizationID) -} - -// MockGCPClienter_SetParentString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetParentString' -type MockGCPClienter_SetParentString_Call struct { - *mock.Call -} - -// SetParentString is a helper method to define mock.On call -// - organizationID string -func (_e *MockGCPClienter_Expecter) SetParentString(organizationID interface{}) *MockGCPClienter_SetParentString_Call { - return &MockGCPClienter_SetParentString_Call{Call: _e.mock.On("SetParentString", organizationID)} -} - -func (_c *MockGCPClienter_SetParentString_Call) Run(run func(organizationID string)) *MockGCPClienter_SetParentString_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_SetParentString_Call) Return() *MockGCPClienter_SetParentString_Call { - _c.Call.Return() - return _c -} - -func (_c *MockGCPClienter_SetParentString_Call) RunAndReturn(run func(string)) *MockGCPClienter_SetParentString_Call { - _c.Call.Return(run) - return _c -} - -// StartResourcePolling provides a mock function with given fields: ctx -func (_m *MockGCPClienter) StartResourcePolling(ctx context.Context) error { - ret := _m.Called(ctx) - - if len(ret) == 0 { - panic("no return value specified for StartResourcePolling") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context) error); ok { - r0 = rf(ctx) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockGCPClienter_StartResourcePolling_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartResourcePolling' -type MockGCPClienter_StartResourcePolling_Call struct { - *mock.Call -} - -// StartResourcePolling is a helper method to define mock.On call -// - ctx context.Context -func (_e *MockGCPClienter_Expecter) StartResourcePolling(ctx interface{}) *MockGCPClienter_StartResourcePolling_Call { - return &MockGCPClienter_StartResourcePolling_Call{Call: _e.mock.On("StartResourcePolling", ctx)} -} - -func (_c *MockGCPClienter_StartResourcePolling_Call) Run(run func(ctx context.Context)) *MockGCPClienter_StartResourcePolling_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context)) - }) - return _c -} - -func (_c *MockGCPClienter_StartResourcePolling_Call) Return(_a0 error) *MockGCPClienter_StartResourcePolling_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockGCPClienter_StartResourcePolling_Call) RunAndReturn(run func(context.Context) error) *MockGCPClienter_StartResourcePolling_Call { - _c.Call.Return(run) - return _c -} - -// ValidateMachineType provides a mock function with given fields: ctx, projectID, machineType, location -func (_m *MockGCPClienter) ValidateMachineType(ctx context.Context, projectID string, machineType string, location string) (bool, error) { - ret := _m.Called(ctx, projectID, machineType, location) - - if len(ret) == 0 { - panic("no return value specified for ValidateMachineType") - } - - var r0 bool - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (bool, error)); ok { - return rf(ctx, projectID, machineType, location) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) bool); ok { - r0 = rf(ctx, projectID, machineType, location) - } else { - r0 = ret.Get(0).(bool) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, projectID, machineType, location) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockGCPClienter_ValidateMachineType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ValidateMachineType' -type MockGCPClienter_ValidateMachineType_Call struct { - *mock.Call -} - -// ValidateMachineType is a helper method to define mock.On call -// - ctx context.Context -// - projectID string -// - machineType string -// - location string -func (_e *MockGCPClienter_Expecter) ValidateMachineType(ctx interface{}, projectID interface{}, machineType interface{}, location interface{}) *MockGCPClienter_ValidateMachineType_Call { - return &MockGCPClienter_ValidateMachineType_Call{Call: _e.mock.On("ValidateMachineType", ctx, projectID, machineType, location)} -} - -func (_c *MockGCPClienter_ValidateMachineType_Call) Run(run func(ctx context.Context, projectID string, machineType string, location string)) *MockGCPClienter_ValidateMachineType_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockGCPClienter_ValidateMachineType_Call) Return(_a0 bool, _a1 error) *MockGCPClienter_ValidateMachineType_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockGCPClienter_ValidateMachineType_Call) RunAndReturn(run func(context.Context, string, string, string) (bool, error)) *MockGCPClienter_ValidateMachineType_Call { - _c.Call.Return(run) - return _c -} - -// NewMockGCPClienter creates a new instance of MockGCPClienter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockGCPClienter(t interface { - mock.TestingT - Cleanup(func()) -}) *MockGCPClienter { - mock := &MockGCPClienter{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPClientCreator.go b/pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPClientCreator.go deleted file mode 100644 index 5fde916e..00000000 --- a/pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPClientCreator.go +++ /dev/null @@ -1,95 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package sshutils - -import ( - sftp "github.com/pkg/sftp" - mock "github.com/stretchr/testify/mock" - - sshutils "github.com/bacalhau-project/andaime/pkg/models/interfaces/sshutils" -) - -// MockSFTPClientCreator is an autogenerated mock type for the SFTPClientCreator type -type MockSFTPClientCreator struct { - mock.Mock -} - -type MockSFTPClientCreator_Expecter struct { - mock *mock.Mock -} - -func (_m *MockSFTPClientCreator) EXPECT() *MockSFTPClientCreator_Expecter { - return &MockSFTPClientCreator_Expecter{mock: &_m.Mock} -} - -// NewSFTPClient provides a mock function with given fields: client -func (_m *MockSFTPClientCreator) NewSFTPClient(client sshutils.SSHClienter) (*sftp.Client, error) { - ret := _m.Called(client) - - if len(ret) == 0 { - panic("no return value specified for NewSFTPClient") - } - - var r0 *sftp.Client - var r1 error - if rf, ok := ret.Get(0).(func(sshutils.SSHClienter) (*sftp.Client, error)); ok { - return rf(client) - } - if rf, ok := ret.Get(0).(func(sshutils.SSHClienter) *sftp.Client); ok { - r0 = rf(client) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*sftp.Client) - } - } - - if rf, ok := ret.Get(1).(func(sshutils.SSHClienter) error); ok { - r1 = rf(client) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSFTPClientCreator_NewSFTPClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewSFTPClient' -type MockSFTPClientCreator_NewSFTPClient_Call struct { - *mock.Call -} - -// NewSFTPClient is a helper method to define mock.On call -// - client sshutils.SSHClienter -func (_e *MockSFTPClientCreator_Expecter) NewSFTPClient(client interface{}) *MockSFTPClientCreator_NewSFTPClient_Call { - return &MockSFTPClientCreator_NewSFTPClient_Call{Call: _e.mock.On("NewSFTPClient", client)} -} - -func (_c *MockSFTPClientCreator_NewSFTPClient_Call) Run(run func(client sshutils.SSHClienter)) *MockSFTPClientCreator_NewSFTPClient_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(sshutils.SSHClienter)) - }) - return _c -} - -func (_c *MockSFTPClientCreator_NewSFTPClient_Call) Return(_a0 *sftp.Client, _a1 error) *MockSFTPClientCreator_NewSFTPClient_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSFTPClientCreator_NewSFTPClient_Call) RunAndReturn(run func(sshutils.SSHClienter) (*sftp.Client, error)) *MockSFTPClientCreator_NewSFTPClient_Call { - _c.Call.Return(run) - return _c -} - -// NewMockSFTPClientCreator creates a new instance of MockSFTPClientCreator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockSFTPClientCreator(t interface { - mock.TestingT - Cleanup(func()) -}) *MockSFTPClientCreator { - mock := &MockSFTPClientCreator{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPClienter.go b/pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPClienter.go deleted file mode 100644 index 5356c02c..00000000 --- a/pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPClienter.go +++ /dev/null @@ -1,291 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package sshutils - -import ( - io "io" - fs "io/fs" - - mock "github.com/stretchr/testify/mock" -) - -// MockSFTPClienter is an autogenerated mock type for the SFTPClienter type -type MockSFTPClienter struct { - mock.Mock -} - -type MockSFTPClienter_Expecter struct { - mock *mock.Mock -} - -func (_m *MockSFTPClienter) EXPECT() *MockSFTPClienter_Expecter { - return &MockSFTPClienter_Expecter{mock: &_m.Mock} -} - -// Chmod provides a mock function with given fields: _a0, _a1 -func (_m *MockSFTPClienter) Chmod(_a0 string, _a1 fs.FileMode) error { - ret := _m.Called(_a0, _a1) - - if len(ret) == 0 { - panic("no return value specified for Chmod") - } - - var r0 error - if rf, ok := ret.Get(0).(func(string, fs.FileMode) error); ok { - r0 = rf(_a0, _a1) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSFTPClienter_Chmod_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Chmod' -type MockSFTPClienter_Chmod_Call struct { - *mock.Call -} - -// Chmod is a helper method to define mock.On call -// - _a0 string -// - _a1 fs.FileMode -func (_e *MockSFTPClienter_Expecter) Chmod(_a0 interface{}, _a1 interface{}) *MockSFTPClienter_Chmod_Call { - return &MockSFTPClienter_Chmod_Call{Call: _e.mock.On("Chmod", _a0, _a1)} -} - -func (_c *MockSFTPClienter_Chmod_Call) Run(run func(_a0 string, _a1 fs.FileMode)) *MockSFTPClienter_Chmod_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(fs.FileMode)) - }) - return _c -} - -func (_c *MockSFTPClienter_Chmod_Call) Return(_a0 error) *MockSFTPClienter_Chmod_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSFTPClienter_Chmod_Call) RunAndReturn(run func(string, fs.FileMode) error) *MockSFTPClienter_Chmod_Call { - _c.Call.Return(run) - return _c -} - -// Close provides a mock function with given fields: -func (_m *MockSFTPClienter) Close() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Close") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSFTPClienter_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close' -type MockSFTPClienter_Close_Call struct { - *mock.Call -} - -// Close is a helper method to define mock.On call -func (_e *MockSFTPClienter_Expecter) Close() *MockSFTPClienter_Close_Call { - return &MockSFTPClienter_Close_Call{Call: _e.mock.On("Close")} -} - -func (_c *MockSFTPClienter_Close_Call) Run(run func()) *MockSFTPClienter_Close_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSFTPClienter_Close_Call) Return(_a0 error) *MockSFTPClienter_Close_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSFTPClienter_Close_Call) RunAndReturn(run func() error) *MockSFTPClienter_Close_Call { - _c.Call.Return(run) - return _c -} - -// Create provides a mock function with given fields: _a0 -func (_m *MockSFTPClienter) Create(_a0 string) (io.WriteCloser, error) { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 io.WriteCloser - var r1 error - if rf, ok := ret.Get(0).(func(string) (io.WriteCloser, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(string) io.WriteCloser); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(io.WriteCloser) - } - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSFTPClienter_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockSFTPClienter_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - _a0 string -func (_e *MockSFTPClienter_Expecter) Create(_a0 interface{}) *MockSFTPClienter_Create_Call { - return &MockSFTPClienter_Create_Call{Call: _e.mock.On("Create", _a0)} -} - -func (_c *MockSFTPClienter_Create_Call) Run(run func(_a0 string)) *MockSFTPClienter_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *MockSFTPClienter_Create_Call) Return(_a0 io.WriteCloser, _a1 error) *MockSFTPClienter_Create_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSFTPClienter_Create_Call) RunAndReturn(run func(string) (io.WriteCloser, error)) *MockSFTPClienter_Create_Call { - _c.Call.Return(run) - return _c -} - -// MkdirAll provides a mock function with given fields: _a0 -func (_m *MockSFTPClienter) MkdirAll(_a0 string) error { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for MkdirAll") - } - - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(_a0) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSFTPClienter_MkdirAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MkdirAll' -type MockSFTPClienter_MkdirAll_Call struct { - *mock.Call -} - -// MkdirAll is a helper method to define mock.On call -// - _a0 string -func (_e *MockSFTPClienter_Expecter) MkdirAll(_a0 interface{}) *MockSFTPClienter_MkdirAll_Call { - return &MockSFTPClienter_MkdirAll_Call{Call: _e.mock.On("MkdirAll", _a0)} -} - -func (_c *MockSFTPClienter_MkdirAll_Call) Run(run func(_a0 string)) *MockSFTPClienter_MkdirAll_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *MockSFTPClienter_MkdirAll_Call) Return(_a0 error) *MockSFTPClienter_MkdirAll_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSFTPClienter_MkdirAll_Call) RunAndReturn(run func(string) error) *MockSFTPClienter_MkdirAll_Call { - _c.Call.Return(run) - return _c -} - -// Open provides a mock function with given fields: _a0 -func (_m *MockSFTPClienter) Open(_a0 string) (io.ReadCloser, error) { - ret := _m.Called(_a0) - - if len(ret) == 0 { - panic("no return value specified for Open") - } - - var r0 io.ReadCloser - var r1 error - if rf, ok := ret.Get(0).(func(string) (io.ReadCloser, error)); ok { - return rf(_a0) - } - if rf, ok := ret.Get(0).(func(string) io.ReadCloser); ok { - r0 = rf(_a0) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(io.ReadCloser) - } - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSFTPClienter_Open_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Open' -type MockSFTPClienter_Open_Call struct { - *mock.Call -} - -// Open is a helper method to define mock.On call -// - _a0 string -func (_e *MockSFTPClienter_Expecter) Open(_a0 interface{}) *MockSFTPClienter_Open_Call { - return &MockSFTPClienter_Open_Call{Call: _e.mock.On("Open", _a0)} -} - -func (_c *MockSFTPClienter_Open_Call) Run(run func(_a0 string)) *MockSFTPClienter_Open_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *MockSFTPClienter_Open_Call) Return(_a0 io.ReadCloser, _a1 error) *MockSFTPClienter_Open_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSFTPClienter_Open_Call) RunAndReturn(run func(string) (io.ReadCloser, error)) *MockSFTPClienter_Open_Call { - _c.Call.Return(run) - return _c -} - -// NewMockSFTPClienter creates a new instance of MockSFTPClienter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockSFTPClienter(t interface { - mock.TestingT - Cleanup(func()) -}) *MockSFTPClienter { - mock := &MockSFTPClienter{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPFile.go b/pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPFile.go deleted file mode 100644 index 50435c57..00000000 --- a/pkg/models/interfaces/aws/mocks/sshutils/mock_SFTPFile.go +++ /dev/null @@ -1,133 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package sshutils - -import mock "github.com/stretchr/testify/mock" - -// MockSFTPFile is an autogenerated mock type for the SFTPFile type -type MockSFTPFile struct { - mock.Mock -} - -type MockSFTPFile_Expecter struct { - mock *mock.Mock -} - -func (_m *MockSFTPFile) EXPECT() *MockSFTPFile_Expecter { - return &MockSFTPFile_Expecter{mock: &_m.Mock} -} - -// Close provides a mock function with given fields: -func (_m *MockSFTPFile) Close() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Close") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSFTPFile_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close' -type MockSFTPFile_Close_Call struct { - *mock.Call -} - -// Close is a helper method to define mock.On call -func (_e *MockSFTPFile_Expecter) Close() *MockSFTPFile_Close_Call { - return &MockSFTPFile_Close_Call{Call: _e.mock.On("Close")} -} - -func (_c *MockSFTPFile_Close_Call) Run(run func()) *MockSFTPFile_Close_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSFTPFile_Close_Call) Return(_a0 error) *MockSFTPFile_Close_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSFTPFile_Close_Call) RunAndReturn(run func() error) *MockSFTPFile_Close_Call { - _c.Call.Return(run) - return _c -} - -// Write provides a mock function with given fields: p -func (_m *MockSFTPFile) Write(p []byte) (int, error) { - ret := _m.Called(p) - - if len(ret) == 0 { - panic("no return value specified for Write") - } - - var r0 int - var r1 error - if rf, ok := ret.Get(0).(func([]byte) (int, error)); ok { - return rf(p) - } - if rf, ok := ret.Get(0).(func([]byte) int); ok { - r0 = rf(p) - } else { - r0 = ret.Get(0).(int) - } - - if rf, ok := ret.Get(1).(func([]byte) error); ok { - r1 = rf(p) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSFTPFile_Write_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Write' -type MockSFTPFile_Write_Call struct { - *mock.Call -} - -// Write is a helper method to define mock.On call -// - p []byte -func (_e *MockSFTPFile_Expecter) Write(p interface{}) *MockSFTPFile_Write_Call { - return &MockSFTPFile_Write_Call{Call: _e.mock.On("Write", p)} -} - -func (_c *MockSFTPFile_Write_Call) Run(run func(p []byte)) *MockSFTPFile_Write_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].([]byte)) - }) - return _c -} - -func (_c *MockSFTPFile_Write_Call) Return(n int, err error) *MockSFTPFile_Write_Call { - _c.Call.Return(n, err) - return _c -} - -func (_c *MockSFTPFile_Write_Call) RunAndReturn(run func([]byte) (int, error)) *MockSFTPFile_Write_Call { - _c.Call.Return(run) - return _c -} - -// NewMockSFTPFile creates a new instance of MockSFTPFile. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockSFTPFile(t interface { - mock.TestingT - Cleanup(func()) -}) *MockSFTPFile { - mock := &MockSFTPFile{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHClientCreator.go b/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHClientCreator.go deleted file mode 100644 index e965f233..00000000 --- a/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHClientCreator.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package sshutils - -import ( - mock "github.com/stretchr/testify/mock" - ssh "golang.org/x/crypto/ssh" - - sshutils "github.com/bacalhau-project/andaime/pkg/models/interfaces/sshutils" -) - -// MockSSHClientCreator is an autogenerated mock type for the SSHClientCreator type -type MockSSHClientCreator struct { - mock.Mock -} - -type MockSSHClientCreator_Expecter struct { - mock *mock.Mock -} - -func (_m *MockSSHClientCreator) EXPECT() *MockSSHClientCreator_Expecter { - return &MockSSHClientCreator_Expecter{mock: &_m.Mock} -} - -// NewClient provides a mock function with given fields: host, port, user, privateKeyPath, config -func (_m *MockSSHClientCreator) NewClient(host string, port int, user string, privateKeyPath string, config *ssh.ClientConfig) (sshutils.SSHClienter, error) { - ret := _m.Called(host, port, user, privateKeyPath, config) - - if len(ret) == 0 { - panic("no return value specified for NewClient") - } - - var r0 sshutils.SSHClienter - var r1 error - if rf, ok := ret.Get(0).(func(string, int, string, string, *ssh.ClientConfig) (sshutils.SSHClienter, error)); ok { - return rf(host, port, user, privateKeyPath, config) - } - if rf, ok := ret.Get(0).(func(string, int, string, string, *ssh.ClientConfig) sshutils.SSHClienter); ok { - r0 = rf(host, port, user, privateKeyPath, config) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(sshutils.SSHClienter) - } - } - - if rf, ok := ret.Get(1).(func(string, int, string, string, *ssh.ClientConfig) error); ok { - r1 = rf(host, port, user, privateKeyPath, config) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSSHClientCreator_NewClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewClient' -type MockSSHClientCreator_NewClient_Call struct { - *mock.Call -} - -// NewClient is a helper method to define mock.On call -// - host string -// - port int -// - user string -// - privateKeyPath string -// - config *ssh.ClientConfig -func (_e *MockSSHClientCreator_Expecter) NewClient(host interface{}, port interface{}, user interface{}, privateKeyPath interface{}, config interface{}) *MockSSHClientCreator_NewClient_Call { - return &MockSSHClientCreator_NewClient_Call{Call: _e.mock.On("NewClient", host, port, user, privateKeyPath, config)} -} - -func (_c *MockSSHClientCreator_NewClient_Call) Run(run func(host string, port int, user string, privateKeyPath string, config *ssh.ClientConfig)) *MockSSHClientCreator_NewClient_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(int), args[2].(string), args[3].(string), args[4].(*ssh.ClientConfig)) - }) - return _c -} - -func (_c *MockSSHClientCreator_NewClient_Call) Return(_a0 sshutils.SSHClienter, _a1 error) *MockSSHClientCreator_NewClient_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSSHClientCreator_NewClient_Call) RunAndReturn(run func(string, int, string, string, *ssh.ClientConfig) (sshutils.SSHClienter, error)) *MockSSHClientCreator_NewClient_Call { - _c.Call.Return(run) - return _c -} - -// NewMockSSHClientCreator creates a new instance of MockSSHClientCreator. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockSSHClientCreator(t interface { - mock.TestingT - Cleanup(func()) -}) *MockSSHClientCreator { - mock := &MockSSHClientCreator{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHClienter.go b/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHClienter.go deleted file mode 100644 index 552a006f..00000000 --- a/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHClienter.go +++ /dev/null @@ -1,288 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package sshutils - -import ( - mock "github.com/stretchr/testify/mock" - ssh "golang.org/x/crypto/ssh" - - sshutils "github.com/bacalhau-project/andaime/pkg/models/interfaces/sshutils" -) - -// MockSSHClienter is an autogenerated mock type for the SSHClienter type -type MockSSHClienter struct { - mock.Mock -} - -type MockSSHClienter_Expecter struct { - mock *mock.Mock -} - -func (_m *MockSSHClienter) EXPECT() *MockSSHClienter_Expecter { - return &MockSSHClienter_Expecter{mock: &_m.Mock} -} - -// Close provides a mock function with given fields: -func (_m *MockSSHClienter) Close() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Close") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHClienter_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close' -type MockSSHClienter_Close_Call struct { - *mock.Call -} - -// Close is a helper method to define mock.On call -func (_e *MockSSHClienter_Expecter) Close() *MockSSHClienter_Close_Call { - return &MockSSHClienter_Close_Call{Call: _e.mock.On("Close")} -} - -func (_c *MockSSHClienter_Close_Call) Run(run func()) *MockSSHClienter_Close_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHClienter_Close_Call) Return(_a0 error) *MockSSHClienter_Close_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHClienter_Close_Call) RunAndReturn(run func() error) *MockSSHClienter_Close_Call { - _c.Call.Return(run) - return _c -} - -// Connect provides a mock function with given fields: -func (_m *MockSSHClienter) Connect() (sshutils.SSHClienter, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Connect") - } - - var r0 sshutils.SSHClienter - var r1 error - if rf, ok := ret.Get(0).(func() (sshutils.SSHClienter, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() sshutils.SSHClienter); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(sshutils.SSHClienter) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSSHClienter_Connect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Connect' -type MockSSHClienter_Connect_Call struct { - *mock.Call -} - -// Connect is a helper method to define mock.On call -func (_e *MockSSHClienter_Expecter) Connect() *MockSSHClienter_Connect_Call { - return &MockSSHClienter_Connect_Call{Call: _e.mock.On("Connect")} -} - -func (_c *MockSSHClienter_Connect_Call) Run(run func()) *MockSSHClienter_Connect_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHClienter_Connect_Call) Return(_a0 sshutils.SSHClienter, _a1 error) *MockSSHClienter_Connect_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSSHClienter_Connect_Call) RunAndReturn(run func() (sshutils.SSHClienter, error)) *MockSSHClienter_Connect_Call { - _c.Call.Return(run) - return _c -} - -// GetClient provides a mock function with given fields: -func (_m *MockSSHClienter) GetClient() *ssh.Client { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetClient") - } - - var r0 *ssh.Client - if rf, ok := ret.Get(0).(func() *ssh.Client); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ssh.Client) - } - } - - return r0 -} - -// MockSSHClienter_GetClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClient' -type MockSSHClienter_GetClient_Call struct { - *mock.Call -} - -// GetClient is a helper method to define mock.On call -func (_e *MockSSHClienter_Expecter) GetClient() *MockSSHClienter_GetClient_Call { - return &MockSSHClienter_GetClient_Call{Call: _e.mock.On("GetClient")} -} - -func (_c *MockSSHClienter_GetClient_Call) Run(run func()) *MockSSHClienter_GetClient_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHClienter_GetClient_Call) Return(_a0 *ssh.Client) *MockSSHClienter_GetClient_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHClienter_GetClient_Call) RunAndReturn(run func() *ssh.Client) *MockSSHClienter_GetClient_Call { - _c.Call.Return(run) - return _c -} - -// IsConnected provides a mock function with given fields: -func (_m *MockSSHClienter) IsConnected() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for IsConnected") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// MockSSHClienter_IsConnected_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsConnected' -type MockSSHClienter_IsConnected_Call struct { - *mock.Call -} - -// IsConnected is a helper method to define mock.On call -func (_e *MockSSHClienter_Expecter) IsConnected() *MockSSHClienter_IsConnected_Call { - return &MockSSHClienter_IsConnected_Call{Call: _e.mock.On("IsConnected")} -} - -func (_c *MockSSHClienter_IsConnected_Call) Run(run func()) *MockSSHClienter_IsConnected_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHClienter_IsConnected_Call) Return(_a0 bool) *MockSSHClienter_IsConnected_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHClienter_IsConnected_Call) RunAndReturn(run func() bool) *MockSSHClienter_IsConnected_Call { - _c.Call.Return(run) - return _c -} - -// NewSession provides a mock function with given fields: -func (_m *MockSSHClienter) NewSession() (sshutils.SSHSessioner, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for NewSession") - } - - var r0 sshutils.SSHSessioner - var r1 error - if rf, ok := ret.Get(0).(func() (sshutils.SSHSessioner, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() sshutils.SSHSessioner); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(sshutils.SSHSessioner) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSSHClienter_NewSession_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewSession' -type MockSSHClienter_NewSession_Call struct { - *mock.Call -} - -// NewSession is a helper method to define mock.On call -func (_e *MockSSHClienter_Expecter) NewSession() *MockSSHClienter_NewSession_Call { - return &MockSSHClienter_NewSession_Call{Call: _e.mock.On("NewSession")} -} - -func (_c *MockSSHClienter_NewSession_Call) Run(run func()) *MockSSHClienter_NewSession_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHClienter_NewSession_Call) Return(_a0 sshutils.SSHSessioner, _a1 error) *MockSSHClienter_NewSession_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSSHClienter_NewSession_Call) RunAndReturn(run func() (sshutils.SSHSessioner, error)) *MockSSHClienter_NewSession_Call { - _c.Call.Return(run) - return _c -} - -// NewMockSSHClienter creates a new instance of MockSSHClienter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockSSHClienter(t interface { - mock.TestingT - Cleanup(func()) -}) *MockSSHClienter { - mock := &MockSSHClienter{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHConfiger.go b/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHConfiger.go deleted file mode 100644 index 4a57c1ab..00000000 --- a/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHConfiger.go +++ /dev/null @@ -1,1067 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package sshutils - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - ssh "golang.org/x/crypto/ssh" - - sshutils "github.com/bacalhau-project/andaime/pkg/models/interfaces/sshutils" - - time "time" -) - -// MockSSHConfiger is an autogenerated mock type for the SSHConfiger type -type MockSSHConfiger struct { - mock.Mock -} - -type MockSSHConfiger_Expecter struct { - mock *mock.Mock -} - -func (_m *MockSSHConfiger) EXPECT() *MockSSHConfiger_Expecter { - return &MockSSHConfiger_Expecter{mock: &_m.Mock} -} - -// Close provides a mock function with given fields: -func (_m *MockSSHConfiger) Close() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Close") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHConfiger_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close' -type MockSSHConfiger_Close_Call struct { - *mock.Call -} - -// Close is a helper method to define mock.On call -func (_e *MockSSHConfiger_Expecter) Close() *MockSSHConfiger_Close_Call { - return &MockSSHConfiger_Close_Call{Call: _e.mock.On("Close")} -} - -func (_c *MockSSHConfiger_Close_Call) Run(run func()) *MockSSHConfiger_Close_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHConfiger_Close_Call) Return(_a0 error) *MockSSHConfiger_Close_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_Close_Call) RunAndReturn(run func() error) *MockSSHConfiger_Close_Call { - _c.Call.Return(run) - return _c -} - -// Connect provides a mock function with given fields: -func (_m *MockSSHConfiger) Connect() (sshutils.SSHClienter, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Connect") - } - - var r0 sshutils.SSHClienter - var r1 error - if rf, ok := ret.Get(0).(func() (sshutils.SSHClienter, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() sshutils.SSHClienter); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(sshutils.SSHClienter) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSSHConfiger_Connect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Connect' -type MockSSHConfiger_Connect_Call struct { - *mock.Call -} - -// Connect is a helper method to define mock.On call -func (_e *MockSSHConfiger_Expecter) Connect() *MockSSHConfiger_Connect_Call { - return &MockSSHConfiger_Connect_Call{Call: _e.mock.On("Connect")} -} - -func (_c *MockSSHConfiger_Connect_Call) Run(run func()) *MockSSHConfiger_Connect_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHConfiger_Connect_Call) Return(_a0 sshutils.SSHClienter, _a1 error) *MockSSHConfiger_Connect_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSSHConfiger_Connect_Call) RunAndReturn(run func() (sshutils.SSHClienter, error)) *MockSSHConfiger_Connect_Call { - _c.Call.Return(run) - return _c -} - -// ExecuteCommand provides a mock function with given fields: ctx, command -func (_m *MockSSHConfiger) ExecuteCommand(ctx context.Context, command string) (string, error) { - ret := _m.Called(ctx, command) - - if len(ret) == 0 { - panic("no return value specified for ExecuteCommand") - } - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (string, error)); ok { - return rf(ctx, command) - } - if rf, ok := ret.Get(0).(func(context.Context, string) string); ok { - r0 = rf(ctx, command) - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, command) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSSHConfiger_ExecuteCommand_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExecuteCommand' -type MockSSHConfiger_ExecuteCommand_Call struct { - *mock.Call -} - -// ExecuteCommand is a helper method to define mock.On call -// - ctx context.Context -// - command string -func (_e *MockSSHConfiger_Expecter) ExecuteCommand(ctx interface{}, command interface{}) *MockSSHConfiger_ExecuteCommand_Call { - return &MockSSHConfiger_ExecuteCommand_Call{Call: _e.mock.On("ExecuteCommand", ctx, command)} -} - -func (_c *MockSSHConfiger_ExecuteCommand_Call) Run(run func(ctx context.Context, command string)) *MockSSHConfiger_ExecuteCommand_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockSSHConfiger_ExecuteCommand_Call) Return(_a0 string, _a1 error) *MockSSHConfiger_ExecuteCommand_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSSHConfiger_ExecuteCommand_Call) RunAndReturn(run func(context.Context, string) (string, error)) *MockSSHConfiger_ExecuteCommand_Call { - _c.Call.Return(run) - return _c -} - -// ExecuteCommandWithCallback provides a mock function with given fields: ctx, command, callback -func (_m *MockSSHConfiger) ExecuteCommandWithCallback(ctx context.Context, command string, callback func(string)) (string, error) { - ret := _m.Called(ctx, command, callback) - - if len(ret) == 0 { - panic("no return value specified for ExecuteCommandWithCallback") - } - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, func(string)) (string, error)); ok { - return rf(ctx, command, callback) - } - if rf, ok := ret.Get(0).(func(context.Context, string, func(string)) string); ok { - r0 = rf(ctx, command, callback) - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func(context.Context, string, func(string)) error); ok { - r1 = rf(ctx, command, callback) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSSHConfiger_ExecuteCommandWithCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExecuteCommandWithCallback' -type MockSSHConfiger_ExecuteCommandWithCallback_Call struct { - *mock.Call -} - -// ExecuteCommandWithCallback is a helper method to define mock.On call -// - ctx context.Context -// - command string -// - callback func(string) -func (_e *MockSSHConfiger_Expecter) ExecuteCommandWithCallback(ctx interface{}, command interface{}, callback interface{}) *MockSSHConfiger_ExecuteCommandWithCallback_Call { - return &MockSSHConfiger_ExecuteCommandWithCallback_Call{Call: _e.mock.On("ExecuteCommandWithCallback", ctx, command, callback)} -} - -func (_c *MockSSHConfiger_ExecuteCommandWithCallback_Call) Run(run func(ctx context.Context, command string, callback func(string))) *MockSSHConfiger_ExecuteCommandWithCallback_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(func(string))) - }) - return _c -} - -func (_c *MockSSHConfiger_ExecuteCommandWithCallback_Call) Return(_a0 string, _a1 error) *MockSSHConfiger_ExecuteCommandWithCallback_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSSHConfiger_ExecuteCommandWithCallback_Call) RunAndReturn(run func(context.Context, string, func(string)) (string, error)) *MockSSHConfiger_ExecuteCommandWithCallback_Call { - _c.Call.Return(run) - return _c -} - -// GetHost provides a mock function with given fields: -func (_m *MockSSHConfiger) GetHost() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetHost") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockSSHConfiger_GetHost_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetHost' -type MockSSHConfiger_GetHost_Call struct { - *mock.Call -} - -// GetHost is a helper method to define mock.On call -func (_e *MockSSHConfiger_Expecter) GetHost() *MockSSHConfiger_GetHost_Call { - return &MockSSHConfiger_GetHost_Call{Call: _e.mock.On("GetHost")} -} - -func (_c *MockSSHConfiger_GetHost_Call) Run(run func()) *MockSSHConfiger_GetHost_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHConfiger_GetHost_Call) Return(_a0 string) *MockSSHConfiger_GetHost_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_GetHost_Call) RunAndReturn(run func() string) *MockSSHConfiger_GetHost_Call { - _c.Call.Return(run) - return _c -} - -// GetPort provides a mock function with given fields: -func (_m *MockSSHConfiger) GetPort() int { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetPort") - } - - var r0 int - if rf, ok := ret.Get(0).(func() int); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(int) - } - - return r0 -} - -// MockSSHConfiger_GetPort_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPort' -type MockSSHConfiger_GetPort_Call struct { - *mock.Call -} - -// GetPort is a helper method to define mock.On call -func (_e *MockSSHConfiger_Expecter) GetPort() *MockSSHConfiger_GetPort_Call { - return &MockSSHConfiger_GetPort_Call{Call: _e.mock.On("GetPort")} -} - -func (_c *MockSSHConfiger_GetPort_Call) Run(run func()) *MockSSHConfiger_GetPort_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHConfiger_GetPort_Call) Return(_a0 int) *MockSSHConfiger_GetPort_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_GetPort_Call) RunAndReturn(run func() int) *MockSSHConfiger_GetPort_Call { - _c.Call.Return(run) - return _c -} - -// GetPrivateKeyMaterial provides a mock function with given fields: -func (_m *MockSSHConfiger) GetPrivateKeyMaterial() []byte { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetPrivateKeyMaterial") - } - - var r0 []byte - if rf, ok := ret.Get(0).(func() []byte); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - return r0 -} - -// MockSSHConfiger_GetPrivateKeyMaterial_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPrivateKeyMaterial' -type MockSSHConfiger_GetPrivateKeyMaterial_Call struct { - *mock.Call -} - -// GetPrivateKeyMaterial is a helper method to define mock.On call -func (_e *MockSSHConfiger_Expecter) GetPrivateKeyMaterial() *MockSSHConfiger_GetPrivateKeyMaterial_Call { - return &MockSSHConfiger_GetPrivateKeyMaterial_Call{Call: _e.mock.On("GetPrivateKeyMaterial")} -} - -func (_c *MockSSHConfiger_GetPrivateKeyMaterial_Call) Run(run func()) *MockSSHConfiger_GetPrivateKeyMaterial_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHConfiger_GetPrivateKeyMaterial_Call) Return(_a0 []byte) *MockSSHConfiger_GetPrivateKeyMaterial_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_GetPrivateKeyMaterial_Call) RunAndReturn(run func() []byte) *MockSSHConfiger_GetPrivateKeyMaterial_Call { - _c.Call.Return(run) - return _c -} - -// GetSFTPClientCreator provides a mock function with given fields: -func (_m *MockSSHConfiger) GetSFTPClientCreator() sshutils.SFTPClientCreator { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetSFTPClientCreator") - } - - var r0 sshutils.SFTPClientCreator - if rf, ok := ret.Get(0).(func() sshutils.SFTPClientCreator); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(sshutils.SFTPClientCreator) - } - } - - return r0 -} - -// MockSSHConfiger_GetSFTPClientCreator_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSFTPClientCreator' -type MockSSHConfiger_GetSFTPClientCreator_Call struct { - *mock.Call -} - -// GetSFTPClientCreator is a helper method to define mock.On call -func (_e *MockSSHConfiger_Expecter) GetSFTPClientCreator() *MockSSHConfiger_GetSFTPClientCreator_Call { - return &MockSSHConfiger_GetSFTPClientCreator_Call{Call: _e.mock.On("GetSFTPClientCreator")} -} - -func (_c *MockSSHConfiger_GetSFTPClientCreator_Call) Run(run func()) *MockSSHConfiger_GetSFTPClientCreator_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHConfiger_GetSFTPClientCreator_Call) Return(_a0 sshutils.SFTPClientCreator) *MockSSHConfiger_GetSFTPClientCreator_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_GetSFTPClientCreator_Call) RunAndReturn(run func() sshutils.SFTPClientCreator) *MockSSHConfiger_GetSFTPClientCreator_Call { - _c.Call.Return(run) - return _c -} - -// GetSSHClient provides a mock function with given fields: -func (_m *MockSSHConfiger) GetSSHClient() *ssh.Client { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetSSHClient") - } - - var r0 *ssh.Client - if rf, ok := ret.Get(0).(func() *ssh.Client); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*ssh.Client) - } - } - - return r0 -} - -// MockSSHConfiger_GetSSHClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSSHClient' -type MockSSHConfiger_GetSSHClient_Call struct { - *mock.Call -} - -// GetSSHClient is a helper method to define mock.On call -func (_e *MockSSHConfiger_Expecter) GetSSHClient() *MockSSHConfiger_GetSSHClient_Call { - return &MockSSHConfiger_GetSSHClient_Call{Call: _e.mock.On("GetSSHClient")} -} - -func (_c *MockSSHConfiger_GetSSHClient_Call) Run(run func()) *MockSSHConfiger_GetSSHClient_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHConfiger_GetSSHClient_Call) Return(_a0 *ssh.Client) *MockSSHConfiger_GetSSHClient_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_GetSSHClient_Call) RunAndReturn(run func() *ssh.Client) *MockSSHConfiger_GetSSHClient_Call { - _c.Call.Return(run) - return _c -} - -// GetSSHClientCreator provides a mock function with given fields: -func (_m *MockSSHConfiger) GetSSHClientCreator() sshutils.SSHClientCreator { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetSSHClientCreator") - } - - var r0 sshutils.SSHClientCreator - if rf, ok := ret.Get(0).(func() sshutils.SSHClientCreator); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(sshutils.SSHClientCreator) - } - } - - return r0 -} - -// MockSSHConfiger_GetSSHClientCreator_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSSHClientCreator' -type MockSSHConfiger_GetSSHClientCreator_Call struct { - *mock.Call -} - -// GetSSHClientCreator is a helper method to define mock.On call -func (_e *MockSSHConfiger_Expecter) GetSSHClientCreator() *MockSSHConfiger_GetSSHClientCreator_Call { - return &MockSSHConfiger_GetSSHClientCreator_Call{Call: _e.mock.On("GetSSHClientCreator")} -} - -func (_c *MockSSHConfiger_GetSSHClientCreator_Call) Run(run func()) *MockSSHConfiger_GetSSHClientCreator_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHConfiger_GetSSHClientCreator_Call) Return(_a0 sshutils.SSHClientCreator) *MockSSHConfiger_GetSSHClientCreator_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_GetSSHClientCreator_Call) RunAndReturn(run func() sshutils.SSHClientCreator) *MockSSHConfiger_GetSSHClientCreator_Call { - _c.Call.Return(run) - return _c -} - -// GetUser provides a mock function with given fields: -func (_m *MockSSHConfiger) GetUser() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for GetUser") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// MockSSHConfiger_GetUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUser' -type MockSSHConfiger_GetUser_Call struct { - *mock.Call -} - -// GetUser is a helper method to define mock.On call -func (_e *MockSSHConfiger_Expecter) GetUser() *MockSSHConfiger_GetUser_Call { - return &MockSSHConfiger_GetUser_Call{Call: _e.mock.On("GetUser")} -} - -func (_c *MockSSHConfiger_GetUser_Call) Run(run func()) *MockSSHConfiger_GetUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHConfiger_GetUser_Call) Return(_a0 string) *MockSSHConfiger_GetUser_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_GetUser_Call) RunAndReturn(run func() string) *MockSSHConfiger_GetUser_Call { - _c.Call.Return(run) - return _c -} - -// InstallSystemdService provides a mock function with given fields: ctx, serviceName, serviceContent -func (_m *MockSSHConfiger) InstallSystemdService(ctx context.Context, serviceName string, serviceContent string) error { - ret := _m.Called(ctx, serviceName, serviceContent) - - if len(ret) == 0 { - panic("no return value specified for InstallSystemdService") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { - r0 = rf(ctx, serviceName, serviceContent) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHConfiger_InstallSystemdService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'InstallSystemdService' -type MockSSHConfiger_InstallSystemdService_Call struct { - *mock.Call -} - -// InstallSystemdService is a helper method to define mock.On call -// - ctx context.Context -// - serviceName string -// - serviceContent string -func (_e *MockSSHConfiger_Expecter) InstallSystemdService(ctx interface{}, serviceName interface{}, serviceContent interface{}) *MockSSHConfiger_InstallSystemdService_Call { - return &MockSSHConfiger_InstallSystemdService_Call{Call: _e.mock.On("InstallSystemdService", ctx, serviceName, serviceContent)} -} - -func (_c *MockSSHConfiger_InstallSystemdService_Call) Run(run func(ctx context.Context, serviceName string, serviceContent string)) *MockSSHConfiger_InstallSystemdService_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string)) - }) - return _c -} - -func (_c *MockSSHConfiger_InstallSystemdService_Call) Return(_a0 error) *MockSSHConfiger_InstallSystemdService_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_InstallSystemdService_Call) RunAndReturn(run func(context.Context, string, string) error) *MockSSHConfiger_InstallSystemdService_Call { - _c.Call.Return(run) - return _c -} - -// IsConnected provides a mock function with given fields: -func (_m *MockSSHConfiger) IsConnected() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for IsConnected") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// MockSSHConfiger_IsConnected_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsConnected' -type MockSSHConfiger_IsConnected_Call struct { - *mock.Call -} - -// IsConnected is a helper method to define mock.On call -func (_e *MockSSHConfiger_Expecter) IsConnected() *MockSSHConfiger_IsConnected_Call { - return &MockSSHConfiger_IsConnected_Call{Call: _e.mock.On("IsConnected")} -} - -func (_c *MockSSHConfiger_IsConnected_Call) Run(run func()) *MockSSHConfiger_IsConnected_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHConfiger_IsConnected_Call) Return(_a0 bool) *MockSSHConfiger_IsConnected_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_IsConnected_Call) RunAndReturn(run func() bool) *MockSSHConfiger_IsConnected_Call { - _c.Call.Return(run) - return _c -} - -// PushFile provides a mock function with given fields: ctx, remotePath, content, executable -func (_m *MockSSHConfiger) PushFile(ctx context.Context, remotePath string, content []byte, executable bool) error { - ret := _m.Called(ctx, remotePath, content, executable) - - if len(ret) == 0 { - panic("no return value specified for PushFile") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, []byte, bool) error); ok { - r0 = rf(ctx, remotePath, content, executable) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHConfiger_PushFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PushFile' -type MockSSHConfiger_PushFile_Call struct { - *mock.Call -} - -// PushFile is a helper method to define mock.On call -// - ctx context.Context -// - remotePath string -// - content []byte -// - executable bool -func (_e *MockSSHConfiger_Expecter) PushFile(ctx interface{}, remotePath interface{}, content interface{}, executable interface{}) *MockSSHConfiger_PushFile_Call { - return &MockSSHConfiger_PushFile_Call{Call: _e.mock.On("PushFile", ctx, remotePath, content, executable)} -} - -func (_c *MockSSHConfiger_PushFile_Call) Run(run func(ctx context.Context, remotePath string, content []byte, executable bool)) *MockSSHConfiger_PushFile_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].([]byte), args[3].(bool)) - }) - return _c -} - -func (_c *MockSSHConfiger_PushFile_Call) Return(_a0 error) *MockSSHConfiger_PushFile_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_PushFile_Call) RunAndReturn(run func(context.Context, string, []byte, bool) error) *MockSSHConfiger_PushFile_Call { - _c.Call.Return(run) - return _c -} - -// PushFileWithCallback provides a mock function with given fields: ctx, remotePath, content, executable, callback -func (_m *MockSSHConfiger) PushFileWithCallback(ctx context.Context, remotePath string, content []byte, executable bool, callback func(int64, int64)) error { - ret := _m.Called(ctx, remotePath, content, executable, callback) - - if len(ret) == 0 { - panic("no return value specified for PushFileWithCallback") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, []byte, bool, func(int64, int64)) error); ok { - r0 = rf(ctx, remotePath, content, executable, callback) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHConfiger_PushFileWithCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PushFileWithCallback' -type MockSSHConfiger_PushFileWithCallback_Call struct { - *mock.Call -} - -// PushFileWithCallback is a helper method to define mock.On call -// - ctx context.Context -// - remotePath string -// - content []byte -// - executable bool -// - callback func(int64 , int64) -func (_e *MockSSHConfiger_Expecter) PushFileWithCallback(ctx interface{}, remotePath interface{}, content interface{}, executable interface{}, callback interface{}) *MockSSHConfiger_PushFileWithCallback_Call { - return &MockSSHConfiger_PushFileWithCallback_Call{Call: _e.mock.On("PushFileWithCallback", ctx, remotePath, content, executable, callback)} -} - -func (_c *MockSSHConfiger_PushFileWithCallback_Call) Run(run func(ctx context.Context, remotePath string, content []byte, executable bool, callback func(int64, int64))) *MockSSHConfiger_PushFileWithCallback_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].([]byte), args[3].(bool), args[4].(func(int64, int64))) - }) - return _c -} - -func (_c *MockSSHConfiger_PushFileWithCallback_Call) Return(_a0 error) *MockSSHConfiger_PushFileWithCallback_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_PushFileWithCallback_Call) RunAndReturn(run func(context.Context, string, []byte, bool, func(int64, int64)) error) *MockSSHConfiger_PushFileWithCallback_Call { - _c.Call.Return(run) - return _c -} - -// RestartService provides a mock function with given fields: ctx, serviceName -func (_m *MockSSHConfiger) RestartService(ctx context.Context, serviceName string) (string, error) { - ret := _m.Called(ctx, serviceName) - - if len(ret) == 0 { - panic("no return value specified for RestartService") - } - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (string, error)); ok { - return rf(ctx, serviceName) - } - if rf, ok := ret.Get(0).(func(context.Context, string) string); ok { - r0 = rf(ctx, serviceName) - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, serviceName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSSHConfiger_RestartService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RestartService' -type MockSSHConfiger_RestartService_Call struct { - *mock.Call -} - -// RestartService is a helper method to define mock.On call -// - ctx context.Context -// - serviceName string -func (_e *MockSSHConfiger_Expecter) RestartService(ctx interface{}, serviceName interface{}) *MockSSHConfiger_RestartService_Call { - return &MockSSHConfiger_RestartService_Call{Call: _e.mock.On("RestartService", ctx, serviceName)} -} - -func (_c *MockSSHConfiger_RestartService_Call) Run(run func(ctx context.Context, serviceName string)) *MockSSHConfiger_RestartService_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockSSHConfiger_RestartService_Call) Return(_a0 string, _a1 error) *MockSSHConfiger_RestartService_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSSHConfiger_RestartService_Call) RunAndReturn(run func(context.Context, string) (string, error)) *MockSSHConfiger_RestartService_Call { - _c.Call.Return(run) - return _c -} - -// SetSFTPClientCreator provides a mock function with given fields: clientCreator -func (_m *MockSSHConfiger) SetSFTPClientCreator(clientCreator sshutils.SFTPClientCreator) { - _m.Called(clientCreator) -} - -// MockSSHConfiger_SetSFTPClientCreator_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetSFTPClientCreator' -type MockSSHConfiger_SetSFTPClientCreator_Call struct { - *mock.Call -} - -// SetSFTPClientCreator is a helper method to define mock.On call -// - clientCreator sshutils.SFTPClientCreator -func (_e *MockSSHConfiger_Expecter) SetSFTPClientCreator(clientCreator interface{}) *MockSSHConfiger_SetSFTPClientCreator_Call { - return &MockSSHConfiger_SetSFTPClientCreator_Call{Call: _e.mock.On("SetSFTPClientCreator", clientCreator)} -} - -func (_c *MockSSHConfiger_SetSFTPClientCreator_Call) Run(run func(clientCreator sshutils.SFTPClientCreator)) *MockSSHConfiger_SetSFTPClientCreator_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(sshutils.SFTPClientCreator)) - }) - return _c -} - -func (_c *MockSSHConfiger_SetSFTPClientCreator_Call) Return() *MockSSHConfiger_SetSFTPClientCreator_Call { - _c.Call.Return() - return _c -} - -func (_c *MockSSHConfiger_SetSFTPClientCreator_Call) RunAndReturn(run func(sshutils.SFTPClientCreator)) *MockSSHConfiger_SetSFTPClientCreator_Call { - _c.Call.Return(run) - return _c -} - -// SetSSHClient provides a mock function with given fields: client -func (_m *MockSSHConfiger) SetSSHClient(client *ssh.Client) { - _m.Called(client) -} - -// MockSSHConfiger_SetSSHClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetSSHClient' -type MockSSHConfiger_SetSSHClient_Call struct { - *mock.Call -} - -// SetSSHClient is a helper method to define mock.On call -// - client *ssh.Client -func (_e *MockSSHConfiger_Expecter) SetSSHClient(client interface{}) *MockSSHConfiger_SetSSHClient_Call { - return &MockSSHConfiger_SetSSHClient_Call{Call: _e.mock.On("SetSSHClient", client)} -} - -func (_c *MockSSHConfiger_SetSSHClient_Call) Run(run func(client *ssh.Client)) *MockSSHConfiger_SetSSHClient_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*ssh.Client)) - }) - return _c -} - -func (_c *MockSSHConfiger_SetSSHClient_Call) Return() *MockSSHConfiger_SetSSHClient_Call { - _c.Call.Return() - return _c -} - -func (_c *MockSSHConfiger_SetSSHClient_Call) RunAndReturn(run func(*ssh.Client)) *MockSSHConfiger_SetSSHClient_Call { - _c.Call.Return(run) - return _c -} - -// SetSSHClientCreator provides a mock function with given fields: clientCreator -func (_m *MockSSHConfiger) SetSSHClientCreator(clientCreator sshutils.SSHClientCreator) { - _m.Called(clientCreator) -} - -// MockSSHConfiger_SetSSHClientCreator_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetSSHClientCreator' -type MockSSHConfiger_SetSSHClientCreator_Call struct { - *mock.Call -} - -// SetSSHClientCreator is a helper method to define mock.On call -// - clientCreator sshutils.SSHClientCreator -func (_e *MockSSHConfiger_Expecter) SetSSHClientCreator(clientCreator interface{}) *MockSSHConfiger_SetSSHClientCreator_Call { - return &MockSSHConfiger_SetSSHClientCreator_Call{Call: _e.mock.On("SetSSHClientCreator", clientCreator)} -} - -func (_c *MockSSHConfiger_SetSSHClientCreator_Call) Run(run func(clientCreator sshutils.SSHClientCreator)) *MockSSHConfiger_SetSSHClientCreator_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(sshutils.SSHClientCreator)) - }) - return _c -} - -func (_c *MockSSHConfiger_SetSSHClientCreator_Call) Return() *MockSSHConfiger_SetSSHClientCreator_Call { - _c.Call.Return() - return _c -} - -func (_c *MockSSHConfiger_SetSSHClientCreator_Call) RunAndReturn(run func(sshutils.SSHClientCreator)) *MockSSHConfiger_SetSSHClientCreator_Call { - _c.Call.Return(run) - return _c -} - -// SetValidateSSHConnection provides a mock function with given fields: fn -func (_m *MockSSHConfiger) SetValidateSSHConnection(fn func() error) { - _m.Called(fn) -} - -// MockSSHConfiger_SetValidateSSHConnection_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetValidateSSHConnection' -type MockSSHConfiger_SetValidateSSHConnection_Call struct { - *mock.Call -} - -// SetValidateSSHConnection is a helper method to define mock.On call -// - fn func() error -func (_e *MockSSHConfiger_Expecter) SetValidateSSHConnection(fn interface{}) *MockSSHConfiger_SetValidateSSHConnection_Call { - return &MockSSHConfiger_SetValidateSSHConnection_Call{Call: _e.mock.On("SetValidateSSHConnection", fn)} -} - -func (_c *MockSSHConfiger_SetValidateSSHConnection_Call) Run(run func(fn func() error)) *MockSSHConfiger_SetValidateSSHConnection_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(func() error)) - }) - return _c -} - -func (_c *MockSSHConfiger_SetValidateSSHConnection_Call) Return() *MockSSHConfiger_SetValidateSSHConnection_Call { - _c.Call.Return() - return _c -} - -func (_c *MockSSHConfiger_SetValidateSSHConnection_Call) RunAndReturn(run func(func() error)) *MockSSHConfiger_SetValidateSSHConnection_Call { - _c.Call.Return(run) - return _c -} - -// StartService provides a mock function with given fields: ctx, serviceName -func (_m *MockSSHConfiger) StartService(ctx context.Context, serviceName string) (string, error) { - ret := _m.Called(ctx, serviceName) - - if len(ret) == 0 { - panic("no return value specified for StartService") - } - - var r0 string - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (string, error)); ok { - return rf(ctx, serviceName) - } - if rf, ok := ret.Get(0).(func(context.Context, string) string); ok { - r0 = rf(ctx, serviceName) - } else { - r0 = ret.Get(0).(string) - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, serviceName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSSHConfiger_StartService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartService' -type MockSSHConfiger_StartService_Call struct { - *mock.Call -} - -// StartService is a helper method to define mock.On call -// - ctx context.Context -// - serviceName string -func (_e *MockSSHConfiger_Expecter) StartService(ctx interface{}, serviceName interface{}) *MockSSHConfiger_StartService_Call { - return &MockSSHConfiger_StartService_Call{Call: _e.mock.On("StartService", ctx, serviceName)} -} - -func (_c *MockSSHConfiger_StartService_Call) Run(run func(ctx context.Context, serviceName string)) *MockSSHConfiger_StartService_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockSSHConfiger_StartService_Call) Return(_a0 string, _a1 error) *MockSSHConfiger_StartService_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSSHConfiger_StartService_Call) RunAndReturn(run func(context.Context, string) (string, error)) *MockSSHConfiger_StartService_Call { - _c.Call.Return(run) - return _c -} - -// WaitForSSH provides a mock function with given fields: ctx, retry, timeout -func (_m *MockSSHConfiger) WaitForSSH(ctx context.Context, retry int, timeout time.Duration) error { - ret := _m.Called(ctx, retry, timeout) - - if len(ret) == 0 { - panic("no return value specified for WaitForSSH") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, int, time.Duration) error); ok { - r0 = rf(ctx, retry, timeout) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHConfiger_WaitForSSH_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitForSSH' -type MockSSHConfiger_WaitForSSH_Call struct { - *mock.Call -} - -// WaitForSSH is a helper method to define mock.On call -// - ctx context.Context -// - retry int -// - timeout time.Duration -func (_e *MockSSHConfiger_Expecter) WaitForSSH(ctx interface{}, retry interface{}, timeout interface{}) *MockSSHConfiger_WaitForSSH_Call { - return &MockSSHConfiger_WaitForSSH_Call{Call: _e.mock.On("WaitForSSH", ctx, retry, timeout)} -} - -func (_c *MockSSHConfiger_WaitForSSH_Call) Run(run func(ctx context.Context, retry int, timeout time.Duration)) *MockSSHConfiger_WaitForSSH_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(int), args[2].(time.Duration)) - }) - return _c -} - -func (_c *MockSSHConfiger_WaitForSSH_Call) Return(_a0 error) *MockSSHConfiger_WaitForSSH_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHConfiger_WaitForSSH_Call) RunAndReturn(run func(context.Context, int, time.Duration) error) *MockSSHConfiger_WaitForSSH_Call { - _c.Call.Return(run) - return _c -} - -// NewMockSSHConfiger creates a new instance of MockSSHConfiger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockSSHConfiger(t interface { - mock.TestingT - Cleanup(func()) -}) *MockSSHConfiger { - mock := &MockSSHConfiger{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHSessioner.go b/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHSessioner.go deleted file mode 100644 index f8d1a556..00000000 --- a/pkg/models/interfaces/aws/mocks/sshutils/mock_SSHSessioner.go +++ /dev/null @@ -1,446 +0,0 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. - -package sshutils - -import ( - io "io" - - mock "github.com/stretchr/testify/mock" - ssh "golang.org/x/crypto/ssh" -) - -// MockSSHSessioner is an autogenerated mock type for the SSHSessioner type -type MockSSHSessioner struct { - mock.Mock -} - -type MockSSHSessioner_Expecter struct { - mock *mock.Mock -} - -func (_m *MockSSHSessioner) EXPECT() *MockSSHSessioner_Expecter { - return &MockSSHSessioner_Expecter{mock: &_m.Mock} -} - -// Close provides a mock function with given fields: -func (_m *MockSSHSessioner) Close() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Close") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHSessioner_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close' -type MockSSHSessioner_Close_Call struct { - *mock.Call -} - -// Close is a helper method to define mock.On call -func (_e *MockSSHSessioner_Expecter) Close() *MockSSHSessioner_Close_Call { - return &MockSSHSessioner_Close_Call{Call: _e.mock.On("Close")} -} - -func (_c *MockSSHSessioner_Close_Call) Run(run func()) *MockSSHSessioner_Close_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHSessioner_Close_Call) Return(_a0 error) *MockSSHSessioner_Close_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHSessioner_Close_Call) RunAndReturn(run func() error) *MockSSHSessioner_Close_Call { - _c.Call.Return(run) - return _c -} - -// CombinedOutput provides a mock function with given fields: cmd -func (_m *MockSSHSessioner) CombinedOutput(cmd string) ([]byte, error) { - ret := _m.Called(cmd) - - if len(ret) == 0 { - panic("no return value specified for CombinedOutput") - } - - var r0 []byte - var r1 error - if rf, ok := ret.Get(0).(func(string) ([]byte, error)); ok { - return rf(cmd) - } - if rf, ok := ret.Get(0).(func(string) []byte); ok { - r0 = rf(cmd) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(cmd) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSSHSessioner_CombinedOutput_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CombinedOutput' -type MockSSHSessioner_CombinedOutput_Call struct { - *mock.Call -} - -// CombinedOutput is a helper method to define mock.On call -// - cmd string -func (_e *MockSSHSessioner_Expecter) CombinedOutput(cmd interface{}) *MockSSHSessioner_CombinedOutput_Call { - return &MockSSHSessioner_CombinedOutput_Call{Call: _e.mock.On("CombinedOutput", cmd)} -} - -func (_c *MockSSHSessioner_CombinedOutput_Call) Run(run func(cmd string)) *MockSSHSessioner_CombinedOutput_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *MockSSHSessioner_CombinedOutput_Call) Return(_a0 []byte, _a1 error) *MockSSHSessioner_CombinedOutput_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSSHSessioner_CombinedOutput_Call) RunAndReturn(run func(string) ([]byte, error)) *MockSSHSessioner_CombinedOutput_Call { - _c.Call.Return(run) - return _c -} - -// Run provides a mock function with given fields: cmd -func (_m *MockSSHSessioner) Run(cmd string) error { - ret := _m.Called(cmd) - - if len(ret) == 0 { - panic("no return value specified for Run") - } - - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(cmd) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHSessioner_Run_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Run' -type MockSSHSessioner_Run_Call struct { - *mock.Call -} - -// Run is a helper method to define mock.On call -// - cmd string -func (_e *MockSSHSessioner_Expecter) Run(cmd interface{}) *MockSSHSessioner_Run_Call { - return &MockSSHSessioner_Run_Call{Call: _e.mock.On("Run", cmd)} -} - -func (_c *MockSSHSessioner_Run_Call) Run(run func(cmd string)) *MockSSHSessioner_Run_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *MockSSHSessioner_Run_Call) Return(_a0 error) *MockSSHSessioner_Run_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHSessioner_Run_Call) RunAndReturn(run func(string) error) *MockSSHSessioner_Run_Call { - _c.Call.Return(run) - return _c -} - -// SetStderr provides a mock function with given fields: _a0 -func (_m *MockSSHSessioner) SetStderr(_a0 io.Writer) { - _m.Called(_a0) -} - -// MockSSHSessioner_SetStderr_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetStderr' -type MockSSHSessioner_SetStderr_Call struct { - *mock.Call -} - -// SetStderr is a helper method to define mock.On call -// - _a0 io.Writer -func (_e *MockSSHSessioner_Expecter) SetStderr(_a0 interface{}) *MockSSHSessioner_SetStderr_Call { - return &MockSSHSessioner_SetStderr_Call{Call: _e.mock.On("SetStderr", _a0)} -} - -func (_c *MockSSHSessioner_SetStderr_Call) Run(run func(_a0 io.Writer)) *MockSSHSessioner_SetStderr_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(io.Writer)) - }) - return _c -} - -func (_c *MockSSHSessioner_SetStderr_Call) Return() *MockSSHSessioner_SetStderr_Call { - _c.Call.Return() - return _c -} - -func (_c *MockSSHSessioner_SetStderr_Call) RunAndReturn(run func(io.Writer)) *MockSSHSessioner_SetStderr_Call { - _c.Call.Return(run) - return _c -} - -// SetStdout provides a mock function with given fields: _a0 -func (_m *MockSSHSessioner) SetStdout(_a0 io.Writer) { - _m.Called(_a0) -} - -// MockSSHSessioner_SetStdout_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetStdout' -type MockSSHSessioner_SetStdout_Call struct { - *mock.Call -} - -// SetStdout is a helper method to define mock.On call -// - _a0 io.Writer -func (_e *MockSSHSessioner_Expecter) SetStdout(_a0 interface{}) *MockSSHSessioner_SetStdout_Call { - return &MockSSHSessioner_SetStdout_Call{Call: _e.mock.On("SetStdout", _a0)} -} - -func (_c *MockSSHSessioner_SetStdout_Call) Run(run func(_a0 io.Writer)) *MockSSHSessioner_SetStdout_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(io.Writer)) - }) - return _c -} - -func (_c *MockSSHSessioner_SetStdout_Call) Return() *MockSSHSessioner_SetStdout_Call { - _c.Call.Return() - return _c -} - -func (_c *MockSSHSessioner_SetStdout_Call) RunAndReturn(run func(io.Writer)) *MockSSHSessioner_SetStdout_Call { - _c.Call.Return(run) - return _c -} - -// Signal provides a mock function with given fields: sig -func (_m *MockSSHSessioner) Signal(sig ssh.Signal) error { - ret := _m.Called(sig) - - if len(ret) == 0 { - panic("no return value specified for Signal") - } - - var r0 error - if rf, ok := ret.Get(0).(func(ssh.Signal) error); ok { - r0 = rf(sig) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHSessioner_Signal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Signal' -type MockSSHSessioner_Signal_Call struct { - *mock.Call -} - -// Signal is a helper method to define mock.On call -// - sig ssh.Signal -func (_e *MockSSHSessioner_Expecter) Signal(sig interface{}) *MockSSHSessioner_Signal_Call { - return &MockSSHSessioner_Signal_Call{Call: _e.mock.On("Signal", sig)} -} - -func (_c *MockSSHSessioner_Signal_Call) Run(run func(sig ssh.Signal)) *MockSSHSessioner_Signal_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(ssh.Signal)) - }) - return _c -} - -func (_c *MockSSHSessioner_Signal_Call) Return(_a0 error) *MockSSHSessioner_Signal_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHSessioner_Signal_Call) RunAndReturn(run func(ssh.Signal) error) *MockSSHSessioner_Signal_Call { - _c.Call.Return(run) - return _c -} - -// Start provides a mock function with given fields: cmd -func (_m *MockSSHSessioner) Start(cmd string) error { - ret := _m.Called(cmd) - - if len(ret) == 0 { - panic("no return value specified for Start") - } - - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(cmd) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHSessioner_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' -type MockSSHSessioner_Start_Call struct { - *mock.Call -} - -// Start is a helper method to define mock.On call -// - cmd string -func (_e *MockSSHSessioner_Expecter) Start(cmd interface{}) *MockSSHSessioner_Start_Call { - return &MockSSHSessioner_Start_Call{Call: _e.mock.On("Start", cmd)} -} - -func (_c *MockSSHSessioner_Start_Call) Run(run func(cmd string)) *MockSSHSessioner_Start_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *MockSSHSessioner_Start_Call) Return(_a0 error) *MockSSHSessioner_Start_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHSessioner_Start_Call) RunAndReturn(run func(string) error) *MockSSHSessioner_Start_Call { - _c.Call.Return(run) - return _c -} - -// StdinPipe provides a mock function with given fields: -func (_m *MockSSHSessioner) StdinPipe() (io.WriteCloser, error) { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for StdinPipe") - } - - var r0 io.WriteCloser - var r1 error - if rf, ok := ret.Get(0).(func() (io.WriteCloser, error)); ok { - return rf() - } - if rf, ok := ret.Get(0).(func() io.WriteCloser); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(io.WriteCloser) - } - } - - if rf, ok := ret.Get(1).(func() error); ok { - r1 = rf() - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockSSHSessioner_StdinPipe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StdinPipe' -type MockSSHSessioner_StdinPipe_Call struct { - *mock.Call -} - -// StdinPipe is a helper method to define mock.On call -func (_e *MockSSHSessioner_Expecter) StdinPipe() *MockSSHSessioner_StdinPipe_Call { - return &MockSSHSessioner_StdinPipe_Call{Call: _e.mock.On("StdinPipe")} -} - -func (_c *MockSSHSessioner_StdinPipe_Call) Run(run func()) *MockSSHSessioner_StdinPipe_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHSessioner_StdinPipe_Call) Return(_a0 io.WriteCloser, _a1 error) *MockSSHSessioner_StdinPipe_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockSSHSessioner_StdinPipe_Call) RunAndReturn(run func() (io.WriteCloser, error)) *MockSSHSessioner_StdinPipe_Call { - _c.Call.Return(run) - return _c -} - -// Wait provides a mock function with given fields: -func (_m *MockSSHSessioner) Wait() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Wait") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockSSHSessioner_Wait_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Wait' -type MockSSHSessioner_Wait_Call struct { - *mock.Call -} - -// Wait is a helper method to define mock.On call -func (_e *MockSSHSessioner_Expecter) Wait() *MockSSHSessioner_Wait_Call { - return &MockSSHSessioner_Wait_Call{Call: _e.mock.On("Wait")} -} - -func (_c *MockSSHSessioner_Wait_Call) Run(run func()) *MockSSHSessioner_Wait_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockSSHSessioner_Wait_Call) Return(_a0 error) *MockSSHSessioner_Wait_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockSSHSessioner_Wait_Call) RunAndReturn(run func() error) *MockSSHSessioner_Wait_Call { - _c.Call.Return(run) - return _c -} - -// NewMockSSHSessioner creates a new instance of MockSSHSessioner. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockSSHSessioner(t interface { - mock.TestingT - Cleanup(func()) -}) *MockSSHSessioner { - mock := &MockSSHSessioner{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -}