예제 #1
0
파일: main.go 프로젝트: viovanov/bosh-agent
func main() {
	logger := newLogger()
	parseFlags(logger)
	installer := installer.New(system.NewOsSystem())
	config := newSSLConfig(logger)

	switch os.Args[1] {
	case "listen":
		portString := os.Args[2]
		port, err := strconv.Atoi(portString)
		if err != nil {
			log.Println("failed to parse port '", portString, "' :", err)
			os.Exit(1)
		}

		l := listener.NewListener(config, installer)
		err = l.ListenAndServe(logger, port)
		if err != nil {
			os.Exit(1)
		}
		l.WaitForServerToExit()

	case "download":
		url := os.Args[2]

		d := downloader.NewDownloader(config, installer)
		err := d.Download(logger, url)
		if err != nil {
			os.Exit(1)
		}

	default:
		usage()
	}

	os.Exit(0)
}
예제 #2
0
	)

	BeforeEach(func() {
		var err error
		log.SetOutput(GinkgoWriter)
		logWriter = spec.NewCapturableWriter(GinkgoWriter)
		sysLog := log.New(logWriter, "", 0)
		logger = boshlogger.New(boshlogger.LevelDebug, sysLog, sysLog)
		directorCert = spec.CertFor("director")
		tmpDir, err = ioutil.TempDir("", "test-tmp")
		Expect(err).ToNot(HaveOccurred())
		installScript := fmt.Sprintf("#!/bin/bash\necho hiya > %s/install.log\n", tmpDir)
		tarballPath = spec.CreateTarball(installScript)
		allowedNames = []string{"*"}
		system := system.NewOsSystem()
		i = installer.New(system)
		port = spec.GetFreePort()
	})

	JustBeforeEach(func() {
		config, err := auth.NewSSLConfig(
			spec.FixtureFilename("certs/bootstrapper.crt"),
			spec.FixtureFilename("certs/bootstrapper.key"),
			(string)(spec.FixtureData("certs/rootCA.pem")),
			allowedNames,
		)
		Expect(err).ToNot(HaveOccurred())

		l = listener.NewListener(config, i)
	})