From 8b106e7966715374b40de4225e187f57280be3d2 Mon Sep 17 00:00:00 2001 From: joshsiv-mulga Date: Wed, 7 Oct 2026 14:36:36 +1000 Subject: [PATCH] refactor: move EC2 snapshot action adapters to domains/ec2/awsapi --- spinifex/accountteardown/reapers_ec2.go | 6 +++--- .../ec2/awsapi}/snapshot/CopySnapshot.go | 2 +- .../ec2/awsapi}/snapshot/CreateSnapshot.go | 2 +- .../ec2/awsapi}/snapshot/DeleteSnapshot.go | 2 +- .../ec2/awsapi}/snapshot/DescribeSnapshots.go | 2 +- .../ec2/awsapi}/snapshot/Snapshot_test.go | 2 +- spinifex/gateway/ec2.go | 10 +++++----- 7 files changed, 13 insertions(+), 13 deletions(-) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/snapshot/CopySnapshot.go (97%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/snapshot/CreateSnapshot.go (97%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/snapshot/DeleteSnapshot.go (97%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/snapshot/DescribeSnapshots.go (97%) rename spinifex/{gateway/ec2 => domains/ec2/awsapi}/snapshot/Snapshot_test.go (99%) diff --git a/spinifex/accountteardown/reapers_ec2.go b/spinifex/accountteardown/reapers_ec2.go index 6c7481cea..c9272ea0d 100644 --- a/spinifex/accountteardown/reapers_ec2.go +++ b/spinifex/accountteardown/reapers_ec2.go @@ -18,10 +18,10 @@ import ( 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" + ec2snapshotapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/snapshot" ec2vpcapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/vpc" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" gateway_ec2_instance "github.com/mulgadc/spinifex/spinifex/gateway/ec2/instance" - 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" ) @@ -162,7 +162,7 @@ func (r *snapshotReaper) Kind() string { return "snapshot" } func (r *snapshotReaper) Stage() Stage { return StageStorage } func (r *snapshotReaper) List(ctx context.Context, accountID string) ([]Resource, error) { - out, err := gateway_ec2_snapshot.DescribeSnapshots(ctx, &ec2.DescribeSnapshotsInput{ + out, err := ec2snapshotapi.DescribeSnapshots(ctx, &ec2.DescribeSnapshotsInput{ OwnerIds: []*string{aws.String(accountID)}, }, r.nc, accountID) if err != nil { @@ -180,7 +180,7 @@ func (r *snapshotReaper) List(ctx context.Context, accountID string) ([]Resource } func (r *snapshotReaper) Delete(ctx context.Context, accountID string, resource Resource, _ bool) error { - _, err := gateway_ec2_snapshot.DeleteSnapshot(ctx, &ec2.DeleteSnapshotInput{ + _, err := ec2snapshotapi.DeleteSnapshot(ctx, &ec2.DeleteSnapshotInput{ SnapshotId: aws.String(resource.ID), }, r.nc, accountID) return ignoreAlreadyGone(err) diff --git a/spinifex/gateway/ec2/snapshot/CopySnapshot.go b/spinifex/domains/ec2/awsapi/snapshot/CopySnapshot.go similarity index 97% rename from spinifex/gateway/ec2/snapshot/CopySnapshot.go rename to spinifex/domains/ec2/awsapi/snapshot/CopySnapshot.go index 25a1bcb18..aaab223ad 100644 --- a/spinifex/gateway/ec2/snapshot/CopySnapshot.go +++ b/spinifex/domains/ec2/awsapi/snapshot/CopySnapshot.go @@ -1,4 +1,4 @@ -package gateway_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/gateway/ec2/snapshot/CreateSnapshot.go b/spinifex/domains/ec2/awsapi/snapshot/CreateSnapshot.go similarity index 97% rename from spinifex/gateway/ec2/snapshot/CreateSnapshot.go rename to spinifex/domains/ec2/awsapi/snapshot/CreateSnapshot.go index d75703ee7..1c58769fa 100644 --- a/spinifex/gateway/ec2/snapshot/CreateSnapshot.go +++ b/spinifex/domains/ec2/awsapi/snapshot/CreateSnapshot.go @@ -1,4 +1,4 @@ -package gateway_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/gateway/ec2/snapshot/DeleteSnapshot.go b/spinifex/domains/ec2/awsapi/snapshot/DeleteSnapshot.go similarity index 97% rename from spinifex/gateway/ec2/snapshot/DeleteSnapshot.go rename to spinifex/domains/ec2/awsapi/snapshot/DeleteSnapshot.go index d888369d0..86d832048 100644 --- a/spinifex/gateway/ec2/snapshot/DeleteSnapshot.go +++ b/spinifex/domains/ec2/awsapi/snapshot/DeleteSnapshot.go @@ -1,4 +1,4 @@ -package gateway_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/gateway/ec2/snapshot/DescribeSnapshots.go b/spinifex/domains/ec2/awsapi/snapshot/DescribeSnapshots.go similarity index 97% rename from spinifex/gateway/ec2/snapshot/DescribeSnapshots.go rename to spinifex/domains/ec2/awsapi/snapshot/DescribeSnapshots.go index 42da0d847..1d0452dbf 100644 --- a/spinifex/gateway/ec2/snapshot/DescribeSnapshots.go +++ b/spinifex/domains/ec2/awsapi/snapshot/DescribeSnapshots.go @@ -1,4 +1,4 @@ -package gateway_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/gateway/ec2/snapshot/Snapshot_test.go b/spinifex/domains/ec2/awsapi/snapshot/Snapshot_test.go similarity index 99% rename from spinifex/gateway/ec2/snapshot/Snapshot_test.go rename to spinifex/domains/ec2/awsapi/snapshot/Snapshot_test.go index 622b31e9e..fa983a42e 100644 --- a/spinifex/gateway/ec2/snapshot/Snapshot_test.go +++ b/spinifex/domains/ec2/awsapi/snapshot/Snapshot_test.go @@ -1,4 +1,4 @@ -package gateway_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/gateway/ec2.go b/spinifex/gateway/ec2.go index 027ade276..0ded06023 100644 --- a/spinifex/gateway/ec2.go +++ b/spinifex/gateway/ec2.go @@ -24,6 +24,7 @@ import ( 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" + ec2snapshotapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/snapshot" 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" @@ -31,7 +32,6 @@ import ( "github.com/mulgadc/spinifex/spinifex/foundation/lifecycle/idempotency" gateway_ec2 "github.com/mulgadc/spinifex/spinifex/gateway/ec2" gateway_ec2_instance "github.com/mulgadc/spinifex/spinifex/gateway/ec2/instance" - 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" gateway_ec2_volume "github.com/mulgadc/spinifex/spinifex/gateway/ec2/volume" @@ -398,16 +398,16 @@ var ec2Actions = map[string]ec2Action{ return gateway_ec2_tags.DescribeTags(ctx, input, gw.NATSConn, accountID) }), "CreateSnapshot": ec2Handler(func(ctx context.Context, input *ec2.CreateSnapshotInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_snapshot.CreateSnapshot(ctx, input, gw.NATSConn, accountID) + return ec2snapshotapi.CreateSnapshot(ctx, input, gw.NATSConn, accountID) }), "DeleteSnapshot": ec2Handler(func(ctx context.Context, input *ec2.DeleteSnapshotInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_snapshot.DeleteSnapshot(ctx, input, gw.NATSConn, accountID) + return ec2snapshotapi.DeleteSnapshot(ctx, input, gw.NATSConn, accountID) }), "DescribeSnapshots": ec2Handler(func(ctx context.Context, input *ec2.DescribeSnapshotsInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_snapshot.DescribeSnapshots(ctx, input, gw.NATSConn, accountID) + return ec2snapshotapi.DescribeSnapshots(ctx, input, gw.NATSConn, accountID) }), "CopySnapshot": ec2Handler(func(ctx context.Context, input *ec2.CopySnapshotInput, gw *GatewayConfig, accountID string) (any, error) { - return gateway_ec2_snapshot.CopySnapshot(ctx, input, gw.NATSConn, accountID) + return ec2snapshotapi.CopySnapshot(ctx, input, gw.NATSConn, accountID) }), "CreateInternetGateway": ec2Handler(func(ctx context.Context, input *ec2.CreateInternetGatewayInput, gw *GatewayConfig, accountID string) (any, error) { return ec2igwapi.CreateInternetGateway(ctx, input, gw.NATSConn, accountID)