From 67992c8f58964ef8a68723af3a3501528b214d80 Mon Sep 17 00:00:00 2001 From: joshsiv-mulga Date: Wed, 7 Oct 2026 14:31:20 +1000 Subject: [PATCH] refactor: move EC2 routetable action adapters to domains/ec2/awsapi --- spinifex/accountteardown/reapers_ec2.go | 8 ++++---- .../awsapi}/routetable/AssociateRouteTable.go | 2 +- .../ec2/awsapi}/routetable/CreateRoute.go | 2 +- .../awsapi}/routetable/CreateRouteTable.go | 2 +- .../ec2/awsapi}/routetable/DeleteRoute.go | 2 +- .../awsapi}/routetable/DeleteRouteTable.go | 2 +- .../awsapi}/routetable/DescribeRouteTables.go | 2 +- .../routetable/DisassociateRouteTable.go | 2 +- .../ec2/awsapi}/routetable/ReplaceRoute.go | 2 +- .../ReplaceRouteTableAssociation.go | 2 +- .../ec2/awsapi}/routetable/routetable_test.go | 2 +- spinifex/gateway/ec2.go | 20 +++++++++---------- 12 files changed, 24 insertions(+), 24 deletions(-) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/routetable/AssociateRouteTable.go (97%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/routetable/CreateRoute.go (97%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/routetable/CreateRouteTable.go (96%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/routetable/DeleteRoute.go (97%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/routetable/DeleteRouteTable.go (96%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/routetable/DescribeRouteTables.go (95%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/routetable/DisassociateRouteTable.go (97%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/routetable/ReplaceRoute.go (97%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/routetable/ReplaceRouteTableAssociation.go (97%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/routetable/routetable_test.go (99%) diff --git a/spinifex/accountteardown/reapers_ec2.go b/spinifex/accountteardown/reapers_ec2.go index e9a11039d..fb0622c3d 100644 --- a/spinifex/accountteardown/reapers_ec2.go +++ b/spinifex/accountteardown/reapers_ec2.go @@ -16,11 +16,11 @@ import ( ec2keyapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/key" ec2launchtemplateapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/launchtemplate" ec2placementgroupapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/placementgroup" + ec2routetableapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/routetable" ec2vpcapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/vpc" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" gateway_ec2_image "github.com/mulgadc/spinifex/spinifex/gateway/ec2/image" gateway_ec2_instance "github.com/mulgadc/spinifex/spinifex/gateway/ec2/instance" - gateway_ec2_routetable "github.com/mulgadc/spinifex/spinifex/gateway/ec2/routetable" gateway_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/gateway/ec2/snapshot" gateway_ec2_volume "github.com/mulgadc/spinifex/spinifex/gateway/ec2/volume" "github.com/nats-io/nats.go" @@ -415,7 +415,7 @@ func (r *routeTableReaper) Stage() Stage { return StageNetwork } // List skips main route tables. A VPC's main table is deleted with the VPC and // cannot be deleted on its own, so listing it would guarantee a stuck report. func (r *routeTableReaper) List(ctx context.Context, accountID string) ([]Resource, error) { - out, err := gateway_ec2_routetable.DescribeRouteTables(ctx, &ec2.DescribeRouteTablesInput{}, r.nc, accountID) + out, err := ec2routetableapi.DescribeRouteTables(ctx, &ec2.DescribeRouteTablesInput{}, r.nc, accountID) if err != nil { return nil, err } @@ -453,13 +453,13 @@ func (r *routeTableReaper) Delete(ctx context.Context, accountID string, resourc if association == "" { continue } - if _, err := gateway_ec2_routetable.DisassociateRouteTable(ctx, &ec2.DisassociateRouteTableInput{ + if _, err := ec2routetableapi.DisassociateRouteTable(ctx, &ec2.DisassociateRouteTableInput{ AssociationId: aws.String(association), }, r.nc, accountID); err != nil && !isAlreadyGone(err) { return err } } - _, err := gateway_ec2_routetable.DeleteRouteTable(ctx, &ec2.DeleteRouteTableInput{ + _, err := ec2routetableapi.DeleteRouteTable(ctx, &ec2.DeleteRouteTableInput{ RouteTableId: aws.String(resource.ID), }, r.nc, accountID) return ignoreAlreadyGone(err) diff --git a/spinifex/gateway/ec2/routetable/AssociateRouteTable.go b/spinifex/domains/ec2/awsapi/routetable/AssociateRouteTable.go similarity index 97% rename from spinifex/gateway/ec2/routetable/AssociateRouteTable.go rename to spinifex/domains/ec2/awsapi/routetable/AssociateRouteTable.go index b3c4e89c2..a041b101a 100644 --- a/spinifex/gateway/ec2/routetable/AssociateRouteTable.go +++ b/spinifex/domains/ec2/awsapi/routetable/AssociateRouteTable.go @@ -1,4 +1,4 @@ -package gateway_ec2_routetable +package routetable import ( "context" diff --git a/spinifex/gateway/ec2/routetable/CreateRoute.go b/spinifex/domains/ec2/awsapi/routetable/CreateRoute.go similarity index 97% rename from spinifex/gateway/ec2/routetable/CreateRoute.go rename to spinifex/domains/ec2/awsapi/routetable/CreateRoute.go index d76747dcd..414637113 100644 --- a/spinifex/gateway/ec2/routetable/CreateRoute.go +++ b/spinifex/domains/ec2/awsapi/routetable/CreateRoute.go @@ -1,4 +1,4 @@ -package gateway_ec2_routetable +package routetable import ( "context" diff --git a/spinifex/gateway/ec2/routetable/CreateRouteTable.go b/spinifex/domains/ec2/awsapi/routetable/CreateRouteTable.go similarity index 96% rename from spinifex/gateway/ec2/routetable/CreateRouteTable.go rename to spinifex/domains/ec2/awsapi/routetable/CreateRouteTable.go index 8ff1cc535..7ff5fb105 100644 --- a/spinifex/gateway/ec2/routetable/CreateRouteTable.go +++ b/spinifex/domains/ec2/awsapi/routetable/CreateRouteTable.go @@ -1,4 +1,4 @@ -package gateway_ec2_routetable +package routetable import ( "context" diff --git a/spinifex/gateway/ec2/routetable/DeleteRoute.go b/spinifex/domains/ec2/awsapi/routetable/DeleteRoute.go similarity index 97% rename from spinifex/gateway/ec2/routetable/DeleteRoute.go rename to spinifex/domains/ec2/awsapi/routetable/DeleteRoute.go index 651501e6d..ce8529129 100644 --- a/spinifex/gateway/ec2/routetable/DeleteRoute.go +++ b/spinifex/domains/ec2/awsapi/routetable/DeleteRoute.go @@ -1,4 +1,4 @@ -package gateway_ec2_routetable +package routetable import ( "context" diff --git a/spinifex/gateway/ec2/routetable/DeleteRouteTable.go b/spinifex/domains/ec2/awsapi/routetable/DeleteRouteTable.go similarity index 96% rename from spinifex/gateway/ec2/routetable/DeleteRouteTable.go rename to spinifex/domains/ec2/awsapi/routetable/DeleteRouteTable.go index b01ee659b..a1d4537aa 100644 --- a/spinifex/gateway/ec2/routetable/DeleteRouteTable.go +++ b/spinifex/domains/ec2/awsapi/routetable/DeleteRouteTable.go @@ -1,4 +1,4 @@ -package gateway_ec2_routetable +package routetable import ( "context" diff --git a/spinifex/gateway/ec2/routetable/DescribeRouteTables.go b/spinifex/domains/ec2/awsapi/routetable/DescribeRouteTables.go similarity index 95% rename from spinifex/gateway/ec2/routetable/DescribeRouteTables.go rename to spinifex/domains/ec2/awsapi/routetable/DescribeRouteTables.go index 230283730..866103b3d 100644 --- a/spinifex/gateway/ec2/routetable/DescribeRouteTables.go +++ b/spinifex/domains/ec2/awsapi/routetable/DescribeRouteTables.go @@ -1,4 +1,4 @@ -package gateway_ec2_routetable +package routetable import ( "context" diff --git a/spinifex/gateway/ec2/routetable/DisassociateRouteTable.go b/spinifex/domains/ec2/awsapi/routetable/DisassociateRouteTable.go similarity index 97% rename from spinifex/gateway/ec2/routetable/DisassociateRouteTable.go rename to spinifex/domains/ec2/awsapi/routetable/DisassociateRouteTable.go index ef0fe7122..ce79878e7 100644 --- a/spinifex/gateway/ec2/routetable/DisassociateRouteTable.go +++ b/spinifex/domains/ec2/awsapi/routetable/DisassociateRouteTable.go @@ -1,4 +1,4 @@ -package gateway_ec2_routetable +package routetable import ( "context" diff --git a/spinifex/gateway/ec2/routetable/ReplaceRoute.go b/spinifex/domains/ec2/awsapi/routetable/ReplaceRoute.go similarity index 97% rename from spinifex/gateway/ec2/routetable/ReplaceRoute.go rename to spinifex/domains/ec2/awsapi/routetable/ReplaceRoute.go index 880728db6..8e50e5419 100644 --- a/spinifex/gateway/ec2/routetable/ReplaceRoute.go +++ b/spinifex/domains/ec2/awsapi/routetable/ReplaceRoute.go @@ -1,4 +1,4 @@ -package gateway_ec2_routetable +package routetable import ( "context" diff --git a/spinifex/gateway/ec2/routetable/ReplaceRouteTableAssociation.go b/spinifex/domains/ec2/awsapi/routetable/ReplaceRouteTableAssociation.go similarity index 97% rename from spinifex/gateway/ec2/routetable/ReplaceRouteTableAssociation.go rename to spinifex/domains/ec2/awsapi/routetable/ReplaceRouteTableAssociation.go index 0e05e6df9..decb648b9 100644 --- a/spinifex/gateway/ec2/routetable/ReplaceRouteTableAssociation.go +++ b/spinifex/domains/ec2/awsapi/routetable/ReplaceRouteTableAssociation.go @@ -1,4 +1,4 @@ -package gateway_ec2_routetable +package routetable import ( "context" diff --git a/spinifex/gateway/ec2/routetable/routetable_test.go b/spinifex/domains/ec2/awsapi/routetable/routetable_test.go similarity index 99% rename from spinifex/gateway/ec2/routetable/routetable_test.go rename to spinifex/domains/ec2/awsapi/routetable/routetable_test.go index 3c8aab8c2..73e5ea44d 100644 --- a/spinifex/gateway/ec2/routetable/routetable_test.go +++ b/spinifex/domains/ec2/awsapi/routetable/routetable_test.go @@ -1,4 +1,4 @@ -package gateway_ec2_routetable +package routetable import ( "context" diff --git a/spinifex/gateway/ec2.go b/spinifex/gateway/ec2.go index 7271efb34..dfa86b410 100644 --- a/spinifex/gateway/ec2.go +++ b/spinifex/gateway/ec2.go @@ -22,6 +22,7 @@ import ( ec2launchtemplateapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/launchtemplate" ec2natgwapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/natgw" ec2placementgroupapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/placementgroup" + ec2routetableapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/routetable" ec2vpcapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/vpc" ec2zoneapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/zone" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" @@ -30,7 +31,6 @@ import ( gateway_ec2 "github.com/mulgadc/spinifex/spinifex/gateway/ec2" gateway_ec2_image "github.com/mulgadc/spinifex/spinifex/gateway/ec2/image" gateway_ec2_instance "github.com/mulgadc/spinifex/spinifex/gateway/ec2/instance" - gateway_ec2_routetable "github.com/mulgadc/spinifex/spinifex/gateway/ec2/routetable" gateway_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/gateway/ec2/snapshot" gateway_ec2_spotinstance "github.com/mulgadc/spinifex/spinifex/gateway/ec2/spotinstance" gateway_ec2_tags "github.com/mulgadc/spinifex/spinifex/gateway/ec2/tags" @@ -526,31 +526,31 @@ var ec2Actions = map[string]ec2Action{ return ec2vpcapi.ModifySubnetAttribute(ctx, input, gw.NATSConn, accountID) }), "CreateRouteTable": ec2IdempotentHandler(func(ctx context.Context, input *ec2.CreateRouteTableInput, gw *GatewayConfig, accountID string) (ec2.CreateRouteTableOutput, error) { - return gateway_ec2_routetable.CreateRouteTable(ctx, input, gw.NATSConn, accountID) + return ec2routetableapi.CreateRouteTable(ctx, input, gw.NATSConn, accountID) }), "DeleteRouteTable": ec2Handler(func(ctx context.Context, input *ec2.DeleteRouteTableInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_routetable.DeleteRouteTable(ctx, input, gw.NATSConn, accountID) + return ec2routetableapi.DeleteRouteTable(ctx, input, gw.NATSConn, accountID) }), "DescribeRouteTables": ec2Handler(func(ctx context.Context, input *ec2.DescribeRouteTablesInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_routetable.DescribeRouteTables(ctx, input, gw.NATSConn, accountID) + return ec2routetableapi.DescribeRouteTables(ctx, input, gw.NATSConn, accountID) }), "CreateRoute": ec2Handler(func(ctx context.Context, input *ec2.CreateRouteInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_routetable.CreateRoute(ctx, input, gw.NATSConn, accountID) + return ec2routetableapi.CreateRoute(ctx, input, gw.NATSConn, accountID) }), "DeleteRoute": ec2Handler(func(ctx context.Context, input *ec2.DeleteRouteInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_routetable.DeleteRoute(ctx, input, gw.NATSConn, accountID) + return ec2routetableapi.DeleteRoute(ctx, input, gw.NATSConn, accountID) }), "ReplaceRoute": ec2Handler(func(ctx context.Context, input *ec2.ReplaceRouteInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_routetable.ReplaceRoute(ctx, input, gw.NATSConn, accountID) + return ec2routetableapi.ReplaceRoute(ctx, input, gw.NATSConn, accountID) }), "AssociateRouteTable": ec2Handler(func(ctx context.Context, input *ec2.AssociateRouteTableInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_routetable.AssociateRouteTable(ctx, input, gw.NATSConn, accountID) + return ec2routetableapi.AssociateRouteTable(ctx, input, gw.NATSConn, accountID) }), "DisassociateRouteTable": ec2Handler(func(ctx context.Context, input *ec2.DisassociateRouteTableInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_routetable.DisassociateRouteTable(ctx, input, gw.NATSConn, accountID) + return ec2routetableapi.DisassociateRouteTable(ctx, input, gw.NATSConn, accountID) }), "ReplaceRouteTableAssociation": ec2Handler(func(ctx context.Context, input *ec2.ReplaceRouteTableAssociationInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_routetable.ReplaceRouteTableAssociation(ctx, input, gw.NATSConn, accountID) + return ec2routetableapi.ReplaceRouteTableAssociation(ctx, input, gw.NATSConn, accountID) }), "CreateNetworkInterface": ec2IdempotentHandler(func(ctx context.Context, input *ec2.CreateNetworkInterfaceInput, gw *GatewayConfig, accountID string) (ec2.CreateNetworkInterfaceOutput, error) { return ec2vpcapi.CreateNetworkInterface(ctx, input, gw.NATSConn, accountID)