Skip to content

Commit

Permalink
fix: ensure log data is outputted in string format (#155)
Browse files Browse the repository at this point in the history
* fix: ensure log data is outputted in string format

* chore: update version for new release
  • Loading branch information
jbrockopp authored Aug 14, 2020
1 parent 658851a commit 6899446
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
16 changes: 14 additions & 2 deletions action/log/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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))
}
}
4 changes: 2 additions & 2 deletions action/log/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
}

Expand Down Expand Up @@ -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()))
}
}
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6899446

Please sign in to comment.