Esempio n. 1
0
func main() {
	logger := newLogger()
	defer logger.HandlePanic("Main")
	fileSystem := boshsys.NewOsFileSystemWithStrictTempRoot(logger)
	workspaceRootPath := path.Join(os.Getenv("HOME"), ".bosh_init")
	ui := biui.NewConsoleUI(logger)

	timeService := clock.NewClock()

	cmdFactory := bicmd.NewFactory(
		fileSystem,
		ui,
		timeService,
		logger,
		boshuuid.NewGenerator(),
		workspaceRootPath,
	)

	cmdRunner := bicmd.NewRunner(cmdFactory)
	stage := biui.NewStage(ui, timeService, logger)
	err := cmdRunner.Run(stage, os.Args[1:]...)
	if err != nil {
		displayHelpFunc := func() {
			if strings.Contains(err.Error(), "Invalid usage") {
				ui.ErrorLinef("")
				cmdRunner.Run(stage, append([]string{"help"}, os.Args[1:]...)...)
			}
		}
		fail(err, ui, logger, displayHelpFunc)
	}
}
Esempio n. 2
0
func (s *factory) NewSSHTunnel(options Options) SSHTunnel {
	timeService := clock.NewClock()
	return &sshTunnel{
		connectionRefusedTimeout: 5 * time.Minute,
		authFailureTimeout:       2 * time.Minute,
		startDialDelay:           500 * time.Millisecond,
		timeService:              timeService,
		options:                  options,
		logger:                   s.logger,
		logTag:                   "sshTunnel",
	}
}
Esempio n. 3
0
		fs            boshsys.FileSystem
		ui            biui.UI
		logger        boshlog.Logger
		uuidGenerator *fakeuuid.FakeGenerator
	)

	BeforeEach(func() {
		logger = boshlog.NewLogger(boshlog.LevelNone)
		fs = fakesys.NewFakeFileSystem()
		ui = &fakebiui.FakeUI{}
		uuidGenerator = &fakeuuid.FakeGenerator{}

		factory = NewFactory(
			fs,
			ui,
			clock.NewClock(),
			logger,
			uuidGenerator,
			"/fake-path",
		)
	})

	It("creates a new factory", func() {
		Expect(factory).ToNot(BeNil())
	})

	Context("known command name", func() {
		Describe("deploy command", func() {
			It("returns deploy command", func() {
				cmd, err := factory.CreateCommand("deploy")
				Expect(err).ToNot(HaveOccurred())
Esempio n. 4
0
func (vm *vm) WaitUntilReady(timeout time.Duration, delay time.Duration) error {
	agentPingRetryable := biagentclient.NewPingRetryable(vm.agentClient)
	timeService := clock.NewClock() //TODO: inject timeService
	agentPingRetryStrategy := boshretry.NewTimeoutRetryStrategy(timeout, delay, agentPingRetryable, timeService, vm.logger)
	return agentPingRetryStrategy.Try()
}