Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions api/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ type Machine struct {
GpuDisplayName string
}
type Runtime struct {
Ports []*PodRuntimePorts
Ports []*Ports
}
type PodRuntimePorts struct {

type Ports struct {
Ip string
IsIpPublic bool
PrivatePort int
PublicPort int
Type string
PortType string
}

func GetPods() (pods []*Pod, err error) {
Expand Down Expand Up @@ -92,12 +93,12 @@ func GetPods() (pods []*Pod, err error) {
gpuDisplayName
}
runtime {
ports {
ports {
ip
publicPort
privatePort
isIpPublic
type
privatePort
publicPort
PortType: type
}
}
}
Expand Down
17 changes: 16 additions & 1 deletion cmd/pod/getPod.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ var GetPodCmd = &cobra.Command{
}
row := []string{p.Id, p.Name, fmt.Sprintf("%d %s", p.GpuCount, p.Machine.GpuDisplayName), p.ImageName, p.DesiredStatus}
if AllFields {

var portEntries int = 0
if p.Runtime != nil && p.Runtime.Ports != nil {
portEntries = len(p.Runtime.Ports)
}
ports := make([]string, portEntries)
for j:=0; j<portEntries; j++ {
var privpub string = "prv"
if p.Runtime.Ports[j].IsIpPublic {
privpub = "pub"
}
ports[j] = fmt.Sprintf("%s:%d->%d\u00A0(%s,%s)", p.Runtime.Ports[j].Ip, p.Runtime.Ports[j].PublicPort, p.Runtime.Ports[j].PrivatePort, privpub, p.Runtime.Ports[j].PortType)
}

row = append(
row,
p.PodType,
Expand All @@ -38,14 +52,15 @@ var GetPodCmd = &cobra.Command{
fmt.Sprintf("%d", p.ContainerDiskInGb),
fmt.Sprintf("%d", p.VolumeInGb),
fmt.Sprintf("%.3f", p.CostPerHr),
fmt.Sprintf("%s", strings.Join(ports[:], "\n") ),
)
}
data[i] = row
}

header := []string{"ID", "Name", "GPU", "Image Name", "Status"}
if AllFields {
header = append(header, "Pod Type", "vCPU", "Mem", "Container Disk", "Volume Disk", "$/hr")
header = append(header, "Pod Type", "vCPU", "Mem", "Container Disk", "Volume Disk", "$/hr", "Ports")
}

tb := tablewriter.NewWriter(os.Stdout)
Expand Down