예제 #1
0
파일: exec.go 프로젝트: sfermigier/nanobox
// isContainer
func isContainer(args []string) bool {

	// fetch services to see if the command is trying to run on a specific container
	var services []server.Service
	if _, err := server.Get("/services", &services); err != nil {
		config.Fatal("[commands/exec] server.Get() failed", err.Error())
	}

	// make an exception for build1, as it wont show up on the list, but will always exist
	if args[0] == "build1" {
		return true
	}

	// look for a match
	for _, service := range services {
		if args[0] == service.Name {
			return true
		}
	}
	return false
}
예제 #2
0
파일: info.go 프로젝트: sfermigier/nanobox
// info runs 'vagrant status'
func info(ccmd *cobra.Command, args []string) {

	// PreRun: runnable

	// determine status
	status := Vagrant.Status()

	fmt.Printf(`
Local Domain   : %s
App Name       : %s
Nanobox state  : %s
Nanobox Files  : %s

`, config.Nanofile.Domain, config.Nanofile.Name, status, config.AppDir)

	if status != "running" {
		fmt.Println("NOTE: To view 'services' information start nanobox with 'nanobox dev' or 'nanobox run'")
		return
	}

	//
	var services []server.Service
	if _, err := server.Get("/services", &services); err != nil {
		server.Fatal("[commands/info] failed", err.Error())
	}

	//
	if len(services) >= 1 {
		fmt.Printf("////////// SERVICES //////////\n")

		//
		for _, service := range services {

			fmt.Printf("\n%s :\n", service.UID)

			if service.Name != "" {
				fmt.Printf("   name  : %s\n", service.Name)
			}

			fmt.Printf("   host  : %s\n", config.Nanofile.Domain)
			fmt.Printf("   ports : %v\n", service.Ports)

			//
			if service.Username != "" {
				fmt.Printf("   username : %s\n", service.Username)
			}

			//
			if service.Password != "" {
				fmt.Printf("   password : %s\n", service.Password)
			}

			// show any environment variables
			if len(service.EnvVars) >= 1 {
				fmt.Printf("   evars :\n")

				for k, v := range service.EnvVars {
					fmt.Printf("      %s : %s\n", k, v)
				}
			}
		}
	}
}