From 227ded818c0eb137620c6b53b9ab11e048050631 Mon Sep 17 00:00:00 2001 From: Erik Rasmussen Date: Tue, 13 Aug 2024 14:27:13 -0500 Subject: [PATCH] Dedupe bins in provisioner output (#129) --- provider/pkg/operation/operation.go | 6 ++++-- provider/pkg/provisioner/command/service.go | 10 ++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/provider/pkg/operation/operation.go b/provider/pkg/operation/operation.go index 70050446..7aa5a5a8 100644 --- a/provider/pkg/operation/operation.go +++ b/provider/pkg/operation/operation.go @@ -21,10 +21,12 @@ func DisplayAll(ops []*pb.Operation) string { b := strings.Builder{} b.WriteRune('[') - for _, o := range ops { - _, _ = b.WriteString(Display(o) + ", ") + d := make([]string, len(ops)) + for i, o := range ops { + d[i] = Display(o) } + b.WriteString(strings.Join(d, ", ")) b.WriteRune(']') return b.String() } diff --git a/provider/pkg/provisioner/command/service.go b/provider/pkg/provisioner/command/service.go index 4173fd81..eb6101f9 100644 --- a/provider/pkg/provisioner/command/service.go +++ b/provider/pkg/provisioner/command/service.go @@ -175,7 +175,10 @@ func (s *service) Delete(ctx context.Context, req *pb.DeleteRequest) (*pb.Delete log.InfoContext(ctx, "finished executing command", "cmd", cmd.String()) commands = append(commands, &pb.Operation{ - Command: &pb.Command{Bin: pb.Bin_BIN_RM, Args: cmd.Args}, + Command: &pb.Command{ + Bin: pb.Bin_BIN_RM, + Args: cmd.Args[1:], + }, Result: &pb.Result{ ExitCode: int32(cmd.ProcessState.ExitCode()), Stdout: stdout.String(), @@ -201,7 +204,10 @@ func (s *service) Delete(ctx context.Context, req *pb.DeleteRequest) (*pb.Delete log.InfoContext(ctx, "finished executing command", "cmd", cmd.String()) commands = append(commands, &pb.Operation{ - Command: &pb.Command{Bin: pb.Bin_BIN_MV, Args: cmd.Args}, + Command: &pb.Command{ + Bin: pb.Bin_BIN_MV, + Args: cmd.Args[1:], + }, Result: &pb.Result{ ExitCode: int32(cmd.ProcessState.ExitCode()), Stdout: stdout.String(),