Beispiel #1
0
func (cmd *CliRpcCmd) CallCoreCommand(args []string, retVal *bool) error {
	defer func() {
		recover()
	}()

	var err error
	cmdRegistry := command_registry.Commands

	cmd.outputBucket = &[]string{}
	cmd.outputCapture.SetOutputBucket(cmd.outputBucket)

	if cmdRegistry.CommandExists(args[0]) {
		deps := command_registry.NewDependency()

		//set deps objs to be the one used by all other codegangsta commands
		//once all commands are converted, we can make fresh deps for each command run
		deps.Config = cmd.cliConfig
		deps.RepoLocator = cmd.repoLocator
		deps.Ui = terminal.NewUI(os.Stdin, cmd.outputCapture.(*terminal.TeePrinter))

		err = cmd.newCmdRunner.Command(args, deps, false)
	} else {
		//call codegangsta command
		err = cmd.coreCommandRunner.Run(append([]string{"CF_NAME"}, args...))
	}

	if err != nil {
		*retVal = false
		return err
	}

	*retVal = true
	return nil
}
func (cmd *CliRpcCmd) CallCoreCommand(args []string, retVal *bool) error {
	defer func() {
		recover()
	}()

	var err error
	cmdRegistry := command_registry.Commands

	if cmdRegistry.CommandExists(args[0]) {
		deps := command_registry.NewDependency()

		//set deps objs to be the one used by all other codegangsta commands
		//once all commands are converted, we can make fresh deps for each command run
		deps.Config = cmd.cliConfig
		deps.RepoLocator = cmd.repoLocator

		err = cmd.newCmdRunner.Command(args, deps)
	} else {
		//call codegangsta command
		err = cmd.coreCommandRunner.Run(append([]string{"CF_NAME"}, args...))
	}

	if err != nil {
		*retVal = false
		return err
	}

	*retVal = true
	return nil
}
func (cmd *CliRpcCmd) GetApp(appName string, retVal *plugin_models.Application) error {
	defer func() {
		recover()
	}()

	deps := command_registry.NewDependency()

	//set deps objs to be the one used by all other codegangsta commands
	//once all commands are converted, we can make fresh deps for each command run
	deps.Config = cmd.cliConfig
	deps.RepoLocator = cmd.repoLocator
	deps.PluginModels.Application = retVal
	deps.Ui.DisableTerminalOutput(true)

	return cmd.newCmdRunner.Command([]string{"app", appName}, deps)
}
func (cmd *CliRpcCmd) GetService(serviceInstance string, retVal *plugin_models.GetService_Model) error {
	defer func() {
		recover()
	}()

	deps := command_registry.NewDependency(cmd.logger)

	//set deps objs to be the one used by all other commands
	//once all commands are converted, we can make fresh deps for each command run
	deps.Config = cmd.cliConfig
	deps.RepoLocator = cmd.repoLocator
	deps.PluginModels.Service = retVal
	cmd.terminalOutputSwitch.DisableTerminalOutput(true)
	deps.Ui = terminal.NewUI(os.Stdin, cmd.terminalOutputSwitch.(*terminal.TeePrinter), cmd.logger)

	return cmd.newCmdRunner.Command([]string{"service", serviceInstance}, deps, true)
}
Beispiel #5
0
func (cmd *CliRpcCmd) GetOrg(orgName string, retVal *plugin_models.Organization) error {
	defer func() {
		recover()
	}()

	deps := command_registry.NewDependency()

	//set deps objs to be the one used by all other codegangsta commands
	//once all commands are converted, we can make fresh deps for each command run
	deps.Config = cmd.cliConfig
	deps.RepoLocator = cmd.repoLocator
	deps.PluginModels.Organization = retVal
	cmd.terminalOutputSwitch.DisableTerminalOutput(true)
	deps.Ui = terminal.NewUI(os.Stdin, cmd.terminalOutputSwitch.(*terminal.TeePrinter))

	return cmd.newCmdRunner.Command([]string{"org", orgName}, deps, true)
}
Beispiel #6
0
func (cmd *CliRpcCmd) GetSpaceUsers(args []string, retVal *[]plugin_models.GetSpaceUsers_Model) error {
	defer func() {
		recover()
	}()

	deps := command_registry.NewDependency()

	//set deps objs to be the one used by all other codegangsta commands
	//once all commands are converted, we can make fresh deps for each command run
	deps.Config = cmd.cliConfig
	deps.RepoLocator = cmd.repoLocator
	deps.PluginModels.SpaceUsers = retVal
	cmd.terminalOutputSwitch.DisableTerminalOutput(true)
	deps.Ui = terminal.NewUI(os.Stdin, cmd.terminalOutputSwitch.(*terminal.TeePrinter))

	return cmd.newCmdRunner.Command(append([]string{"space-users"}, args...), deps, true)
}
func (cmd *CliRpcCmd) CallCoreCommand(args []string, retVal *bool) error {
	defer func() {
		recover()
	}()

	var err error
	cmdRegistry := command_registry.Commands

	cmd.outputBucket = &[]string{}
	cmd.outputCapture.SetOutputBucket(cmd.outputBucket)

	if cmdRegistry.CommandExists(args[0]) {
		deps := command_registry.NewDependency(cmd.logger)

		//set deps objs to be the one used by all other commands
		//once all commands are converted, we can make fresh deps for each command run
		deps.Config = cmd.cliConfig
		deps.RepoLocator = cmd.repoLocator

		//set command ui's TeePrinter to be the one used by RpcService, for output to be captured
		deps.Ui = terminal.NewUI(os.Stdin, cmd.outputCapture.(*terminal.TeePrinter), cmd.logger)

		err = cmd.newCmdRunner.Command(args, deps, false)
	} else {
		*retVal = false
		return nil
	}

	if err != nil {
		*retVal = false
		return err
	}

	*retVal = true
	return nil
}
Beispiel #8
0
func (cmd *CliRpcCmd) CallCoreCommand(args []string, retVal *bool) error {
	defer func() {
		recover()
	}()

	var err error
	cmdRegistry := command_registry.Commands

	if cmdRegistry.CommandExists(args[0]) {
		//non-codegangsta path
		deps := command_registry.NewDependency()

		//set deps objs to be the one used by all other codegangsta commands
		//once all commands are converted, we can make fresh deps for each command run
		deps.Config = cmd.cliConfig
		deps.RepoLocator = cmd.repoLocator

		fc := flags.NewFlagContext(cmdRegistry.FindCommand(args[0]).MetaData().Flags)
		err = fc.Parse(args[1:]...)
		if err == nil {
			cmdRegistry.SetCommand(cmdRegistry.FindCommand(args[0]).SetDependency(deps))
			cmdRegistry.FindCommand(args[0]).Execute(fc)
		}
	} else {
		//call codegangsta command
		err = cmd.coreCommandRunner.Run(append([]string{"CF_NAME"}, args...))
	}

	if err != nil {
		*retVal = false
		return err
	}

	*retVal = true
	return nil
}
Beispiel #9
0
	}

	BeforeEach(func() {
		ui = &testterm.FakeUI{}
		appSummaryRepo = &testapi.FakeAppSummaryRepo{}
		appLogsNoaaRepo = &testapi.FakeLogsNoaaRepository{}
		appInstancesRepo = &testAppInstanaces.FakeAppInstancesRepository{}
		configRepo = testconfig.NewRepositoryWithDefaults()
		requirementsFactory = &testreq.FakeReqFactory{
			LoginSuccess:         true,
			TargetedSpaceSuccess: true,
		}
		app = makeAppWithRoute("my-app")
		appSummaryRepo.GetSummarySummary = app

		deps = command_registry.NewDependency()
		updateCommandDependency(false)
	})

	runCommand := func(args ...string) bool {
		cmd := command_registry.Commands.FindCommand("app")
		return testcmd.RunCliCommand(cmd, args, requirementsFactory)
	}

	Describe("requirements", func() {
		It("fails if not logged in", func() {
			requirementsFactory.LoginSuccess = false
			Expect(runCommand("my-app")).To(BeFalse())
		})

		It("fails if a space is not targeted", func() {
Beispiel #10
0
func Init(path string) {
	os.Setenv("CF_HOME", path)
	command_registry.InitI18nFunc()
	deps = command_registry.NewDependency()
}