forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
repository_locator.go
270 lines (225 loc) · 12.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
package api
import (
"crypto/tls"
"net/http"
"github.com/cloudfoundry/cli/cf/api/environment_variable_groups"
"github.com/cloudfoundry/cli/cf/api/organizations"
"github.com/cloudfoundry/cli/cf/api/app_events"
api_app_files "github.com/cloudfoundry/cli/cf/api/app_files"
"github.com/cloudfoundry/cli/cf/api/app_instances"
"github.com/cloudfoundry/cli/cf/api/application_bits"
applications "github.com/cloudfoundry/cli/cf/api/applications"
"github.com/cloudfoundry/cli/cf/api/authentication"
"github.com/cloudfoundry/cli/cf/api/copy_application_source"
"github.com/cloudfoundry/cli/cf/api/feature_flags"
"github.com/cloudfoundry/cli/cf/api/password"
"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"
stacks "github.com/cloudfoundry/cli/cf/api/stacks"
"github.com/cloudfoundry/cli/cf/api/strategy"
"github.com/cloudfoundry/cli/cf/app_files"
"github.com/cloudfoundry/cli/cf/configuration/core_config"
"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 organizations.CloudControllerOrganizationRepository
quotaRepo quotas.CloudControllerQuotaRepository
spaceRepo spaces.CloudControllerSpaceRepository
appRepo applications.CloudControllerApplicationRepository
appBitsRepo application_bits.CloudControllerApplicationBitsRepository
appSummaryRepo CloudControllerAppSummaryRepository
appInstancesRepo app_instances.CloudControllerAppInstancesRepository
appEventsRepo app_events.CloudControllerAppEventsRepository
appFilesRepo api_app_files.CloudControllerAppFilesRepository
domainRepo CloudControllerDomainRepository
routeRepo CloudControllerRouteRepository
stackRepo stacks.CloudControllerStackRepository
serviceRepo CloudControllerServiceRepository
serviceBindingRepo CloudControllerServiceBindingRepository
serviceSummaryRepo CloudControllerServiceSummaryRepository
userRepo CloudControllerUserRepository
passwordRepo password.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
featureFlagRepo feature_flags.FeatureFlagRepository
environmentVariableGroupRepo environment_variable_groups.EnvironmentVariableGroupsRepository
copyAppSourceRepo copy_application_source.CopyApplicationSourceRepository
}
func NewRepositoryLocator(config core_config.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 = application_bits.NewCloudControllerApplicationBitsRepository(config, cloudControllerGateway)
loc.appEventsRepo = app_events.NewCloudControllerAppEventsRepository(config, cloudControllerGateway, strategy)
loc.appFilesRepo = api_app_files.NewCloudControllerAppFilesRepository(config, cloudControllerGateway)
loc.appRepo = applications.NewCloudControllerApplicationRepository(config, cloudControllerGateway)
loc.appSummaryRepo = NewCloudControllerAppSummaryRepository(config, cloudControllerGateway)
loc.appInstancesRepo = app_instances.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 = organizations.NewCloudControllerOrganizationRepository(config, cloudControllerGateway)
loc.passwordRepo = password.NewCloudControllerPasswordRepository(config, uaaGateway)
loc.quotaRepo = quotas.NewCloudControllerQuotaRepository(config, cloudControllerGateway)
loc.routeRepo = NewCloudControllerRouteRepository(config, cloudControllerGateway)
loc.stackRepo = stacks.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)
loc.featureFlagRepo = feature_flags.NewCloudControllerFeatureFlagRepository(config, cloudControllerGateway)
loc.environmentVariableGroupRepo = environment_variable_groups.NewCloudControllerEnvironmentVariableGroupsRepository(config, cloudControllerGateway)
loc.copyAppSourceRepo = copy_application_source.NewCloudControllerCopyApplicationSourceRepository(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() organizations.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() applications.ApplicationRepository {
return locator.appRepo
}
func (locator RepositoryLocator) GetApplicationBitsRepository() application_bits.ApplicationBitsRepository {
return locator.appBitsRepo
}
func (locator RepositoryLocator) GetAppSummaryRepository() AppSummaryRepository {
return locator.appSummaryRepo
}
func (locator RepositoryLocator) GetAppInstancesRepository() app_instances.AppInstancesRepository {
return locator.appInstancesRepo
}
func (locator RepositoryLocator) GetAppEventsRepository() app_events.AppEventsRepository {
return locator.appEventsRepo
}
func (locator RepositoryLocator) GetAppFilesRepository() api_app_files.AppFilesRepository {
return locator.appFilesRepo
}
func (locator RepositoryLocator) GetDomainRepository() DomainRepository {
return locator.domainRepo
}
func (locator RepositoryLocator) GetRouteRepository() RouteRepository {
return locator.routeRepo
}
func (locator RepositoryLocator) GetStackRepository() stacks.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() password.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
}
func (locator RepositoryLocator) GetFeatureFlagRepository() feature_flags.FeatureFlagRepository {
return locator.featureFlagRepo
}
func (locator RepositoryLocator) GetEnvironmentVariableGroupsRepository() environment_variable_groups.EnvironmentVariableGroupsRepository {
return locator.environmentVariableGroupRepo
}
func (locator RepositoryLocator) GetCopyApplicationSourceRepository() copy_application_source.CopyApplicationSourceRepository {
return locator.copyAppSourceRepo
}