From 68994467da92b25a7bb75fb420cb4713ad7a1eea Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Fri, 14 Aug 2020 08:46:08 -0500 Subject: [PATCH] fix: ensure log data is outputted in string format (#155) * fix: ensure log data is outputted in string format * chore: update version for new release --- action/log/get.go | 16 ++++++++++++++-- action/log/view.go | 4 ++-- version/version.go | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/action/log/get.go b/action/log/get.go index c0fc74a6..949d4e84 100644 --- a/action/log/get.go +++ b/action/log/get.go @@ -16,6 +16,8 @@ import ( func (c *Config) Get(client *vela.Client) error { logrus.Debug("executing get for log configuration") + logrus.Tracef("capturing logs for build %s/%s/%d", c.Org, c.Repo, c.Build) + // send API call to capture a list of build logs // // https://pkg.go.dev/github.com/go-vela/sdk-go/vela?tab=doc#BuildService.GetLogs @@ -24,7 +26,17 @@ func (c *Config) Get(client *vela.Client) error { return err } - logrus.Tracef("capturing logs for build %s/%s/%d", c.Org, c.Repo, c.Build) + // create variable for storing all build logs + data := []byte{} + + // iterate through all build logs + for _, log := range *logs { + // add the logs for the step from the build + data = append(data, log.GetData()...) + + // add a new line to separate the logs + data = append(data, []byte("\n")...) + } // handle the output based off the provided configuration switch c.Output { @@ -52,6 +64,6 @@ func (c *Config) Get(client *vela.Client) error { // output the logs in stdout format // // https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#Stdout - return output.Stdout(logs) + return output.Stdout(string(data)) } } diff --git a/action/log/view.go b/action/log/view.go index 7c0cdf1b..8acac989 100644 --- a/action/log/view.go +++ b/action/log/view.go @@ -52,7 +52,7 @@ func (c *Config) ViewService(client *vela.Client) error { // output the service log in stdout format // // https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#Stdout - return output.Stdout(log) + return output.Stdout(string(log.GetData())) } } @@ -96,6 +96,6 @@ func (c *Config) ViewStep(client *vela.Client) error { // output the step log in stdout format // // https://pkg.go.dev/github.com/go-vela/cli/internal/output?tab=doc#Stdout - return output.Stdout(log) + return output.Stdout(string(log.GetData())) } } diff --git a/version/version.go b/version/version.go index 1573d42b..40ab467f 100644 --- a/version/version.go +++ b/version/version.go @@ -12,7 +12,7 @@ var ( // VersionMinor is for functionality in a backwards-compatible manner VersionMinor int64 = 5 // VersionPatch is for backwards-compatible bug fixes - VersionPatch int64 + VersionPatch int64 = 2 ) // Version is the specification version that the package types support.