Exemplo n.º 1
0
func createCommandFactory() command_factory.Factory {
	fakeUI := &testterm.FakeUI{}
	configRepo := testconfig.NewRepository()
	manifestRepo := manifest.NewManifestDiskRepository()
	apiRepoLocator := api.NewRepositoryLocator(configRepo, map[string]net.Gateway{
		"auth":             net.NewUAAGateway(configRepo),
		"cloud-controller": net.NewCloudControllerGateway(configRepo),
		"uaa":              net.NewUAAGateway(configRepo),
	})

	return command_factory.NewFactory(fakeUI, configRepo, manifestRepo, apiRepoLocator)
}
Exemplo n.º 2
0
Arquivo: cf.go Projeto: nota-ja/cli
func main() {
	defer handlePanics()

	deps := setupDependencies()
	defer deps.configRepo.Close()

	cmdFactory := command_factory.NewFactory(deps.termUI, deps.configRepo, deps.manifestRepo, deps.apiRepoLocator)
	requirementsFactory := requirements.NewFactory(deps.termUI, deps.configRepo, deps.apiRepoLocator)
	cmdRunner := command_runner.NewRunner(cmdFactory, requirementsFactory)

	app.NewApp(cmdRunner, cmdFactory.CommandMetadatas()...).Run(os.Args)

	gateways := gatewaySliceFromMap(deps.gateways)
	net.NewWarningsCollector(deps.termUI, gateways...).PrintWarnings()
}
Exemplo n.º 3
0
func findCommand(cmdName string) (cmd cli.Command) {
	fakeUI := &testterm.FakeUI{}
	configRepo := testconfig.NewRepository()
	manifestRepo := manifest.NewManifestDiskRepository()
	apiRepoLocator := api.NewRepositoryLocator(configRepo, map[string]net.Gateway{
		"auth":             net.NewUAAGateway(configRepo),
		"cloud-controller": net.NewCloudControllerGateway(configRepo),
		"uaa":              net.NewUAAGateway(configRepo),
	})

	cmdFactory := command_factory.NewFactory(fakeUI, configRepo, manifestRepo, apiRepoLocator)
	requirementsFactory := &testreq.FakeReqFactory{}
	cmdRunner := command_runner.NewRunner(cmdFactory, requirementsFactory)
	myApp := app.NewApp(cmdRunner, cmdFactory.CommandMetadatas()...)

	for _, cmd := range myApp.Commands {
		if cmd.Name == cmdName {
			return cmd
		}
	}
	panic(fmt.Sprintf("command %s does not exist", cmdName))
	return
}
Exemplo n.º 4
0
	"quotas", "create-quota", "delete-quota", "quota", "set-quota",
}

var _ = Describe("App", func() {
	It("#NewApp", func() {
		ui := &testterm.FakeUI{}
		config := testconfig.NewRepository()
		manifestRepo := &testmanifest.FakeManifestRepository{}

		repoLocator := api.NewRepositoryLocator(config, map[string]net.Gateway{
			"auth":             net.NewUAAGateway(config),
			"cloud-controller": net.NewCloudControllerGateway(config),
			"uaa":              net.NewUAAGateway(config),
		})

		cmdFactory := command_factory.NewFactory(ui, config, manifestRepo, repoLocator)

		metadatas := []command_metadata.CommandMetadata{}
		for _, cmdName := range expectedCommandNames {
			metadatas = append(metadatas, command_metadata.CommandMetadata{Name: cmdName})
		}

		for _, cmdName := range expectedCommandNames {
			cmdRunner := &FakeRunner{cmdFactory: cmdFactory}
			output := bytes.NewBuffer(make([]byte, 1024))
			trace.SetStdout(output)
			trace.EnableTrace()

			app := NewApp(cmdRunner, cmdFactory.CommandMetadatas()...)
			Expect(output.String()).To(ContainSubstring("VERSION:\n" + cf.Version))