-
Notifications
You must be signed in to change notification settings - Fork 0
/
repository_locator.go
241 lines (199 loc) · 10.7 KB
/
repository_locator.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
package api
import (
"crypto/tls"
"net/http"
"github.com/cloudfoundry/cli/cf/api/authentication"
"github.com/cloudfoundry/cli/cf/api/quotas"
"github.com/cloudfoundry/cli/cf/api/security_groups"
"github.com/cloudfoundry/cli/cf/api/security_groups/defaults/running"
"github.com/cloudfoundry/cli/cf/api/security_groups/defaults/staging"
securitygroupspaces "github.com/cloudfoundry/cli/cf/api/security_groups/spaces"
"github.com/cloudfoundry/cli/cf/api/space_quotas"
"github.com/cloudfoundry/cli/cf/api/spaces"
"github.com/cloudfoundry/cli/cf/api/strategy"
"github.com/cloudfoundry/cli/cf/app_files"
"github.com/cloudfoundry/cli/cf/configuration"
"github.com/cloudfoundry/cli/cf/net"
"github.com/cloudfoundry/cli/cf/terminal"
consumer "github.com/cloudfoundry/loggregator_consumer"
)
type RepositoryLocator struct {
authRepo authentication.AuthenticationRepository
curlRepo CurlRepository
endpointRepo RemoteEndpointRepository
organizationRepo CloudControllerOrganizationRepository
quotaRepo quotas.CloudControllerQuotaRepository
spaceRepo spaces.CloudControllerSpaceRepository
appRepo CloudControllerApplicationRepository
appBitsRepo CloudControllerApplicationBitsRepository
appSummaryRepo CloudControllerAppSummaryRepository
appInstancesRepo CloudControllerAppInstancesRepository
appEventsRepo CloudControllerAppEventsRepository
appFilesRepo CloudControllerAppFilesRepository
domainRepo CloudControllerDomainRepository
routeRepo CloudControllerRouteRepository
stackRepo CloudControllerStackRepository
serviceRepo CloudControllerServiceRepository
serviceBindingRepo CloudControllerServiceBindingRepository
serviceSummaryRepo CloudControllerServiceSummaryRepository
userRepo CloudControllerUserRepository
passwordRepo CloudControllerPasswordRepository
logsRepo LogsRepository
authTokenRepo CloudControllerServiceAuthTokenRepository
serviceBrokerRepo CloudControllerServiceBrokerRepository
servicePlanRepo CloudControllerServicePlanRepository
servicePlanVisibilityRepo ServicePlanVisibilityRepository
userProvidedServiceInstanceRepo CCUserProvidedServiceInstanceRepository
buildpackRepo CloudControllerBuildpackRepository
buildpackBitsRepo CloudControllerBuildpackBitsRepository
securityGroupRepo security_groups.SecurityGroupRepo
stagingSecurityGroupRepo staging.StagingSecurityGroupsRepo
runningSecurityGroupRepo running.RunningSecurityGroupsRepo
securityGroupSpaceBinder securitygroupspaces.SecurityGroupSpaceBinder
spaceQuotaRepo space_quotas.SpaceQuotaRepository
}
func NewRepositoryLocator(config configuration.ReadWriter, gatewaysByName map[string]net.Gateway) (loc RepositoryLocator) {
strategy := strategy.NewEndpointStrategy(config.ApiVersion())
authGateway := gatewaysByName["auth"]
cloudControllerGateway := gatewaysByName["cloud-controller"]
uaaGateway := gatewaysByName["uaa"]
loc.authRepo = authentication.NewUAAAuthenticationRepository(authGateway, config)
// ensure gateway refreshers are set before passing them by value to repositories
cloudControllerGateway.SetTokenRefresher(loc.authRepo)
uaaGateway.SetTokenRefresher(loc.authRepo)
tlsConfig := net.NewTLSConfig([]tls.Certificate{}, config.IsSSLDisabled())
loggregatorConsumer := consumer.New(config.LoggregatorEndpoint(), tlsConfig, http.ProxyFromEnvironment)
loggregatorConsumer.SetDebugPrinter(terminal.DebugPrinter{})
loc.appBitsRepo = NewCloudControllerApplicationBitsRepository(config, cloudControllerGateway, app_files.ApplicationZipper{})
loc.appEventsRepo = NewCloudControllerAppEventsRepository(config, cloudControllerGateway, strategy)
loc.appFilesRepo = NewCloudControllerAppFilesRepository(config, cloudControllerGateway)
loc.appRepo = NewCloudControllerApplicationRepository(config, cloudControllerGateway)
loc.appSummaryRepo = NewCloudControllerAppSummaryRepository(config, cloudControllerGateway)
loc.appInstancesRepo = NewCloudControllerAppInstancesRepository(config, cloudControllerGateway)
loc.authTokenRepo = NewCloudControllerServiceAuthTokenRepository(config, cloudControllerGateway)
loc.curlRepo = NewCloudControllerCurlRepository(config, cloudControllerGateway)
loc.domainRepo = NewCloudControllerDomainRepository(config, cloudControllerGateway, strategy)
loc.endpointRepo = NewEndpointRepository(config, cloudControllerGateway)
loc.logsRepo = NewLoggregatorLogsRepository(config, loggregatorConsumer, loc.authRepo)
loc.organizationRepo = NewCloudControllerOrganizationRepository(config, cloudControllerGateway)
loc.passwordRepo = NewCloudControllerPasswordRepository(config, uaaGateway)
loc.quotaRepo = quotas.NewCloudControllerQuotaRepository(config, cloudControllerGateway)
loc.routeRepo = NewCloudControllerRouteRepository(config, cloudControllerGateway)
loc.stackRepo = NewCloudControllerStackRepository(config, cloudControllerGateway)
loc.serviceRepo = NewCloudControllerServiceRepository(config, cloudControllerGateway)
loc.serviceBindingRepo = NewCloudControllerServiceBindingRepository(config, cloudControllerGateway)
loc.serviceBrokerRepo = NewCloudControllerServiceBrokerRepository(config, cloudControllerGateway)
loc.servicePlanRepo = NewCloudControllerServicePlanRepository(config, cloudControllerGateway)
loc.servicePlanVisibilityRepo = NewCloudControllerServicePlanVisibilityRepository(config, cloudControllerGateway)
loc.serviceSummaryRepo = NewCloudControllerServiceSummaryRepository(config, cloudControllerGateway)
loc.spaceRepo = spaces.NewCloudControllerSpaceRepository(config, cloudControllerGateway)
loc.userProvidedServiceInstanceRepo = NewCCUserProvidedServiceInstanceRepository(config, cloudControllerGateway)
loc.userRepo = NewCloudControllerUserRepository(config, uaaGateway, cloudControllerGateway)
loc.buildpackRepo = NewCloudControllerBuildpackRepository(config, cloudControllerGateway)
loc.buildpackBitsRepo = NewCloudControllerBuildpackBitsRepository(config, cloudControllerGateway, app_files.ApplicationZipper{})
loc.securityGroupRepo = security_groups.NewSecurityGroupRepo(config, cloudControllerGateway)
loc.stagingSecurityGroupRepo = staging.NewStagingSecurityGroupsRepo(config, cloudControllerGateway)
loc.runningSecurityGroupRepo = running.NewRunningSecurityGroupsRepo(config, cloudControllerGateway)
loc.securityGroupSpaceBinder = securitygroupspaces.NewSecurityGroupSpaceBinder(config, cloudControllerGateway)
loc.spaceQuotaRepo = space_quotas.NewCloudControllerSpaceQuotaRepository(config, cloudControllerGateway)
return
}
func (locator RepositoryLocator) GetAuthenticationRepository() authentication.AuthenticationRepository {
return locator.authRepo
}
func (locator RepositoryLocator) GetCurlRepository() CurlRepository {
return locator.curlRepo
}
func (locator RepositoryLocator) GetEndpointRepository() EndpointRepository {
return locator.endpointRepo
}
func (locator RepositoryLocator) GetOrganizationRepository() OrganizationRepository {
return locator.organizationRepo
}
func (locator RepositoryLocator) GetQuotaRepository() quotas.QuotaRepository {
return locator.quotaRepo
}
func (locator RepositoryLocator) GetSpaceRepository() spaces.SpaceRepository {
return locator.spaceRepo
}
func (locator RepositoryLocator) GetApplicationRepository() ApplicationRepository {
return locator.appRepo
}
func (locator RepositoryLocator) GetApplicationBitsRepository() ApplicationBitsRepository {
return locator.appBitsRepo
}
func (locator RepositoryLocator) GetAppSummaryRepository() AppSummaryRepository {
return locator.appSummaryRepo
}
func (locator RepositoryLocator) GetAppInstancesRepository() AppInstancesRepository {
return locator.appInstancesRepo
}
func (locator RepositoryLocator) GetAppEventsRepository() AppEventsRepository {
return locator.appEventsRepo
}
func (locator RepositoryLocator) GetAppFilesRepository() AppFilesRepository {
return locator.appFilesRepo
}
func (locator RepositoryLocator) GetDomainRepository() DomainRepository {
return locator.domainRepo
}
func (locator RepositoryLocator) GetRouteRepository() RouteRepository {
return locator.routeRepo
}
func (locator RepositoryLocator) GetStackRepository() StackRepository {
return locator.stackRepo
}
func (locator RepositoryLocator) GetServiceRepository() ServiceRepository {
return locator.serviceRepo
}
func (locator RepositoryLocator) GetServiceBindingRepository() ServiceBindingRepository {
return locator.serviceBindingRepo
}
func (locator RepositoryLocator) GetServiceSummaryRepository() ServiceSummaryRepository {
return locator.serviceSummaryRepo
}
func (locator RepositoryLocator) GetUserRepository() UserRepository {
return locator.userRepo
}
func (locator RepositoryLocator) GetPasswordRepository() PasswordRepository {
return locator.passwordRepo
}
func (locator RepositoryLocator) GetLogsRepository() LogsRepository {
return locator.logsRepo
}
func (locator RepositoryLocator) GetServiceAuthTokenRepository() ServiceAuthTokenRepository {
return locator.authTokenRepo
}
func (locator RepositoryLocator) GetServiceBrokerRepository() ServiceBrokerRepository {
return locator.serviceBrokerRepo
}
func (locator RepositoryLocator) GetServicePlanRepository() ServicePlanRepository {
return locator.servicePlanRepo
}
func (locator RepositoryLocator) GetUserProvidedServiceInstanceRepository() UserProvidedServiceInstanceRepository {
return locator.userProvidedServiceInstanceRepo
}
func (locator RepositoryLocator) GetBuildpackRepository() BuildpackRepository {
return locator.buildpackRepo
}
func (locator RepositoryLocator) GetBuildpackBitsRepository() BuildpackBitsRepository {
return locator.buildpackBitsRepo
}
func (locator RepositoryLocator) GetSecurityGroupRepository() security_groups.SecurityGroupRepo {
return locator.securityGroupRepo
}
func (locator RepositoryLocator) GetStagingSecurityGroupsRepository() staging.StagingSecurityGroupsRepo {
return locator.stagingSecurityGroupRepo
}
func (locator RepositoryLocator) GetRunningSecurityGroupsRepository() running.RunningSecurityGroupsRepo {
return locator.runningSecurityGroupRepo
}
func (locator RepositoryLocator) GetSecurityGroupSpaceBinder() securitygroupspaces.SecurityGroupSpaceBinder {
return locator.securityGroupSpaceBinder
}
func (locator RepositoryLocator) GetServicePlanVisibilityRepository() ServicePlanVisibilityRepository {
return locator.servicePlanVisibilityRepo
}
func (locator RepositoryLocator) GetSpaceQuotaRepository() space_quotas.SpaceQuotaRepository {
return locator.spaceQuotaRepo
}