Merge pull request #25337 from jhorwit2/jah/25332

Add --no-trunc to service/node/stack ps output
This commit is contained in:
Michael Crosby
2016-08-16 09:25:45 -07:00
committed by GitHub
8 changed files with 17 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ import (
type psOptions struct {
nodeID string
noResolve bool
noTrunc bool
filter opts.FilterOpt
}
@@ -31,6 +32,7 @@ func newPSCommand(dockerCli *client.DockerCli) *cobra.Command {
},
}
flags := cmd.Flags()
flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output")
flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names")
flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided")
@@ -59,5 +61,5 @@ func runPS(dockerCli *client.DockerCli, opts psOptions) error {
return err
}
return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve))
return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve), opts.noTrunc)
}

View File

@@ -16,6 +16,7 @@ import (
type psOptions struct {
serviceID string
noResolve bool
noTrunc bool
filter opts.FilterOpt
}
@@ -32,6 +33,7 @@ func newPSCommand(dockerCli *client.DockerCli) *cobra.Command {
},
}
flags := cmd.Flags()
flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output")
flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names")
flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided")
@@ -66,5 +68,5 @@ func runPS(dockerCli *client.DockerCli, opts psOptions) error {
return err
}
return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve))
return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve), opts.noTrunc)
}

View File

@@ -20,6 +20,7 @@ import (
type psOptions struct {
all bool
filter opts.FilterOpt
noTrunc bool
namespace string
noResolve bool
}
@@ -38,6 +39,7 @@ func newPSCommand(dockerCli *client.DockerCli) *cobra.Command {
}
flags := cmd.Flags()
flags.BoolVarP(&opts.all, "all", "a", false, "Display all tasks")
flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate output")
flags.BoolVar(&opts.noResolve, "no-resolve", false, "Do not map IDs to Names")
flags.VarP(&opts.filter, "filter", "f", "Filter output based on conditions provided")
@@ -66,5 +68,5 @@ func runPS(dockerCli *client.DockerCli, opts psOptions) error {
return nil
}
return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve))
return task.Print(dockerCli, ctx, tasks, idresolver.New(client, opts.noResolve), opts.noTrunc)
}

View File

@@ -41,7 +41,7 @@ func (t tasksBySlot) Less(i, j int) bool {
}
// Print task information in a table format
func Print(dockerCli *client.DockerCli, ctx context.Context, tasks []swarm.Task, resolver *idresolver.IDResolver) error {
func Print(dockerCli *client.DockerCli, ctx context.Context, tasks []swarm.Task, resolver *idresolver.IDResolver, noTrunc bool) error {
sort.Stable(tasksBySlot(tasks))
writer := tabwriter.NewWriter(dockerCli.Out(), 0, 4, 2, ' ', 0)
@@ -75,7 +75,7 @@ func Print(dockerCli *client.DockerCli, ctx context.Context, tasks []swarm.Task,
// Trim and quote the error message.
taskErr := task.Status.Err
if len(taskErr) > maxErrLength {
if !noTrunc && len(taskErr) > maxErrLength {
taskErr = fmt.Sprintf("%s…", taskErr[:maxErrLength-1])
}
if len(taskErr) > 0 {