Пример #1
0
func (c *NozzlerCmd) Run(cliConnection plugin.CliConnection, args []string) {
	var options *firehose.ClientOptions

	traceLogger := trace.NewLogger(os.Stdout, true, os.Getenv("CF_TRACE"), "")
	c.ui = terminal.NewUI(os.Stdin, os.Stdout, terminal.NewTeePrinter(os.Stdout), traceLogger)

	switch args[0] {
	case "nozzle":
		options = c.buildClientOptions(args)
	case "app-nozzle":
		options = c.buildClientOptions(args)
		appModel, err := cliConnection.GetApp(args[1])
		if err != nil {
			c.ui.Warn(err.Error())
			return
		}

		options.AppGUID = appModel.Guid
	default:
		return
	}

	dopplerEndpoint, err := cliConnection.DopplerEndpoint()
	if err != nil {
		c.ui.Failed(err.Error())
	}

	authToken, err := cliConnection.AccessToken()
	if err != nil {
		c.ui.Failed(err.Error())
	}

	client := firehose.NewClient(authToken, dopplerEndpoint, options, c.ui)
	client.Start()
}
Пример #2
0
			return fmt.Fprintf(stdout, format, a...)
		}
		tracePrinter = new(tracefakes.FakePrinter)

		ui = terminal.NewUI(stdin, stdout, printer, tracePrinter)
	})

	Describe("Start", func() {
		var options *firehose.ClientOptions
		Context("for app connections", func() {
			BeforeEach(func() {
				options = &firehose.ClientOptions{AppGUID: "spring-music", Debug: false, NoFilter: true}
			})
			Context("when the connection to doppler cannot be established", func() {
				It("shows a meaningful error", func() {
					client := firehose.NewClient("invalidToken", "badEndpoint", options, ui)
					client.Start()
					Expect(stdout).To(ContainSubstring("Error dialing trafficcontroller server"))
				})
			})
			Context("when the connection to doppler works", func() {
				var fakeFirehose *testhelpers.FakeFirehose
				BeforeEach(func() {
					fakeFirehose = testhelpers.NewFakeFirehoseInAppMode("ACCESS_TOKEN", "spring-music")
					fakeFirehose.SendEvent(events.Envelope_LogMessage, "This is a very special test message")
					fakeFirehose.SendEvent(events.Envelope_ValueMetric, "valuemetric")
					fakeFirehose.SendEvent(events.Envelope_CounterEvent, "counterevent")
					fakeFirehose.SendEvent(events.Envelope_ContainerMetric, "containermetric")
					fakeFirehose.SendEvent(events.Envelope_Error, "this is an error")
					fakeFirehose.SendEvent(events.Envelope_HttpStart, "start request")
					fakeFirehose.SendEvent(events.Envelope_HttpStop, "stop request")