-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwire_gen.go
151 lines (132 loc) · 5.57 KB
/
wire_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire
//go:build !wireinject
// +build !wireinject
package di
import (
"context"
"github.com/nao1215/rainbow/app/domain/model"
"github.com/nao1215/rainbow/app/external"
"github.com/nao1215/rainbow/app/interactor"
"github.com/nao1215/rainbow/app/usecase"
)
// Injectors from wire.go:
// NewS3App creates a new S3App.
func NewS3App(ctx context.Context, profile model.AWSProfile, region model.Region) (*S3App, error) {
awsConfig, err := model.NewAWSConfig(ctx, profile, region)
if err != nil {
return nil, err
}
client, err := external.NewS3Client(awsConfig)
if err != nil {
return nil, err
}
s3BucketCreator := external.NewS3BucketCreator(client)
interactorS3BucketCreator := interactor.NewS3BucketCreator(s3BucketCreator)
s3BucketLister := external.NewS3BucketLister(client)
s3BucketLocationGetter := external.NewS3BucketLocationGetter(client)
interactorS3BucketLister := interactor.NewS3BucketLister(s3BucketLister, s3BucketLocationGetter)
s3BucketDeleter := external.NewS3BucketDeleter(client)
interactorS3BucketDeleter := interactor.NewS3BucketDeleter(s3BucketDeleter, s3BucketLocationGetter)
s3BucketObjectsLister := external.NewS3BucketObjectsLister(client)
interactorS3BucketObjectsLister := interactor.NewS3BucketObjectsLister(s3BucketObjectsLister)
s3BucketObjectsDeleter := external.NewS3BucketObjectsDeleter(client)
interactorS3BucketObjectsDeleter := interactor.NewS3BucketObjectsDeleter(s3BucketObjectsDeleter, s3BucketLocationGetter)
s3App := newS3App(interactorS3BucketCreator, interactorS3BucketLister, interactorS3BucketDeleter, interactorS3BucketObjectsLister, interactorS3BucketObjectsDeleter)
return s3App, nil
}
// NewSpareApp creates a new SpareApp.
func NewSpareApp(ctx context.Context, profile model.AWSProfile, region model.Region) (*SpareApp, error) {
awsConfig, err := model.NewAWSConfig(ctx, profile, region)
if err != nil {
return nil, err
}
client, err := external.NewCloudFrontClient(awsConfig)
if err != nil {
return nil, err
}
cloudFrontCreator := external.NewCloudFrontCreator(client)
cloudFrontOAICreator := external.NewCloudFrontOAICreator(client)
cloudFrontCreatorOptions := &interactor.CloudFrontCreatorOptions{
CloudFrontCreator: cloudFrontCreator,
OAICreator: cloudFrontOAICreator,
}
interactorCloudFrontCreator := interactor.NewCloudFrontCreator(cloudFrontCreatorOptions)
s3Client, err := external.NewS3Client(awsConfig)
if err != nil {
return nil, err
}
s3BucketObjectUploader := external.NewS3BucketObjectUploader(s3Client)
fileUploaderOptions := &interactor.FileUploaderOptions{
S3BucketObjectUploader: s3BucketObjectUploader,
}
fileUploader := interactor.NewFileUploader(fileUploaderOptions)
s3BucketCreator := external.NewS3BucketCreator(s3Client)
interactorS3BucketCreator := interactor.NewS3BucketCreator(s3BucketCreator)
s3BucketPublicAccessBlocker := external.NewS3BucketPublicAccessBlocker(s3Client)
interactorS3BucketPublicAccessBlocker := interactor.NewS3BucketPublicAccessBlocker(s3BucketPublicAccessBlocker)
s3BucketPolicySetter := external.NewS3BucketPolicySetter(s3Client)
interactorS3BucketPolicySetter := interactor.NewS3BucketPolicySetter(s3BucketPolicySetter)
spareApp := newSpareApp(interactorCloudFrontCreator, fileUploader, interactorS3BucketCreator, interactorS3BucketPublicAccessBlocker, interactorS3BucketPolicySetter)
return spareApp, nil
}
// wire.go:
// S3App is the application service for S3.
type S3App struct {
usecase.
// S3BucketCreator is the usecase for creating a new S3 bucket.
S3BucketCreator
usecase.S3BucketLister
usecase.S3BucketDeleter
// S3BucketLister is the usecase for listing S3 buckets.
// S3BucketDeleter is the usecase for deleting a S3 bucket.
usecase.S3BucketObjectsLister
// S3BucketObjectsLister is the usecase for listing S3 bucket objects.
usecase.S3BucketObjectsDeleter
// S3BucketObjectsDeleter is the usecase for deleting S3 bucket objects.
}
func newS3App(
s3BucketCreator usecase.S3BucketCreator,
s3BucketLister usecase.S3BucketLister,
s3BucketDeleter usecase.S3BucketDeleter,
s3BucketObjectsLister usecase.S3BucketObjectsLister,
s3BucketObjectsDeleter usecase.S3BucketObjectsDeleter,
) *S3App {
return &S3App{
S3BucketCreator: s3BucketCreator,
S3BucketLister: s3BucketLister,
S3BucketDeleter: s3BucketDeleter,
S3BucketObjectsLister: s3BucketObjectsLister,
S3BucketObjectsDeleter: s3BucketObjectsDeleter,
}
}
// SpareApp is the application service for spare command.
type SpareApp struct {
usecase.
// CloudFrontCreator is the usecase for creating CloudFront.
CloudFrontCreator
usecase.FileUploader
usecase.S3BucketCreator
// FileUploader is the usecase for uploading a file.
// S3BucketCreator is the usecase for creating a new S3 bucket.
usecase.S3BucketPublicAccessBlocker
// S3BucketPublicAccessBlocker is the usecase for blocking public access to a S3 bucket.
usecase.S3BucketPolicySetter
// BucketPolicySetter is the usecase for setting a bucket policy.
}
// newSpareApp creates a new SpareApp.
func newSpareApp(
cloudFrontCreator usecase.CloudFrontCreator,
fileUploader usecase.FileUploader,
s3BucketCreator usecase.S3BucketCreator,
s3BucketPublicAccessBlocker usecase.S3BucketPublicAccessBlocker,
s3BucketPolicySetter usecase.S3BucketPolicySetter,
) *SpareApp {
return &SpareApp{
CloudFrontCreator: cloudFrontCreator,
FileUploader: fileUploader,
S3BucketCreator: s3BucketCreator,
S3BucketPublicAccessBlocker: s3BucketPublicAccessBlocker,
S3BucketPolicySetter: s3BucketPolicySetter,
}
}