예제 #1
0
func listContainers() {

	response := instainerGet("/containers")

	defer response.Body.Close()
	contents, err := ioutil.ReadAll(response.Body)
	check(err)
	v, err := jason.NewObjectFromBytes(contents)
	data, err := v.GetObject("data")

	permanents, err := data.GetObjectArray("permanents")
	nonpermanents, err := data.GetObjectArray("nonPermanents")

	banner.Print("instainer")
	fmt.Println("")
	fmt.Println("")

	fmt.Println("Permanent Containers")
	fmt.Println("")

	fmt.Printf("%-32s %-52s %-32s %-24s\n", "CONTAINER ID", "NAME", "IMAGE NAME", "CREATED")

	for _, container := range permanents {

		containerId, err := container.GetString("id")
		name, err := container.GetString("name")
		imageName, err := container.GetString("imageName")
		createdTime, err := container.GetString("createdTime")

		check(err)

		fmt.Printf("%-32s %-52s %-32s %-24s\n", containerId, name, imageName, createdTime)

	}
	fmt.Println("")
	fmt.Println("")

	fmt.Println("Non-Permanent Containers")
	fmt.Println("")

	fmt.Printf("%-32s %-52s %-32s %-24s\n", "CONTAINER ID", "NAME", "IMAGE NAME", "CREATED")

	for _, container := range nonpermanents {

		containerId, err := container.GetString("id")
		name, err := container.GetString("name")
		imageName, err := container.GetString("imageName")
		createdTime, err := container.GetString("createdTime")

		check(err)

		fmt.Printf("%-32s %-52s %-32s %-24s\n", containerId, name, imageName, createdTime)

	}
}
예제 #2
0
파일: main.go 프로젝트: adriamb/gopad
func main() {
	banner.Print("runes")
	server.ExecuteCmd()
}
예제 #3
0
파일: main.go 프로젝트: gernest/banner
func main() {
	banner.Print("abcdefghijkl")
	banner.Print("mnopqrstuvwxyz")
	banner.Print("1234567890?-_.")
}
예제 #4
0
func upCompose(dockerComposeFile string) {
	dat, err := ioutil.ReadFile(dockerComposeFile)
	check(err)
	response := instainerPost("/compose/up", string(dat))

	defer response.Body.Close()
	contents, err := ioutil.ReadAll(response.Body)
	check(err)

	fmt.Println(string(contents))

	v, err := jason.NewObjectFromBytes(contents)
	data, err := v.GetObjectArray("data")

	banner.Print("instainer")
	fmt.Println("")
	fmt.Println("")

	for _, container := range data {
		username, err := container.GetString("gitUser")
		password, err := container.GetString("gitPassword")

		name, err := container.GetString("name")
		containerId, err := container.GetString("id")

		fmt.Println("Container Name ", name)
		fmt.Println("Container Id  ", containerId)

		fmt.Println("")
		color.Green("------------Git Information------------")
		color.Yellow("Git User      = %s", username)
		color.Yellow("Git Password  = %s", password)
		fmt.Println("")
		fmt.Println("")

		color.Green("----------Volumes Information----------")
		volumes, err := container.GetObjectArray("volumes")
		for _, volume := range volumes {
			mntDir, err := volume.GetString("mntDir")
			gitUrl, err := volume.GetString("gitUrl")
			check(err)
			color.Blue("    %s", mntDir)
			color.Yellow("    Git URL  = %s", gitUrl)
			fmt.Println("")
		}
		fmt.Println("")

		color.Green("------------Port Information------------")
		ports, err := container.GetObjectArray("ports")

		for _, port := range ports {
			dockerPort, err := port.GetString("dockerPort")
			instainerPort, err := port.GetString("instainerPort")
			check(err)
			color.Blue("  Container Port    %s", dockerPort)
			color.Yellow("  Instainer Port    instainer.io:%s", instainerPort)
			fmt.Println("")
		}
		fmt.Println("")

		envVariablesData, err := container.GetStringArray("envVariables")

		if len(envVariablesData) > 0 {
			color.Green("---------Environment Variables----------")

			for _, variable := range envVariablesData {
				color.Yellow("    Variable=Value      = %s", variable)
			}
		}
		fmt.Println("")
		fmt.Println("")
		check(err)
	}

	fmt.Println("Successfully deployed!")
	fmt.Println("")
	fmt.Println("")

}
예제 #5
0
func createContainer(dockerName string, volumeRequest []string, envVariables []string) {

	m := &RunParams{VolumeRequests: volumeRequest, EnvVariables: envVariables}
	b, err := json.Marshal(m)

	response := instainerPost("/container/run?image="+dockerName, string(b))

	defer response.Body.Close()

	contents, err := ioutil.ReadAll(response.Body)
	check(err)
	v, err := jason.NewObjectFromBytes(contents)
	data, err := v.GetObject("data")

	username, err := data.GetString("gitUser")
	password, err := data.GetString("gitPassword")

	banner.Print("instainer")
	fmt.Println("")
	fmt.Println("")

	color.Green("------------Git Information------------")
	color.Yellow("Git User      = %s", username)
	color.Yellow("Git Password  = %s", password)
	fmt.Println("")
	fmt.Println("")

	color.Green("----------Volumes Information----------")
	volumes, err := data.GetObjectArray("volumes")
	for _, volume := range volumes {
		mntDir, err := volume.GetString("mntDir")
		gitUrl, err := volume.GetString("gitUrl")
		check(err)
		color.Blue("    %s", mntDir)
		color.Yellow("    Git URL  = %s", gitUrl)
		fmt.Println("")
	}
	fmt.Println("")

	color.Green("------------Port Information------------")
	ports, err := data.GetObjectArray("ports")

	for _, port := range ports {
		dockerPort, err := port.GetString("dockerPort")
		instainerPort, err := port.GetString("instainerPort")
		check(err)
		color.Blue("  Container Port    %s", dockerPort)
		color.Yellow("  Instainer Port    instainer.io:%s", instainerPort)
		fmt.Println("")
	}
	fmt.Println("")

	envVariablesData, err := data.GetStringArray("envVariables")

	if len(envVariablesData) > 0 {
		color.Green("---------Environment Variables----------")

		for _, variable := range envVariablesData {
			color.Yellow("    Variable=Value      = %s", variable)
		}
	}
	fmt.Println("")
	fmt.Println("")
	fmt.Println("Successfully deployed!")
	fmt.Println("")
	fmt.Println("")

	check(err)
}