func printTaskStatus(w io.Writer, t *api.Task) { fmt.Fprintln(w, "Status\t") fmt.Fprintf(w, " Desired State\t: %s\n", t.DesiredState.String()) fmt.Fprintf(w, " Last State\t: %s\n", t.Status.State.String()) if t.Status.Timestamp != nil { fmt.Fprintf(w, " Timestamp\t: %s\n", ptypes.TimestampString(t.Status.Timestamp)) } if t.Status.Message != "" { fmt.Fprintf(w, " Message\t: %s\n", t.Status.Message) } if t.Status.Err != "" { fmt.Fprintf(w, " Error\t: %s\n", t.Status.Err) } ctnr := t.Status.GetContainer() if ctnr == nil { return } if ctnr.ContainerID != "" { fmt.Fprintf(w, " ContainerID:\t: %s\n", ctnr.ContainerID) } if ctnr.PID != 0 { fmt.Fprintf(w, " Pid\t: %d\n", ctnr.PID) } if t.Status.State > api.TaskStateRunning { fmt.Fprintf(w, " ExitCode\t: %d\n", ctnr.ExitCode) } }
func printSecretSummary(secret *api.Secret) { w := tabwriter.NewWriter(os.Stdout, 8, 8, 8, ' ', 0) defer w.Flush() common.FprintfIfNotEmpty(w, "ID\t: %s\n", secret.ID) common.FprintfIfNotEmpty(w, "Name\t: %s\n", secret.Spec.Annotations.Name) if len(secret.Spec.Annotations.Labels) > 0 { fmt.Fprintln(w, "Labels\t") for k, v := range secret.Spec.Annotations.Labels { fmt.Fprintf(w, " %s\t: %s\n", k, v) } } common.FprintfIfNotEmpty(w, "Created\t: %s\n", ptypes.TimestampString(secret.Meta.CreatedAt)) }
func printTaskStatus(w io.Writer, t *api.Task) { fmt.Fprintln(w, "Status\t") fmt.Fprintf(w, " Desired State\t: %s\n", t.DesiredState.String()) fmt.Fprintf(w, " Last State\t: %s\n", t.Status.State.String()) if t.Status.Timestamp != nil { fmt.Fprintf(w, " Timestamp\t: %s\n", ptypes.TimestampString(t.Status.Timestamp)) } if t.Status.Message != "" { fmt.Fprintf(w, " Message\t: %s\n", t.Status.Message) } if t.Status.Err != "" { fmt.Fprintf(w, " Error\t: %s\n", t.Status.Err) } ctnr := t.Status.GetContainer() if ctnr == nil { return } if ctnr.ContainerID != "" { fmt.Fprintf(w, " ContainerID:\t: %s\n", ctnr.ContainerID) } if ctnr.PID != 0 { fmt.Fprintf(w, " Pid\t: %d\n", ctnr.PID) } if t.Status.State > api.TaskStateRunning { fmt.Fprintf(w, " ExitCode\t: %d\n", ctnr.ExitCode) } if t.Status.PortStatus != nil && len(t.Status.PortStatus.Ports) > 0 { ports := []string{} for _, port := range t.Status.PortStatus.Ports { ports = append(ports, fmt.Sprintf("0.0.0.0:%d->%d/%s", port.PublishedPort, port.TargetPort, strings.ToLower(port.Protocol.String()))) } fmt.Fprintf(w, "Ports\t: %s\n", strings.Join(ports, ", ")) } }