mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 17:11:30 +00:00
refactor: move EC2 igw action adapters to domains/ec2/awsapi
This commit is contained in:
@@ -12,12 +12,12 @@ import (
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
ec2eipapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/eip"
|
||||
ec2igwapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/igw"
|
||||
ec2keyapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/key"
|
||||
ec2launchtemplateapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/launchtemplate"
|
||||
ec2placementgroupapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/placementgroup"
|
||||
ec2vpcapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/vpc"
|
||||
"github.com/mulgadc/spinifex/spinifex/foundation/aws/errors"
|
||||
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_routetable "github.com/mulgadc/spinifex/spinifex/gateway/ec2/routetable"
|
||||
@@ -364,7 +364,7 @@ func (r *igwReaper) Kind() string { return "internet-gateway" }
|
||||
func (r *igwReaper) Stage() Stage { return StageNetwork }
|
||||
|
||||
func (r *igwReaper) List(ctx context.Context, accountID string) ([]Resource, error) {
|
||||
out, err := gateway_ec2_igw.DescribeInternetGateways(ctx, &ec2.DescribeInternetGatewaysInput{}, r.nc, accountID)
|
||||
out, err := ec2igwapi.DescribeInternetGateways(ctx, &ec2.DescribeInternetGatewaysInput{}, r.nc, accountID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -390,7 +390,7 @@ func (r *igwReaper) List(ctx context.Context, accountID string) ([]Resource, err
|
||||
// cannot be deleted while it is attached.
|
||||
func (r *igwReaper) Delete(ctx context.Context, accountID string, resource Resource, _ bool) error {
|
||||
if resource.Detail != "" {
|
||||
if _, err := gateway_ec2_igw.DetachInternetGateway(ctx, &ec2.DetachInternetGatewayInput{
|
||||
if _, err := ec2igwapi.DetachInternetGateway(ctx, &ec2.DetachInternetGatewayInput{
|
||||
InternetGatewayId: aws.String(resource.ID),
|
||||
VpcId: aws.String(resource.Detail),
|
||||
}, r.nc, accountID); err != nil && !isAlreadyGone(err) {
|
||||
@@ -401,7 +401,7 @@ func (r *igwReaper) Delete(ctx context.Context, accountID string, resource Resou
|
||||
// Detail is empty and the delete is refused. DeleteVpc rejects while the
|
||||
// gateway is attached, so the VPC survives and the next sweep, once the
|
||||
// attachment is confirmed, takes the branch above.
|
||||
_, err := gateway_ec2_igw.DeleteInternetGateway(ctx, &ec2.DeleteInternetGatewayInput{
|
||||
_, err := ec2igwapi.DeleteInternetGateway(ctx, &ec2.DeleteInternetGatewayInput{
|
||||
InternetGatewayId: aws.String(resource.ID),
|
||||
}, r.nc, accountID)
|
||||
return ignoreAlreadyGone(err)
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package gateway_ec2_igw
|
||||
package igw
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package gateway_ec2_igw
|
||||
package igw
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package gateway_ec2_igw
|
||||
package igw
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package gateway_ec2_igw
|
||||
package igw
|
||||
|
||||
import (
|
||||
"context"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package gateway_ec2_igw
|
||||
package igw
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package gateway_ec2_igw
|
||||
package igw
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
ec2capacityreservationapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/capacityreservation"
|
||||
ec2eigwapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/eigw"
|
||||
ec2eipapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/eip"
|
||||
ec2igwapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/igw"
|
||||
ec2keyapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/key"
|
||||
ec2launchtemplateapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/launchtemplate"
|
||||
ec2placementgroupapi "github.com/mulgadc/spinifex/spinifex/domains/ec2/awsapi/placementgroup"
|
||||
@@ -26,7 +27,6 @@ import (
|
||||
awsxml "github.com/mulgadc/spinifex/spinifex/foundation/aws/xml"
|
||||
"github.com/mulgadc/spinifex/spinifex/foundation/lifecycle/idempotency"
|
||||
gateway_ec2 "github.com/mulgadc/spinifex/spinifex/gateway/ec2"
|
||||
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_natgw "github.com/mulgadc/spinifex/spinifex/gateway/ec2/natgw"
|
||||
@@ -410,19 +410,19 @@ var ec2Actions = map[string]ec2Action{
|
||||
return gateway_ec2_snapshot.CopySnapshot(ctx, input, gw.NATSConn, accountID)
|
||||
}),
|
||||
"CreateInternetGateway": ec2Handler(func(ctx context.Context, input *ec2.CreateInternetGatewayInput, gw *GatewayConfig, accountID string) (any, error) {
|
||||
return gateway_ec2_igw.CreateInternetGateway(ctx, input, gw.NATSConn, accountID)
|
||||
return ec2igwapi.CreateInternetGateway(ctx, input, gw.NATSConn, accountID)
|
||||
}),
|
||||
"DeleteInternetGateway": ec2Handler(func(ctx context.Context, input *ec2.DeleteInternetGatewayInput, gw *GatewayConfig, accountID string) (any, error) {
|
||||
return gateway_ec2_igw.DeleteInternetGateway(ctx, input, gw.NATSConn, accountID)
|
||||
return ec2igwapi.DeleteInternetGateway(ctx, input, gw.NATSConn, accountID)
|
||||
}),
|
||||
"DescribeInternetGateways": ec2Handler(func(ctx context.Context, input *ec2.DescribeInternetGatewaysInput, gw *GatewayConfig, accountID string) (any, error) {
|
||||
return gateway_ec2_igw.DescribeInternetGateways(ctx, input, gw.NATSConn, accountID)
|
||||
return ec2igwapi.DescribeInternetGateways(ctx, input, gw.NATSConn, accountID)
|
||||
}),
|
||||
"AttachInternetGateway": ec2Handler(func(ctx context.Context, input *ec2.AttachInternetGatewayInput, gw *GatewayConfig, accountID string) (any, error) {
|
||||
return gateway_ec2_igw.AttachInternetGateway(ctx, input, gw.NATSConn, accountID)
|
||||
return ec2igwapi.AttachInternetGateway(ctx, input, gw.NATSConn, accountID)
|
||||
}),
|
||||
"DetachInternetGateway": ec2Handler(func(ctx context.Context, input *ec2.DetachInternetGatewayInput, gw *GatewayConfig, accountID string) (any, error) {
|
||||
return gateway_ec2_igw.DetachInternetGateway(ctx, input, gw.NATSConn, accountID)
|
||||
return ec2igwapi.DetachInternetGateway(ctx, input, gw.NATSConn, accountID)
|
||||
}),
|
||||
"CreateEgressOnlyInternetGateway": ec2IdempotentHandler(func(ctx context.Context, input *ec2.CreateEgressOnlyInternetGatewayInput, gw *GatewayConfig, accountID string) (ec2.CreateEgressOnlyInternetGatewayOutput, error) {
|
||||
return ec2eigwapi.CreateEgressOnlyInternetGateway(ctx, input, gw.NATSConn, accountID)
|
||||
|
||||
Reference in New Issue
Block a user