forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory.go
385 lines (346 loc) · 22.4 KB
/
factory.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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
package command_factory
import (
"errors"
actor_plugin_repo "github.com/cloudfoundry/cli/cf/actors/plugin_repo"
"github.com/cloudfoundry/cli/plugin/rpc"
"github.com/cloudfoundry/cli/utils"
"github.com/cloudfoundry/cli/cf/actors/plan_builder"
"github.com/cloudfoundry/cli/cf/actors/service_builder"
"github.com/cloudfoundry/cli/cf/flag_helpers"
. "github.com/cloudfoundry/cli/cf/i18n"
"github.com/codegangsta/cli"
"github.com/cloudfoundry/cli/cf/actors"
"github.com/cloudfoundry/cli/cf/actors/broker_builder"
"github.com/cloudfoundry/cli/cf/api"
"github.com/cloudfoundry/cli/cf/app_files"
"github.com/cloudfoundry/cli/cf/command"
"github.com/cloudfoundry/cli/cf/command_metadata"
"github.com/cloudfoundry/cli/cf/commands"
"github.com/cloudfoundry/cli/cf/commands/application"
"github.com/cloudfoundry/cli/cf/commands/buildpack"
"github.com/cloudfoundry/cli/cf/commands/domain"
"github.com/cloudfoundry/cli/cf/commands/environmentvariablegroup"
"github.com/cloudfoundry/cli/cf/commands/featureflag"
"github.com/cloudfoundry/cli/cf/commands/organization"
"github.com/cloudfoundry/cli/cf/commands/plugin"
"github.com/cloudfoundry/cli/cf/commands/plugin_repo"
"github.com/cloudfoundry/cli/cf/commands/quota"
"github.com/cloudfoundry/cli/cf/commands/route"
"github.com/cloudfoundry/cli/cf/commands/securitygroup"
"github.com/cloudfoundry/cli/cf/commands/service"
"github.com/cloudfoundry/cli/cf/commands/serviceaccess"
"github.com/cloudfoundry/cli/cf/commands/serviceauthtoken"
"github.com/cloudfoundry/cli/cf/commands/servicebroker"
"github.com/cloudfoundry/cli/cf/commands/servicekey"
"github.com/cloudfoundry/cli/cf/commands/space"
"github.com/cloudfoundry/cli/cf/commands/spacequota"
"github.com/cloudfoundry/cli/cf/commands/user"
"github.com/cloudfoundry/cli/cf/configuration/core_config"
"github.com/cloudfoundry/cli/cf/configuration/plugin_config"
"github.com/cloudfoundry/cli/cf/manifest"
"github.com/cloudfoundry/cli/cf/terminal"
"github.com/cloudfoundry/cli/words/generator"
)
type Factory interface {
GetByCmdName(cmdName string) (cmd command.Command, err error)
CommandMetadatas() []command_metadata.CommandMetadata
CheckIfCoreCmdExists(cmdName string) bool
GetCommandFlags(string) []string
GetCommandTotalArgs(string) (int, error)
}
type concreteFactory struct {
cmdsByName map[string]command.Command
}
func NewFactory(ui terminal.UI, config core_config.ReadWriter, manifestRepo manifest.ManifestRepository, repoLocator api.RepositoryLocator, pluginConfig plugin_config.PluginConfiguration, rpcService *rpc.CliRpcService) (factory concreteFactory) {
factory.cmdsByName = make(map[string]command.Command)
planBuilder := plan_builder.NewBuilder(
repoLocator.GetServicePlanRepository(),
repoLocator.GetServicePlanVisibilityRepository(),
repoLocator.GetOrganizationRepository(),
)
serviceBuilder := service_builder.NewBuilder(
repoLocator.GetServiceRepository(),
planBuilder,
)
brokerBuilder := broker_builder.NewBuilder(
repoLocator.GetServiceBrokerRepository(),
serviceBuilder,
)
factory.cmdsByName["auth"] = commands.NewAuthenticate(ui, config, repoLocator.GetAuthenticationRepository())
factory.cmdsByName["buildpacks"] = buildpack.NewListBuildpacks(ui, repoLocator.GetBuildpackRepository())
factory.cmdsByName["config"] = commands.NewConfig(ui, config)
factory.cmdsByName["create-app-manifest"] = commands.NewCreateAppManifest(ui, config, repoLocator.GetAppSummaryRepository(), manifest.NewGenerator())
factory.cmdsByName["create-buildpack"] = buildpack.NewCreateBuildpack(ui, repoLocator.GetBuildpackRepository(), repoLocator.GetBuildpackBitsRepository())
factory.cmdsByName["create-domain"] = domain.NewCreateDomain(ui, config, repoLocator.GetDomainRepository())
factory.cmdsByName["create-org"] = organization.NewCreateOrg(ui, config, repoLocator.GetOrganizationRepository(), repoLocator.GetQuotaRepository())
factory.cmdsByName["create-service"] = service.NewCreateService(ui, config, repoLocator.GetServiceRepository(), serviceBuilder)
factory.cmdsByName["update-service"] = service.NewUpdateService(
ui,
config,
repoLocator.GetServiceRepository(),
plan_builder.NewBuilder(
repoLocator.GetServicePlanRepository(),
repoLocator.GetServicePlanVisibilityRepository(),
repoLocator.GetOrganizationRepository(),
),
)
factory.cmdsByName["create-service-auth-token"] = serviceauthtoken.NewCreateServiceAuthToken(ui, config, repoLocator.GetServiceAuthTokenRepository())
factory.cmdsByName["create-service-broker"] = servicebroker.NewCreateServiceBroker(ui, config, repoLocator.GetServiceBrokerRepository())
factory.cmdsByName["create-service-key"] = servicekey.NewCreateServiceKey(ui, config, repoLocator.GetServiceRepository(), repoLocator.GetServiceKeyRepository())
factory.cmdsByName["create-user"] = user.NewCreateUser(ui, config, repoLocator.GetUserRepository())
factory.cmdsByName["create-user-provided-service"] = service.NewCreateUserProvidedService(ui, config, repoLocator.GetUserProvidedServiceInstanceRepository())
factory.cmdsByName["curl"] = commands.NewCurl(ui, config, repoLocator.GetCurlRepository())
factory.cmdsByName["delete"] = application.NewDeleteApp(ui, config, repoLocator.GetApplicationRepository(), repoLocator.GetRouteRepository())
factory.cmdsByName["delete-buildpack"] = buildpack.NewDeleteBuildpack(ui, repoLocator.GetBuildpackRepository())
factory.cmdsByName["delete-domain"] = domain.NewDeleteDomain(ui, config, repoLocator.GetDomainRepository())
factory.cmdsByName["delete-shared-domain"] = domain.NewDeleteSharedDomain(ui, config, repoLocator.GetDomainRepository())
factory.cmdsByName["delete-org"] = organization.NewDeleteOrg(ui, config, repoLocator.GetOrganizationRepository())
factory.cmdsByName["delete-orphaned-routes"] = route.NewDeleteOrphanedRoutes(ui, config, repoLocator.GetRouteRepository())
factory.cmdsByName["delete-route"] = route.NewDeleteRoute(ui, config, repoLocator.GetRouteRepository())
factory.cmdsByName["delete-service"] = service.NewDeleteService(ui, config, repoLocator.GetServiceRepository())
factory.cmdsByName["delete-service-key"] = servicekey.NewDeleteServiceKey(ui, config, repoLocator.GetServiceRepository(), repoLocator.GetServiceKeyRepository())
factory.cmdsByName["delete-service-auth-token"] = serviceauthtoken.NewDeleteServiceAuthToken(ui, config, repoLocator.GetServiceAuthTokenRepository())
factory.cmdsByName["delete-service-broker"] = servicebroker.NewDeleteServiceBroker(ui, config, repoLocator.GetServiceBrokerRepository())
factory.cmdsByName["delete-space"] = space.NewDeleteSpace(ui, config, repoLocator.GetSpaceRepository())
factory.cmdsByName["delete-user"] = user.NewDeleteUser(ui, config, repoLocator.GetUserRepository())
factory.cmdsByName["domains"] = domain.NewListDomains(ui, config, repoLocator.GetDomainRepository())
factory.cmdsByName["env"] = application.NewEnv(ui, config, repoLocator.GetApplicationRepository())
factory.cmdsByName["events"] = application.NewEvents(ui, config, repoLocator.GetAppEventsRepository())
factory.cmdsByName["files"] = application.NewFiles(ui, config, repoLocator.GetAppFilesRepository())
factory.cmdsByName["login"] = commands.NewLogin(ui, config, repoLocator.GetAuthenticationRepository(), repoLocator.GetEndpointRepository(), repoLocator.GetOrganizationRepository(), repoLocator.GetSpaceRepository())
factory.cmdsByName["logout"] = commands.NewLogout(ui, config)
factory.cmdsByName["logs"] = application.NewLogs(ui, config, repoLocator.GetLogsNoaaRepository(), repoLocator.GetOldLogsRepository())
factory.cmdsByName["oauth-token"] = commands.NewOAuthToken(ui, config, repoLocator.GetAuthenticationRepository())
factory.cmdsByName["passwd"] = commands.NewPassword(ui, repoLocator.GetPasswordRepository(), config)
factory.cmdsByName["purge-service-offering"] = service.NewPurgeServiceOffering(ui, config, repoLocator.GetServiceRepository())
factory.cmdsByName["quotas"] = quota.NewListQuotas(ui, config, repoLocator.GetQuotaRepository())
factory.cmdsByName["quota"] = quota.NewShowQuota(ui, config, repoLocator.GetQuotaRepository())
factory.cmdsByName["create-quota"] = quota.NewCreateQuota(ui, config, repoLocator.GetQuotaRepository())
factory.cmdsByName["update-quota"] = quota.NewUpdateQuota(ui, config, repoLocator.GetQuotaRepository())
factory.cmdsByName["delete-quota"] = quota.NewDeleteQuota(ui, config, repoLocator.GetQuotaRepository())
factory.cmdsByName["rename"] = application.NewRenameApp(ui, config, repoLocator.GetApplicationRepository())
factory.cmdsByName["rename-buildpack"] = buildpack.NewRenameBuildpack(ui, repoLocator.GetBuildpackRepository())
factory.cmdsByName["rename-org"] = organization.NewRenameOrg(ui, config, repoLocator.GetOrganizationRepository())
factory.cmdsByName["rename-service"] = service.NewRenameService(ui, config, repoLocator.GetServiceRepository())
factory.cmdsByName["rename-service-broker"] = servicebroker.NewRenameServiceBroker(ui, config, repoLocator.GetServiceBrokerRepository())
factory.cmdsByName["rename-space"] = space.NewRenameSpace(ui, config, repoLocator.GetSpaceRepository())
factory.cmdsByName["routes"] = route.NewListRoutes(ui, config, repoLocator.GetRouteRepository())
factory.cmdsByName["check-route"] = route.NewCheckRoute(ui, config, repoLocator.GetRouteRepository(), repoLocator.GetDomainRepository())
factory.cmdsByName["service-auth-tokens"] = serviceauthtoken.NewListServiceAuthTokens(ui, config, repoLocator.GetServiceAuthTokenRepository())
factory.cmdsByName["service-brokers"] = servicebroker.NewListServiceBrokers(ui, config, repoLocator.GetServiceBrokerRepository())
factory.cmdsByName["service-keys"] = servicekey.NewListServiceKeys(ui, config, repoLocator.GetServiceRepository(), repoLocator.GetServiceKeyRepository())
factory.cmdsByName["service-key"] = servicekey.NewGetServiceKey(ui, config, repoLocator.GetServiceRepository(), repoLocator.GetServiceKeyRepository())
factory.cmdsByName["migrate-service-instances"] = service.NewMigrateServiceInstances(ui, config, repoLocator.GetServiceRepository())
factory.cmdsByName["set-env"] = application.NewSetEnv(ui, config, repoLocator.GetApplicationRepository())
factory.cmdsByName["set-org-role"] = user.NewSetOrgRole(ui, config, repoLocator.GetUserRepository())
factory.cmdsByName["set-quota"] = organization.NewSetQuota(ui, config, repoLocator.GetQuotaRepository())
factory.cmdsByName["create-shared-domain"] = domain.NewCreateSharedDomain(ui, config, repoLocator.GetDomainRepository())
factory.cmdsByName["stacks"] = commands.NewListStacks(ui, config, repoLocator.GetStackRepository())
factory.cmdsByName["stack"] = commands.NewListStack(ui, config, repoLocator.GetStackRepository())
factory.cmdsByName["target"] = commands.NewTarget(ui, config, repoLocator.GetOrganizationRepository(), repoLocator.GetSpaceRepository())
factory.cmdsByName["unbind-service"] = service.NewUnbindService(ui, config, repoLocator.GetServiceBindingRepository())
factory.cmdsByName["unset-env"] = application.NewUnsetEnv(ui, config, repoLocator.GetApplicationRepository())
factory.cmdsByName["unset-org-role"] = user.NewUnsetOrgRole(ui, config, repoLocator.GetUserRepository())
factory.cmdsByName["unset-space-role"] = user.NewUnsetSpaceRole(ui, config, repoLocator.GetSpaceRepository(), repoLocator.GetUserRepository())
factory.cmdsByName["update-buildpack"] = buildpack.NewUpdateBuildpack(ui, repoLocator.GetBuildpackRepository(), repoLocator.GetBuildpackBitsRepository())
factory.cmdsByName["update-service-broker"] = servicebroker.NewUpdateServiceBroker(ui, config, repoLocator.GetServiceBrokerRepository())
factory.cmdsByName["update-service-auth-token"] = serviceauthtoken.NewUpdateServiceAuthToken(ui, config, repoLocator.GetServiceAuthTokenRepository())
factory.cmdsByName["update-user-provided-service"] = service.NewUpdateUserProvidedService(ui, config, repoLocator.GetUserProvidedServiceInstanceRepository())
factory.cmdsByName["create-security-group"] = securitygroup.NewCreateSecurityGroup(ui, config, repoLocator.GetSecurityGroupRepository())
factory.cmdsByName["update-security-group"] = securitygroup.NewUpdateSecurityGroup(ui, config, repoLocator.GetSecurityGroupRepository())
factory.cmdsByName["delete-security-group"] = securitygroup.NewDeleteSecurityGroup(ui, config, repoLocator.GetSecurityGroupRepository())
factory.cmdsByName["security-group"] = securitygroup.NewShowSecurityGroup(ui, config, repoLocator.GetSecurityGroupRepository())
factory.cmdsByName["security-groups"] = securitygroup.NewSecurityGroups(ui, config, repoLocator.GetSecurityGroupRepository())
factory.cmdsByName["bind-staging-security-group"] = securitygroup.NewBindToStagingGroup(
ui,
config,
repoLocator.GetSecurityGroupRepository(),
repoLocator.GetStagingSecurityGroupsRepository(),
)
factory.cmdsByName["staging-security-groups"] = securitygroup.NewListStagingSecurityGroups(ui, config, repoLocator.GetStagingSecurityGroupsRepository())
factory.cmdsByName["unbind-staging-security-group"] = securitygroup.NewUnbindFromStagingGroup(
ui,
config,
repoLocator.GetSecurityGroupRepository(),
repoLocator.GetStagingSecurityGroupsRepository(),
)
factory.cmdsByName["bind-running-security-group"] = securitygroup.NewBindToRunningGroup(
ui,
config,
repoLocator.GetSecurityGroupRepository(),
repoLocator.GetRunningSecurityGroupsRepository(),
)
factory.cmdsByName["unbind-running-security-group"] = securitygroup.NewUnbindFromRunningGroup(
ui,
config,
repoLocator.GetSecurityGroupRepository(),
repoLocator.GetRunningSecurityGroupsRepository(),
)
factory.cmdsByName["running-security-groups"] = securitygroup.NewListRunningSecurityGroups(ui, config, repoLocator.GetRunningSecurityGroupsRepository())
factory.cmdsByName["bind-security-group"] = securitygroup.NewBindSecurityGroup(
ui,
config,
repoLocator.GetSecurityGroupRepository(),
repoLocator.GetSpaceRepository(),
repoLocator.GetOrganizationRepository(),
repoLocator.GetSecurityGroupSpaceBinder(),
)
factory.cmdsByName["unbind-security-group"] = securitygroup.NewUnbindSecurityGroup(ui, config, repoLocator.GetSecurityGroupRepository(), repoLocator.GetOrganizationRepository(), repoLocator.GetSpaceRepository(), repoLocator.GetSecurityGroupSpaceBinder())
createRoute := route.NewCreateRoute(ui, config, repoLocator.GetRouteRepository())
factory.cmdsByName["create-route"] = createRoute
factory.cmdsByName["map-route"] = route.NewMapRoute(ui, config, repoLocator.GetRouteRepository(), createRoute)
factory.cmdsByName["unmap-route"] = route.NewUnmapRoute(ui, config, repoLocator.GetRouteRepository())
displayApp := application.NewShowApp(ui, config, repoLocator.GetAppSummaryRepository(), repoLocator.GetAppInstancesRepository(), repoLocator.GetLogsNoaaRepository())
start := application.NewStart(ui, config, displayApp, repoLocator.GetApplicationRepository(), repoLocator.GetAppInstancesRepository(), repoLocator.GetLogsNoaaRepository(), repoLocator.GetOldLogsRepository())
stop := application.NewStop(ui, config, repoLocator.GetApplicationRepository())
restart := application.NewRestart(ui, config, start, stop)
restage := application.NewRestage(ui, config, repoLocator.GetApplicationRepository(), start)
bind := service.NewBindService(ui, config, repoLocator.GetServiceBindingRepository())
factory.cmdsByName["bind-service"] = bind
factory.cmdsByName["start"] = start
factory.cmdsByName["stop"] = stop
factory.cmdsByName["restart"] = restart
factory.cmdsByName["restart-app-instance"] = application.NewRestartAppInstance(ui, config, repoLocator.GetAppInstancesRepository())
factory.cmdsByName["restage"] = restage
factory.cmdsByName["push"] = application.NewPush(
ui, config, manifestRepo, start, stop, bind,
repoLocator.GetApplicationRepository(),
repoLocator.GetDomainRepository(),
repoLocator.GetRouteRepository(),
repoLocator.GetStackRepository(),
repoLocator.GetServiceRepository(),
repoLocator.GetAuthenticationRepository(),
generator.NewWordGenerator(),
actors.NewPushActor(repoLocator.GetApplicationBitsRepository(), app_files.ApplicationZipper{}, app_files.ApplicationFiles{}),
app_files.ApplicationZipper{},
app_files.ApplicationFiles{})
factory.cmdsByName["scale"] = application.NewScale(ui, config, restart, repoLocator.GetApplicationRepository())
spaceRoleSetter := user.NewSetSpaceRole(ui, config, repoLocator.GetSpaceRepository(), repoLocator.GetUserRepository())
factory.cmdsByName["set-space-role"] = spaceRoleSetter
factory.cmdsByName["create-space"] = space.NewCreateSpace(ui, config, spaceRoleSetter, repoLocator.GetSpaceRepository(), repoLocator.GetOrganizationRepository(), repoLocator.GetUserRepository(), repoLocator.GetSpaceQuotaRepository())
factory.cmdsByName["service-access"] = serviceaccess.NewServiceAccess(
ui, config,
actors.NewServiceHandler(
repoLocator.GetOrganizationRepository(),
brokerBuilder,
serviceBuilder,
),
repoLocator.GetAuthenticationRepository(),
)
factory.cmdsByName["enable-service-access"] = serviceaccess.NewEnableServiceAccess(
ui, config,
actors.NewServicePlanHandler(
repoLocator.GetServicePlanRepository(),
repoLocator.GetServicePlanVisibilityRepository(),
repoLocator.GetOrganizationRepository(),
planBuilder,
serviceBuilder,
),
repoLocator.GetAuthenticationRepository(),
)
factory.cmdsByName["disable-service-access"] = serviceaccess.NewDisableServiceAccess(
ui, config,
actors.NewServicePlanHandler(
repoLocator.GetServicePlanRepository(),
repoLocator.GetServicePlanVisibilityRepository(),
repoLocator.GetOrganizationRepository(),
planBuilder,
serviceBuilder,
),
repoLocator.GetAuthenticationRepository(),
)
factory.cmdsByName["marketplace"] = service.NewMarketplaceServices(ui, config, serviceBuilder)
factory.cmdsByName["create-space-quota"] = spacequota.NewCreateSpaceQuota(ui, config, repoLocator.GetSpaceQuotaRepository(), repoLocator.GetOrganizationRepository())
factory.cmdsByName["delete-space-quota"] = spacequota.NewDeleteSpaceQuota(ui, config, repoLocator.GetSpaceQuotaRepository())
factory.cmdsByName["space-quotas"] = spacequota.NewListSpaceQuotas(ui, config, repoLocator.GetSpaceQuotaRepository())
factory.cmdsByName["space-quota"] = spacequota.NewSpaceQuota(ui, config, repoLocator.GetSpaceQuotaRepository())
factory.cmdsByName["update-space-quota"] = spacequota.NewUpdateSpaceQuota(ui, config, repoLocator.GetSpaceQuotaRepository())
factory.cmdsByName["set-space-quota"] = spacequota.NewSetSpaceQuota(ui, config, repoLocator.GetSpaceRepository(), repoLocator.GetSpaceQuotaRepository())
factory.cmdsByName["unset-space-quota"] = spacequota.NewUnsetSpaceQuota(ui, config, repoLocator.GetSpaceQuotaRepository(), repoLocator.GetSpaceRepository())
factory.cmdsByName["feature-flags"] = featureflag.NewListFeatureFlags(ui, config, repoLocator.GetFeatureFlagRepository())
factory.cmdsByName["feature-flag"] = featureflag.NewShowFeatureFlag(ui, config, repoLocator.GetFeatureFlagRepository())
factory.cmdsByName["enable-feature-flag"] = featureflag.NewEnableFeatureFlag(ui, config, repoLocator.GetFeatureFlagRepository())
factory.cmdsByName["disable-feature-flag"] = featureflag.NewDisableFeatureFlag(ui, config, repoLocator.GetFeatureFlagRepository())
factory.cmdsByName["running-environment-variable-group"] = environmentvariablegroup.NewRunningEnvironmentVariableGroup(ui, config, repoLocator.GetEnvironmentVariableGroupsRepository())
factory.cmdsByName["staging-environment-variable-group"] = environmentvariablegroup.NewStagingEnvironmentVariableGroup(ui, config, repoLocator.GetEnvironmentVariableGroupsRepository())
factory.cmdsByName["set-staging-environment-variable-group"] = environmentvariablegroup.NewSetStagingEnvironmentVariableGroup(ui, config, repoLocator.GetEnvironmentVariableGroupsRepository())
factory.cmdsByName["set-running-environment-variable-group"] = environmentvariablegroup.NewSetRunningEnvironmentVariableGroup(ui, config, repoLocator.GetEnvironmentVariableGroupsRepository())
factory.cmdsByName["uninstall-plugin"] = plugin.NewPluginUninstall(ui, pluginConfig, rpcService)
factory.cmdsByName["install-plugin"] = plugin.NewPluginInstall(ui, config, pluginConfig, factory.cmdsByName, actor_plugin_repo.NewPluginRepo(), utils.NewSha1Checksum(""), rpcService)
factory.cmdsByName["plugins"] = plugin.NewPlugins(ui, pluginConfig)
factory.cmdsByName["add-plugin-repo"] = plugin_repo.NewAddPluginRepo(ui, config)
factory.cmdsByName["list-plugin-repos"] = plugin_repo.NewListPluginRepos(ui, config)
factory.cmdsByName["remove-plugin-repo"] = plugin_repo.NewRemovePluginRepo(ui, config)
factory.cmdsByName["repo-plugins"] = plugin_repo.NewRepoPlugins(ui, config, actor_plugin_repo.NewPluginRepo())
factory.cmdsByName["copy-source"] = application.NewCopySource(
ui,
config,
repoLocator.GetAuthenticationRepository(),
repoLocator.GetApplicationRepository(),
repoLocator.GetOrganizationRepository(),
repoLocator.GetSpaceRepository(),
repoLocator.GetCopyApplicationSourceRepository(),
restart, //note this is built up above.
)
factory.cmdsByName["share-private-domain"] = organization.NewSharePrivateDomain(ui, config, repoLocator.GetOrganizationRepository(), repoLocator.GetDomainRepository())
factory.cmdsByName["unshare-private-domain"] = organization.NewUnsharePrivateDomain(ui, config, repoLocator.GetOrganizationRepository(), repoLocator.GetDomainRepository())
return
}
func (f concreteFactory) GetByCmdName(cmdName string) (cmd command.Command, err error) {
cmd, found := f.cmdsByName[cmdName]
if !found {
for _, c := range f.cmdsByName {
if c.Metadata().ShortName == cmdName {
return c, nil
}
}
err = errors.New(T("Command not found"))
}
return
}
func (f concreteFactory) CheckIfCoreCmdExists(cmdName string) bool {
if _, exists := f.cmdsByName[cmdName]; exists {
return true
}
for _, singleCmd := range f.cmdsByName {
metaData := singleCmd.Metadata()
if metaData.ShortName == cmdName {
return true
}
}
return false
}
func (factory concreteFactory) CommandMetadatas() (commands []command_metadata.CommandMetadata) {
for _, command := range factory.cmdsByName {
commands = append(commands, command.Metadata())
}
return
}
func (f concreteFactory) GetCommandFlags(command string) []string {
cmd, err := f.GetByCmdName(command)
if err != nil {
return []string{}
}
var flags []string
for _, flag := range cmd.Metadata().Flags {
switch t := flag.(type) {
default:
case flag_helpers.StringSliceFlagWithNoDefault:
flags = append(flags, t.Name)
case flag_helpers.IntFlagWithNoDefault:
flags = append(flags, t.Name)
case flag_helpers.StringFlagWithNoDefault:
flags = append(flags, t.Name)
case cli.BoolFlag:
flags = append(flags, t.Name)
}
}
return flags
}
func (f concreteFactory) GetCommandTotalArgs(command string) (int, error) {
cmd, err := f.GetByCmdName(command)
if err != nil {
return 0, err
}
return cmd.Metadata().TotalArgs, nil
}