func NewCliApp() *cli.App { config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot()))) signalChan := make(chan os.Signal) signal.Notify(signalChan, os.Interrupt, syscall.SIGHUP, syscall.SIGTERM) exitHandler := exit_handler.New(signalChan, os.Exit) go exitHandler.Run() receptorClientCreator := receptor_client.ProxyAwareCreator{} return cli_app_factory.MakeCliApp( diegoVersion, latticeVersion, ltcConfigRoot(), exitHandler, config, logger(), receptorClientCreator, target_verifier.New(receptorClientCreator), os.Stdout, ) }
package config_helpers_test import ( "path/filepath" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/cloudfoundry-incubator/ltc/config/config_helpers" ) var _ = Describe("ConfigHelpers", func() { Describe("ConfigFileLocation", func() { It("returns the config location for the diego home path", func() { fileLocation := config_helpers.ConfigFileLocation(filepath.Join("home", "chicago")) Expect(fileLocation).To(Equal(filepath.Join("home", "chicago", ".lattice", "config.json"))) }) }) })
ghttp.VerifyRequest("GET", "/v1/actual_lrps"), ghttp.RespondWithJSONEncoded(http.StatusOK, actualResponse), ), ) fakeServer.RouteToHandler("GET", "/v1/tasks", ghttp.CombineHandlers( ghttp.VerifyRequest("GET", "/v1/tasks"), ghttp.RespondWithJSONEncoded(http.StatusOK, tasksResponse), ), ) var err error configRoot, err = ioutil.TempDir("", "config") Expect(err).NotTo(HaveOccurred()) ltcConfig := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(configRoot))) listenerHost, listenerPort, err = net.SplitHostPort(listenerAddr) Expect(err).NotTo(HaveOccurred()) ltcConfig.SetTarget(fmt.Sprintf("%s.xip.io:%s", listenerHost, listenerPort)) Expect(ltcConfig.Save()).To(Succeed()) os.Setenv(latticeCliHomeVar, configRoot) }) AfterEach(func() { fakeServer.Close() Expect(os.RemoveAll(configRoot)).To(Succeed()) Expect(os.Unsetenv(latticeCliHomeVar)).To(Succeed()) }) ltcCommand := func(args ...string) *exec.Cmd {
package config_helpers_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/cloudfoundry-incubator/ltc/config/config_helpers" ) var _ = Describe("ConfigHelpers", func() { Describe("ConfigFileLocation", func() { It("returns the config location for the diego home path", func() { fileLocation := config_helpers.ConfigFileLocation("/home/chicago") Expect(fileLocation).To(Equal("/home/chicago/.lattice/config.json")) }) }) })