示例#1
0
文件: ps.go 项目: hako/dry
func (r *DockerPs) containerInformation(daemon docker.ContainerDaemon, cursor *ui.Cursor) string {
	buf := bytes.NewBufferString("")
	context := docker.FormattingContext{
		Output:   buf,
		Template: r.containerTemplate,
		Trunc:    true,
		Selected: cursor.Line,
	}
	docker.Format(
		context,
		daemon.Containers())

	return buf.String()
}
示例#2
0
文件: ps.go 项目: hako/dry
func dockerInfo(daemon docker.ContainerDaemon) string {
	version, _ := daemon.Version()

	buffer := new(bytes.Buffer)

	data := [][]string{
		[]string{"Docker Host:", whiteText(daemon.DockerEnv().DockerHost), "", "Docker Version:", whiteText(version.Version)},
		[]string{"Cert Path:", whiteText(daemon.DockerEnv().DockerCertPath), "", "APIVersion:", whiteText(version.APIVersion)},
		[]string{"Verify Certificate:", whiteText(strconv.FormatBool(daemon.DockerEnv().DockerTLSVerify)),
			"",
			"OS/Arch/Kernel:",
			whiteText(version.Os + "/" + version.Arch + "/" + version.KernelVersion)},
	}

	table := tablewriter.NewWriter(buffer)
	table.SetBorder(false)
	table.SetColumnSeparator("")
	table.SetAlignment(tablewriter.ALIGN_LEFT)
	table.AppendBulk(data)
	table.Render()
	return buffer.String()
}