From 5d60184e8911cb377c4d514b8459ac1a2b67ac86 Mon Sep 17 00:00:00 2001 From: joshsiv-mulga Date: Wed, 7 Oct 2026 09:39:09 +1000 Subject: [PATCH] refactor: move EC2 compute and storage packages to the EC2 domain Move handlers/ec2/{instance,volume,snapshot,image,tags} to domains/ec2/, each named after its directory and imported as ec2, which empties handlers/ec2. The daemon's e2e suite selection now lists the moved EC2 resource paths in place of handlers/ec2, so EC2-only changes select the daemon suites again. --- docs/service-interfaces.yaml | 22 ++++++++-- spinifex/daemon/bedrock_deps.go | 2 +- spinifex/daemon/daemon.go | 42 +++++++++---------- spinifex/daemon/daemon_handlers_image.go | 4 +- spinifex/daemon/daemon_handlers_instance.go | 10 ++--- .../daemon_handlers_instance_tags_test.go | 8 ++-- .../daemon/daemon_handlers_instance_test.go | 28 ++++++------- .../daemon/daemon_handlers_monitoring_test.go | 4 +- spinifex/daemon/daemon_handlers_test.go | 34 +++++++-------- spinifex/daemon/daemon_handlers_volume.go | 4 +- spinifex/daemon/daemon_system_instance.go | 2 +- spinifex/daemon/daemon_test.go | 34 +++++++-------- spinifex/daemon/eks_worker_launch.go | 4 +- spinifex/daemon/eks_worker_launch_test.go | 4 +- spinifex/daemon/gpu_adapter.go | 6 +-- spinifex/daemon/instance_recovery.go | 4 +- spinifex/daemon/instance_recovery_test.go | 6 +-- spinifex/daemon/vpc_adapter.go | 26 ++++++------ .../ec2/guestmetadata/instance_lookup.go | 4 +- .../ec2/image/ami_source_volume_test.go | 2 +- .../image/deregister_legacy_config_test.go | 2 +- .../ec2/image/describe_byid_test.go | 28 ++++++------- .../ec2/image/drain_test.go | 4 +- .../ec2/image/provider_snapshot_test.go | 2 +- .../ec2/image/provider_test.go | 2 +- .../ec2/image/service.go | 2 +- .../ec2/image/service_impl.go | 8 ++-- .../ec2/image/service_impl_encryption_test.go | 2 +- .../ec2/image/service_impl_recordtags_test.go | 2 +- .../ec2/image/service_impl_test.go | 2 +- .../ec2/image/service_nats.go | 2 +- .../ec2/image/service_nats_test.go | 2 +- .../ec2/instance/data_volumes_test.go | 26 ++++++------ .../ec2/instance/export_test.go | 2 +- .../instance/iam_profile_association_test.go | 2 +- .../ec2/instance/instance_filter_test.go | 2 +- .../ec2/instance/instance_monitoring_test.go | 2 +- .../ec2/instance/instance_tags_test.go | 2 +- .../instance/launch_claimed_relaunch_test.go | 2 +- .../ec2/instance/metadata_options.go | 2 +- .../ec2/instance/metadata_options_test.go | 2 +- .../ec2/instance/projection.go | 2 +- .../ec2/instance/projection_public_ip_test.go | 2 +- .../ec2/instance/projection_test.go | 2 +- .../ec2/instance/provider_efi_volume_test.go | 2 +- .../ec2/instance/provider_root_volume_test.go | 2 +- .../ec2/instance/service.go | 8 ++-- .../ec2/instance/service_impl.go | 2 +- .../ec2/instance/service_impl_test.go | 2 +- .../ec2/instance/service_nats.go | 2 +- .../ec2/instance/service_nats_test.go | 2 +- .../ec2/instance/start_public_ip_test.go | 2 +- .../ec2/instance/status_selection.go | 2 +- .../instance/volume_held_elsewhere_test.go | 2 +- spinifex/domains/ec2/key/service_impl.go | 2 +- .../delete_snapshot_pagination_test.go | 6 +-- .../ec2/snapshot/describe_byid_test.go | 8 ++-- .../ec2/snapshot/describe_fanout_test.go | 8 ++-- .../ec2/snapshot/drain_test.go | 2 +- .../ec2/snapshot/record_tags_test.go | 2 +- .../ec2/snapshot/service.go | 2 +- .../ec2/snapshot/service_impl.go | 4 +- .../ec2/snapshot/service_impl_test.go | 2 +- .../ec2/snapshot/service_nats.go | 2 +- .../ec2/snapshot/snapshot_partition_test.go | 2 +- .../ec2/tags/key_pair_tags_test.go | 12 +++--- .../{handlers => domains}/ec2/tags/service.go | 2 +- .../ec2/tags/service_impl.go | 6 +-- .../ec2/tags/service_impl_test.go | 2 +- .../ec2/tags/service_nats.go | 2 +- .../{handlers => domains}/ec2/tags/store.go | 2 +- .../ec2/tags/store_test.go | 2 +- .../volume/config_route_invariants_test.go | 2 +- .../describe_volumes_provider_bench_test.go | 2 +- ...describe_volumes_provider_fastpath_test.go | 2 +- .../ec2/volume/force_detach_test.go | 2 +- .../get_volume_metadata_provider_test.go | 2 +- .../ec2/volume/lifecycle_invariants_test.go | 2 +- .../ec2/volume/main_test.go | 2 +- .../volume/provider_snapshot_source_test.go | 6 +-- .../ec2/volume/record_tags_test.go | 2 +- .../ec2/volume/service.go | 2 +- .../ec2/volume/service_impl.go | 8 ++-- .../volume/service_impl_encryption_test.go | 2 +- .../ec2/volume/service_impl_test.go | 2 +- .../ec2/volume/service_nats.go | 2 +- .../ec2/volume/testhelpers_test.go | 2 +- .../ec2/volume/volume_leak_reaper.go | 2 +- .../ec2/volume/volume_leak_reaper_test.go | 2 +- .../ec2/volume/volume_partition_test.go | 2 +- spinifex/domains/ec2/vpc/service.go | 2 +- spinifex/gateway/ec2/image/CopyImage.go | 4 +- spinifex/gateway/ec2/image/CreateImage.go | 4 +- spinifex/gateway/ec2/image/DeregisterImage.go | 4 +- .../ec2/image/DescribeImageAttribute.go | 4 +- spinifex/gateway/ec2/image/DescribeImages.go | 4 +- .../gateway/ec2/image/ModifyImageAttribute.go | 4 +- spinifex/gateway/ec2/image/RegisterImage.go | 4 +- .../gateway/ec2/image/ResetImageAttribute.go | 4 +- spinifex/gateway/ec2/instance/RunInstances.go | 4 +- .../gateway/ec2/instance/status_synthesis.go | 6 +-- spinifex/gateway/ec2/snapshot/CopySnapshot.go | 4 +- .../gateway/ec2/snapshot/CreateSnapshot.go | 4 +- .../gateway/ec2/snapshot/DeleteSnapshot.go | 4 +- .../gateway/ec2/snapshot/DescribeSnapshots.go | 4 +- spinifex/gateway/ec2/tags/CreateTags.go | 4 +- spinifex/gateway/ec2/tags/DeleteTags.go | 4 +- spinifex/gateway/ec2/tags/DescribeTags.go | 4 +- spinifex/gateway/ec2/volume/CreateVolume.go | 4 +- spinifex/gateway/ec2/volume/DeleteVolume.go | 4 +- .../ec2/volume/DescribeVolumeStatus.go | 4 +- .../gateway/ec2/volume/DescribeVolumes.go | 4 +- .../volume/DescribeVolumesModifications.go | 4 +- spinifex/gateway/ec2/volume/DetachVolume.go | 4 +- spinifex/gateway/ec2/volume/ModifyVolume.go | 4 +- spinifex/gateway/tagging/GetResources.go | 4 +- spinifex/handlers/rds/lifecycle.go | 6 +-- spinifex/runtime/compute/cache/cache_test.go | 2 +- spinifex/runtime/compute/vm/mock/mock.go | 2 +- spinifex/runtime/roles/awsgw/awsgw.go | 4 +- .../services/viperblockd/provider_handlers.go | 2 +- .../viperblockd/provider_handlers_test.go | 2 +- tests/e2e/iam/instance_iam_profile_test.go | 2 +- tests/integration/daemon_lite.go | 10 ++--- tests/integration/image_daemon_lite.go | 8 ++-- tests/integration/tags_test.go | 2 +- tests/integration/volume_daemon_lite.go | 10 ++--- tests/integration/volume_test.go | 2 +- 128 files changed, 334 insertions(+), 318 deletions(-) rename spinifex/{handlers => domains}/ec2/image/ami_source_volume_test.go (99%) rename spinifex/{handlers => domains}/ec2/image/deregister_legacy_config_test.go (98%) rename spinifex/{handlers => domains}/ec2/image/describe_byid_test.go (93%) rename spinifex/{handlers => domains}/ec2/image/drain_test.go (98%) rename spinifex/{handlers => domains}/ec2/image/provider_snapshot_test.go (99%) rename spinifex/{handlers => domains}/ec2/image/provider_test.go (99%) rename spinifex/{handlers => domains}/ec2/image/service.go (97%) rename spinifex/{handlers => domains}/ec2/image/service_impl.go (99%) rename spinifex/{handlers => domains}/ec2/image/service_impl_encryption_test.go (98%) rename spinifex/{handlers => domains}/ec2/image/service_impl_recordtags_test.go (99%) rename spinifex/{handlers => domains}/ec2/image/service_impl_test.go (99%) rename spinifex/{handlers => domains}/ec2/image/service_nats.go (99%) rename spinifex/{handlers => domains}/ec2/image/service_nats_test.go (98%) rename spinifex/{handlers => domains}/ec2/instance/data_volumes_test.go (87%) rename spinifex/{handlers => domains}/ec2/instance/export_test.go (98%) rename spinifex/{handlers => domains}/ec2/instance/iam_profile_association_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/instance_filter_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/instance_monitoring_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/instance_tags_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/launch_claimed_relaunch_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/metadata_options.go (99%) rename spinifex/{handlers => domains}/ec2/instance/metadata_options_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/projection.go (99%) rename spinifex/{handlers => domains}/ec2/instance/projection_public_ip_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/projection_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/provider_efi_volume_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/provider_root_volume_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/service.go (98%) rename spinifex/{handlers => domains}/ec2/instance/service_impl.go (99%) rename spinifex/{handlers => domains}/ec2/instance/service_impl_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/service_nats.go (99%) rename spinifex/{handlers => domains}/ec2/instance/service_nats_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/start_public_ip_test.go (99%) rename spinifex/{handlers => domains}/ec2/instance/status_selection.go (98%) rename spinifex/{handlers => domains}/ec2/instance/volume_held_elsewhere_test.go (98%) rename spinifex/{handlers => domains}/ec2/snapshot/delete_snapshot_pagination_test.go (93%) rename spinifex/{handlers => domains}/ec2/snapshot/describe_byid_test.go (97%) rename spinifex/{handlers => domains}/ec2/snapshot/describe_fanout_test.go (93%) rename spinifex/{handlers => domains}/ec2/snapshot/drain_test.go (99%) rename spinifex/{handlers => domains}/ec2/snapshot/record_tags_test.go (98%) rename spinifex/{handlers => domains}/ec2/snapshot/service.go (95%) rename spinifex/{handlers => domains}/ec2/snapshot/service_impl.go (99%) rename spinifex/{handlers => domains}/ec2/snapshot/service_impl_test.go (99%) rename spinifex/{handlers => domains}/ec2/snapshot/service_nats.go (98%) rename spinifex/{handlers => domains}/ec2/snapshot/snapshot_partition_test.go (99%) rename spinifex/{handlers => domains}/ec2/tags/key_pair_tags_test.go (85%) rename spinifex/{handlers => domains}/ec2/tags/service.go (95%) rename spinifex/{handlers => domains}/ec2/tags/service_impl.go (98%) rename spinifex/{handlers => domains}/ec2/tags/service_impl_test.go (99%) rename spinifex/{handlers => domains}/ec2/tags/service_nats.go (98%) rename spinifex/{handlers => domains}/ec2/tags/store.go (99%) rename spinifex/{handlers => domains}/ec2/tags/store_test.go (99%) rename spinifex/{handlers => domains}/ec2/volume/config_route_invariants_test.go (99%) rename spinifex/{handlers => domains}/ec2/volume/describe_volumes_provider_bench_test.go (99%) rename spinifex/{handlers => domains}/ec2/volume/describe_volumes_provider_fastpath_test.go (99%) rename spinifex/{handlers => domains}/ec2/volume/force_detach_test.go (99%) rename spinifex/{handlers => domains}/ec2/volume/get_volume_metadata_provider_test.go (99%) rename spinifex/{handlers => domains}/ec2/volume/lifecycle_invariants_test.go (99%) rename spinifex/{handlers => domains}/ec2/volume/main_test.go (97%) rename spinifex/{handlers => domains}/ec2/volume/provider_snapshot_source_test.go (97%) rename spinifex/{handlers => domains}/ec2/volume/record_tags_test.go (99%) rename spinifex/{handlers => domains}/ec2/volume/service.go (97%) rename spinifex/{handlers => domains}/ec2/volume/service_impl.go (99%) rename spinifex/{handlers => domains}/ec2/volume/service_impl_encryption_test.go (98%) rename spinifex/{handlers => domains}/ec2/volume/service_impl_test.go (99%) rename spinifex/{handlers => domains}/ec2/volume/service_nats.go (98%) rename spinifex/{handlers => domains}/ec2/volume/testhelpers_test.go (98%) rename spinifex/{handlers => domains}/ec2/volume/volume_leak_reaper.go (99%) rename spinifex/{handlers => domains}/ec2/volume/volume_leak_reaper_test.go (99%) rename spinifex/{handlers => domains}/ec2/volume/volume_partition_test.go (99%) diff --git a/docs/service-interfaces.yaml b/docs/service-interfaces.yaml index f91dc07e4..3dd766b0e 100644 --- a/docs/service-interfaces.yaml +++ b/docs/service-interfaces.yaml @@ -49,12 +49,28 @@ services: # forwards to vpcd / viperblockd / predastore. # # Source layout: spinifex/runtime/roles/spinifex (entry), spinifex/daemon - # (subscribe registration), spinifex/handlers/{ec2,elbv2,iam} (per- - # subject handler bodies). Selector treats all four paths as belonging + # (subscribe registration), spinifex/domains/ec2/ and spinifex/handlers/{elbv2,iam} (per- + # subject handler bodies). Selector treats these paths as belonging # to this service via the `additional_paths` field. additional_paths: - spinifex/daemon - - spinifex/handlers/ec2 + - spinifex/domains/ec2/account + - spinifex/domains/ec2/eigw + - spinifex/domains/ec2/eip + - spinifex/domains/ec2/igw + - spinifex/domains/ec2/image + - spinifex/domains/ec2/instance + - spinifex/domains/ec2/key + - spinifex/domains/ec2/launchtemplate + - spinifex/domains/ec2/natgw + - spinifex/domains/ec2/placementgroup + - spinifex/domains/ec2/routetable + - spinifex/domains/ec2/snapshot + - spinifex/domains/ec2/spotinstance + - spinifex/domains/ec2/tags + - spinifex/domains/ec2/volume + - spinifex/domains/ec2/volumestate + - spinifex/domains/ec2/vpc - spinifex/handlers/elbv2 - spinifex/domains/acm - spinifex/handlers/iam diff --git a/spinifex/daemon/bedrock_deps.go b/spinifex/daemon/bedrock_deps.go index c21bdffa7..ec6e00e72 100644 --- a/spinifex/daemon/bedrock_deps.go +++ b/spinifex/daemon/bedrock_deps.go @@ -73,7 +73,7 @@ func (d *Daemon) buildBedrockServiceDeps() ochre.ServiceDeps { // daemonGPUSnapshotter adapts *gpu.Manager to domains/ochre's Snapshot-only // capacity-check surface, keeping the gpu package out of that handler package -// the same way daemonGPUClaimer keeps it out of handlers_ec2_instance. +// the same way daemonGPUClaimer keeps it out of ec2instance. // // It holds the daemon rather than the manager because applyGPUConfig swaps // d.gpuManager on a passthrough toggle. Capturing the pointer here would leave diff --git a/spinifex/daemon/daemon.go b/spinifex/daemon/daemon.go index f1e4433a8..752711bae 100644 --- a/spinifex/daemon/daemon.go +++ b/spinifex/daemon/daemon.go @@ -46,13 +46,18 @@ import ( ec2eigw "github.com/mulgadc/spinifex/spinifex/domains/ec2/eigw" ec2eip "github.com/mulgadc/spinifex/spinifex/domains/ec2/eip" ec2igw "github.com/mulgadc/spinifex/spinifex/domains/ec2/igw" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/domains/ec2/instancetypes" ec2key "github.com/mulgadc/spinifex/spinifex/domains/ec2/key" ec2launchtemplate "github.com/mulgadc/spinifex/spinifex/domains/ec2/launchtemplate" ec2natgw "github.com/mulgadc/spinifex/spinifex/domains/ec2/natgw" ec2placementgroup "github.com/mulgadc/spinifex/spinifex/domains/ec2/placementgroup" ec2routetable "github.com/mulgadc/spinifex/spinifex/domains/ec2/routetable" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" ec2spotinstance "github.com/mulgadc/spinifex/spinifex/domains/ec2/spotinstance" + ec2tags "github.com/mulgadc/spinifex/spinifex/domains/ec2/tags" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" ec2vpc "github.com/mulgadc/spinifex/spinifex/domains/ec2/vpc" handlers_ecr "github.com/mulgadc/spinifex/spinifex/domains/ecr" "github.com/mulgadc/spinifex/spinifex/domains/network/external" @@ -66,11 +71,6 @@ import ( "github.com/mulgadc/spinifex/spinifex/foundation/state/clustersize" "github.com/mulgadc/spinifex/spinifex/foundation/state/kvutil" "github.com/mulgadc/spinifex/spinifex/foundation/telemetry" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" - handlers_ec2_tags "github.com/mulgadc/spinifex/spinifex/handlers/ec2/tags" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" handlers_ecs "github.com/mulgadc/spinifex/spinifex/handlers/ecs" handlers_eks "github.com/mulgadc/spinifex/spinifex/handlers/eks" handlers_elbv2 "github.com/mulgadc/spinifex/spinifex/handlers/elbv2" @@ -143,19 +143,19 @@ type Daemon struct { config *config.Config natsConn *nats.Conn resourceMgr *ResourceManager - instanceService *handlers_ec2_instance.InstanceServiceImpl + instanceService *ec2instance.InstanceServiceImpl dnsWriter *dns.Writer dnsReconciler *dns.Reconciler dnsBaseDomain string dnsInternalDomain string keyService *ec2key.KeyServiceImpl - imageService *handlers_ec2_image.ImageServiceImpl - volumeService *handlers_ec2_volume.VolumeServiceImpl + imageService *ec2image.ImageServiceImpl + volumeService *ec2volume.VolumeServiceImpl // ebsProvider is the sole EBS backend, set once during startup. ebsProvider ebsprovider.EBSProvider accountService *ec2account.AccountSettingsServiceImpl - snapshotService *handlers_ec2_snapshot.SnapshotServiceImpl - tagsService *handlers_ec2_tags.TagsServiceImpl + snapshotService *ec2snapshot.SnapshotServiceImpl + tagsService *ec2tags.TagsServiceImpl eigwService *ec2eigw.EgressOnlyIGWServiceImpl igwService *ec2igw.IGWServiceImpl placementGroupService *ec2placementgroup.PlacementGroupServiceImpl @@ -1756,20 +1756,20 @@ func (d *Daemon) startCluster() error { // Create services before loading/launching instances, since LaunchInstance depends on them store := objectstore.NewS3ObjectStoreFromConfig(netaddr.DialTarget(d.config.Predastore.Host), d.config.Predastore.Region, d.config.Predastore.AccessKey, d.config.Predastore.SecretKey) - d.instanceService = handlers_ec2_instance.NewInstanceServiceImpl(d.config, d.resourceMgr.instanceTypes, d.natsConn, store, d.vmMgr, d.resourceMgr, d.jsManager) + d.instanceService = ec2instance.NewInstanceServiceImpl(d.config, d.resourceMgr.instanceTypes, d.natsConn, store, d.vmMgr, d.resourceMgr, d.jsManager) d.dnsWriter = dns.NewWriter(d.config, d.clusterConfig, d.natsConn) d.dnsReconciler = dns.NewReconciler(d.config, d.clusterConfig, d.natsConn, d.dnsWriter, d.dnsDesiredSet, d.dnsWatchSources()...) d.dnsBaseDomain = dns.ResolveBaseDomain(d.config) d.dnsInternalDomain = dns.ResolveInternalDomain(d.config) d.keyService = ec2key.NewKeyServiceImpl(d.config) - d.imageService = handlers_ec2_image.NewImageServiceImpl(d.config, d.natsConn) + d.imageService = ec2image.NewImageServiceImpl(d.config, d.natsConn) type snapResult struct { - svc *handlers_ec2_snapshot.SnapshotServiceImpl + svc *ec2snapshot.SnapshotServiceImpl kv jetstream.KeyValue } snap, err := initServiceWithRetry("snapshot service", func() (snapResult, error) { - svc, kv, err := handlers_ec2_snapshot.NewSnapshotServiceImplWithNATS(d.ctx, d.config, d.natsConn) + svc, kv, err := ec2snapshot.NewSnapshotServiceImplWithNATS(d.ctx, d.config, d.natsConn) return snapResult{svc, kv}, err }) if err != nil { @@ -1777,7 +1777,7 @@ func (d *Daemon) startCluster() error { } d.snapshotService = snap.svc - d.volumeService = handlers_ec2_volume.NewVolumeServiceImpl(d.config, d.natsConn, snap.kv) + d.volumeService = ec2volume.NewVolumeServiceImpl(d.config, d.natsConn, snap.kv) if err := d.configureEBSProvider(); err != nil { return fmt.Errorf("configure EBS provider: %w", err) } @@ -1786,12 +1786,12 @@ func (d *Daemon) startCluster() error { if jsErr != nil { return nil, fmt.Errorf("jetstream handle: %w", jsErr) } - return handlers_ec2_tags.GetOrCreateTagsBucket(d.ctx, tagsJS) + return ec2tags.GetOrCreateTagsBucket(d.ctx, tagsJS) }) if err != nil { return fmt.Errorf("failed to get tags KV bucket: %w", err) } - d.tagsService = handlers_ec2_tags.NewTagsServiceImpl(d.config, tagsKV) + d.tagsService = ec2tags.NewTagsServiceImpl(d.config, tagsKV) // Key pairs keep their creation tags in their own metadata; project them so // describe-tags sees them, and clear them when the key pair is deleted. d.keyService.SetCentralTagStore(d.tagsService) @@ -1939,8 +1939,8 @@ func (d *Daemon) startCluster() error { // the concrete value over only once init succeeded — otherwise the service's // own nil checks pass and the allocate path derefs a nil receiver. var ( - ipAllocator handlers_ec2_instance.PublicIPAllocator - ipReleaser handlers_ec2_instance.PublicIPReleaser + ipAllocator ec2instance.PublicIPAllocator + ipReleaser ec2instance.PublicIPReleaser ) if d.externalIPAM != nil { ipAllocator = d.externalIPAM @@ -3218,9 +3218,9 @@ func (rm *ResourceManager) deallocate(instanceType *ec2.InstanceTypeInfo) { rm.updateInstanceSubscriptions() } -var _ handlers_ec2_instance.InstanceTypeAllocator = (*ResourceManager)(nil) +var _ ec2instance.InstanceTypeAllocator = (*ResourceManager)(nil) -// Allocate, Deallocate, CanAllocate satisfy handlers_ec2_instance.InstanceTypeAllocator. +// Allocate, Deallocate, CanAllocate satisfy ec2instance.InstanceTypeAllocator. func (rm *ResourceManager) Allocate(it *ec2.InstanceTypeInfo) error { return rm.allocate(it) } func (rm *ResourceManager) Deallocate(it *ec2.InstanceTypeInfo) { rm.deallocate(it) } func (rm *ResourceManager) CanAllocate(it *ec2.InstanceTypeInfo, count int) int { diff --git a/spinifex/daemon/daemon_handlers_image.go b/spinifex/daemon/daemon_handlers_image.go index 8b419a971..181828520 100644 --- a/spinifex/daemon/daemon_handlers_image.go +++ b/spinifex/daemon/daemon_handlers_image.go @@ -8,8 +8,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/mulgadc/spinifex/spinifex/admin" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" "github.com/nats-io/nats.go" @@ -162,7 +162,7 @@ func (d *Daemon) handleEC2CreateImage(msg *nats.Msg) string { return outcomeError } - params := handlers_ec2_image.CreateImageParams{ + params := ec2image.CreateImageParams{ Input: input, RootVolumeID: rootVolumeID, SourceImageID: sourceImageID, diff --git a/spinifex/daemon/daemon_handlers_instance.go b/spinifex/daemon/daemon_handlers_instance.go index 001e0b842..5bdcf64a8 100644 --- a/spinifex/daemon/daemon_handlers_instance.go +++ b/spinifex/daemon/daemon_handlers_instance.go @@ -12,8 +12,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mulgadc/spinifex/contracts/ec2/v1" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" "github.com/nats-io/nats.go" "go.opentelemetry.io/otel" @@ -45,14 +45,14 @@ func (d *Daemon) handleSetInstanceTags(ctx context.Context, msg *nats.Msg, comma missingRecord = true return } - newTags = handlers_ec2_instance.ApplyInstanceTagMutation(v.Instance.Tags, data, remove) + newTags = ec2instance.ApplyInstanceTagMutation(v.Instance.Tags, data, remove) }) if missingRecord { return respondErrorOutcome(d.node, msg, awserrors.ErrorServerInternal) } accountID := natsmsg.AccountIDFromMsg(msg) - if err := d.tagsService.PutResourceTags(ctx, accountID, instance.ID, handlers_ec2_instance.TagsToMap(newTags)); err != nil { + if err := d.tagsService.PutResourceTags(ctx, accountID, instance.ID, ec2instance.TagsToMap(newTags)); err != nil { slog.ErrorContext(ctx, "SetInstanceTags: central tag store write failed", "instanceId", instance.ID, "err", err) return respondErrorOutcome(d.node, msg, awserrors.ErrorServerInternal) @@ -62,7 +62,7 @@ func (d *Daemon) handleSetInstanceTags(ctx context.Context, msg *nats.Msg, comma if v.Instance == nil { return false } - v.Instance.Tags = handlers_ec2_instance.ApplyInstanceTagMutation(v.Instance.Tags, data, remove) + v.Instance.Tags = ec2instance.ApplyInstanceTagMutation(v.Instance.Tags, data, remove) return true }) if err != nil { @@ -231,7 +231,7 @@ func (d *Daemon) handleEC2RunInstances(msg *nats.Msg) string { continue } if err := d.tagsService.PutResourceTags(ctx, accountID, instance.ID, - handlers_ec2_instance.TagsToMap(instance.Instance.Tags)); err != nil { + ec2instance.TagsToMap(instance.Instance.Tags)); err != nil { slog.Error("handleEC2RunInstances: launch tag central store write failed", "instanceId", instance.ID, "err", err) } diff --git a/spinifex/daemon/daemon_handlers_instance_tags_test.go b/spinifex/daemon/daemon_handlers_instance_tags_test.go index 4879e86e7..09768004c 100644 --- a/spinifex/daemon/daemon_handlers_instance_tags_test.go +++ b/spinifex/daemon/daemon_handlers_instance_tags_test.go @@ -8,9 +8,9 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mulgadc/spinifex/contracts/ec2/v1" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" + ec2tags "github.com/mulgadc/spinifex/spinifex/domains/ec2/tags" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" - handlers_ec2_tags "github.com/mulgadc/spinifex/spinifex/handlers/ec2/tags" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" vmmock "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm/mock" @@ -30,10 +30,10 @@ func tagTestDaemon(t *testing.T, instanceID string, initial map[string]string) * func tagTestDaemonWithStopped(t *testing.T, instanceID string, initial map[string]string) (*Daemon, *vmmock.StateStore) { t.Helper() d := createTestDaemon(t, sharedNATSURL) - d.tagsService = handlers_ec2_tags.NewTagsServiceImplWithStore(d.config, objectstore.NewMemoryObjectStore(), testTagsKV(t)) + d.tagsService = ec2tags.NewTagsServiceImplWithStore(d.config, objectstore.NewMemoryObjectStore(), testTagsKV(t)) stopped := vmmock.New() - d.instanceService = handlers_ec2_instance.NewInstanceServiceImpl( + d.instanceService = ec2instance.NewInstanceServiceImpl( d.config, d.resourceMgr.instanceTypes, d.natsConn, objectstore.NewMemoryObjectStore(), d.vmMgr, d.resourceMgr, stopped) diff --git a/spinifex/daemon/daemon_handlers_instance_test.go b/spinifex/daemon/daemon_handlers_instance_test.go index 4ed0ffa3a..759510ccb 100644 --- a/spinifex/daemon/daemon_handlers_instance_test.go +++ b/spinifex/daemon/daemon_handlers_instance_test.go @@ -9,8 +9,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" vmmock "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm/mock" @@ -34,7 +34,7 @@ func daemonWithFakeStateStore(t *testing.T, store *vmmock.StateStore) *Daemon { t.Helper() d := createTestDaemon(t, sharedNATSURL) d.stateStore = store - d.instanceService = handlers_ec2_instance.NewInstanceServiceImpl( + d.instanceService = ec2instance.NewInstanceServiceImpl( d.config, d.resourceMgr.instanceTypes, d.natsConn, objectstore.NewMemoryObjectStore(), d.vmMgr, d.resourceMgr, store, ) @@ -90,7 +90,7 @@ func TestHandleEC2StartStoppedInstance_LoadError(t *testing.T) { store.LoadStoppedErr = errors.New("kv unavailable") d := daemonWithFakeStateStore(t, store) - body, _ := json.Marshal(handlers_ec2_instance.StartStoppedInstanceInput{InstanceID: "i-load-fail"}) + body, _ := json.Marshal(ec2instance.StartStoppedInstanceInput{InstanceID: "i-load-fail"}) reply := requestHandler(t, d.natsConn, "ec2.start.test1", asMsgHandler(d.handleEC2StartStoppedInstance), testAccountID, body) assert.Equal(t, awserrors.ErrorServerInternal, decodeError(t, reply.Data)["Code"]) } @@ -99,7 +99,7 @@ func TestHandleEC2StartStoppedInstance_StateStoreNil(t *testing.T) { d := createTestDaemon(t, sharedNATSURL) // d.stateStore intentionally left nil. - body, _ := json.Marshal(handlers_ec2_instance.StartStoppedInstanceInput{InstanceID: "i-no-store"}) + body, _ := json.Marshal(ec2instance.StartStoppedInstanceInput{InstanceID: "i-no-store"}) reply := requestHandler(t, d.natsConn, "ec2.start.test2", asMsgHandler(d.handleEC2StartStoppedInstance), testAccountID, body) assert.Equal(t, awserrors.ErrorServerInternal, decodeError(t, reply.Data)["Code"]) } @@ -109,7 +109,7 @@ func TestHandleEC2StartStoppedInstance_CrossTenantRejected(t *testing.T) { store.Stopped["i-foreign"] = stoppedVMFixture("i-foreign", "999988887777") d := daemonWithFakeStateStore(t, store) - body, _ := json.Marshal(handlers_ec2_instance.StartStoppedInstanceInput{InstanceID: "i-foreign"}) + body, _ := json.Marshal(ec2instance.StartStoppedInstanceInput{InstanceID: "i-foreign"}) reply := requestHandler(t, d.natsConn, "ec2.start.test3", asMsgHandler(d.handleEC2StartStoppedInstance), testAccountID, body) assert.Equal(t, awserrors.ErrorInvalidInstanceIDNotFound, decodeError(t, reply.Data)["Code"]) @@ -126,7 +126,7 @@ func TestHandleEC2StartStoppedInstance_InstanceTypeUnknown(t *testing.T) { store.Stopped[v.ID] = v d := daemonWithFakeStateStore(t, store) - body, _ := json.Marshal(handlers_ec2_instance.StartStoppedInstanceInput{InstanceID: v.ID}) + body, _ := json.Marshal(ec2instance.StartStoppedInstanceInput{InstanceID: v.ID}) reply := requestHandler(t, d.natsConn, "ec2.start.test4", asMsgHandler(d.handleEC2StartStoppedInstance), testAccountID, body) assert.Equal(t, awserrors.ErrorInsufficientInstanceCapacity, decodeError(t, reply.Data)["Code"]) } @@ -165,7 +165,7 @@ func TestHandleEC2StartStoppedInstance_ForwardTimeoutFallsBackLocally(t *testing require.NoError(t, err) t.Cleanup(func() { _ = silentSub.Unsubscribe() }) - body, _ := json.Marshal(handlers_ec2_instance.StartStoppedInstanceInput{InstanceID: v.ID}) + body, _ := json.Marshal(ec2instance.StartStoppedInstanceInput{InstanceID: v.ID}) reply := requestHandler(t, d.natsConn, "ec2.start.test5", asMsgHandler(d.handleEC2StartStoppedInstance), testAccountID, body) assert.Equal(t, awserrors.ErrorInsufficientInstanceCapacity, decodeError(t, reply.Data)["Code"], "a forward timeout must fall back to a local start attempt, not a bare ServerInternal") @@ -197,7 +197,7 @@ func TestHandleEC2StartStoppedInstance_ForwardTimeoutAfterRemoteClaim_NoDoubleSt require.NoError(t, err) t.Cleanup(func() { _ = claimingSub.Unsubscribe() }) - body, _ := json.Marshal(handlers_ec2_instance.StartStoppedInstanceInput{InstanceID: v.ID}) + body, _ := json.Marshal(ec2instance.StartStoppedInstanceInput{InstanceID: v.ID}) reply := requestHandler(t, d.natsConn, "ec2.start.test6", asMsgHandler(d.handleEC2StartStoppedInstance), testAccountID, body) assert.Equal(t, awserrors.ErrorInvalidInstanceIDNotFound, decodeError(t, reply.Data)["Code"], @@ -213,7 +213,7 @@ func TestHandleEC2TerminateStoppedInstance_LoadError(t *testing.T) { store.LoadStoppedErr = errors.New("kv unavailable") d := daemonWithFakeStateStore(t, store) - body, _ := json.Marshal(handlers_ec2_instance.TerminateStoppedInstanceInput{InstanceID: "i-load-fail"}) + body, _ := json.Marshal(ec2instance.TerminateStoppedInstanceInput{InstanceID: "i-load-fail"}) reply := requestHandler(t, d.natsConn, "ec2.terminate.test1", asMsgHandler(handleNATSRequest(d.node, d.instanceService.TerminateStoppedInstance)), testAccountID, body) assert.Equal(t, awserrors.ErrorServerInternal, decodeError(t, reply.Data)["Code"]) } @@ -221,7 +221,7 @@ func TestHandleEC2TerminateStoppedInstance_LoadError(t *testing.T) { func TestHandleEC2TerminateStoppedInstance_StateStoreNil(t *testing.T) { d := createTestDaemon(t, sharedNATSURL) - body, _ := json.Marshal(handlers_ec2_instance.TerminateStoppedInstanceInput{InstanceID: "i-no-store"}) + body, _ := json.Marshal(ec2instance.TerminateStoppedInstanceInput{InstanceID: "i-no-store"}) reply := requestHandler(t, d.natsConn, "ec2.terminate.test2", asMsgHandler(handleNATSRequest(d.node, d.instanceService.TerminateStoppedInstance)), testAccountID, body) assert.Equal(t, awserrors.ErrorServerInternal, decodeError(t, reply.Data)["Code"]) } @@ -235,7 +235,7 @@ func TestHandleEC2TerminateStoppedInstance_WriteTerminatedFailureAborts(t *testi store.Stopped[v.ID] = v d := daemonWithFakeStateStore(t, store) - body, _ := json.Marshal(handlers_ec2_instance.TerminateStoppedInstanceInput{InstanceID: v.ID}) + body, _ := json.Marshal(ec2instance.TerminateStoppedInstanceInput{InstanceID: v.ID}) reply := requestHandler(t, d.natsConn, "ec2.terminate.test3", asMsgHandler(handleNATSRequest(d.node, d.instanceService.TerminateStoppedInstance)), testAccountID, body) assert.Equal(t, awserrors.ErrorServerInternal, decodeError(t, reply.Data)["Code"]) @@ -256,7 +256,7 @@ func TestHandleEC2TerminateStoppedInstance_DeleteRetrySucceeds(t *testing.T) { store.Stopped[v.ID] = v d := daemonWithFakeStateStore(t, store) - body, _ := json.Marshal(handlers_ec2_instance.TerminateStoppedInstanceInput{InstanceID: v.ID}) + body, _ := json.Marshal(ec2instance.TerminateStoppedInstanceInput{InstanceID: v.ID}) reply := requestHandler(t, d.natsConn, "ec2.terminate.test4", asMsgHandler(handleNATSRequest(d.node, d.instanceService.TerminateStoppedInstance)), testAccountID, body) var resp map[string]string @@ -281,7 +281,7 @@ func TestHandleEC2TerminateStoppedInstance_DeleteAlwaysFailsKeepsTerminated(t *t store.Stopped[v.ID] = v d := daemonWithFakeStateStore(t, store) - body, _ := json.Marshal(handlers_ec2_instance.TerminateStoppedInstanceInput{InstanceID: v.ID}) + body, _ := json.Marshal(ec2instance.TerminateStoppedInstanceInput{InstanceID: v.ID}) reply := requestHandler(t, d.natsConn, "ec2.terminate.test5", asMsgHandler(handleNATSRequest(d.node, d.instanceService.TerminateStoppedInstance)), testAccountID, body) var resp map[string]string @@ -297,7 +297,7 @@ func TestHandleEC2TerminateStoppedInstance_CrossTenantRejected(t *testing.T) { store.Stopped["i-foreign-term"] = stoppedVMFixture("i-foreign-term", "999988887777") d := daemonWithFakeStateStore(t, store) - body, _ := json.Marshal(handlers_ec2_instance.TerminateStoppedInstanceInput{InstanceID: "i-foreign-term"}) + body, _ := json.Marshal(ec2instance.TerminateStoppedInstanceInput{InstanceID: "i-foreign-term"}) reply := requestHandler(t, d.natsConn, "ec2.terminate.test6", asMsgHandler(handleNATSRequest(d.node, d.instanceService.TerminateStoppedInstance)), testAccountID, body) assert.Equal(t, awserrors.ErrorInvalidInstanceIDNotFound, decodeError(t, reply.Data)["Code"]) diff --git a/spinifex/daemon/daemon_handlers_monitoring_test.go b/spinifex/daemon/daemon_handlers_monitoring_test.go index d46e251e7..deb266406 100644 --- a/spinifex/daemon/daemon_handlers_monitoring_test.go +++ b/spinifex/daemon/daemon_handlers_monitoring_test.go @@ -10,8 +10,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" vmmock "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm/mock" @@ -26,7 +26,7 @@ func monitoringTestDaemon(t *testing.T, instanceID string, enabled bool) (*Daemo d := createTestDaemon(t, sharedNATSURL) stopped := vmmock.New() - d.instanceService = handlers_ec2_instance.NewInstanceServiceImpl( + d.instanceService = ec2instance.NewInstanceServiceImpl( d.config, d.resourceMgr.instanceTypes, d.natsConn, objectstore.NewMemoryObjectStore(), d.vmMgr, d.resourceMgr, stopped) diff --git a/spinifex/daemon/daemon_handlers_test.go b/spinifex/daemon/daemon_handlers_test.go index c932f6bf4..23ae61bf1 100644 --- a/spinifex/daemon/daemon_handlers_test.go +++ b/spinifex/daemon/daemon_handlers_test.go @@ -28,17 +28,17 @@ import ( ec2eigw "github.com/mulgadc/spinifex/spinifex/domains/ec2/eigw" ec2eip "github.com/mulgadc/spinifex/spinifex/domains/ec2/eip" ec2igw "github.com/mulgadc/spinifex/spinifex/domains/ec2/igw" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" ec2key "github.com/mulgadc/spinifex/spinifex/domains/ec2/key" ec2placementgroup "github.com/mulgadc/spinifex/spinifex/domains/ec2/placementgroup" ec2routetable "github.com/mulgadc/spinifex/spinifex/domains/ec2/routetable" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" + ec2tags "github.com/mulgadc/spinifex/spinifex/domains/ec2/tags" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" ec2vpc "github.com/mulgadc/spinifex/spinifex/domains/ec2/vpc" "github.com/mulgadc/spinifex/spinifex/domains/network/external" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" - handlers_ec2_tags "github.com/mulgadc/spinifex/spinifex/handlers/ec2/tags" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/mulgadc/spinifex/spinifex/runtime/compute/qmp" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" @@ -60,7 +60,7 @@ func testTagsKV(t *testing.T) jetstream.KeyValue { t.Helper() _, nc, _ := testutil.StartTestJetStream(t) js := testutil.NewJetStream(t, nc) - kv, err := handlers_ec2_tags.GetOrCreateTagsBucket(t.Context(), js) + kv, err := ec2tags.GetOrCreateTagsBucket(t.Context(), js) require.NoError(t, err) return kv } @@ -82,10 +82,10 @@ func createFullTestDaemonWithStore(t *testing.T, natsURL string) (*Daemon, *obje cfg := daemon.config daemon.keyService = ec2key.NewKeyServiceImplWithStore(memStore, cfg.Predastore.Bucket) - daemon.imageService = handlers_ec2_image.NewImageServiceImplWithStore(memStore, cfg.Predastore.Bucket) - daemon.volumeService = handlers_ec2_volume.NewVolumeServiceImplWithStore(cfg, memStore, daemon.natsConn) - daemon.snapshotService = handlers_ec2_snapshot.NewSnapshotServiceImplWithStore(cfg, memStore, daemon.natsConn) - daemon.tagsService = handlers_ec2_tags.NewTagsServiceImplWithStore(cfg, memStore, testTagsKV(t)) + daemon.imageService = ec2image.NewImageServiceImplWithStore(memStore, cfg.Predastore.Bucket) + daemon.volumeService = ec2volume.NewVolumeServiceImplWithStore(cfg, memStore, daemon.natsConn) + daemon.snapshotService = ec2snapshot.NewSnapshotServiceImplWithStore(cfg, memStore, daemon.natsConn) + daemon.tagsService = ec2tags.NewTagsServiceImplWithStore(cfg, memStore, testTagsKV(t)) wireTestEBSProvider(daemon, memStore) initAccountServiceForTest(t, daemon) @@ -144,7 +144,7 @@ func createFullTestDaemonWithJetStream(t *testing.T, natsURL string) *Daemon { // Re-bind the instance service so describe-stopped/terminated handlers see // the KV that was just initialised. - daemon.instanceService = handlers_ec2_instance.NewInstanceServiceImpl( + daemon.instanceService = ec2instance.NewInstanceServiceImpl( daemon.config, daemon.resourceMgr.instanceTypes, daemon.natsConn, objectstore.NewMemoryObjectStore(), daemon.vmMgr, daemon.resourceMgr, daemon.jsManager, @@ -551,7 +551,7 @@ func TestHandleEC2RunInstances_ServiceErrorPropagated(t *testing.T) { // The resourceMgr still has instance types, so the daemon-level check passes, // but RunInstance() will fail with ErrorInvalidInstanceType. emptyTypes := map[string]*ec2.InstanceTypeInfo{} - daemon.instanceService = handlers_ec2_instance.NewInstanceServiceImpl( + daemon.instanceService = ec2instance.NewInstanceServiceImpl( daemon.config, emptyTypes, daemon.natsConn, objectstore.NewMemoryObjectStore(), daemon.vmMgr, daemon.resourceMgr, nil, @@ -591,7 +591,7 @@ func runInstancesAndCheckENISGs(t *testing.T, mutator func(input *ec2.RunInstanc memStore := objectstore.NewMemoryObjectStore() bucket := daemon.config.Predastore.Bucket - daemon.imageService = handlers_ec2_image.NewImageServiceImplWithStore(memStore, bucket) + daemon.imageService = ec2image.NewImageServiceImplWithStore(memStore, bucket) daemon.keyService = ec2key.NewKeyServiceImplWithStore(memStore, bucket) seedTestAMI(t, memStore, bucket, "ami-sgprop") daemon.instanceService.SetRunInstancesDeps(daemon.imageService, daemon.keyService, &daemonENICreator{d: daemon}, nil) @@ -1380,7 +1380,7 @@ func TestHandleEC2DescribeStoppedInstances_WithFilter(t *testing.T) { // --- handleEC2TerminateStoppedInstance wrapper smoke test --- // // Detailed logic coverage lives in -// handlers/ec2/instance/service_impl_test.go (TestTerminateStoppedInstance_*). +// domains/ec2/instance/service_impl_test.go (TestTerminateStoppedInstance_*). // The wrapper smoke case is TestHandleEC2TerminateStoppedInstance_WritesToTerminatedKV // further below; it confirms the NATS → handleNATSRequest → service round-trip // stays intact end-to-end against real JetStream KV. @@ -1550,7 +1550,7 @@ func TestAttachVolume_ZoneMismatch(t *testing.T) { // --- handleEC2ModifyInstanceAttribute wrapper smoke test --- // // Detailed logic coverage lives in -// handlers/ec2/instance/service_impl_test.go (TestModifyInstanceAttribute_*). +// domains/ec2/instance/service_impl_test.go (TestModifyInstanceAttribute_*). // This case keeps one end-to-end NATS → handleNATSRequest → service round-trip // to confirm the daemon wiring stays intact. @@ -2007,7 +2007,7 @@ func TestDelegateHandlers_RoundTrip(t *testing.T) { // DeleteTags' no-owner path falls back to the shared stopped store; give // the service an empty one so an absent instance resolves to NotFound. - daemon.instanceService = handlers_ec2_instance.NewInstanceServiceImpl( + daemon.instanceService = ec2instance.NewInstanceServiceImpl( daemon.config, daemon.resourceMgr.instanceTypes, daemon.natsConn, objectstore.NewMemoryObjectStore(), daemon.vmMgr, daemon.resourceMgr, vmmock.New()) @@ -3483,7 +3483,7 @@ func TestHandleEC2TerminateStoppedInstance_WritesToTerminatedKV(t *testing.T) { require.NoError(t, err) defer sub.Unsubscribe() - reqData, _ := json.Marshal(handlers_ec2_instance.TerminateStoppedInstanceInput{InstanceID: stoppedVM.ID}) + reqData, _ := json.Marshal(ec2instance.TerminateStoppedInstanceInput{InstanceID: stoppedVM.ID}) reply, err := natsRequest(daemon.natsConn, "ec2.terminate", reqData, 30*time.Second) require.NoError(t, err) assert.Contains(t, string(reply.Data), "terminated") diff --git a/spinifex/daemon/daemon_handlers_volume.go b/spinifex/daemon/daemon_handlers_volume.go index b4a0678b2..581e7bd2b 100644 --- a/spinifex/daemon/daemon_handlers_volume.go +++ b/spinifex/daemon/daemon_handlers_volume.go @@ -11,8 +11,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/mulgadc/spinifex/contracts/ec2/v1" viperblocklegacyv1 "github.com/mulgadc/spinifex/contracts/viperblockd/legacy/v1" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" "github.com/nats-io/nats.go" ) @@ -174,7 +174,7 @@ func (d *Daemon) handleDrainVolume(ctx context.Context, msg *nats.Msg, command e // A missing or unresponsive socket under a running instance means the writes // cannot be made current, so the caller must fail its snapshot rather than // read a stale checkpoint. - if err = handlers_ec2_snapshot.DrainVolumeSocket(d.config.DataDir, volumeID); err != nil { + if err = ec2snapshot.DrainVolumeSocket(d.config.DataDir, volumeID); err != nil { slog.ErrorContext(ctx, "DrainVolume: drain failed", "volumeId", volumeID, "instanceId", command.ID, "err", err) return respondErrorOutcome(d.node, msg, awserrors.ErrorServerInternal) } diff --git a/spinifex/daemon/daemon_system_instance.go b/spinifex/daemon/daemon_system_instance.go index 54f797bf5..556fa2e66 100644 --- a/spinifex/daemon/daemon_system_instance.go +++ b/spinifex/daemon/daemon_system_instance.go @@ -139,7 +139,7 @@ func (d *Daemon) LaunchSystemInstance(input *handlers_elbv2.SystemInstanceInput) instance.Reservation.SetReservationId(awsidentifiers.GenerateResourceID("r")) instance.Reservation.SetOwnerId(accountID) instance.Reservation.Instances = []*ec2.Instance{ec2Instance} - // Mirror the customer-instance path (handlers/ec2/instance/service_impl.go:334) + // Mirror the customer-instance path (domains/ec2/instance/service_impl.go:334) // so consumers reading instance.Instance (e.g. onInstanceUpHook's NAT // republish, device_map, volumes) see the same metadata for system VMs. instance.Instance = ec2Instance diff --git a/spinifex/daemon/daemon_test.go b/spinifex/daemon/daemon_test.go index c3fdbbcfd..cf52b0699 100644 --- a/spinifex/daemon/daemon_test.go +++ b/spinifex/daemon/daemon_test.go @@ -38,17 +38,17 @@ import ( ec2eigw "github.com/mulgadc/spinifex/spinifex/domains/ec2/eigw" ec2eip "github.com/mulgadc/spinifex/spinifex/domains/ec2/eip" ec2igw "github.com/mulgadc/spinifex/spinifex/domains/ec2/igw" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/domains/ec2/instancetypes" ec2natgw "github.com/mulgadc/spinifex/spinifex/domains/ec2/natgw" ec2placementgroup "github.com/mulgadc/spinifex/spinifex/domains/ec2/placementgroup" ec2routetable "github.com/mulgadc/spinifex/spinifex/domains/ec2/routetable" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" ec2spotinstance "github.com/mulgadc/spinifex/spinifex/domains/ec2/spotinstance" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" ec2vpc "github.com/mulgadc/spinifex/spinifex/domains/ec2/vpc" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" handlers_elbv2 "github.com/mulgadc/spinifex/spinifex/handlers/elbv2" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/mulgadc/spinifex/spinifex/runtime/compute/gpu" @@ -131,8 +131,8 @@ func createTestDaemon(t *testing.T, natsURL string) *Daemon { // jsManager is nil here; pass a nil literal to keep the StoppedInstanceStore // interface itself nil (rather than a typed-nil pointer) so the service can // short-circuit cleanly when no KV is available. - daemon.instanceService = handlers_ec2_instance.NewInstanceServiceImpl(cfg, daemon.resourceMgr.instanceTypes, nc, objectstore.NewMemoryObjectStore(), daemon.vmMgr, daemon.resourceMgr, nil) - daemon.volumeService = handlers_ec2_volume.NewVolumeServiceImplWithStore(cfg, objectstore.NewMemoryObjectStore(), nc) + daemon.instanceService = ec2instance.NewInstanceServiceImpl(cfg, daemon.resourceMgr.instanceTypes, nc, objectstore.NewMemoryObjectStore(), daemon.vmMgr, daemon.resourceMgr, nil) + daemon.volumeService = ec2volume.NewVolumeServiceImplWithStore(cfg, objectstore.NewMemoryObjectStore(), nc) // Wire the minimum vm.Deps that handler tests rely on. Lifecycle (Run/Start/ // Stop/Terminate) tests still set up their own deps; this gives the @@ -1571,7 +1571,7 @@ func TestInstanceCleanerAdapter_DeleteVolumes_BootVolumeDeletedAfterAttachmentCl Bucket: "snap-kv-" + strings.ReplaceAll(t.Name(), "/", "-"), }) require.NoError(t, err) - daemon.volumeService = handlers_ec2_volume.NewVolumeServiceImplWithStore(daemon.config, store, daemon.natsConn, snapKV) + daemon.volumeService = ec2volume.NewVolumeServiceImplWithStore(daemon.config, store, daemon.natsConn, snapKV) daemon.volumeService.SetEBSProvider(daemon.ebsProvider) volumeID := "vol-root-attached" @@ -1684,7 +1684,7 @@ func TestInstanceCleanerAdapter_DeleteVolumes_NonBootNonDoTVolumeDetachedNotDele // TestTerminatedTeardownReaper_SelfHealsFailedVolumeTeardown proves the // go-forward self-heal: a stopped-terminate that stamped // Teardown[volumes]=failed on a transient error (deleteInstanceVolumes, -// handlers/ec2/instance/service_impl.go) is retried by +// domains/ec2/instance/service_impl.go) is retried by // TerminatedTeardownReaper.Sweep (vm/teardown_reaper.go) through the real // instanceCleanerAdapter, which stage 1 rerouted through // DeleteVolumeOnTerminate. The retry clears the stale attachment, the delete @@ -1706,7 +1706,7 @@ func TestTerminatedTeardownReaper_SelfHealsFailedVolumeTeardown(t *testing.T) { Bucket: "snap-kv-" + strings.ReplaceAll(t.Name(), "/", "-"), }) require.NoError(t, err) - daemon.volumeService = handlers_ec2_volume.NewVolumeServiceImplWithStore(daemon.config, store, daemon.natsConn, snapKV) + daemon.volumeService = ec2volume.NewVolumeServiceImplWithStore(daemon.config, store, daemon.natsConn, snapKV) daemon.volumeService.SetEBSProvider(daemon.ebsProvider) volumeID := "vol-root-self-heal" @@ -4508,10 +4508,10 @@ func TestAssertNoClusterServicesInitialised_PerField(t *testing.T) { cases := []fieldCase{ {name: "natsConn", set: func(d *Daemon) { d.natsConn = &nats.Conn{} }, wantMsg: "natsConn"}, {name: "jsManager", set: func(d *Daemon) { d.jsManager = &JetStreamManager{} }, wantMsg: "jsManager"}, - {name: "instanceService", set: func(d *Daemon) { d.instanceService = &handlers_ec2_instance.InstanceServiceImpl{} }, wantMsg: "instanceService"}, - {name: "imageService", set: func(d *Daemon) { d.imageService = &handlers_ec2_image.ImageServiceImpl{} }, wantMsg: "imageService"}, - {name: "snapshotService", set: func(d *Daemon) { d.snapshotService = &handlers_ec2_snapshot.SnapshotServiceImpl{} }, wantMsg: "snapshotService"}, - {name: "volumeService", set: func(d *Daemon) { d.volumeService = &handlers_ec2_volume.VolumeServiceImpl{} }, wantMsg: "volumeService"}, + {name: "instanceService", set: func(d *Daemon) { d.instanceService = &ec2instance.InstanceServiceImpl{} }, wantMsg: "instanceService"}, + {name: "imageService", set: func(d *Daemon) { d.imageService = &ec2image.ImageServiceImpl{} }, wantMsg: "imageService"}, + {name: "snapshotService", set: func(d *Daemon) { d.snapshotService = &ec2snapshot.SnapshotServiceImpl{} }, wantMsg: "snapshotService"}, + {name: "volumeService", set: func(d *Daemon) { d.volumeService = &ec2volume.VolumeServiceImpl{} }, wantMsg: "volumeService"}, {name: "eigwService", set: func(d *Daemon) { d.eigwService = &ec2eigw.EgressOnlyIGWServiceImpl{} }, wantMsg: "eigwService"}, {name: "igwService", set: func(d *Daemon) { d.igwService = &ec2igw.IGWServiceImpl{} }, wantMsg: "igwService"}, {name: "placementGroupService", set: func(d *Daemon) { d.placementGroupService = &ec2placementgroup.PlacementGroupServiceImpl{} }, wantMsg: "placementGroupService"}, @@ -4562,10 +4562,10 @@ func newEBSProviderTestDaemon(t *testing.T, provider string) *Daemon { config: cfg, natsConn: nc, jsManager: jsManager, - instanceService: &handlers_ec2_instance.InstanceServiceImpl{}, - imageService: handlers_ec2_image.NewImageServiceImplWithStore(store, cfg.Predastore.Bucket), - snapshotService: handlers_ec2_snapshot.NewSnapshotServiceImplWithStore(cfg, store, nc), - volumeService: handlers_ec2_volume.NewVolumeServiceImplWithStore(cfg, store, nc), + instanceService: &ec2instance.InstanceServiceImpl{}, + imageService: ec2image.NewImageServiceImplWithStore(store, cfg.Predastore.Bucket), + snapshotService: ec2snapshot.NewSnapshotServiceImplWithStore(cfg, store, nc), + volumeService: ec2volume.NewVolumeServiceImplWithStore(cfg, store, nc), } } diff --git a/spinifex/daemon/eks_worker_launch.go b/spinifex/daemon/eks_worker_launch.go index 6bd89f990..daa37d070 100644 --- a/spinifex/daemon/eks_worker_launch.go +++ b/spinifex/daemon/eks_worker_launch.go @@ -13,8 +13,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mulgadc/spinifex/contracts/ec2/v1" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" handlers_eks "github.com/mulgadc/spinifex/spinifex/handlers/eks" "github.com/nats-io/nats.go" ) @@ -147,7 +147,7 @@ func (d *Daemon) terminateWorkerInstance(ctx context.Context, instanceID, accoun // NotFound payload — or no responder at all — means the instance is already // gone, which a retried teardown treats as idempotent success. func (d *Daemon) terminateStoppedWorker(ctx context.Context, instanceID, accountID string) error { - req, err := json.Marshal(handlers_ec2_instance.TerminateStoppedInstanceInput{InstanceID: instanceID}) + req, err := json.Marshal(ec2instance.TerminateStoppedInstanceInput{InstanceID: instanceID}) if err != nil { return fmt.Errorf("marshal stopped-terminate request: %w", err) } diff --git a/spinifex/daemon/eks_worker_launch_test.go b/spinifex/daemon/eks_worker_launch_test.go index 9c916d927..070f36219 100644 --- a/spinifex/daemon/eks_worker_launch_test.go +++ b/spinifex/daemon/eks_worker_launch_test.go @@ -9,8 +9,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mulgadc/spinifex/contracts/ec2/v1" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" "github.com/nats-io/nats.go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -122,7 +122,7 @@ func TestTerminateWorkerInstances_StoppedFallbackToEC2Terminate(t *testing.T) { gotID := make(chan string, 1) sub, err := nc.Subscribe("ec2.terminate", func(msg *nats.Msg) { - var req handlers_ec2_instance.TerminateStoppedInstanceInput + var req ec2instance.TerminateStoppedInstanceInput _ = json.Unmarshal(msg.Data, &req) gotID <- req.InstanceID _ = msg.Respond([]byte(`{"status":"terminated"}`)) diff --git a/spinifex/daemon/gpu_adapter.go b/spinifex/daemon/gpu_adapter.go index c3c087527..6622fc6f2 100644 --- a/spinifex/daemon/gpu_adapter.go +++ b/spinifex/daemon/gpu_adapter.go @@ -4,18 +4,18 @@ import ( "errors" "fmt" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/runtime/compute/gpu" ) // daemonGPUClaimer adapts the daemon's gpu.Manager + GPUModelOverrides config to -// the transport-neutral handlers_ec2_instance.GPUClaimer surface. Keeps the gpu +// the transport-neutral ec2instance.GPUClaimer surface. Keeps the gpu // package out of the instance service. type daemonGPUClaimer struct { d *Daemon } -var _ handlers_ec2_instance.GPUClaimer = (*daemonGPUClaimer)(nil) +var _ ec2instance.GPUClaimer = (*daemonGPUClaimer)(nil) func (g *daemonGPUClaimer) manager() *gpu.Manager { g.d.mu.Lock() diff --git a/spinifex/daemon/instance_recovery.go b/spinifex/daemon/instance_recovery.go index 5e22e8edc..3f912bce2 100644 --- a/spinifex/daemon/instance_recovery.go +++ b/spinifex/daemon/instance_recovery.go @@ -10,9 +10,9 @@ import ( "slices" "time" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" "github.com/mulgadc/spinifex/spinifex/foundation/telemetry" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" "github.com/mulgadc/spinifex/spinifex/runtime/compute/cache" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" "go.opentelemetry.io/otel" @@ -301,7 +301,7 @@ func (f recoveryFault) stateReasonCode() string { // classifyRecoveryFault reads what the launch refused with. func classifyRecoveryFault(err error) recoveryFault { - if errors.Is(err, handlers_ec2_instance.ErrVolumeHeldElsewhere) { + if errors.Is(err, ec2instance.ErrVolumeHeldElsewhere) { return recoveryFaultLeaseHeld } if code, ok := awserrors.ResolveErrorCode(err); ok && code == awserrors.ErrorInsufficientInstanceCapacity { diff --git a/spinifex/daemon/instance_recovery_test.go b/spinifex/daemon/instance_recovery_test.go index 02ce2cf8f..579d995de 100644 --- a/spinifex/daemon/instance_recovery_test.go +++ b/spinifex/daemon/instance_recovery_test.go @@ -16,9 +16,9 @@ import ( "time" "github.com/mulgadc/spinifex/spinifex/bootstrap/config" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" "github.com/mulgadc/spinifex/spinifex/foundation/lifecycle/resource" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" "github.com/mulgadc/spinifex/spinifex/runtime/compute/cache" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" "github.com/stretchr/testify/assert" @@ -224,7 +224,7 @@ func TestWhatStopsTheLoopStarting(t *testing.T) { node: "node-1", clusterConfig: &config.ClusterConfig{Nodes: map[string]config.Config{"node-1": {}, "node-2": {}}}, jsManager: &JetStreamManager{}, - instanceService: &handlers_ec2_instance.InstanceServiceImpl{}, + instanceService: &ec2instance.InstanceServiceImpl{}, } }}, } @@ -374,7 +374,7 @@ func TestWhatTheLaunchRefusalMeansForTheNextAttempt(t *testing.T) { { name: "the old owner still holds the volume lease", err: fmt.Errorf("mount refused: %w", fmt.Errorf("%w: %w", - handlers_ec2_instance.ErrVolumeHeldElsewhere, + ec2instance.ErrVolumeHeldElsewhere, awserrors.Errorf(awserrors.ErrorIncorrectState, "volume is leased by another owner: node-1"))), want: recoveryFaultLeaseHeld, code: "Server.HostRecoveryFailed", diff --git a/spinifex/daemon/vpc_adapter.go b/spinifex/daemon/vpc_adapter.go index 97c8524a0..69d747a75 100644 --- a/spinifex/daemon/vpc_adapter.go +++ b/spinifex/daemon/vpc_adapter.go @@ -4,49 +4,49 @@ import ( "context" "github.com/aws/aws-sdk-go/service/ec2" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" ) // daemonENICreator adapts the daemon's VPCServiceImpl to the -// handlers_ec2_instance.ENICreator interface so RunInstances can stay free of +// ec2instance.ENICreator interface so RunInstances can stay free of // the wider VPC service surface. Returned subnet records are translated to -// handlers_ec2_instance.SubnetInfo to avoid a cyclic instance↔vpc import. +// ec2instance.SubnetInfo to avoid a cyclic instance↔vpc import. type daemonENICreator struct { d *Daemon } -var _ handlers_ec2_instance.ENICreator = (*daemonENICreator)(nil) +var _ ec2instance.ENICreator = (*daemonENICreator)(nil) -func (a *daemonENICreator) GetDefaultSubnet(_ context.Context, accountID string) (*handlers_ec2_instance.SubnetInfo, error) { +func (a *daemonENICreator) GetDefaultSubnet(_ context.Context, accountID string) (*ec2instance.SubnetInfo, error) { rec, err := a.d.vpcService.GetDefaultSubnet(accountID) if err != nil { return nil, err } - return &handlers_ec2_instance.SubnetInfo{ + return &ec2instance.SubnetInfo{ SubnetID: rec.SubnetId, VpcID: rec.VpcId, MapPublicIpOnLaunch: rec.MapPublicIpOnLaunch, }, nil } -func (a *daemonENICreator) GetSubnet(_ context.Context, accountID, subnetID string) (*handlers_ec2_instance.SubnetInfo, error) { +func (a *daemonENICreator) GetSubnet(_ context.Context, accountID, subnetID string) (*ec2instance.SubnetInfo, error) { rec, err := a.d.vpcService.GetSubnet(accountID, subnetID) if err != nil { return nil, err } - return &handlers_ec2_instance.SubnetInfo{ + return &ec2instance.SubnetInfo{ SubnetID: rec.SubnetId, VpcID: rec.VpcId, MapPublicIpOnLaunch: rec.MapPublicIpOnLaunch, }, nil } -func (a *daemonENICreator) GetENI(_ context.Context, accountID, eniID string) (*handlers_ec2_instance.ENIInfo, error) { +func (a *daemonENICreator) GetENI(_ context.Context, accountID, eniID string) (*ec2instance.ENIInfo, error) { rec, err := a.d.vpcService.GetENIRecord(accountID, eniID) if err != nil { return nil, err } - return &handlers_ec2_instance.ENIInfo{ + return &ec2instance.ENIInfo{ NetworkInterfaceID: rec.NetworkInterfaceId, SubnetID: rec.SubnetId, VpcID: rec.VpcId, @@ -81,14 +81,14 @@ func (a *daemonENICreator) ENIHasEIP(ctx context.Context, accountID, eniID strin return a.d.vpcService.ENIHasEIP(ctx, accountID, eniID) } -func (a *daemonENICreator) ListInstanceENIs(_ context.Context, accountID, instanceID string) ([]handlers_ec2_instance.ENIInfo, error) { +func (a *daemonENICreator) ListInstanceENIs(_ context.Context, accountID, instanceID string) ([]ec2instance.ENIInfo, error) { records, err := a.d.vpcService.ListInstanceENIs(accountID, instanceID) if err != nil { return nil, err } - out := make([]handlers_ec2_instance.ENIInfo, 0, len(records)) + out := make([]ec2instance.ENIInfo, 0, len(records)) for _, rec := range records { - out = append(out, handlers_ec2_instance.ENIInfo{ + out = append(out, ec2instance.ENIInfo{ NetworkInterfaceID: rec.NetworkInterfaceId, SubnetID: rec.SubnetId, VpcID: rec.VpcId, diff --git a/spinifex/domains/ec2/guestmetadata/instance_lookup.go b/spinifex/domains/ec2/guestmetadata/instance_lookup.go index 77b318d10..aa5334e4d 100644 --- a/spinifex/domains/ec2/guestmetadata/instance_lookup.go +++ b/spinifex/domains/ec2/guestmetadata/instance_lookup.go @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" ) @@ -80,7 +80,7 @@ func (l *localInstanceLookup) describe(ctx context.Context, accountID, instanceI return nil, err } } - if v == nil || !handlers_ec2_instance.IsInstanceVisibleToCaller(accountID, v) { + if v == nil || !ec2instance.IsInstanceVisibleToCaller(accountID, v) { return nil, nil // not present, or not visible to the caller } return instanceFactsFromVM(v), nil diff --git a/spinifex/handlers/ec2/image/ami_source_volume_test.go b/spinifex/domains/ec2/image/ami_source_volume_test.go similarity index 99% rename from spinifex/handlers/ec2/image/ami_source_volume_test.go rename to spinifex/domains/ec2/image/ami_source_volume_test.go index 4d672135c..82555ffe3 100644 --- a/spinifex/handlers/ec2/image/ami_source_volume_test.go +++ b/spinifex/domains/ec2/image/ami_source_volume_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" diff --git a/spinifex/handlers/ec2/image/deregister_legacy_config_test.go b/spinifex/domains/ec2/image/deregister_legacy_config_test.go similarity index 98% rename from spinifex/handlers/ec2/image/deregister_legacy_config_test.go rename to spinifex/domains/ec2/image/deregister_legacy_config_test.go index 75c6169f0..b1e3c8797 100644 --- a/spinifex/handlers/ec2/image/deregister_legacy_config_test.go +++ b/spinifex/domains/ec2/image/deregister_legacy_config_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" diff --git a/spinifex/handlers/ec2/image/describe_byid_test.go b/spinifex/domains/ec2/image/describe_byid_test.go similarity index 93% rename from spinifex/handlers/ec2/image/describe_byid_test.go rename to spinifex/domains/ec2/image/describe_byid_test.go index 81baf74e6..930e73051 100644 --- a/spinifex/handlers/ec2/image/describe_byid_test.go +++ b/spinifex/domains/ec2/image/describe_byid_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_image_test +package image_test import ( "context" @@ -14,8 +14,8 @@ import ( "github.com/aws/aws-sdk-go/service/s3" "github.com/mulgadc/spinifex/internal/testkit/recordingstore" "github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/metadata" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -68,7 +68,7 @@ func TestDescribeImagesByID_ReadsOnlyTheNamedDocument(t *testing.T) { for _, catalog := range []int{1, 500} { t.Run("catalog"+strconv.Itoa(catalog), func(t *testing.T) { store := recordingstore.New() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) putByIDAMI(t, store, byIDAMIDoc(byIDImage, byIDAccount)) seedByIDCatalog(t, store, catalog) @@ -90,7 +90,7 @@ func TestDescribeImagesByID_ReadsOnlyTheNamedDocument(t *testing.T) { // matched each document once however often the request named it. func TestDescribeImagesByID_MultipleAndDuplicateIDs(t *testing.T) { store := recordingstore.New() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) putByIDAMI(t, store, byIDAMIDoc("ami-a", byIDAccount)) putByIDAMI(t, store, byIDAMIDoc("ami-b", byIDAccount)) @@ -125,7 +125,7 @@ func TestDescribeImagesByID_HiddenAndMissingAreIndistinguishable(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { store := recordingstore.New() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) if tt.seedImage { putByIDAMI(t, store, byIDAMIDoc(byIDImage, tt.seedOwner)) } @@ -146,7 +146,7 @@ func TestDescribeImagesByID_HiddenAndMissingAreIndistinguishable(t *testing.T) { // account before any owner comparison and stays visible to every tenant. func TestDescribeImagesByID_SystemAMIIsVisibleToEveryAccount(t *testing.T) { store := recordingstore.New() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) putByIDAMI(t, store, byIDAMIDoc(byIDImage, "amazon")) out, err := svc.DescribeImages(t.Context(), &ec2.DescribeImagesInput{ @@ -175,7 +175,7 @@ func TestDescribeImagesByID_SystemAMIRendersPublicAmazon(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { store := recordingstore.New() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) putByIDAMI(t, store, byIDAMIDoc(byIDImage, tt.ownerAlias)) out, err := svc.DescribeImages(t.Context(), &ec2.DescribeImagesInput{ @@ -217,7 +217,7 @@ func TestDescribeImagesByID_OwnerFilters(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { store := recordingstore.New() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) putByIDAMI(t, store, byIDAMIDoc(byIDImage, tt.ownerAlias)) out, err := svc.DescribeImages(t.Context(), &ec2.DescribeImagesInput{ @@ -257,7 +257,7 @@ func TestDescribeImagesByID_AttributeFilters(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { store := recordingstore.New() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) putByIDAMI(t, store, byIDAMIDoc(byIDImage, byIDAccount)) out, err := svc.DescribeImages(t.Context(), &ec2.DescribeImagesInput{ @@ -284,7 +284,7 @@ func TestDescribeImagesByID_AttributeFilters(t *testing.T) { // unreadable document fails the call instead of reporting it as absent. func TestDescribeImagesByID_CorruptDocumentFailsTheCall(t *testing.T) { store := recordingstore.New() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) _, err := store.PutObject(t.Context(), &s3.PutObjectInput{ Bucket: aws.String(byIDBucket), Key: aws.String(amiKey(t, byIDImage)), @@ -321,7 +321,7 @@ func (s *getFailingStore) GetObject(ctx context.Context, input *s3.GetObjectInpu func TestDescribeImagesByID_StoreErrorIsInternal(t *testing.T) { memory := objectstore.NewMemoryObjectStore() store := &getFailingStore{MemoryObjectStore: memory, failKey: amiKey(t, byIDImage)} - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) putByIDAMI(t, memory, byIDAMIDoc(byIDImage, byIDAccount)) _, err := svc.DescribeImages(t.Context(), &ec2.DescribeImagesInput{ @@ -338,7 +338,7 @@ func TestDescribeImagesByID_StoreErrorIsInternal(t *testing.T) { func TestDescribeImagesByID_StoreErrorOutranksAMissingID(t *testing.T) { memory := objectstore.NewMemoryObjectStore() store := &getFailingStore{MemoryObjectStore: memory, failKey: amiKey(t, byIDImage)} - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) putByIDAMI(t, memory, byIDAMIDoc(byIDImage, byIDAccount)) _, err := svc.DescribeImages(t.Context(), &ec2.DescribeImagesInput{ @@ -353,7 +353,7 @@ func TestDescribeImagesByID_StoreErrorOutranksAMissingID(t *testing.T) { // reads as "this image does not exist". func TestDescribeImagesByID_CancelledContextFails(t *testing.T) { store := recordingstore.New() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) putByIDAMI(t, store, byIDAMIDoc(byIDImage, byIDAccount)) ctx, cancel := context.WithCancel(t.Context()) cancel() @@ -371,7 +371,7 @@ func TestDescribeImagesByID_CancelledContextFails(t *testing.T) { // rather than a missing image, and reads nothing to find that out. func TestDescribeImagesByID_OnlyNilIDs(t *testing.T) { store := recordingstore.New() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, byIDBucket) + svc := ec2image.NewImageServiceImplWithStore(store, byIDBucket) putByIDAMI(t, store, byIDAMIDoc(byIDImage, byIDAccount)) out, err := svc.DescribeImages(t.Context(), &ec2.DescribeImagesInput{ImageIds: []*string{nil}}, byIDAccount) diff --git a/spinifex/handlers/ec2/image/drain_test.go b/spinifex/domains/ec2/image/drain_test.go similarity index 98% rename from spinifex/handlers/ec2/image/drain_test.go rename to spinifex/domains/ec2/image/drain_test.go index 9993b7b4c..b329add1f 100644 --- a/spinifex/handlers/ec2/image/drain_test.go +++ b/spinifex/domains/ec2/image/drain_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" @@ -21,7 +21,7 @@ import ( const drainImageInstanceID = "i-image-drain-host" -// setupDrainImageService mirrors handlers/ec2/snapshot's setupDrainService: a +// setupDrainImageService mirrors domains/ec2/snapshot's setupDrainService: a // reachable (but rejecting) Predastore host so a drained volume falls through // into the real snapshot path and fails fast, a data dir with no local drain // socket, and a NATS connection to route the drain to the hosting node. diff --git a/spinifex/handlers/ec2/image/provider_snapshot_test.go b/spinifex/domains/ec2/image/provider_snapshot_test.go similarity index 99% rename from spinifex/handlers/ec2/image/provider_snapshot_test.go rename to spinifex/domains/ec2/image/provider_snapshot_test.go index 59b77d301..6b9a11990 100644 --- a/spinifex/handlers/ec2/image/provider_snapshot_test.go +++ b/spinifex/domains/ec2/image/provider_snapshot_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" diff --git a/spinifex/handlers/ec2/image/provider_test.go b/spinifex/domains/ec2/image/provider_test.go similarity index 99% rename from spinifex/handlers/ec2/image/provider_test.go rename to spinifex/domains/ec2/image/provider_test.go index 6213cd290..d52c0c124 100644 --- a/spinifex/handlers/ec2/image/provider_test.go +++ b/spinifex/domains/ec2/image/provider_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" diff --git a/spinifex/handlers/ec2/image/service.go b/spinifex/domains/ec2/image/service.go similarity index 97% rename from spinifex/handlers/ec2/image/service.go rename to spinifex/domains/ec2/image/service.go index 774218f15..fe62ed14d 100644 --- a/spinifex/handlers/ec2/image/service.go +++ b/spinifex/domains/ec2/image/service.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" diff --git a/spinifex/handlers/ec2/image/service_impl.go b/spinifex/domains/ec2/image/service_impl.go similarity index 99% rename from spinifex/handlers/ec2/image/service_impl.go rename to spinifex/domains/ec2/image/service_impl.go index da1b02f29..d88c9441a 100644 --- a/spinifex/handlers/ec2/image/service_impl.go +++ b/spinifex/domains/ec2/image/service_impl.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" @@ -18,11 +18,11 @@ import ( "github.com/mulgadc/spinifex/spinifex/bootstrap/config" "github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/metadata" ec2platform "github.com/mulgadc/spinifex/spinifex/domains/ec2/platform" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" awsfilters "github.com/mulgadc/spinifex/spinifex/foundation/aws/filters" awsidentifiers "github.com/mulgadc/spinifex/spinifex/foundation/aws/identifiers" awstags "github.com/mulgadc/spinifex/spinifex/foundation/aws/tags" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/providers/ebs" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/mulgadc/spinifex/spinifex/utils" @@ -517,7 +517,7 @@ func (s *ImageServiceImpl) CreateImageFromInstance(params CreateImageParams, acc // snapshotRunningVolume creates a snapshot of a running instance's volume by // draining it to the node hosting it (so any writes buffered there reach S3), // then reading the live checkpoint written by nbdkit on every NBD Flush. This -// shares handlers/ec2/snapshot's DrainVolume with ec2.CreateSnapshot so the two +// shares domains/ec2/snapshot's DrainVolume with ec2.CreateSnapshot so the two // live-snapshot paths cannot diverge on when a drain is required. func (s *ImageServiceImpl) snapshotRunningVolume(volumeID, snapshotID, accountID string) error { if s.config == nil { @@ -535,7 +535,7 @@ func (s *ImageServiceImpl) snapshotRunningVolume(volumeID, snapshotID, accountID // predating e.g. a guest-triggered GPT rewrite (growpart on first boot). An // attached volume that cannot be drained fails here rather than silently // producing an image from a stale checkpoint. - if err := handlers_ec2_snapshot.DrainVolume(context.Background(), s.config, s.store, s.natsConn, volumeID, volMeta.State, volMeta.AttachedInstance, accountID); err != nil { + if err := ec2snapshot.DrainVolume(context.Background(), s.config, s.store, s.natsConn, volumeID, volMeta.State, volMeta.AttachedInstance, accountID); err != nil { slog.Error("snapshotRunningVolume: drain failed", "volumeId", volumeID, "err", err) return errors.New(awserrors.ErrorServerInternal) } diff --git a/spinifex/handlers/ec2/image/service_impl_encryption_test.go b/spinifex/domains/ec2/image/service_impl_encryption_test.go similarity index 98% rename from spinifex/handlers/ec2/image/service_impl_encryption_test.go rename to spinifex/domains/ec2/image/service_impl_encryption_test.go index 94fd40ed8..81a346ea1 100644 --- a/spinifex/handlers/ec2/image/service_impl_encryption_test.go +++ b/spinifex/domains/ec2/image/service_impl_encryption_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "crypto/rand" diff --git a/spinifex/handlers/ec2/image/service_impl_recordtags_test.go b/spinifex/domains/ec2/image/service_impl_recordtags_test.go similarity index 99% rename from spinifex/handlers/ec2/image/service_impl_recordtags_test.go rename to spinifex/domains/ec2/image/service_impl_recordtags_test.go index 4490da700..1929fab9c 100644 --- a/spinifex/handlers/ec2/image/service_impl_recordtags_test.go +++ b/spinifex/domains/ec2/image/service_impl_recordtags_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" diff --git a/spinifex/handlers/ec2/image/service_impl_test.go b/spinifex/domains/ec2/image/service_impl_test.go similarity index 99% rename from spinifex/handlers/ec2/image/service_impl_test.go rename to spinifex/domains/ec2/image/service_impl_test.go index 6222a67db..461cbc109 100644 --- a/spinifex/handlers/ec2/image/service_impl_test.go +++ b/spinifex/domains/ec2/image/service_impl_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" diff --git a/spinifex/handlers/ec2/image/service_nats.go b/spinifex/domains/ec2/image/service_nats.go similarity index 99% rename from spinifex/handlers/ec2/image/service_nats.go rename to spinifex/domains/ec2/image/service_nats.go index 621ff1ff9..4b4f4ad3b 100644 --- a/spinifex/handlers/ec2/image/service_nats.go +++ b/spinifex/domains/ec2/image/service_nats.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" diff --git a/spinifex/handlers/ec2/image/service_nats_test.go b/spinifex/domains/ec2/image/service_nats_test.go similarity index 98% rename from spinifex/handlers/ec2/image/service_nats_test.go rename to spinifex/domains/ec2/image/service_nats_test.go index c89cdba54..2a78a3551 100644 --- a/spinifex/handlers/ec2/image/service_nats_test.go +++ b/spinifex/domains/ec2/image/service_nats_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_image +package image import ( "context" diff --git a/spinifex/handlers/ec2/instance/data_volumes_test.go b/spinifex/domains/ec2/instance/data_volumes_test.go similarity index 87% rename from spinifex/handlers/ec2/instance/data_volumes_test.go rename to spinifex/domains/ec2/instance/data_volumes_test.go index 417d73bbd..c28f7652a 100644 --- a/spinifex/handlers/ec2/instance/data_volumes_test.go +++ b/spinifex/domains/ec2/instance/data_volumes_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance_test +package instance_test import ( "context" @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/mulgadc/bluebottle/pkg/safecast" "github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/metadata" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/providers/ebs" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" "github.com/stretchr/testify/assert" @@ -51,9 +51,9 @@ func (f *fakeVolumeCreator) DeleteVolume(_ context.Context, input *ec2.DeleteVol // dataVolumeService builds an instance service with a metadata store and the // fake creator wired in, which is all the data-volume path touches. -func dataVolumeService(t *testing.T, creator *fakeVolumeCreator) *handlers_ec2_instance.InstanceServiceImpl { +func dataVolumeService(t *testing.T, creator *fakeVolumeCreator) *ec2instance.InstanceServiceImpl { t.Helper() - svc := handlers_ec2_instance.NewProviderRootVolumeTestService(t) + svc := ec2instance.NewProviderRootVolumeTestService(t) creator.metadata = svc.MetadataStore() svc.SetVolumeCreator(creator) return svc @@ -80,7 +80,7 @@ func dataMappingInput(devices ...string) *ec2.RunInstancesInput { func TestPrepareDataVolumes_CreatesOnePerMapping(t *testing.T) { creator := &fakeVolumeCreator{} svc := dataVolumeService(t, creator) - instance := &vm.VM{AccountID: handlers_ec2_instance.TestRootAccount} + instance := &vm.VM{AccountID: ec2instance.TestRootAccount} infos, err := svc.PrepareDataVolumes(context.Background(), dataMappingInput("/dev/sdf", "/dev/sdg"), instance) require.NoError(t, err) @@ -91,7 +91,7 @@ func TestPrepareDataVolumes_CreatesOnePerMapping(t *testing.T) { require.Len(t, creator.created, 2) assert.Equal(t, int64(4), aws.Int64Value(creator.created[0].Size)) assert.Equal(t, int64(5), aws.Int64Value(creator.created[1].Size)) - assert.Equal(t, handlers_ec2_instance.TestRootAZ, aws.StringValue(creator.created[0].AvailabilityZone)) + assert.Equal(t, ec2instance.TestRootAZ, aws.StringValue(creator.created[0].AvailabilityZone)) require.Len(t, instance.EBSRequests.Requests, 2) for i, req := range instance.EBSRequests.Requests { @@ -105,7 +105,7 @@ func TestPrepareDataVolumes_CreatesOnePerMapping(t *testing.T) { func TestPrepareDataVolumes_NoMappingsCreatesNothing(t *testing.T) { creator := &fakeVolumeCreator{} svc := dataVolumeService(t, creator) - instance := &vm.VM{AccountID: handlers_ec2_instance.TestRootAccount} + instance := &vm.VM{AccountID: ec2instance.TestRootAccount} infos, err := svc.PrepareDataVolumes(context.Background(), dataMappingInput(), instance) require.NoError(t, err) @@ -119,7 +119,7 @@ func TestPrepareDataVolumes_NoMappingsCreatesNothing(t *testing.T) { func TestPrepareDataVolumes_UnwindsWhatItCreated(t *testing.T) { creator := &fakeVolumeCreator{failFrom: 1} svc := dataVolumeService(t, creator) - instance := &vm.VM{AccountID: handlers_ec2_instance.TestRootAccount} + instance := &vm.VM{AccountID: ec2instance.TestRootAccount} _, err := svc.PrepareDataVolumes(context.Background(), dataMappingInput("/dev/sdf", "/dev/sdg"), instance) require.Error(t, err) @@ -132,7 +132,7 @@ func TestPrepareDataVolumes_UnwindsWhatItCreated(t *testing.T) { func TestPrepareDataVolumes_RecordsDeleteOnTermination(t *testing.T) { creator := &fakeVolumeCreator{} svc := dataVolumeService(t, creator) - instance := &vm.VM{AccountID: handlers_ec2_instance.TestRootAccount} + instance := &vm.VM{AccountID: ec2instance.TestRootAccount} input := dataMappingInput("/dev/sdf") input.BlockDeviceMappings[1].Ebs.DeleteOnTermination = aws.Bool(false) @@ -143,16 +143,16 @@ func TestPrepareDataVolumes_RecordsDeleteOnTermination(t *testing.T) { require.Len(t, instance.EBSRequests.Requests, 1) assert.False(t, instance.EBSRequests.Requests[0].DeleteOnTermination) - doc, err := svc.MetadataStore().GetVolume(context.Background(), handlers_ec2_instance.TestRootAccount, infos[0].VolumeId) + doc, err := svc.MetadataStore().GetVolume(context.Background(), ec2instance.TestRootAccount, infos[0].VolumeId) require.NoError(t, err) assert.False(t, doc.DeleteOnTermination) kept := &fakeVolumeCreator{} keptSvc := dataVolumeService(t, kept) - keptInfos, err := keptSvc.PrepareDataVolumes(context.Background(), dataMappingInput("/dev/sdf"), &vm.VM{AccountID: handlers_ec2_instance.TestRootAccount}) + keptInfos, err := keptSvc.PrepareDataVolumes(context.Background(), dataMappingInput("/dev/sdf"), &vm.VM{AccountID: ec2instance.TestRootAccount}) require.NoError(t, err) require.Len(t, keptInfos, 1) - doc, err = keptSvc.MetadataStore().GetVolume(context.Background(), handlers_ec2_instance.TestRootAccount, keptInfos[0].VolumeId) + doc, err = keptSvc.MetadataStore().GetVolume(context.Background(), ec2instance.TestRootAccount, keptInfos[0].VolumeId) require.NoError(t, err) assert.True(t, doc.DeleteOnTermination) } @@ -166,7 +166,7 @@ func TestParseDataVolumeParams_SkipsRootAndEphemeral(t *testing.T) { {DeviceName: aws.String("/dev/sdb"), VirtualName: aws.String("ephemeral0")}, }, } - params := handlers_ec2_instance.ParseDataVolumeParams(input) + params := ec2instance.ParseDataVolumeParams(input) require.Len(t, params, 1) assert.Equal(t, "/dev/sdf", params[0].DeviceName) assert.Equal(t, int64(4), params[0].SizeGiB) diff --git a/spinifex/handlers/ec2/instance/export_test.go b/spinifex/domains/ec2/instance/export_test.go similarity index 98% rename from spinifex/handlers/ec2/instance/export_test.go rename to spinifex/domains/ec2/instance/export_test.go index cd9786761..30ce8b8a1 100644 --- a/spinifex/handlers/ec2/instance/export_test.go +++ b/spinifex/domains/ec2/instance/export_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/iam_profile_association_test.go b/spinifex/domains/ec2/instance/iam_profile_association_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/iam_profile_association_test.go rename to spinifex/domains/ec2/instance/iam_profile_association_test.go index ab2f679fc..f594cdb62 100644 --- a/spinifex/handlers/ec2/instance/iam_profile_association_test.go +++ b/spinifex/domains/ec2/instance/iam_profile_association_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/instance_filter_test.go b/spinifex/domains/ec2/instance/instance_filter_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/instance_filter_test.go rename to spinifex/domains/ec2/instance/instance_filter_test.go index 9bc8b157b..52d976bcf 100644 --- a/spinifex/handlers/ec2/instance/instance_filter_test.go +++ b/spinifex/domains/ec2/instance/instance_filter_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "testing" diff --git a/spinifex/handlers/ec2/instance/instance_monitoring_test.go b/spinifex/domains/ec2/instance/instance_monitoring_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/instance_monitoring_test.go rename to spinifex/domains/ec2/instance/instance_monitoring_test.go index cb54bd8ee..e5d6202ba 100644 --- a/spinifex/handlers/ec2/instance/instance_monitoring_test.go +++ b/spinifex/domains/ec2/instance/instance_monitoring_test.go @@ -2,7 +2,7 @@ //stoppedStore field set, so the stopped path is exercised without standing up //the rest of the service. -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/instance_tags_test.go b/spinifex/domains/ec2/instance/instance_tags_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/instance_tags_test.go rename to spinifex/domains/ec2/instance/instance_tags_test.go index 559aa67d3..7687d7fb8 100644 --- a/spinifex/handlers/ec2/instance/instance_tags_test.go +++ b/spinifex/domains/ec2/instance/instance_tags_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/launch_claimed_relaunch_test.go b/spinifex/domains/ec2/instance/launch_claimed_relaunch_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/launch_claimed_relaunch_test.go rename to spinifex/domains/ec2/instance/launch_claimed_relaunch_test.go index 9eb9b452c..739bc726f 100644 --- a/spinifex/handlers/ec2/instance/launch_claimed_relaunch_test.go +++ b/spinifex/domains/ec2/instance/launch_claimed_relaunch_test.go @@ -3,7 +3,7 @@ // surface: it is driven by the recovery reconciler, not by a request. // //test:in-package — the service's dependencies and launchClaimedInstance itself are unexported. -package handlers_ec2_instance +package instance import ( "testing" diff --git a/spinifex/handlers/ec2/instance/metadata_options.go b/spinifex/domains/ec2/instance/metadata_options.go similarity index 99% rename from spinifex/handlers/ec2/instance/metadata_options.go rename to spinifex/domains/ec2/instance/metadata_options.go index 8958b2fcb..bcd0a0a77 100644 --- a/spinifex/handlers/ec2/instance/metadata_options.go +++ b/spinifex/domains/ec2/instance/metadata_options.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "errors" diff --git a/spinifex/handlers/ec2/instance/metadata_options_test.go b/spinifex/domains/ec2/instance/metadata_options_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/metadata_options_test.go rename to spinifex/domains/ec2/instance/metadata_options_test.go index caab6921c..2e020f88d 100644 --- a/spinifex/handlers/ec2/instance/metadata_options_test.go +++ b/spinifex/domains/ec2/instance/metadata_options_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/projection.go b/spinifex/domains/ec2/instance/projection.go similarity index 99% rename from spinifex/handlers/ec2/instance/projection.go rename to spinifex/domains/ec2/instance/projection.go index c49e60d17..2cd3b3365 100644 --- a/spinifex/handlers/ec2/instance/projection.go +++ b/spinifex/domains/ec2/instance/projection.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "errors" diff --git a/spinifex/handlers/ec2/instance/projection_public_ip_test.go b/spinifex/domains/ec2/instance/projection_public_ip_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/projection_public_ip_test.go rename to spinifex/domains/ec2/instance/projection_public_ip_test.go index f0c6b2377..cb6d9e9f4 100644 --- a/spinifex/handlers/ec2/instance/projection_public_ip_test.go +++ b/spinifex/domains/ec2/instance/projection_public_ip_test.go @@ -1,7 +1,7 @@ //test:in-package — extends projection_test.go's in-package fullVM fixture and // projects through the unexported field set it builds. -package handlers_ec2_instance +package instance import ( "testing" diff --git a/spinifex/handlers/ec2/instance/projection_test.go b/spinifex/domains/ec2/instance/projection_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/projection_test.go rename to spinifex/domains/ec2/instance/projection_test.go index f9bac02ba..e58fc6b6a 100644 --- a/spinifex/handlers/ec2/instance/projection_test.go +++ b/spinifex/domains/ec2/instance/projection_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "testing" diff --git a/spinifex/handlers/ec2/instance/provider_efi_volume_test.go b/spinifex/domains/ec2/instance/provider_efi_volume_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/provider_efi_volume_test.go rename to spinifex/domains/ec2/instance/provider_efi_volume_test.go index aea752c27..b1dc58dde 100644 --- a/spinifex/handlers/ec2/instance/provider_efi_volume_test.go +++ b/spinifex/domains/ec2/instance/provider_efi_volume_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "bytes" diff --git a/spinifex/handlers/ec2/instance/provider_root_volume_test.go b/spinifex/domains/ec2/instance/provider_root_volume_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/provider_root_volume_test.go rename to spinifex/domains/ec2/instance/provider_root_volume_test.go index aa16e34ac..c3b6ab217 100644 --- a/spinifex/handlers/ec2/instance/provider_root_volume_test.go +++ b/spinifex/domains/ec2/instance/provider_root_volume_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/service.go b/spinifex/domains/ec2/instance/service.go similarity index 98% rename from spinifex/handlers/ec2/instance/service.go rename to spinifex/domains/ec2/instance/service.go index 34bff2794..c351d7fa8 100644 --- a/spinifex/handlers/ec2/instance/service.go +++ b/spinifex/domains/ec2/instance/service.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "context" @@ -101,13 +101,13 @@ type StoppedInstanceStore interface { // InstanceTagWriter projects an instance record's full tag set into the // central tag store, and removes it on terminate. Implemented by -// handlers/ec2/tags.TagsServiceImpl. +// domains/ec2/tags.TagsServiceImpl. type InstanceTagWriter interface { PutResourceTags(ctx context.Context, accountID, resourceID string, tags map[string]string) error DeleteAllTags(ctx context.Context, accountID, resourceID string) error } -// VolumeDeleter deletes EBS volumes. Implemented by handlers/ec2/volume's +// VolumeDeleter deletes EBS volumes. Implemented by domains/ec2/volume's // VolumeServiceImpl (used by the daemon). type VolumeDeleter interface { DeleteVolume(ctx context.Context, input *ec2.DeleteVolumeInput, accountID string) (*ec2.DeleteVolumeOutput, error) @@ -126,7 +126,7 @@ type VolumeDeleter interface { } // VolumeCreator creates the volumes a launch names beyond the root device, and -// deletes them again when the launch fails. Implemented by handlers/ec2/volume's +// deletes them again when the launch fails. Implemented by domains/ec2/volume's // VolumeServiceImpl. type VolumeCreator interface { CreateVolume(ctx context.Context, input *ec2.CreateVolumeInput, accountID string) (*ec2.Volume, error) diff --git a/spinifex/handlers/ec2/instance/service_impl.go b/spinifex/domains/ec2/instance/service_impl.go similarity index 99% rename from spinifex/handlers/ec2/instance/service_impl.go rename to spinifex/domains/ec2/instance/service_impl.go index 86cb0ed5a..e91fbaf69 100644 --- a/spinifex/handlers/ec2/instance/service_impl.go +++ b/spinifex/domains/ec2/instance/service_impl.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/service_impl_test.go b/spinifex/domains/ec2/instance/service_impl_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/service_impl_test.go rename to spinifex/domains/ec2/instance/service_impl_test.go index b7a700758..d0afb5d36 100644 --- a/spinifex/handlers/ec2/instance/service_impl_test.go +++ b/spinifex/domains/ec2/instance/service_impl_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/service_nats.go b/spinifex/domains/ec2/instance/service_nats.go similarity index 99% rename from spinifex/handlers/ec2/instance/service_nats.go rename to spinifex/domains/ec2/instance/service_nats.go index 40a033e56..b90964637 100644 --- a/spinifex/handlers/ec2/instance/service_nats.go +++ b/spinifex/domains/ec2/instance/service_nats.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/service_nats_test.go b/spinifex/domains/ec2/instance/service_nats_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/service_nats_test.go rename to spinifex/domains/ec2/instance/service_nats_test.go index ddf6bc9ef..94c88e837 100644 --- a/spinifex/handlers/ec2/instance/service_nats_test.go +++ b/spinifex/domains/ec2/instance/service_nats_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/start_public_ip_test.go b/spinifex/domains/ec2/instance/start_public_ip_test.go similarity index 99% rename from spinifex/handlers/ec2/instance/start_public_ip_test.go rename to spinifex/domains/ec2/instance/start_public_ip_test.go index 16fd130d8..3e226979e 100644 --- a/spinifex/handlers/ec2/instance/start_public_ip_test.go +++ b/spinifex/domains/ec2/instance/start_public_ip_test.go @@ -3,7 +3,7 @@ // did to the address before the launch it then fails. // //test:in-package — every dependency it substitutes is an unexported field. -package handlers_ec2_instance +package instance import ( "context" diff --git a/spinifex/handlers/ec2/instance/status_selection.go b/spinifex/domains/ec2/instance/status_selection.go similarity index 98% rename from spinifex/handlers/ec2/instance/status_selection.go rename to spinifex/domains/ec2/instance/status_selection.go index 31ff1ae1d..e8d5e1fa4 100644 --- a/spinifex/handlers/ec2/instance/status_selection.go +++ b/spinifex/domains/ec2/instance/status_selection.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance import ( "log/slog" diff --git a/spinifex/handlers/ec2/instance/volume_held_elsewhere_test.go b/spinifex/domains/ec2/instance/volume_held_elsewhere_test.go similarity index 98% rename from spinifex/handlers/ec2/instance/volume_held_elsewhere_test.go rename to spinifex/domains/ec2/instance/volume_held_elsewhere_test.go index 82866fd99..6561a315c 100644 --- a/spinifex/handlers/ec2/instance/volume_held_elsewhere_test.go +++ b/spinifex/domains/ec2/instance/volume_held_elsewhere_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_instance +package instance //test:in-package — volumeHeldElsewhereError is unexported, and exporting it //would widen the handler API for a test rather than for a caller. diff --git a/spinifex/domains/ec2/key/service_impl.go b/spinifex/domains/ec2/key/service_impl.go index c7efe8129..4509cee3b 100644 --- a/spinifex/domains/ec2/key/service_impl.go +++ b/spinifex/domains/ec2/key/service_impl.go @@ -51,7 +51,7 @@ type KeyServiceImpl struct { } // CentralTagStore keeps the central tag index in step with key-pair records, so -// DescribeTags sees creation tags. Implemented by handlers/ec2/tags.TagsServiceImpl. +// DescribeTags sees creation tags. Implemented by domains/ec2/tags.TagsServiceImpl. type CentralTagStore interface { PutResourceTags(ctx context.Context, accountID, resourceID string, tags map[string]string) error DeleteAllTags(ctx context.Context, accountID, resourceID string) error diff --git a/spinifex/handlers/ec2/snapshot/delete_snapshot_pagination_test.go b/spinifex/domains/ec2/snapshot/delete_snapshot_pagination_test.go similarity index 93% rename from spinifex/handlers/ec2/snapshot/delete_snapshot_pagination_test.go rename to spinifex/domains/ec2/snapshot/delete_snapshot_pagination_test.go index 7e4696964..b3173b705 100644 --- a/spinifex/handlers/ec2/snapshot/delete_snapshot_pagination_test.go +++ b/spinifex/domains/ec2/snapshot/delete_snapshot_pagination_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_snapshot_test +package snapshot_test import ( "context" @@ -12,7 +12,7 @@ import ( "github.com/mulgadc/spinifex/internal/testkit/pagedstore" "github.com/mulgadc/spinifex/spinifex/bootstrap/config" "github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/metadata" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/providers/ebs" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -34,7 +34,7 @@ func TestDeleteSnapshot_RemovesEveryObjectAcrossMultiplePages(t *testing.T) { AccessKey: "test-owner-123", }, } - svc := handlers_ec2_snapshot.NewSnapshotServiceImplWithStore(cfg, store, nil) + svc := ec2snapshot.NewSnapshotServiceImplWithStore(cfg, store, nil) provider := ebsprovider.NewMemoryProvider(ebsprovider.Capabilities{}) svc.SetEBSProvider(provider) diff --git a/spinifex/handlers/ec2/snapshot/describe_byid_test.go b/spinifex/domains/ec2/snapshot/describe_byid_test.go similarity index 97% rename from spinifex/handlers/ec2/snapshot/describe_byid_test.go rename to spinifex/domains/ec2/snapshot/describe_byid_test.go index f18e13dcf..bd4d9c12d 100644 --- a/spinifex/handlers/ec2/snapshot/describe_byid_test.go +++ b/spinifex/domains/ec2/snapshot/describe_byid_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_snapshot_test +package snapshot_test import ( "context" @@ -14,8 +14,8 @@ import ( "github.com/mulgadc/spinifex/internal/testkit/recordingstore" "github.com/mulgadc/spinifex/spinifex/bootstrap/config" "github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/metadata" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -31,9 +31,9 @@ const ( // newByIDService builds a snapshot service over store, with no EBS provider: // every test here answers out of the metadata documents alone. -func newByIDService(store objectstore.ObjectStore) *handlers_ec2_snapshot.SnapshotServiceImpl { +func newByIDService(store objectstore.ObjectStore) *ec2snapshot.SnapshotServiceImpl { cfg := &config.Config{Predastore: config.PredastoreConfig{Bucket: byIDBucket}} - return handlers_ec2_snapshot.NewSnapshotServiceImplWithStore(cfg, store, nil) + return ec2snapshot.NewSnapshotServiceImplWithStore(cfg, store, nil) } func putByIDSnapshot(t *testing.T, store objectstore.ObjectStore, snapshot ebsmetadata.Snapshot) { diff --git a/spinifex/handlers/ec2/snapshot/describe_fanout_test.go b/spinifex/domains/ec2/snapshot/describe_fanout_test.go similarity index 93% rename from spinifex/handlers/ec2/snapshot/describe_fanout_test.go rename to spinifex/domains/ec2/snapshot/describe_fanout_test.go index fbf18036c..986f7f348 100644 --- a/spinifex/handlers/ec2/snapshot/describe_fanout_test.go +++ b/spinifex/domains/ec2/snapshot/describe_fanout_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_snapshot_test +package snapshot_test import ( "context" @@ -10,8 +10,8 @@ import ( "github.com/aws/aws-sdk-go/service/s3" "github.com/mulgadc/spinifex/spinifex/bootstrap/config" "github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/metadata" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -52,10 +52,10 @@ func (s *slowMetadataStore) GetObject(ctx context.Context, input *s3.GetObjectIn return s.ObjectStore.GetObject(ctx, input) } -func seedSnapshots(t *testing.T, store objectstore.ObjectStore, n int) *handlers_ec2_snapshot.SnapshotServiceImpl { +func seedSnapshots(t *testing.T, store objectstore.ObjectStore, n int) *ec2snapshot.SnapshotServiceImpl { t.Helper() cfg := &config.Config{Predastore: config.PredastoreConfig{Bucket: "test-bucket"}} - svc := handlers_ec2_snapshot.NewSnapshotServiceImplWithStore(cfg, store, nil) + svc := ec2snapshot.NewSnapshotServiceImplWithStore(cfg, store, nil) metadata := ebsmetadata.NewStore(store, "test-bucket") for i := range n { id := "snap-fanout" + string(rune('a'+i%26)) + string(rune('a'+i/26)) diff --git a/spinifex/handlers/ec2/snapshot/drain_test.go b/spinifex/domains/ec2/snapshot/drain_test.go similarity index 99% rename from spinifex/handlers/ec2/snapshot/drain_test.go rename to spinifex/domains/ec2/snapshot/drain_test.go index e4e479c4b..4f58ad0f7 100644 --- a/spinifex/handlers/ec2/snapshot/drain_test.go +++ b/spinifex/domains/ec2/snapshot/drain_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/handlers/ec2/snapshot/record_tags_test.go b/spinifex/domains/ec2/snapshot/record_tags_test.go similarity index 98% rename from spinifex/handlers/ec2/snapshot/record_tags_test.go rename to spinifex/domains/ec2/snapshot/record_tags_test.go index b2ae711e9..808d5e84b 100644 --- a/spinifex/handlers/ec2/snapshot/record_tags_test.go +++ b/spinifex/domains/ec2/snapshot/record_tags_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/handlers/ec2/snapshot/service.go b/spinifex/domains/ec2/snapshot/service.go similarity index 95% rename from spinifex/handlers/ec2/snapshot/service.go rename to spinifex/domains/ec2/snapshot/service.go index decfaf3a7..7f5fb562d 100644 --- a/spinifex/handlers/ec2/snapshot/service.go +++ b/spinifex/domains/ec2/snapshot/service.go @@ -1,4 +1,4 @@ -package handlers_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/handlers/ec2/snapshot/service_impl.go b/spinifex/domains/ec2/snapshot/service_impl.go similarity index 99% rename from spinifex/handlers/ec2/snapshot/service_impl.go rename to spinifex/domains/ec2/snapshot/service_impl.go index 6908d94de..c1b871b8c 100644 --- a/spinifex/handlers/ec2/snapshot/service_impl.go +++ b/spinifex/domains/ec2/snapshot/service_impl.go @@ -1,4 +1,4 @@ -package handlers_ec2_snapshot +package snapshot import ( "context" @@ -311,7 +311,7 @@ func (s *SnapshotServiceImpl) drainVolume(ctx context.Context, volumeID string, // DrainVolume flushes the volume's in-flight writes to S3 before a live // checkpoint is read from there. Shared by ec2.CreateSnapshot and -// ec2.CreateImage's running-instance path (handlers/ec2/image) so the two +// ec2.CreateImage's running-instance path (domains/ec2/image) so the two // live-snapshot call sites cannot diverge on when a drain is required. // // The drain socket lives on the node serving the volume, but both callers are diff --git a/spinifex/handlers/ec2/snapshot/service_impl_test.go b/spinifex/domains/ec2/snapshot/service_impl_test.go similarity index 99% rename from spinifex/handlers/ec2/snapshot/service_impl_test.go rename to spinifex/domains/ec2/snapshot/service_impl_test.go index 3c3bcf5c4..61ecb158a 100644 --- a/spinifex/handlers/ec2/snapshot/service_impl_test.go +++ b/spinifex/domains/ec2/snapshot/service_impl_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/handlers/ec2/snapshot/service_nats.go b/spinifex/domains/ec2/snapshot/service_nats.go similarity index 98% rename from spinifex/handlers/ec2/snapshot/service_nats.go rename to spinifex/domains/ec2/snapshot/service_nats.go index 602949cf8..a521f6389 100644 --- a/spinifex/handlers/ec2/snapshot/service_nats.go +++ b/spinifex/domains/ec2/snapshot/service_nats.go @@ -1,4 +1,4 @@ -package handlers_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/handlers/ec2/snapshot/snapshot_partition_test.go b/spinifex/domains/ec2/snapshot/snapshot_partition_test.go similarity index 99% rename from spinifex/handlers/ec2/snapshot/snapshot_partition_test.go rename to spinifex/domains/ec2/snapshot/snapshot_partition_test.go index a015996ec..9398aad25 100644 --- a/spinifex/handlers/ec2/snapshot/snapshot_partition_test.go +++ b/spinifex/domains/ec2/snapshot/snapshot_partition_test.go @@ -2,7 +2,7 @@ // createTestVolume, all package-internal. // //test:in-package -package handlers_ec2_snapshot +package snapshot import ( "context" diff --git a/spinifex/handlers/ec2/tags/key_pair_tags_test.go b/spinifex/domains/ec2/tags/key_pair_tags_test.go similarity index 85% rename from spinifex/handlers/ec2/tags/key_pair_tags_test.go rename to spinifex/domains/ec2/tags/key_pair_tags_test.go index 038d9e126..42d6d210f 100644 --- a/spinifex/handlers/ec2/tags/key_pair_tags_test.go +++ b/spinifex/domains/ec2/tags/key_pair_tags_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_tags_test +package tags_test import ( "testing" @@ -8,7 +8,7 @@ import ( "github.com/mulgadc/spinifex/internal/testkit" "github.com/mulgadc/spinifex/spinifex/bootstrap/config" ec2key "github.com/mulgadc/spinifex/spinifex/domains/ec2/key" - handlers_ec2_tags "github.com/mulgadc/spinifex/spinifex/handlers/ec2/tags" + ec2tags "github.com/mulgadc/spinifex/spinifex/domains/ec2/tags" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -19,13 +19,13 @@ const ( testED25519PubKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl" ) -func newTagsService(t *testing.T) *handlers_ec2_tags.TagsServiceImpl { +func newTagsService(t *testing.T) *ec2tags.TagsServiceImpl { t.Helper() _, nc, _ := testutil.StartTestJetStream(t) - kv, err := handlers_ec2_tags.GetOrCreateTagsBucket(t.Context(), testutil.NewJetStream(t, nc)) + kv, err := ec2tags.GetOrCreateTagsBucket(t.Context(), testutil.NewJetStream(t, nc)) require.NoError(t, err) cfg := &config.Config{Predastore: config.PredastoreConfig{Bucket: "test-bucket"}} - return handlers_ec2_tags.NewTagsServiceImplWithStore(cfg, objectstore.NewMemoryObjectStore(), kv) + return ec2tags.NewTagsServiceImplWithStore(cfg, objectstore.NewMemoryObjectStore(), kv) } func keyPairTagSpec(tags map[string]string) []*ec2.TagSpecification { @@ -36,7 +36,7 @@ func keyPairTagSpec(tags map[string]string) []*ec2.TagSpecification { return []*ec2.TagSpecification{spec} } -func describeKeyPairTags(t *testing.T, svc *handlers_ec2_tags.TagsServiceImpl) map[string]map[string]string { +func describeKeyPairTags(t *testing.T, svc *ec2tags.TagsServiceImpl) map[string]map[string]string { t.Helper() out, err := svc.DescribeTags(t.Context(), &ec2.DescribeTagsInput{ Filters: []*ec2.Filter{{Name: aws.String("resource-type"), Values: []*string{aws.String("key-pair")}}}, diff --git a/spinifex/handlers/ec2/tags/service.go b/spinifex/domains/ec2/tags/service.go similarity index 95% rename from spinifex/handlers/ec2/tags/service.go rename to spinifex/domains/ec2/tags/service.go index 5444ff13c..bd4e6ba4e 100644 --- a/spinifex/handlers/ec2/tags/service.go +++ b/spinifex/domains/ec2/tags/service.go @@ -1,4 +1,4 @@ -package handlers_ec2_tags +package tags import ( "context" diff --git a/spinifex/handlers/ec2/tags/service_impl.go b/spinifex/domains/ec2/tags/service_impl.go similarity index 98% rename from spinifex/handlers/ec2/tags/service_impl.go rename to spinifex/domains/ec2/tags/service_impl.go index 25b86d2fe..bc348ea59 100644 --- a/spinifex/handlers/ec2/tags/service_impl.go +++ b/spinifex/domains/ec2/tags/service_impl.go @@ -1,4 +1,4 @@ -package handlers_ec2_tags +package tags import ( "context" @@ -16,13 +16,13 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/s3" "github.com/mulgadc/spinifex/spinifex/bootstrap/config" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" ec2key "github.com/mulgadc/spinifex/spinifex/domains/ec2/key" ec2vpc "github.com/mulgadc/spinifex/spinifex/domains/ec2/vpc" "github.com/mulgadc/spinifex/spinifex/foundation/aws/arn" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" awsfilters "github.com/mulgadc/spinifex/spinifex/foundation/aws/filters" "github.com/mulgadc/spinifex/spinifex/foundation/state/kvutil" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/nats-io/nats.go/jetstream" ) @@ -31,7 +31,7 @@ import ( var _ TagsService = (*TagsServiceImpl)(nil) // Ensure TagsServiceImpl can project instance record tags into the store. -var _ handlers_ec2_instance.InstanceTagWriter = (*TagsServiceImpl)(nil) +var _ ec2instance.InstanceTagWriter = (*TagsServiceImpl)(nil) // Ensure TagsServiceImpl can both project and clear vpc/subnet/sg/eni record tags. var _ ec2vpc.CentralTagStore = (*TagsServiceImpl)(nil) diff --git a/spinifex/handlers/ec2/tags/service_impl_test.go b/spinifex/domains/ec2/tags/service_impl_test.go similarity index 99% rename from spinifex/handlers/ec2/tags/service_impl_test.go rename to spinifex/domains/ec2/tags/service_impl_test.go index 329813ade..586437a2f 100644 --- a/spinifex/handlers/ec2/tags/service_impl_test.go +++ b/spinifex/domains/ec2/tags/service_impl_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_tags +package tags import ( "context" diff --git a/spinifex/handlers/ec2/tags/service_nats.go b/spinifex/domains/ec2/tags/service_nats.go similarity index 98% rename from spinifex/handlers/ec2/tags/service_nats.go rename to spinifex/domains/ec2/tags/service_nats.go index d364b7780..bb1142638 100644 --- a/spinifex/handlers/ec2/tags/service_nats.go +++ b/spinifex/domains/ec2/tags/service_nats.go @@ -1,4 +1,4 @@ -package handlers_ec2_tags +package tags import ( "context" diff --git a/spinifex/handlers/ec2/tags/store.go b/spinifex/domains/ec2/tags/store.go similarity index 99% rename from spinifex/handlers/ec2/tags/store.go rename to spinifex/domains/ec2/tags/store.go index e75ce4899..af473e4ea 100644 --- a/spinifex/handlers/ec2/tags/store.go +++ b/spinifex/domains/ec2/tags/store.go @@ -1,4 +1,4 @@ -package handlers_ec2_tags +package tags import ( "context" diff --git a/spinifex/handlers/ec2/tags/store_test.go b/spinifex/domains/ec2/tags/store_test.go similarity index 99% rename from spinifex/handlers/ec2/tags/store_test.go rename to spinifex/domains/ec2/tags/store_test.go index 4e39a5a9b..440ad79de 100644 --- a/spinifex/handlers/ec2/tags/store_test.go +++ b/spinifex/domains/ec2/tags/store_test.go @@ -2,7 +2,7 @@ // not tell a migrated resource from one that was never written. // //test:in-package — the read-through fallback and the key layout are -package handlers_ec2_tags +package tags import ( "bytes" diff --git a/spinifex/handlers/ec2/volume/config_route_invariants_test.go b/spinifex/domains/ec2/volume/config_route_invariants_test.go similarity index 99% rename from spinifex/handlers/ec2/volume/config_route_invariants_test.go rename to spinifex/domains/ec2/volume/config_route_invariants_test.go index 9ac562855..7c17b320d 100644 --- a/spinifex/handlers/ec2/volume/config_route_invariants_test.go +++ b/spinifex/domains/ec2/volume/config_route_invariants_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "testing" diff --git a/spinifex/handlers/ec2/volume/describe_volumes_provider_bench_test.go b/spinifex/domains/ec2/volume/describe_volumes_provider_bench_test.go similarity index 99% rename from spinifex/handlers/ec2/volume/describe_volumes_provider_bench_test.go rename to spinifex/domains/ec2/volume/describe_volumes_provider_bench_test.go index 16e299f07..4af025fcf 100644 --- a/spinifex/handlers/ec2/volume/describe_volumes_provider_bench_test.go +++ b/spinifex/domains/ec2/volume/describe_volumes_provider_bench_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/describe_volumes_provider_fastpath_test.go b/spinifex/domains/ec2/volume/describe_volumes_provider_fastpath_test.go similarity index 99% rename from spinifex/handlers/ec2/volume/describe_volumes_provider_fastpath_test.go rename to spinifex/domains/ec2/volume/describe_volumes_provider_fastpath_test.go index 83e0cdf7a..c00c06a04 100644 --- a/spinifex/handlers/ec2/volume/describe_volumes_provider_fastpath_test.go +++ b/spinifex/domains/ec2/volume/describe_volumes_provider_fastpath_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/force_detach_test.go b/spinifex/domains/ec2/volume/force_detach_test.go similarity index 99% rename from spinifex/handlers/ec2/volume/force_detach_test.go rename to spinifex/domains/ec2/volume/force_detach_test.go index d1cbc2560..900ea1420 100644 --- a/spinifex/handlers/ec2/volume/force_detach_test.go +++ b/spinifex/domains/ec2/volume/force_detach_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume //test:in-package — seeding a volume's metadata document is how the attachment // under test is created, and the metadata store is unexported. diff --git a/spinifex/handlers/ec2/volume/get_volume_metadata_provider_test.go b/spinifex/domains/ec2/volume/get_volume_metadata_provider_test.go similarity index 99% rename from spinifex/handlers/ec2/volume/get_volume_metadata_provider_test.go rename to spinifex/domains/ec2/volume/get_volume_metadata_provider_test.go index db3f71366..748e72875 100644 --- a/spinifex/handlers/ec2/volume/get_volume_metadata_provider_test.go +++ b/spinifex/domains/ec2/volume/get_volume_metadata_provider_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/lifecycle_invariants_test.go b/spinifex/domains/ec2/volume/lifecycle_invariants_test.go similarity index 99% rename from spinifex/handlers/ec2/volume/lifecycle_invariants_test.go rename to spinifex/domains/ec2/volume/lifecycle_invariants_test.go index d5f7c42ac..e6fbbd7d5 100644 --- a/spinifex/handlers/ec2/volume/lifecycle_invariants_test.go +++ b/spinifex/domains/ec2/volume/lifecycle_invariants_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/main_test.go b/spinifex/domains/ec2/volume/main_test.go similarity index 97% rename from spinifex/handlers/ec2/volume/main_test.go rename to spinifex/domains/ec2/volume/main_test.go index f64549f0e..d8676e736 100644 --- a/spinifex/handlers/ec2/volume/main_test.go +++ b/spinifex/domains/ec2/volume/main_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "io" diff --git a/spinifex/handlers/ec2/volume/provider_snapshot_source_test.go b/spinifex/domains/ec2/volume/provider_snapshot_source_test.go similarity index 97% rename from spinifex/handlers/ec2/volume/provider_snapshot_source_test.go rename to spinifex/domains/ec2/volume/provider_snapshot_source_test.go index 951febb79..f70b06b15 100644 --- a/spinifex/handlers/ec2/volume/provider_snapshot_source_test.go +++ b/spinifex/domains/ec2/volume/provider_snapshot_source_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" @@ -10,7 +10,7 @@ import ( "github.com/mulgadc/spinifex/spinifex/bootstrap/config" "github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/metadata" ebspolicy "github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/policy" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/providers/ebs" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" @@ -135,7 +135,7 @@ func TestDescribeVolumes_Provider_SeesInstanceRootVolume(t *testing.T) { }) require.NoError(t, err) - instanceSvc := handlers_ec2_instance.NewInstanceServiceImpl(cfg, nil, nil, store, nil, nil, nil) + instanceSvc := ec2instance.NewInstanceServiceImpl(cfg, nil, nil, store, nil, nil, nil) instanceSvc.SetEBSProvider(provider) instanceSvc.SetRunInstancesDeps(&fixedAMILoader{ meta: ebsmetadata.AMI{ImageID: "ami-1", SnapshotID: "snap-src", VolumeSizeGiB: 4}, diff --git a/spinifex/handlers/ec2/volume/record_tags_test.go b/spinifex/domains/ec2/volume/record_tags_test.go similarity index 99% rename from spinifex/handlers/ec2/volume/record_tags_test.go rename to spinifex/domains/ec2/volume/record_tags_test.go index 4f9809532..465ff3a51 100644 --- a/spinifex/handlers/ec2/volume/record_tags_test.go +++ b/spinifex/domains/ec2/volume/record_tags_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "bytes" diff --git a/spinifex/handlers/ec2/volume/service.go b/spinifex/domains/ec2/volume/service.go similarity index 97% rename from spinifex/handlers/ec2/volume/service.go rename to spinifex/domains/ec2/volume/service.go index ab50ebbeb..a89b95602 100644 --- a/spinifex/handlers/ec2/volume/service.go +++ b/spinifex/domains/ec2/volume/service.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/service_impl.go b/spinifex/domains/ec2/volume/service_impl.go similarity index 99% rename from spinifex/handlers/ec2/volume/service_impl.go rename to spinifex/domains/ec2/volume/service_impl.go index 90b2bf47b..29ee6705d 100644 --- a/spinifex/handlers/ec2/volume/service_impl.go +++ b/spinifex/domains/ec2/volume/service_impl.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" @@ -20,11 +20,11 @@ import ( "github.com/mulgadc/spinifex/spinifex/bootstrap/config" "github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/metadata" ebspolicy "github.com/mulgadc/spinifex/spinifex/domains/ec2/ebs/policy" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" awsfilters "github.com/mulgadc/spinifex/spinifex/foundation/aws/filters" awsidentifiers "github.com/mulgadc/spinifex/spinifex/foundation/aws/identifiers" awstags "github.com/mulgadc/spinifex/spinifex/foundation/aws/tags" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" "github.com/mulgadc/spinifex/spinifex/providers/ebs" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" @@ -40,10 +40,10 @@ var _ VolumeService = (*VolumeServiceImpl)(nil) // can call UpdateVolumeState directly without a daemon-side adapter. var _ vm.VolumeStateUpdater = (*VolumeServiceImpl)(nil) -// Ensure VolumeServiceImpl satisfies handlers/ec2/instance's VolumeDeleter so +// Ensure VolumeServiceImpl satisfies domains/ec2/instance's VolumeDeleter so // InstanceServiceImpl can call DeleteVolume/DeleteVolumeOnTerminate through // the dependency wired via SetTerminationDeps. -var _ handlers_ec2_instance.VolumeDeleter = (*VolumeServiceImpl)(nil) +var _ ec2instance.VolumeDeleter = (*VolumeServiceImpl)(nil) // VolumeServiceImpl handles EBS volume operations with S3 storage. type VolumeServiceImpl struct { diff --git a/spinifex/handlers/ec2/volume/service_impl_encryption_test.go b/spinifex/domains/ec2/volume/service_impl_encryption_test.go similarity index 98% rename from spinifex/handlers/ec2/volume/service_impl_encryption_test.go rename to spinifex/domains/ec2/volume/service_impl_encryption_test.go index 6a8192da2..aff5b5a24 100644 --- a/spinifex/handlers/ec2/volume/service_impl_encryption_test.go +++ b/spinifex/domains/ec2/volume/service_impl_encryption_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/service_impl_test.go b/spinifex/domains/ec2/volume/service_impl_test.go similarity index 99% rename from spinifex/handlers/ec2/volume/service_impl_test.go rename to spinifex/domains/ec2/volume/service_impl_test.go index 7509fc132..0a7b4e5b3 100644 --- a/spinifex/handlers/ec2/volume/service_impl_test.go +++ b/spinifex/domains/ec2/volume/service_impl_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/service_nats.go b/spinifex/domains/ec2/volume/service_nats.go similarity index 98% rename from spinifex/handlers/ec2/volume/service_nats.go rename to spinifex/domains/ec2/volume/service_nats.go index 35d5794ea..8826405ed 100644 --- a/spinifex/handlers/ec2/volume/service_nats.go +++ b/spinifex/domains/ec2/volume/service_nats.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/testhelpers_test.go b/spinifex/domains/ec2/volume/testhelpers_test.go similarity index 98% rename from spinifex/handlers/ec2/volume/testhelpers_test.go rename to spinifex/domains/ec2/volume/testhelpers_test.go index ae35865c8..c48571383 100644 --- a/spinifex/handlers/ec2/volume/testhelpers_test.go +++ b/spinifex/domains/ec2/volume/testhelpers_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/volume_leak_reaper.go b/spinifex/domains/ec2/volume/volume_leak_reaper.go similarity index 99% rename from spinifex/handlers/ec2/volume/volume_leak_reaper.go rename to spinifex/domains/ec2/volume/volume_leak_reaper.go index cb0250f8a..add69effa 100644 --- a/spinifex/handlers/ec2/volume/volume_leak_reaper.go +++ b/spinifex/domains/ec2/volume/volume_leak_reaper.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/volume_leak_reaper_test.go b/spinifex/domains/ec2/volume/volume_leak_reaper_test.go similarity index 99% rename from spinifex/handlers/ec2/volume/volume_leak_reaper_test.go rename to spinifex/domains/ec2/volume/volume_leak_reaper_test.go index 0f0f63589..cbb00342d 100644 --- a/spinifex/handlers/ec2/volume/volume_leak_reaper_test.go +++ b/spinifex/domains/ec2/volume/volume_leak_reaper_test.go @@ -1,4 +1,4 @@ -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/handlers/ec2/volume/volume_partition_test.go b/spinifex/domains/ec2/volume/volume_partition_test.go similarity index 99% rename from spinifex/handlers/ec2/volume/volume_partition_test.go rename to spinifex/domains/ec2/volume/volume_partition_test.go index c9dd87109..8c7f93eeb 100644 --- a/spinifex/handlers/ec2/volume/volume_partition_test.go +++ b/spinifex/domains/ec2/volume/volume_partition_test.go @@ -2,7 +2,7 @@ // package-internal. // //test:in-package -package handlers_ec2_volume +package volume import ( "context" diff --git a/spinifex/domains/ec2/vpc/service.go b/spinifex/domains/ec2/vpc/service.go index 43470dac0..7ec60f7ae 100644 --- a/spinifex/domains/ec2/vpc/service.go +++ b/spinifex/domains/ec2/vpc/service.go @@ -38,7 +38,7 @@ type VPCService interface { // CentralTagStore keeps the central tag index in step with this package's // records, so DescribeTags agrees with a resource's own describe for as long as // the resource exists and says nothing about it afterwards. Implemented by -// handlers/ec2/tags.TagsServiceImpl. +// domains/ec2/tags.TagsServiceImpl. type CentralTagStore interface { PutResourceTags(ctx context.Context, accountID, resourceID string, tags map[string]string) error DeleteAllTags(ctx context.Context, accountID, resourceID string) error diff --git a/spinifex/gateway/ec2/image/CopyImage.go b/spinifex/gateway/ec2/image/CopyImage.go index b4605d90e..a19157c4e 100644 --- a/spinifex/gateway/ec2/image/CopyImage.go +++ b/spinifex/gateway/ec2/image/CopyImage.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" "github.com/nats-io/nats.go" ) @@ -61,7 +61,7 @@ func CopyImage(ctx context.Context, input *ec2.CopyImageInput, natsConn *nats.Co return output, err } - svc := handlers_ec2_image.NewNATSImageService(natsConn, 0) + svc := ec2image.NewNATSImageService(natsConn, 0) result, err := svc.CopyImage(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/image/CreateImage.go b/spinifex/gateway/ec2/image/CreateImage.go index 8ca2da5ef..6fcc75b4d 100644 --- a/spinifex/gateway/ec2/image/CreateImage.go +++ b/spinifex/gateway/ec2/image/CreateImage.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" "github.com/nats-io/nats.go" ) @@ -40,7 +40,7 @@ func CreateImage(ctx context.Context, input *ec2.CreateImageInput, natsConn *nat return output, err } - svc := handlers_ec2_image.NewNATSImageService(natsConn, expectedNodes) + svc := ec2image.NewNATSImageService(natsConn, expectedNodes) result, err := svc.CreateImage(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/image/DeregisterImage.go b/spinifex/gateway/ec2/image/DeregisterImage.go index 1a4ab4dc5..430a5a425 100644 --- a/spinifex/gateway/ec2/image/DeregisterImage.go +++ b/spinifex/gateway/ec2/image/DeregisterImage.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" "github.com/nats-io/nats.go" ) @@ -28,7 +28,7 @@ func DeregisterImage(ctx context.Context, input *ec2.DeregisterImageInput, natsC return output, err } - svc := handlers_ec2_image.NewNATSImageService(natsConn, 0) + svc := ec2image.NewNATSImageService(natsConn, 0) result, err := svc.DeregisterImage(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/image/DescribeImageAttribute.go b/spinifex/gateway/ec2/image/DescribeImageAttribute.go index 082261184..eb11fa07c 100644 --- a/spinifex/gateway/ec2/image/DescribeImageAttribute.go +++ b/spinifex/gateway/ec2/image/DescribeImageAttribute.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" "github.com/nats-io/nats.go" ) @@ -45,7 +45,7 @@ func DescribeImageAttribute(ctx context.Context, input *ec2.DescribeImageAttribu return output, err } - svc := handlers_ec2_image.NewNATSImageService(natsConn, 0) + svc := ec2image.NewNATSImageService(natsConn, 0) result, err := svc.DescribeImageAttribute(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/image/DescribeImages.go b/spinifex/gateway/ec2/image/DescribeImages.go index 53b1e60e8..df8e4169b 100644 --- a/spinifex/gateway/ec2/image/DescribeImages.go +++ b/spinifex/gateway/ec2/image/DescribeImages.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" "github.com/nats-io/nats.go" ) @@ -33,7 +33,7 @@ func DescribeImages(ctx context.Context, input *ec2.DescribeImagesInput, natsCon return output, err } - imageService := handlers_ec2_image.NewNATSImageService(natsConn, 0) + imageService := ec2image.NewNATSImageService(natsConn, 0) result, err := imageService.DescribeImages(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/image/ModifyImageAttribute.go b/spinifex/gateway/ec2/image/ModifyImageAttribute.go index b20f2b183..035385030 100644 --- a/spinifex/gateway/ec2/image/ModifyImageAttribute.go +++ b/spinifex/gateway/ec2/image/ModifyImageAttribute.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" "github.com/nats-io/nats.go" ) @@ -79,7 +79,7 @@ func ModifyImageAttribute(ctx context.Context, input *ec2.ModifyImageAttributeIn return output, err } - svc := handlers_ec2_image.NewNATSImageService(natsConn, 0) + svc := ec2image.NewNATSImageService(natsConn, 0) result, err := svc.ModifyImageAttribute(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/image/RegisterImage.go b/spinifex/gateway/ec2/image/RegisterImage.go index 91746ab82..6d18623d5 100644 --- a/spinifex/gateway/ec2/image/RegisterImage.go +++ b/spinifex/gateway/ec2/image/RegisterImage.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" "github.com/nats-io/nats.go" ) @@ -131,7 +131,7 @@ func RegisterImage(ctx context.Context, input *ec2.RegisterImageInput, natsConn return output, err } - svc := handlers_ec2_image.NewNATSImageService(natsConn, 0) + svc := ec2image.NewNATSImageService(natsConn, 0) result, err := svc.RegisterImage(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/image/ResetImageAttribute.go b/spinifex/gateway/ec2/image/ResetImageAttribute.go index 69b28c468..5d959e463 100644 --- a/spinifex/gateway/ec2/image/ResetImageAttribute.go +++ b/spinifex/gateway/ec2/image/ResetImageAttribute.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" "github.com/nats-io/nats.go" ) @@ -39,7 +39,7 @@ func ResetImageAttribute(ctx context.Context, input *ec2.ResetImageAttributeInpu return output, err } - svc := handlers_ec2_image.NewNATSImageService(natsConn, 0) + svc := ec2image.NewNATSImageService(natsConn, 0) result, err := svc.ResetImageAttribute(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/instance/RunInstances.go b/spinifex/gateway/ec2/instance/RunInstances.go index 13e38e693..e482fe9f2 100644 --- a/spinifex/gateway/ec2/instance/RunInstances.go +++ b/spinifex/gateway/ec2/instance/RunInstances.go @@ -12,10 +12,10 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" ec2launchtemplate "github.com/mulgadc/spinifex/spinifex/domains/ec2/launchtemplate" ec2placementgroup "github.com/mulgadc/spinifex/spinifex/domains/ec2/placementgroup" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" handlers_iam "github.com/mulgadc/spinifex/spinifex/handlers/iam" "github.com/nats-io/nats.go" ) @@ -78,7 +78,7 @@ func ValidateRunInstancesInput(input *ec2.RunInstancesInput) (err error) { // A volume the launch creates beyond the root is empty and sized by the // request, so a mapping asking for anything else is refused by name rather // than served as something it did not ask for. - if unserved := handlers_ec2_instance.UnservedBlockDeviceMappings(input.BlockDeviceMappings); len(unserved) > 0 { + if unserved := ec2instance.UnservedBlockDeviceMappings(input.BlockDeviceMappings); len(unserved) > 0 { return awserrors.Errorf(awserrors.ErrorInvalidParameterValue, "BlockDeviceMappings: cannot create %s", strings.Join(unserved, ", ")) } diff --git a/spinifex/gateway/ec2/instance/status_synthesis.go b/spinifex/gateway/ec2/instance/status_synthesis.go index 7d5e4588c..684b5ae26 100644 --- a/spinifex/gateway/ec2/instance/status_synthesis.go +++ b/spinifex/gateway/ec2/instance/status_synthesis.go @@ -6,7 +6,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/runtime/compute/cache" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" ) @@ -67,7 +67,7 @@ func (s StatusSynthesis) synthesize(ctx context.Context, input *ec2.DescribeInst // The fan-out already reported a malformed request through its own error // path. Adding nothing here avoids answering a request the node rejected. - selection, err := handlers_ec2_instance.ParseStatusSelection(input, accountID) + selection, err := ec2instance.ParseStatusSelection(input, accountID) if err != nil { return nil } @@ -97,7 +97,7 @@ func (s StatusSynthesis) synthesize(ctx context.Context, input *ec2.DescribeInst // SystemImpaired is node-local memory pressure only an answering node // can report. A silent node's is unknowable, so it is not fabricated. - status := selection.StatusFor(v, handlers_ec2_instance.StatusOptions{AZ: v.AZ}) + status := selection.StatusFor(v, ec2instance.StatusOptions{AZ: v.AZ}) if status == nil { continue } diff --git a/spinifex/gateway/ec2/snapshot/CopySnapshot.go b/spinifex/gateway/ec2/snapshot/CopySnapshot.go index 4c4e887f0..25a1bcb18 100644 --- a/spinifex/gateway/ec2/snapshot/CopySnapshot.go +++ b/spinifex/gateway/ec2/snapshot/CopySnapshot.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" "github.com/nats-io/nats.go" ) @@ -40,7 +40,7 @@ func CopySnapshot(ctx context.Context, input *ec2.CopySnapshotInput, natsConn *n return output, err } - svc := handlers_ec2_snapshot.NewNATSSnapshotService(natsConn) + svc := ec2snapshot.NewNATSSnapshotService(natsConn) result, err := svc.CopySnapshot(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/snapshot/CreateSnapshot.go b/spinifex/gateway/ec2/snapshot/CreateSnapshot.go index e038a651b..d75703ee7 100644 --- a/spinifex/gateway/ec2/snapshot/CreateSnapshot.go +++ b/spinifex/gateway/ec2/snapshot/CreateSnapshot.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" "github.com/nats-io/nats.go" ) @@ -36,7 +36,7 @@ func CreateSnapshot(ctx context.Context, input *ec2.CreateSnapshotInput, natsCon return output, err } - svc := handlers_ec2_snapshot.NewNATSSnapshotService(natsConn) + svc := ec2snapshot.NewNATSSnapshotService(natsConn) result, err := svc.CreateSnapshot(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/snapshot/DeleteSnapshot.go b/spinifex/gateway/ec2/snapshot/DeleteSnapshot.go index 7caeffa31..d888369d0 100644 --- a/spinifex/gateway/ec2/snapshot/DeleteSnapshot.go +++ b/spinifex/gateway/ec2/snapshot/DeleteSnapshot.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" "github.com/nats-io/nats.go" ) @@ -36,7 +36,7 @@ func DeleteSnapshot(ctx context.Context, input *ec2.DeleteSnapshotInput, natsCon return output, err } - svc := handlers_ec2_snapshot.NewNATSSnapshotService(natsConn) + svc := ec2snapshot.NewNATSSnapshotService(natsConn) result, err := svc.DeleteSnapshot(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/snapshot/DescribeSnapshots.go b/spinifex/gateway/ec2/snapshot/DescribeSnapshots.go index 9692d8913..42da0d847 100644 --- a/spinifex/gateway/ec2/snapshot/DescribeSnapshots.go +++ b/spinifex/gateway/ec2/snapshot/DescribeSnapshots.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2snapshot "github.com/mulgadc/spinifex/spinifex/domains/ec2/snapshot" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/handlers/ec2/snapshot" "github.com/nats-io/nats.go" ) @@ -34,7 +34,7 @@ func DescribeSnapshots(ctx context.Context, input *ec2.DescribeSnapshotsInput, n return output, err } - svc := handlers_ec2_snapshot.NewNATSSnapshotService(natsConn) + svc := ec2snapshot.NewNATSSnapshotService(natsConn) result, err := svc.DescribeSnapshots(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/tags/CreateTags.go b/spinifex/gateway/ec2/tags/CreateTags.go index 6abe199e4..98982a317 100644 --- a/spinifex/gateway/ec2/tags/CreateTags.go +++ b/spinifex/gateway/ec2/tags/CreateTags.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2tags "github.com/mulgadc/spinifex/spinifex/domains/ec2/tags" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_tags "github.com/mulgadc/spinifex/spinifex/handlers/ec2/tags" "github.com/nats-io/nats.go" ) @@ -47,7 +47,7 @@ func CreateTags(ctx context.Context, input *ec2.CreateTagsInput, natsConn *nats. return output, err } - svc := handlers_ec2_tags.NewNATSTagsService(natsConn) + svc := ec2tags.NewNATSTagsService(natsConn) result, err := svc.CreateTags(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/tags/DeleteTags.go b/spinifex/gateway/ec2/tags/DeleteTags.go index f298ff647..df2cdc871 100644 --- a/spinifex/gateway/ec2/tags/DeleteTags.go +++ b/spinifex/gateway/ec2/tags/DeleteTags.go @@ -5,8 +5,8 @@ import ( "errors" "github.com/aws/aws-sdk-go/service/ec2" + ec2tags "github.com/mulgadc/spinifex/spinifex/domains/ec2/tags" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_tags "github.com/mulgadc/spinifex/spinifex/handlers/ec2/tags" "github.com/nats-io/nats.go" ) @@ -31,7 +31,7 @@ func DeleteTags(ctx context.Context, input *ec2.DeleteTagsInput, natsConn *nats. return output, err } - svc := handlers_ec2_tags.NewNATSTagsService(natsConn) + svc := ec2tags.NewNATSTagsService(natsConn) result, err := svc.DeleteTags(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/tags/DescribeTags.go b/spinifex/gateway/ec2/tags/DescribeTags.go index 6b0b6cd01..94277288d 100644 --- a/spinifex/gateway/ec2/tags/DescribeTags.go +++ b/spinifex/gateway/ec2/tags/DescribeTags.go @@ -3,7 +3,7 @@ package gateway_ec2_tags import ( "context" "github.com/aws/aws-sdk-go/service/ec2" - handlers_ec2_tags "github.com/mulgadc/spinifex/spinifex/handlers/ec2/tags" + ec2tags "github.com/mulgadc/spinifex/spinifex/domains/ec2/tags" "github.com/nats-io/nats.go" ) @@ -11,7 +11,7 @@ import ( func DescribeTags(ctx context.Context, input *ec2.DescribeTagsInput, natsConn *nats.Conn, accountID string) (ec2.DescribeTagsOutput, error) { var output ec2.DescribeTagsOutput - svc := handlers_ec2_tags.NewNATSTagsService(natsConn) + svc := ec2tags.NewNATSTagsService(natsConn) result, err := svc.DescribeTags(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/volume/CreateVolume.go b/spinifex/gateway/ec2/volume/CreateVolume.go index deb32e56d..6be46c709 100644 --- a/spinifex/gateway/ec2/volume/CreateVolume.go +++ b/spinifex/gateway/ec2/volume/CreateVolume.go @@ -5,8 +5,8 @@ import ( "errors" "github.com/aws/aws-sdk-go/service/ec2" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" "github.com/nats-io/nats.go" ) @@ -45,7 +45,7 @@ func CreateVolume(ctx context.Context, input *ec2.CreateVolumeInput, natsConn *n return output, err } - volumeService := handlers_ec2_volume.NewNATSVolumeService(natsConn) + volumeService := ec2volume.NewNATSVolumeService(natsConn) result, err := volumeService.CreateVolume(ctx, input, accountID) if err != nil { diff --git a/spinifex/gateway/ec2/volume/DeleteVolume.go b/spinifex/gateway/ec2/volume/DeleteVolume.go index 267385309..6129385f2 100644 --- a/spinifex/gateway/ec2/volume/DeleteVolume.go +++ b/spinifex/gateway/ec2/volume/DeleteVolume.go @@ -8,9 +8,9 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" gateway_ec2_instance "github.com/mulgadc/spinifex/spinifex/gateway/ec2/instance" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" "github.com/nats-io/nats.go" ) @@ -89,7 +89,7 @@ func DeleteVolume(ctx context.Context, input *ec2.DeleteVolumeInput, natsConn *n return output, errors.New(awserrors.ErrorVolumeInUse) } - volumeService := handlers_ec2_volume.NewNATSVolumeService(natsConn) + volumeService := ec2volume.NewNATSVolumeService(natsConn) result, err := volumeService.DeleteVolume(ctx, input, accountID) if err != nil { diff --git a/spinifex/gateway/ec2/volume/DescribeVolumeStatus.go b/spinifex/gateway/ec2/volume/DescribeVolumeStatus.go index 46f587175..7da7adc47 100644 --- a/spinifex/gateway/ec2/volume/DescribeVolumeStatus.go +++ b/spinifex/gateway/ec2/volume/DescribeVolumeStatus.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" "github.com/nats-io/nats.go" ) @@ -34,7 +34,7 @@ func DescribeVolumeStatus(ctx context.Context, input *ec2.DescribeVolumeStatusIn return output, err } - volumeService := handlers_ec2_volume.NewNATSVolumeService(natsConn) + volumeService := ec2volume.NewNATSVolumeService(natsConn) result, err := volumeService.DescribeVolumeStatus(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/volume/DescribeVolumes.go b/spinifex/gateway/ec2/volume/DescribeVolumes.go index 68d7a23d1..614428842 100644 --- a/spinifex/gateway/ec2/volume/DescribeVolumes.go +++ b/spinifex/gateway/ec2/volume/DescribeVolumes.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" "github.com/nats-io/nats.go" ) @@ -36,7 +36,7 @@ func DescribeVolumes(ctx context.Context, input *ec2.DescribeVolumesInput, natsC return output, err } - volumeService := handlers_ec2_volume.NewNATSVolumeService(natsConn) + volumeService := ec2volume.NewNATSVolumeService(natsConn) result, err := volumeService.DescribeVolumes(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/volume/DescribeVolumesModifications.go b/spinifex/gateway/ec2/volume/DescribeVolumesModifications.go index cdf7152fa..a9c82913a 100644 --- a/spinifex/gateway/ec2/volume/DescribeVolumesModifications.go +++ b/spinifex/gateway/ec2/volume/DescribeVolumesModifications.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" "github.com/nats-io/nats.go" ) @@ -34,7 +34,7 @@ func DescribeVolumesModifications(ctx context.Context, input *ec2.DescribeVolume return output, err } - volumeService := handlers_ec2_volume.NewNATSVolumeService(natsConn) + volumeService := ec2volume.NewNATSVolumeService(natsConn) result, err := volumeService.DescribeVolumesModifications(ctx, input, accountID) if err != nil { return output, err diff --git a/spinifex/gateway/ec2/volume/DetachVolume.go b/spinifex/gateway/ec2/volume/DetachVolume.go index 27bb477df..74fdba874 100644 --- a/spinifex/gateway/ec2/volume/DetachVolume.go +++ b/spinifex/gateway/ec2/volume/DetachVolume.go @@ -11,8 +11,8 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/mulgadc/spinifex/contracts/ec2/v1" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" "github.com/nats-io/nats.go" ) @@ -49,7 +49,7 @@ func DetachVolume(ctx context.Context, input *ec2.DetachVolumeInput, natsConn *n if input.InstanceId != nil && *input.InstanceId != "" { instanceID = *input.InstanceId } else { - volSvc := handlers_ec2_volume.NewNATSVolumeService(natsConn) + volSvc := ec2volume.NewNATSVolumeService(natsConn) descOutput, err := volSvc.DescribeVolumes(ctx, &ec2.DescribeVolumesInput{ VolumeIds: []*string{&volumeID}, }, accountID) diff --git a/spinifex/gateway/ec2/volume/ModifyVolume.go b/spinifex/gateway/ec2/volume/ModifyVolume.go index 60a865957..8764b746a 100644 --- a/spinifex/gateway/ec2/volume/ModifyVolume.go +++ b/spinifex/gateway/ec2/volume/ModifyVolume.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" "github.com/nats-io/nats.go" ) @@ -36,7 +36,7 @@ func ModifyVolume(ctx context.Context, input *ec2.ModifyVolumeInput, natsConn *n return output, err } - volumeService := handlers_ec2_volume.NewNATSVolumeService(natsConn) + volumeService := ec2volume.NewNATSVolumeService(natsConn) result, err := volumeService.ModifyVolume(ctx, input, accountID) if err != nil { diff --git a/spinifex/gateway/tagging/GetResources.go b/spinifex/gateway/tagging/GetResources.go index b686668ec..474c5fffb 100644 --- a/spinifex/gateway/tagging/GetResources.go +++ b/spinifex/gateway/tagging/GetResources.go @@ -13,9 +13,9 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/elbv2" rgt "github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi" + ec2tags "github.com/mulgadc/spinifex/spinifex/domains/ec2/tags" "github.com/mulgadc/spinifex/spinifex/foundation/aws/arn" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" - handlers_ec2_tags "github.com/mulgadc/spinifex/spinifex/handlers/ec2/tags" handlers_elbv2 "github.com/mulgadc/spinifex/spinifex/handlers/elbv2" "github.com/nats-io/nats.go" ) @@ -93,7 +93,7 @@ func (l *natsLister) listELBv2(ctx context.Context, typeFilters map[string]bool) } func (l *natsLister) listEC2(ctx context.Context, typeFilters map[string]bool) ([]*rgt.ResourceTagMapping, error) { - svc := handlers_ec2_tags.NewNATSTagsService(l.natsConn) + svc := ec2tags.NewNATSTagsService(l.natsConn) tagsOut, err := svc.DescribeTags(ctx, &ec2.DescribeTagsInput{}, l.accountID) if err != nil { return nil, err diff --git a/spinifex/handlers/rds/lifecycle.go b/spinifex/handlers/rds/lifecycle.go index 3e3a22e07..0dfa9500f 100644 --- a/spinifex/handlers/rds/lifecycle.go +++ b/spinifex/handlers/rds/lifecycle.go @@ -14,9 +14,9 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/rds" "github.com/mulgadc/spinifex/contracts/ec2/v1" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/foundation/aws/errors" "github.com/mulgadc/spinifex/spinifex/foundation/state/kvstore" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" "github.com/nats-io/nats.go" ) @@ -448,7 +448,7 @@ func (c *natsInstanceCommander) send(ctx context.Context, instanceID string, att } func (c *natsInstanceCommander) StartStoppedInstance(ctx context.Context, instanceID string) error { - _, err := natsmsg.NATSRequest[handlers_ec2_instance.StartStoppedInstanceOutput](ctx, c.nc, "ec2.start", - handlers_ec2_instance.StartStoppedInstanceInput{InstanceID: instanceID}, c.timeout, awsidentifiers.GlobalAccountID) + _, err := natsmsg.NATSRequest[ec2instance.StartStoppedInstanceOutput](ctx, c.nc, "ec2.start", + ec2instance.StartStoppedInstanceInput{InstanceID: instanceID}, c.timeout, awsidentifiers.GlobalAccountID) return err } diff --git a/spinifex/runtime/compute/cache/cache_test.go b/spinifex/runtime/compute/cache/cache_test.go index 4df47f081..65fa38646 100644 --- a/spinifex/runtime/compute/cache/cache_test.go +++ b/spinifex/runtime/compute/cache/cache_test.go @@ -16,9 +16,9 @@ import ( "time" "github.com/mulgadc/spinifex/internal/testkit" + instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/foundation/lifecycle/resource" "github.com/mulgadc/spinifex/spinifex/foundation/state/kvstore" - instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" "github.com/mulgadc/spinifex/spinifex/runtime/compute/vm" "github.com/nats-io/nats.go/jetstream" "github.com/stretchr/testify/require" diff --git a/spinifex/runtime/compute/vm/mock/mock.go b/spinifex/runtime/compute/vm/mock/mock.go index 86c7b8937..4b288ea3a 100644 --- a/spinifex/runtime/compute/vm/mock/mock.go +++ b/spinifex/runtime/compute/vm/mock/mock.go @@ -1,7 +1,7 @@ // Package mock provides a single shared in-memory fake for vm.StateStore, // reused by every package that stands up a stopped/terminated instance // store in its tests. It also structurally satisfies the narrower -// handlers/ec2/instance.StoppedInstanceStore (see mock_test.go for the +// domains/ec2/instance.StoppedInstanceStore (see mock_test.go for the // compile-time check, kept out of this file to avoid importing that // package from here). package mock diff --git a/spinifex/runtime/roles/awsgw/awsgw.go b/spinifex/runtime/roles/awsgw/awsgw.go index 1b3859512..addb741f9 100644 --- a/spinifex/runtime/roles/awsgw/awsgw.go +++ b/spinifex/runtime/roles/awsgw/awsgw.go @@ -24,6 +24,7 @@ import ( "github.com/mulgadc/spinifex/spinifex/admin" "github.com/mulgadc/spinifex/spinifex/bootstrap/config" "github.com/mulgadc/spinifex/spinifex/daemon" + ec2instance "github.com/mulgadc/spinifex/spinifex/domains/ec2/instance" "github.com/mulgadc/spinifex/spinifex/domains/ecr" ecrauth "github.com/mulgadc/spinifex/spinifex/domains/ecr/auth" awsapi "github.com/mulgadc/spinifex/spinifex/domains/ecr/awsapi" @@ -37,7 +38,6 @@ import ( "github.com/mulgadc/spinifex/spinifex/gateway" gateway_bedrock "github.com/mulgadc/spinifex/spinifex/gateway/bedrock" gateway_ec2_instance "github.com/mulgadc/spinifex/spinifex/gateway/ec2/instance" - handlers_ec2_instance "github.com/mulgadc/spinifex/spinifex/handlers/ec2/instance" handlers_iam "github.com/mulgadc/spinifex/spinifex/handlers/iam" handlers_quota "github.com/mulgadc/spinifex/spinifex/handlers/quota" handlers_sts "github.com/mulgadc/spinifex/spinifex/handlers/sts" @@ -540,7 +540,7 @@ func launchService(config *config.ClusterConfig) error { instanceCache := instancecache.New(js, instancecache.Config{ Bucket: kvstore.Config{Name: daemon.InstanceStateBucket, History: 1}, Prefix: daemon.InstanceRecordPrefix, - VisibleToCaller: handlers_ec2_instance.IsInstanceVisibleToCaller, + VisibleToCaller: ec2instance.IsInstanceVisibleToCaller, FallbackAccountID: awsidentifiers.GlobalAccountID, }) go instanceCache.Run(janitorCtx) diff --git a/spinifex/services/viperblockd/provider_handlers.go b/spinifex/services/viperblockd/provider_handlers.go index e3b183fef..bb704ac0c 100644 --- a/spinifex/services/viperblockd/provider_handlers.go +++ b/spinifex/services/viperblockd/provider_handlers.go @@ -780,7 +780,7 @@ func probeVolumeOwner(nc *nats.Conn, volumeID string) volumeOwnership { } // deleteObjectPrefix deletes every object under prefix in bucket, paginating -// through ListObjectsV2. Mirrors handlers/ec2/volume's deleteS3Prefix so +// through ListObjectsV2. Mirrors domains/ec2/volume's deleteS3Prefix so // DeleteVolume and DeleteSnapshot get the same idempotent-when-absent // behaviour without a second copy of the pagination loop. func deleteObjectPrefix(ctx context.Context, store objectstore.ObjectStore, bucket, prefix string) error { diff --git a/spinifex/services/viperblockd/provider_handlers_test.go b/spinifex/services/viperblockd/provider_handlers_test.go index b8ca798fa..edf9908e7 100644 --- a/spinifex/services/viperblockd/provider_handlers_test.go +++ b/spinifex/services/viperblockd/provider_handlers_test.go @@ -7,7 +7,7 @@ package viperblockd // tests that need a real viperblock engine but not real predastore. Success paths // that require opening a DETACHED engine against S3 (CreateVolume of a fresh // volume, GetVolume/ExpandVolume of an unmounted one) are out of scope here for -// the same reason handlers/ec2/volume's unit tests stop at validation: nothing +// the same reason domains/ec2/volume's unit tests stop at validation: nothing // past Backend.Init() can execute without a live backend, and this file must not // add a network dependency to a unit test. diff --git a/tests/e2e/iam/instance_iam_profile_test.go b/tests/e2e/iam/instance_iam_profile_test.go index 13d951371..0ceb2dbbf 100644 --- a/tests/e2e/iam/instance_iam_profile_test.go +++ b/tests/e2e/iam/instance_iam_profile_test.go @@ -43,7 +43,7 @@ const ( // is already asserted by tests/integration's TestIAMRolesAndProfiles. The // association lifecycle itself (Associate/AlreadyAssociated/Replace/ // Disassociate/DeleteInstanceProfile-while-bound) is implemented in -// InstanceServiceImpl (handlers/ec2/instance/service_impl.go) against a real +// InstanceServiceImpl (domains/ec2/instance/service_impl.go) against a real // *vm.VM's mutable IamInstanceProfileArn/AssociationId fields — daemon-side // state a live guest actually carries. A static stub could only stand in for // it by modelling the whole instance lifecycle, which is why this stays live diff --git a/tests/integration/daemon_lite.go b/tests/integration/daemon_lite.go index 762bbe3ae..07c5c7828 100644 --- a/tests/integration/daemon_lite.go +++ b/tests/integration/daemon_lite.go @@ -18,7 +18,7 @@ import ( ec2igw "github.com/mulgadc/spinifex/spinifex/domains/ec2/igw" ec2key "github.com/mulgadc/spinifex/spinifex/domains/ec2/key" ec2routetable "github.com/mulgadc/spinifex/spinifex/domains/ec2/routetable" - handlers_ec2_tags "github.com/mulgadc/spinifex/spinifex/handlers/ec2/tags" + ec2tags "github.com/mulgadc/spinifex/spinifex/domains/ec2/tags" ec2vpc "github.com/mulgadc/spinifex/spinifex/domains/ec2/vpc" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/nats-io/nats.go" @@ -35,7 +35,7 @@ const testPredastoreBucket = "integration-test-bucket" // DaemonLite is a minimal in-process stand-in for a live spinifex daemon. It // subscribes the REAL key/tags/route-table/VPC-subnet-SG/IGW service // implementations — the same production code a live daemon runs — to the -// NATS subjects the gateway's handlers_ec2_*.NewNATS*Service clients call, +// NATS subjects the gateway's ec2*.NewNATS*Service clients call, // so a test exercises genuine daemon-side business logic instead of a // StubSubject canned reply. // @@ -47,7 +47,7 @@ const testPredastoreBucket = "integration-test-bucket" // intentionally avoids. type DaemonLite struct { Key *ec2key.KeyServiceImpl - Tags *handlers_ec2_tags.TagsServiceImpl + Tags *ec2tags.TagsServiceImpl VPC *ec2vpc.VPCServiceImpl RouteTable *ec2routetable.RouteTableServiceImpl IGW *ec2igw.IGWServiceImpl @@ -113,9 +113,9 @@ func StartDaemonLite(t *testing.T, gw *Gateway, opts ...DaemonLiteOption) *Daemo tagsJS, err := jetstream.New(nc) require.NoError(t, err, "jetstream handle for the tag store") - tagsKV, err := handlers_ec2_tags.GetOrCreateTagsBucket(t.Context(), tagsJS) + tagsKV, err := ec2tags.GetOrCreateTagsBucket(t.Context(), tagsJS) require.NoError(t, err, "tag store bucket") - tagsSvc := handlers_ec2_tags.NewTagsServiceImplWithStore(cfg, memStore, tagsKV) + tagsSvc := ec2tags.NewTagsServiceImplWithStore(cfg, memStore, tagsKV) vpcSvc, err := ec2vpc.NewVPCServiceImplWithNATS(t.Context(), cfg, nc) require.NoError(t, err, "construct VPC service") diff --git a/tests/integration/image_daemon_lite.go b/tests/integration/image_daemon_lite.go index 14aca7453..60869fa1e 100644 --- a/tests/integration/image_daemon_lite.go +++ b/tests/integration/image_daemon_lite.go @@ -5,7 +5,7 @@ package integration import ( "testing" - handlers_ec2_image "github.com/mulgadc/spinifex/spinifex/handlers/ec2/image" + ec2image "github.com/mulgadc/spinifex/spinifex/domains/ec2/image" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" ) @@ -15,7 +15,7 @@ import ( // never resolved against a real Predastore. const testImageBucket = "integration-test-images" -// StartImageDaemonLite subscribes a real handlers_ec2_image.ImageServiceImpl +// StartImageDaemonLite subscribes a real ec2image.ImageServiceImpl // — the same production code a live daemon runs (daemon/daemon_handlers_image.go) // — to its ec2.* subjects, backed by a memory // object store rather than a real Predastore. The store itself is returned @@ -24,11 +24,11 @@ const testImageBucket = "integration-test-images" // // Deliberately separate from StartDaemonLite (like StartVolumeDaemonLite): // only a test that actually exercises images should wire it. -func StartImageDaemonLite(t *testing.T, gw *Gateway) (*handlers_ec2_image.ImageServiceImpl, objectstore.ObjectStore) { +func StartImageDaemonLite(t *testing.T, gw *Gateway) (*ec2image.ImageServiceImpl, objectstore.ObjectStore) { t.Helper() store := objectstore.NewMemoryObjectStore() - svc := handlers_ec2_image.NewImageServiceImplWithStore(store, testImageBucket) + svc := ec2image.NewImageServiceImplWithStore(store, testImageBucket) subscribeServiceMethods(t, gw.NATSConn, "ec2", svc) diff --git a/tests/integration/tags_test.go b/tests/integration/tags_test.go index a408a7c72..6190055d2 100644 --- a/tests/integration/tags_test.go +++ b/tests/integration/tags_test.go @@ -20,7 +20,7 @@ import ( // in for the same two-resource-isolation shape: a scratch VPC (stand-in for // "instance") and its own auto-created main route table (stand-in for "root // volume"). CreateTags/DescribeTags/DeleteTags never inspect resource -// existence or type beyond the ID string (handlers/ec2/tags/service_impl.go +// existence or type beyond the ID string (domains/ec2/tags/service_impl.go // getResourceType), so every assertion below — per-resource tag counts, // resource-id/resource-type/key filtering, Name overwrite-on-recreate, // unconditional vs. value-scoped delete-tags, cross-resource isolation — diff --git a/tests/integration/volume_daemon_lite.go b/tests/integration/volume_daemon_lite.go index 2f84ba5ee..88ebc079a 100644 --- a/tests/integration/volume_daemon_lite.go +++ b/tests/integration/volume_daemon_lite.go @@ -8,7 +8,7 @@ import ( "time" "github.com/mulgadc/spinifex/spinifex/bootstrap/config" - handlers_ec2_volume "github.com/mulgadc/spinifex/spinifex/handlers/ec2/volume" + ec2volume "github.com/mulgadc/spinifex/spinifex/domains/ec2/volume" "github.com/mulgadc/spinifex/spinifex/providers/ebs" "github.com/mulgadc/spinifex/spinifex/providers/objectstore" "github.com/mulgadc/spinifex/spinifex/services/viperblockd" @@ -32,7 +32,7 @@ const testProviderNodeName = "integration-node" // because the first CreateVolume pays the real predastore's cold start. const providerRequestTimeout = 60 * time.Second -// StartVolumeDaemonLite subscribes a real handlers_ec2_volume.VolumeServiceImpl +// StartVolumeDaemonLite subscribes a real ec2volume.VolumeServiceImpl // — the same production code a live daemon runs (daemon/daemon_handlers_volume.go) // — to its ec2.* subjects, backed by a // real predastore daemon (testpredastore.Start) rather than the memory-backed @@ -40,7 +40,7 @@ const providerRequestTimeout = 60 * time.Second // // This is deliberately a separate opt-in wiring rather than part of // StartDaemonLite: CreateVolume constructs viperblock.New and calls -// Backend.Init() unconditionally (handlers/ec2/volume/service_impl.go), so it +// Backend.Init() unconditionally (domains/ec2/volume/service_impl.go), so it // needs a reachable Predastore to do anything beyond input validation, while // every other DaemonLite-wired resource is happy with an in-memory stand-in. // Only a test that actually exercises volume storage should pay the shared @@ -48,7 +48,7 @@ const providerRequestTimeout = 60 * time.Second // // Must be called before a test issues a volume request; like // StartECRDaemonLite it wires its own subjects independent of StartDaemonLite. -func StartVolumeDaemonLite(t *testing.T, gw *Gateway) *handlers_ec2_volume.VolumeServiceImpl { +func StartVolumeDaemonLite(t *testing.T, gw *Gateway) *ec2volume.VolumeServiceImpl { t.Helper() fixture := testpredastore.Start(t) @@ -71,7 +71,7 @@ func StartVolumeDaemonLite(t *testing.T, gw *Gateway) *handlers_ec2_volume.Volum } nc := gw.NATSConn - svc := handlers_ec2_volume.NewVolumeServiceImplWithStore(cfg, store, nc) + svc := ec2volume.NewVolumeServiceImplWithStore(cfg, store, nc) // The control plane no longer builds volumes itself; it asks a provider. // Serve the provider contract from viperblockd against the same fixture, diff --git a/tests/integration/volume_test.go b/tests/integration/volume_test.go index c9cc95ef9..d1d062d4b 100644 --- a/tests/integration/volume_test.go +++ b/tests/integration/volume_test.go @@ -20,7 +20,7 @@ import ( // ec2.CreateVolume through the real gateway and a real VolumeServiceImpl, // which constructs viperblock.New and calls Backend.Init()/SaveState() // against an actual predastore daemon rather than an unreachable host. The -// previous unit-test equivalent (handlers/ec2/volume's +// previous unit-test equivalent (domains/ec2/volume's // TestCreateVolume_PassesValidation) could only assert the returned error // wasn't a validation error, because nothing past validation could execute // without a live backend. Here CreateVolume is expected to fully succeed,