refactor: move EC2 launchtemplate action adapters to domains/ec2/awsapi

This commit is contained in:
joshsiv-mulga
2026-10-07 14:23:04 +10:00
parent e630703d75
commit eb68ec460d
12 changed files with 21 additions and 21 deletions
+3 -3
View File
@@ -12,12 +12,12 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/s3"
ec2keyapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/key"
ec2launchtemplateapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/launchtemplate"
"github.com/mulgadc/spinifex/spinifex/foundation/aws/errors"
gateway_ec2_eip "github.com/mulgadc/spinifex/spinifex/gateway/ec2/eip"
gateway_ec2_igw "github.com/mulgadc/spinifex/spinifex/gateway/ec2/igw"
gateway_ec2_image "github.com/mulgadc/spinifex/spinifex/gateway/ec2/image"
gateway_ec2_instance "github.com/mulgadc/spinifex/spinifex/gateway/ec2/instance"
gateway_ec2_launchtemplate "github.com/mulgadc/spinifex/spinifex/gateway/ec2/launchtemplate"
gateway_ec2_placementgroup "github.com/mulgadc/spinifex/spinifex/gateway/ec2/placementgroup"
gateway_ec2_routetable "github.com/mulgadc/spinifex/spinifex/gateway/ec2/routetable"
gateway_ec2_snapshot "github.com/mulgadc/spinifex/spinifex/gateway/ec2/snapshot"
@@ -624,7 +624,7 @@ func (r *launchTemplateReaper) Kind() string { return "launch-template" }
func (r *launchTemplateReaper) Stage() Stage { return StagePlatform }
func (r *launchTemplateReaper) List(ctx context.Context, accountID string) ([]Resource, error) {
out, err := gateway_ec2_launchtemplate.DescribeLaunchTemplates(ctx, &ec2.DescribeLaunchTemplatesInput{}, r.nc, accountID)
out, err := ec2launchtemplateapi.DescribeLaunchTemplates(ctx, &ec2.DescribeLaunchTemplatesInput{}, r.nc, accountID)
if err != nil {
return nil, err
}
@@ -640,7 +640,7 @@ func (r *launchTemplateReaper) List(ctx context.Context, accountID string) ([]Re
}
func (r *launchTemplateReaper) Delete(ctx context.Context, accountID string, resource Resource, _ bool) error {
_, err := gateway_ec2_launchtemplate.DeleteLaunchTemplate(ctx, &ec2.DeleteLaunchTemplateInput{
_, err := ec2launchtemplateapi.DeleteLaunchTemplate(ctx, &ec2.DeleteLaunchTemplateInput{
LaunchTemplateId: aws.String(resource.ID),
}, r.nc, accountID)
return ignoreAlreadyGone(err)
@@ -1,4 +1,4 @@
package gateway_ec2_launchtemplate
package launchtemplate
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_launchtemplate
package launchtemplate
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_launchtemplate
package launchtemplate
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_launchtemplate
package launchtemplate
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_launchtemplate
package launchtemplate
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_launchtemplate
package launchtemplate
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_launchtemplate
package launchtemplate
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_launchtemplate
package launchtemplate
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_launchtemplate
package launchtemplate
import (
"errors"
+8 -8
View File
@@ -16,6 +16,7 @@ import (
ec2accountapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/account"
ec2capacityreservationapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/capacityreservation"
ec2keyapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/key"
ec2launchtemplateapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/launchtemplate"
"github.com/mulgadc/spinifex/spinifex/foundation/aws/errors"
awsxml "github.com/mulgadc/spinifex/spinifex/foundation/aws/xml"
"github.com/mulgadc/spinifex/spinifex/foundation/lifecycle/idempotency"
@@ -25,7 +26,6 @@ import (
gateway_ec2_igw "github.com/mulgadc/spinifex/spinifex/gateway/ec2/igw"
gateway_ec2_image "github.com/mulgadc/spinifex/spinifex/gateway/ec2/image"
gateway_ec2_instance "github.com/mulgadc/spinifex/spinifex/gateway/ec2/instance"
gateway_ec2_launchtemplate "github.com/mulgadc/spinifex/spinifex/gateway/ec2/launchtemplate"
gateway_ec2_natgw "github.com/mulgadc/spinifex/spinifex/gateway/ec2/natgw"
gateway_ec2_placementgroup "github.com/mulgadc/spinifex/spinifex/gateway/ec2/placementgroup"
gateway_ec2_routetable "github.com/mulgadc/spinifex/spinifex/gateway/ec2/routetable"
@@ -452,25 +452,25 @@ var ec2Actions = map[string]ec2Action{
return ec2capacityreservationapi.CancelCapacityReservation(ctx, input, gw.NATSConn, gw.ExpectedNodes, accountID)
}),
"CreateLaunchTemplate": ec2Handler(func(ctx context.Context, input *ec2.CreateLaunchTemplateInput, gw *GatewayConfig, accountID string) (any, error) {
return gateway_ec2_launchtemplate.CreateLaunchTemplate(ctx, input, gw.NATSConn, accountID)
return ec2launchtemplateapi.CreateLaunchTemplate(ctx, input, gw.NATSConn, accountID)
}),
"CreateLaunchTemplateVersion": ec2IdempotentHandler(func(ctx context.Context, input *ec2.CreateLaunchTemplateVersionInput, gw *GatewayConfig, accountID string) (ec2.CreateLaunchTemplateVersionOutput, error) {
return gateway_ec2_launchtemplate.CreateLaunchTemplateVersion(ctx, input, gw.NATSConn, accountID)
return ec2launchtemplateapi.CreateLaunchTemplateVersion(ctx, input, gw.NATSConn, accountID)
}),
"DeleteLaunchTemplate": ec2Handler(func(ctx context.Context, input *ec2.DeleteLaunchTemplateInput, gw *GatewayConfig, accountID string) (any, error) {
return gateway_ec2_launchtemplate.DeleteLaunchTemplate(ctx, input, gw.NATSConn, accountID)
return ec2launchtemplateapi.DeleteLaunchTemplate(ctx, input, gw.NATSConn, accountID)
}),
"DeleteLaunchTemplateVersions": ec2Handler(func(ctx context.Context, input *ec2.DeleteLaunchTemplateVersionsInput, gw *GatewayConfig, accountID string) (any, error) {
return gateway_ec2_launchtemplate.DeleteLaunchTemplateVersions(ctx, input, gw.NATSConn, accountID)
return ec2launchtemplateapi.DeleteLaunchTemplateVersions(ctx, input, gw.NATSConn, accountID)
}),
"ModifyLaunchTemplate": ec2Handler(func(ctx context.Context, input *ec2.ModifyLaunchTemplateInput, gw *GatewayConfig, accountID string) (any, error) {
return gateway_ec2_launchtemplate.ModifyLaunchTemplate(ctx, input, gw.NATSConn, accountID)
return ec2launchtemplateapi.ModifyLaunchTemplate(ctx, input, gw.NATSConn, accountID)
}),
"DescribeLaunchTemplates": ec2Handler(func(ctx context.Context, input *ec2.DescribeLaunchTemplatesInput, gw *GatewayConfig, accountID string) (any, error) {
return gateway_ec2_launchtemplate.DescribeLaunchTemplates(ctx, input, gw.NATSConn, accountID)
return ec2launchtemplateapi.DescribeLaunchTemplates(ctx, input, gw.NATSConn, accountID)
}),
"DescribeLaunchTemplateVersions": ec2Handler(func(ctx context.Context, input *ec2.DescribeLaunchTemplateVersionsInput, gw *GatewayConfig, accountID string) (any, error) {
return gateway_ec2_launchtemplate.DescribeLaunchTemplateVersions(ctx, input, gw.NATSConn, accountID)
return ec2launchtemplateapi.DescribeLaunchTemplateVersions(ctx, input, gw.NATSConn, accountID)
}),
"RequestSpotInstances": ec2HandlerWithReq(func(ctx context.Context, input *ec2.RequestSpotInstancesInput, gw *GatewayConfig, accountID string, r *http.Request) (any, error) {
passRoleCheck := func(roleARN string) error {
@@ -14,7 +14,7 @@ import (
// ec2launchtemplate.LaunchTemplateServiceImpl — the same production
// code a live daemon runs (daemon/daemon_handlers_launchtemplate.go) — to
// every ec2.*LaunchTemplate* subject the gateway's NATSLaunchTemplateService
// client calls (gateway/ec2/launchtemplate/*.go, RunInstances.go's
// client calls (domains/ec2/awsapi/launchtemplate/*.go, RunInstances.go's
// expandLaunchTemplate). Unlike StubSubject's static canned JSON, this
// exercises the real KV-backed CRUD and version-resolution logic, matching
// how RunInstances resolves a referenced template into effective ImageId/