diff --git a/app/di/wire_gen.go b/app/di/wire_gen.go index 36cf759..bf0433e 100644 --- a/app/di/wire_gen.go +++ b/app/di/wire_gen.go @@ -22,10 +22,7 @@ func NewS3App(ctx context.Context, profile model.AWSProfile, region model.Region if err != nil { return nil, err } - client, err := external.NewS3Client(awsConfig) - if err != nil { - return nil, err - } + client := external.NewS3Client(awsConfig) s3BucketCreator := external.NewS3BucketCreator(client) interactorS3BucketCreator := interactor.NewS3BucketCreator(s3BucketCreator) s3BucketLister := external.NewS3BucketLister(client) @@ -53,10 +50,7 @@ func NewSpareApp(ctx context.Context, profile model.AWSProfile, region model.Reg if err != nil { return nil, err } - client, err := external.NewCloudFrontClient(awsConfig) - if err != nil { - return nil, err - } + client := external.NewCloudFrontClient(awsConfig) cloudFrontCreator := external.NewCloudFrontCreator(client) cloudFrontOAICreator := external.NewCloudFrontOAICreator(client) cloudFrontCreatorOptions := &interactor.CloudFrontCreatorOptions{ @@ -64,10 +58,7 @@ func NewSpareApp(ctx context.Context, profile model.AWSProfile, region model.Reg OAICreator: cloudFrontOAICreator, } interactorCloudFrontCreator := interactor.NewCloudFrontCreator(cloudFrontCreatorOptions) - s3Client, err := external.NewS3Client(awsConfig) - if err != nil { - return nil, err - } + s3Client := external.NewS3Client(awsConfig) s3ObjectUploader := external.NewS3ObjectUploader(s3Client) fileUploader := interactor.NewFileUploader(s3ObjectUploader) s3BucketCreator := external.NewS3BucketCreator(s3Client) diff --git a/app/external/cloudfront.go b/app/external/cloudfront.go index c77a83a..4c9b931 100644 --- a/app/external/cloudfront.go +++ b/app/external/cloudfront.go @@ -15,8 +15,8 @@ import ( ) // NewCloudFrontClient returns a new CloudFront client. -func NewCloudFrontClient(cfg *model.AWSConfig) (*cloudfront.Client, error) { - return cloudfront.NewFromConfig(*cfg.Config), nil +func NewCloudFrontClient(cfg *model.AWSConfig) *cloudfront.Client { + return cloudfront.NewFromConfig(*cfg.Config) } // CloudFrontCreatorSet is a provider set for CloudFrontCreator. diff --git a/app/external/s3.go b/app/external/s3.go index 205b867..45940fd 100644 --- a/app/external/s3.go +++ b/app/external/s3.go @@ -19,8 +19,8 @@ import ( // NewS3Client creates a new S3 service client. // If profile is empty, the default profile is used. -func NewS3Client(cfg *model.AWSConfig) (*s3.Client, error) { - return s3.NewFromConfig(*cfg.Config), nil +func NewS3Client(cfg *model.AWSConfig) *s3.Client { + return s3.NewFromConfig(*cfg.Config) } // S3BucketCreator implements the S3BucketCreator interface. diff --git a/app/external/s3_helper_test.go b/app/external/s3_helper_test.go index 01524fd..6dab305 100644 --- a/app/external/s3_helper_test.go +++ b/app/external/s3_helper_test.go @@ -17,11 +17,7 @@ func S3Client(t *testing.T) *s3.Client { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } - return client + return NewS3Client(config) } // CreateS3Buckets creates S3 buckets. Region is fixed to ap-northeast-1. diff --git a/app/external/s3_test.go b/app/external/s3_test.go index 8a8308e..4392a3e 100644 --- a/app/external/s3_test.go +++ b/app/external/s3_test.go @@ -21,10 +21,7 @@ func TestS3BucketCreator_CreateS3Bucket(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) s3BucketCreator := NewS3BucketCreator(client) input := &service.S3BucketCreatorInput{ @@ -47,10 +44,7 @@ func TestS3BucketCreator_CreateS3Bucket(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) s3BucketCreator := NewS3BucketCreator(client) input := &service.S3BucketCreatorInput{ @@ -74,10 +68,7 @@ func TestS3BucketCreator_CreateS3Bucket(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) s3BucketCreator := NewS3BucketCreator(client) input := &service.S3BucketCreatorInput{ @@ -97,10 +88,7 @@ func TestS3BucketCreator_CreateS3Bucket(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) s3BucketCreator := NewS3BucketCreator(client) input := &service.S3BucketCreatorInput{ @@ -120,10 +108,7 @@ func TestS3BucketCreator_CreateS3Bucket(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) s3BucketCreator := NewS3BucketCreator(client) input := &service.S3BucketCreatorInput{ @@ -147,10 +132,7 @@ func TestS3BucketLister_ListS3Buckets(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) CreateS3Buckets(t, client, []model.Bucket{ model.Bucket("test-bucket-3"), @@ -191,10 +173,7 @@ func TestS3BucketLister_ListS3Buckets(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) s3BucketLister := NewS3BucketLister(client) got, err := s3BucketLister.ListS3Buckets(context.Background(), &service.S3BucketListerInput{}) @@ -220,10 +199,7 @@ func TestS3BucketLocationGetter_GetS3BucketLocation(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) CreateS3Buckets(t, client, []model.Bucket{ model.Bucket("test-bucket-1"), @@ -253,10 +229,7 @@ func TestS3BucketLocationGetter_GetS3BucketLocation(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) s3BucketLocationGetter := NewS3BucketLocationGetter(client) _, got := s3BucketLocationGetter.GetS3BucketLocation(context.Background(), &service.S3BucketLocationGetterInput{ @@ -274,10 +247,7 @@ func TestS3BucketLocationGetter_GetS3BucketLocation(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) s3BucketCreator := NewS3BucketCreator(client) input := &service.S3BucketCreatorInput{ @@ -327,10 +297,8 @@ func TestS3BucketDeleter_DeleteS3Bucket(t *testing.T) { if err != nil { t.Fatal(err) } - client, err := NewS3Client(config) - if err != nil { - t.Fatal(err) - } + client := NewS3Client(config) + s3BucketCreator := NewS3BucketCreator(client) input := &service.S3BucketCreatorInput{ Bucket: model.Bucket("test-bucket"), diff --git a/go.mod b/go.mod index ee7f2ff..2e6aec7 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/aws/aws-sdk-go-v2 v1.24.1 github.com/aws/aws-sdk-go-v2/config v1.26.3 + github.com/aws/aws-sdk-go-v2/service/cloudformation v1.42.6 github.com/aws/aws-sdk-go-v2/service/cloudfront v1.32.6 github.com/aws/aws-sdk-go-v2/service/s3 v1.48.0 github.com/charmbracelet/bubbles v0.17.1 diff --git a/go.sum b/go.sum index c853e3c..8a938e8 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,8 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2 h1:GrSw8s0Gs/5zZ0SX+gX4zQjRnRsM github.com/aws/aws-sdk-go-v2/internal/ini v1.7.2/go.mod h1:6fQQgfuGmw8Al/3M2IgIllycxV7ZW7WCdVSqfBeUiCY= github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.10 h1:5oE2WzJE56/mVveuDZPJESKlg/00AaS2pY2QZcnxg4M= github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.10/go.mod h1:FHbKWQtRBYUz4vO5WBWjzMD2by126ny5y/1EoaWoLfI= +github.com/aws/aws-sdk-go-v2/service/cloudformation v1.42.6 h1:XdEBz/eAB4K5QyQ9fx3sgbthOW3WiNOSomnhFXk6R+g= +github.com/aws/aws-sdk-go-v2/service/cloudformation v1.42.6/go.mod h1:3+AceTAg/X5AUM/SkAbgxzviOBmsGaf9POso/Ymz5vc= github.com/aws/aws-sdk-go-v2/service/cloudfront v1.32.6 h1:xKbFXea2CIF/Wskauz1TMr//wZ6FyzEafMdSBIQqn80= github.com/aws/aws-sdk-go-v2/service/cloudfront v1.32.6/go.mod h1:iB6PQSb3ULRrrlEiuFfVE318JiBOdk4k46BbuzrrgXc= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 h1:/b31bi3YVNlkzkBrm9LfpaKoaYZUxIAj4sHfOTmLfqw=