Example #1
0
func makePartFromContainer(name string) (v Parts, err error) {
	// this block pulls out functionality from
	// PrintLineByContainerName{Id} & printLine
	var contID *docker.Container
	cont, exists := util.ParseContainers(name, true)
	if exists {
		contID, err = util.DockerClient.InspectContainer(cont.ID)
		if err != nil {
			return Parts{}, err
		}
	}
	if err != nil {
		return Parts{}, err
	}
	tmp, err := reflections.GetField(contID, "Name")
	if err != nil {
		return Parts{}, err
	}

	n := tmp.(string)

	Names := util.ContainerDisassemble(n)

	v = Parts{
		ShortName: Names.ShortName,
		//Running: set in previous function
		FullName:    Names.FullName,
		PortsOutput: util.FormulatePortsOutput(contID),
	}
	return v, nil
}
Example #2
0
// this function populates the listing functions
func printLine(container *docker.Container) ([]string, error) {
	tmp, err := reflections.GetField(container, "Name")
	if err != nil {
		return nil, err
	}
	n := tmp.(string)

	Names := util.ContainerDisassemble(n)
	parts := []string{Names.ShortName, Names.FullName, Names.Type, fmt.Sprintf("%d", Names.Number), formulatePortsOutput(container)}
	return parts, nil
}