Пример #1
0
func (s *GaudiTestSuite) TestEnterContainerShouldUseNsEnter(c *C) {
	os.RemoveAll("/var/tmp/gaudi/")

	// Create a gomock controller, and arrange for it's finish to be called
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()

	// Setup the docker mock package
	docker.MOCK().SetController(ctrl)

	// Setup the util mock package
	util.MOCK().SetController(ctrl)

	// Disable the util package mock
	util.MOCK().DisableMock("IsDir")
	util.MOCK().DisableMock("IsFile")

	util.EXPECT().PrintGreen("Retrieving templates ...")

	images := make(map[string]string)
	images["jpetazzo/nsenter"] = "123"

	docker.EXPECT().ImageExists(gomock.Any()).Return(true).Times(1)
	docker.EXPECT().HasDocker().Return(true).Times(1)
	docker.EXPECT().GetImages().Return(images, nil).Times(1)
	docker.EXPECT().Enter(gomock.Any()).Times(1)

	g := gaudi.Gaudi{}
	g.Init(`
applications:
    app:
        type: apache
`)
	g.Enter("app")
}
Пример #2
0
func main() {
	flag.Parse()

	if *flagVersion {
		fmt.Println(gaudi.VERSION)
		return
	}

	rebuild := len(flag.Args()) > 0 && flag.Args()[0] == "rebuild"
	g := gaudi.Gaudi{}
	g.InitFromFile(retrieveConfigPath(*config))

	if len(flag.Args()) == 0 || rebuild {
		// Start all applications
		g.StartApplications(rebuild)
	} else {
		switch os.Args[1] {
		case "run":
			// Run a specific command
			g.Run(os.Args[2], os.Args[3:])
			break
		case "enter":
			// Enter in a specific container
			g.Enter(os.Args[2])
			break
		case "stop":
			// Stop all applications
			g.StopApplications()
			break
		case "check":
			// Check if all applications are running
			g.Check()
			break
		case "clean":
			// Clean application containers
			g.Clean()
			break
		default:
			util.LogError("Argument " + os.Args[1] + " was not found")
			break
		}
	}
}