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

This commit is contained in:
joshsiv-mulga
2026-10-07 14:23:04 +10:00
parent d500e3802f
commit e630703d75
10 changed files with 16 additions and 16 deletions
+3 -3
View File
@@ -11,12 +11,12 @@ import (
"github.com/aws/aws-sdk-go/aws"
"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"
"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_key "github.com/mulgadc/spinifex/spinifex/gateway/ec2/key"
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"
@@ -568,7 +568,7 @@ func (r *keyPairReaper) Kind() string { return "key-pair" }
func (r *keyPairReaper) Stage() Stage { return StagePlatform }
func (r *keyPairReaper) List(ctx context.Context, accountID string) ([]Resource, error) {
out, err := gateway_ec2_key.DescribeKeyPairs(ctx, &ec2.DescribeKeyPairsInput{}, r.nc, accountID)
out, err := ec2keyapi.DescribeKeyPairs(ctx, &ec2.DescribeKeyPairsInput{}, r.nc, accountID)
if err != nil {
return nil, err
}
@@ -584,7 +584,7 @@ func (r *keyPairReaper) List(ctx context.Context, accountID string) ([]Resource,
}
func (r *keyPairReaper) Delete(ctx context.Context, accountID string, resource Resource, _ bool) error {
_, err := gateway_ec2_key.DeleteKeyPair(ctx, &ec2.DeleteKeyPairInput{
_, err := ec2keyapi.DeleteKeyPair(ctx, &ec2.DeleteKeyPairInput{
KeyName: aws.String(resource.ID),
}, r.nc, accountID)
return ignoreAlreadyGone(err)
@@ -1,4 +1,4 @@
package gateway_ec2_key
package key
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_key
package key
import (
"testing"
@@ -1,4 +1,4 @@
package gateway_ec2_key
package key
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_key
package key
import (
"testing"
@@ -1,4 +1,4 @@
package gateway_ec2_key
package key
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_key
package key
import (
"context"
@@ -1,4 +1,4 @@
package gateway_ec2_key
package key
import (
"errors"
@@ -1,4 +1,4 @@
package gateway_ec2_key
package key
import (
"context"
+5 -5
View File
@@ -15,6 +15,7 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
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"
"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"
@@ -24,7 +25,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_key "github.com/mulgadc/spinifex/spinifex/gateway/ec2/key"
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"
@@ -289,16 +289,16 @@ var ec2Actions = map[string]ec2Action{
return gateway_ec2_instance.DescribeInstanceCreditSpecifications(input)
}),
"CreateKeyPair": ec2Handler(func(ctx context.Context, input *ec2.CreateKeyPairInput, gw *GatewayConfig, accountID string) (any, error) {
return gateway_ec2_key.CreateKeyPair(ctx, input, gw.NATSConn, accountID)
return ec2keyapi.CreateKeyPair(ctx, input, gw.NATSConn, accountID)
}),
"DeleteKeyPair": ec2Handler(func(ctx context.Context, input *ec2.DeleteKeyPairInput, gw *GatewayConfig, accountID string) (any, error) {
return gateway_ec2_key.DeleteKeyPair(ctx, input, gw.NATSConn, accountID)
return ec2keyapi.DeleteKeyPair(ctx, input, gw.NATSConn, accountID)
}),
"DescribeKeyPairs": ec2Handler(func(ctx context.Context, input *ec2.DescribeKeyPairsInput, gw *GatewayConfig, accountID string) (any, error) {
return gateway_ec2_key.DescribeKeyPairs(ctx, input, gw.NATSConn, accountID)
return ec2keyapi.DescribeKeyPairs(ctx, input, gw.NATSConn, accountID)
}),
"ImportKeyPair": ec2Handler(func(ctx context.Context, input *ec2.ImportKeyPairInput, gw *GatewayConfig, accountID string) (any, error) {
return gateway_ec2_key.ImportKeyPair(ctx, input, gw.NATSConn, accountID)
return ec2keyapi.ImportKeyPair(ctx, input, gw.NATSConn, accountID)
}).withQueryPreprocessor(func(q map[string]string) {
// Parser leaves Base64 padding URL-encoded; decode it before dispatch.
if strings.HasSuffix(q["PublicKeyMaterial"], "%3D%3D") {