mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-05-13 22:16:40 +02:00
feat: improve output (#3966)
- log keys will be ordered as intended instead of sorted - paths always relative to cwd --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
45b80dfa26
commit
6fd5fd45ea
3
go.mod
3
go.mod
@ -12,7 +12,7 @@ require (
|
||||
github.com/caarlos0/go-reddit/v3 v3.0.1
|
||||
github.com/caarlos0/go-shellwords v1.0.12
|
||||
github.com/caarlos0/go-version v0.1.1
|
||||
github.com/caarlos0/log v0.2.2
|
||||
github.com/caarlos0/log v0.4.0
|
||||
github.com/charmbracelet/keygen v0.4.2
|
||||
github.com/charmbracelet/lipgloss v0.7.1
|
||||
github.com/chrismellard/docker-credential-acr-env v0.0.0-20220327082430-c57b701bfc08
|
||||
@ -138,6 +138,7 @@ require (
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/docker/go-metrics v0.0.1 // indirect
|
||||
github.com/docker/go-units v0.5.0
|
||||
github.com/elliotchance/orderedmap/v2 v2.2.0 // indirect
|
||||
github.com/emirpasic/gods v1.12.0 // indirect
|
||||
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
|
8
go.sum
8
go.sum
@ -704,8 +704,8 @@ github.com/caarlos0/go-shellwords v1.0.12 h1:HWrUnu6lGbWfrDcFiHcZiwOLzHWjjrPVehU
|
||||
github.com/caarlos0/go-shellwords v1.0.12/go.mod h1:bYeeX1GrTLPl5cAMYEzdm272qdsQAZiaHgeF0KTk1Gw=
|
||||
github.com/caarlos0/go-version v0.1.1 h1:1bikKHkGGVIIxqCmufhSSs3hpBScgHGacrvsi8FuIfc=
|
||||
github.com/caarlos0/go-version v0.1.1/go.mod h1:Ze5Qx4TsBBi5FyrSKVg1Ibc44KGV/llAaKGp86oTwZ0=
|
||||
github.com/caarlos0/log v0.2.2 h1:Rier7889+dTKHjvwf0cMNu8DjMF+/wCYC7wrPj9fXFk=
|
||||
github.com/caarlos0/log v0.2.2/go.mod h1:IbSeDN+hKHdOwE6t2z9i2rcraz+r6N1XZkRHE4BAKm0=
|
||||
github.com/caarlos0/log v0.4.0 h1:6e6F5hpFIstCh9tqIAu21gRLoiAp3IYtXpz/yuPy83A=
|
||||
github.com/caarlos0/log v0.4.0/go.mod h1:KZ4KwLhipK/sWIPGOCNVg3ke+iD2A3GC3+1WLEjTehw=
|
||||
github.com/caarlos0/sshmarshal v0.1.0 h1:zTCZrDORFfWh526Tsb7vCm3+Yg/SfW/Ub8aQDeosk0I=
|
||||
github.com/caarlos0/sshmarshal v0.1.0/go.mod h1:7Pd/0mmq9x/JCzKauogNjSQEhivBclCQHfr9dlpDIyA=
|
||||
github.com/caarlos0/testfs v0.4.4 h1:3PHvzHi5Lt+g332CiShwS8ogTgS3HjrmzZxCm6JCDr8=
|
||||
@ -975,6 +975,8 @@ github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFP
|
||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/edsrzf/mmap-go v1.1.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q=
|
||||
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||
github.com/elliotchance/orderedmap/v2 v2.2.0 h1:7/2iwO98kYT4XkOjA9mBEIwvi4KpGB4cyHeOFOnj4Vk=
|
||||
github.com/elliotchance/orderedmap/v2 v2.2.0/go.mod h1:85lZyVbpGaGvHvnKa7Qhx7zncAdBIBq6u56Hb1PRU5Q=
|
||||
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
|
||||
@ -1627,8 +1629,8 @@ github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsI
|
||||
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
|
||||
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
|
||||
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
|
||||
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
|
||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||
github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
|
@ -15,6 +15,8 @@ import (
|
||||
"hash/crc32"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/caarlos0/log"
|
||||
@ -316,15 +318,40 @@ func (artifacts *Artifacts) GroupByPlatform() map[string][]*Artifact {
|
||||
return result
|
||||
}
|
||||
|
||||
func relPath(a *Artifact) (string, error) {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !strings.HasPrefix(a.Path, cwd) {
|
||||
return "", nil
|
||||
}
|
||||
return filepath.Rel(cwd, a.Path)
|
||||
}
|
||||
|
||||
func shouldRelPath(a *Artifact) bool {
|
||||
switch a.Type {
|
||||
case DockerImage, DockerManifest, PublishableDockerImage:
|
||||
return false
|
||||
default:
|
||||
return filepath.IsAbs(a.Path)
|
||||
}
|
||||
}
|
||||
|
||||
// Add safely adds a new artifact to an artifact list.
|
||||
func (artifacts *Artifacts) Add(a *Artifact) {
|
||||
artifacts.lock.Lock()
|
||||
defer artifacts.lock.Unlock()
|
||||
log.WithFields(log.Fields{
|
||||
"name": a.Name,
|
||||
"path": a.Path,
|
||||
"type": a.Type,
|
||||
}).Debug("added new artifact")
|
||||
if shouldRelPath(a) {
|
||||
rel, err := relPath(a)
|
||||
if rel != "" && err == nil {
|
||||
a.Path = rel
|
||||
}
|
||||
}
|
||||
log.WithField("name", a.Name).
|
||||
WithField("type", a.Type).
|
||||
WithField("path", a.Path).
|
||||
Debug("added new artifact")
|
||||
artifacts.items = append(artifacts.items, a)
|
||||
}
|
||||
|
||||
@ -340,11 +367,10 @@ func (artifacts *Artifacts) Remove(filter Filter) error {
|
||||
result := New()
|
||||
for _, a := range artifacts.items {
|
||||
if filter(a) {
|
||||
log.WithFields(log.Fields{
|
||||
"name": a.Name,
|
||||
"path": a.Path,
|
||||
"type": a.Type,
|
||||
}).Debug("removing")
|
||||
log.WithField("name", a.Name).
|
||||
WithField("type", a.Type).
|
||||
WithField("path", a.Path).
|
||||
Debug("removing")
|
||||
} else {
|
||||
result.items = append(result.items, a)
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ func TestBuild(t *testing.T) {
|
||||
require.ElementsMatch(t, ctx.Artifacts.List(), []*artifact.Artifact{
|
||||
{
|
||||
Name: "bin/foo-v5.6.7",
|
||||
Path: filepath.Join(folder, "dist", "linux_amd64", "bin", "foo-v5.6.7"),
|
||||
Path: filepath.Join("dist", "linux_amd64", "bin", "foo-v5.6.7"),
|
||||
Goos: "linux",
|
||||
Goarch: "amd64",
|
||||
Type: artifact.Binary,
|
||||
@ -435,7 +435,7 @@ func TestBuild(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Name: "bin/foo-v5.6.7",
|
||||
Path: filepath.Join(folder, "dist", "linux_mips_softfloat", "bin", "foo-v5.6.7"),
|
||||
Path: filepath.Join("dist", "linux_mips_softfloat", "bin", "foo-v5.6.7"),
|
||||
Goos: "linux",
|
||||
Goarch: "mips",
|
||||
Gomips: "softfloat",
|
||||
@ -449,7 +449,7 @@ func TestBuild(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Name: "bin/foo-v5.6.7",
|
||||
Path: filepath.Join(folder, "dist", "linux_mips64le_softfloat", "bin", "foo-v5.6.7"),
|
||||
Path: filepath.Join("dist", "linux_mips64le_softfloat", "bin", "foo-v5.6.7"),
|
||||
Goos: "linux",
|
||||
Goarch: "mips64le",
|
||||
Gomips: "softfloat",
|
||||
@ -463,7 +463,7 @@ func TestBuild(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Name: "bin/foo-v5.6.7",
|
||||
Path: filepath.Join(folder, "dist", "darwin_amd64", "bin", "foo-v5.6.7"),
|
||||
Path: filepath.Join("dist", "darwin_amd64", "bin", "foo-v5.6.7"),
|
||||
Goos: "darwin",
|
||||
Goarch: "amd64",
|
||||
Type: artifact.Binary,
|
||||
@ -476,7 +476,7 @@ func TestBuild(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Name: "bin/foo-v5.6.7",
|
||||
Path: filepath.Join(folder, "dist", "linux_arm_6", "bin", "foo-v5.6.7"),
|
||||
Path: filepath.Join("dist", "linux_arm_6", "bin", "foo-v5.6.7"),
|
||||
Goos: "linux",
|
||||
Goarch: "arm",
|
||||
Goarm: "6",
|
||||
@ -490,7 +490,7 @@ func TestBuild(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Name: "bin/foo-v5.6.7.exe",
|
||||
Path: filepath.Join(folder, "dist", "windows_amd64", "bin", "foo-v5.6.7.exe"),
|
||||
Path: filepath.Join("dist", "windows_amd64", "bin", "foo-v5.6.7.exe"),
|
||||
Goos: "windows",
|
||||
Goarch: "amd64",
|
||||
Type: artifact.Binary,
|
||||
@ -503,7 +503,7 @@ func TestBuild(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Name: "bin/foo-v5.6.7.wasm",
|
||||
Path: filepath.Join(folder, "dist", "js_wasm", "bin", "foo-v5.6.7.wasm"),
|
||||
Path: filepath.Join("dist", "js_wasm", "bin", "foo-v5.6.7.wasm"),
|
||||
Goos: "js",
|
||||
Goarch: "wasm",
|
||||
Type: artifact.Binary,
|
||||
@ -558,7 +558,7 @@ func TestBuildInvalidEnv(t *testing.T) {
|
||||
err := Default.Build(ctx, build, api.Options{
|
||||
Target: runtimeTarget,
|
||||
Name: build.Binary,
|
||||
Path: filepath.Join(folder, "dist", runtimeTarget, build.Binary),
|
||||
Path: filepath.Join("dist", runtimeTarget, build.Binary),
|
||||
Ext: "",
|
||||
})
|
||||
testlib.RequireTemplateError(t, err)
|
||||
@ -591,7 +591,7 @@ func TestBuildCodeInSubdir(t *testing.T) {
|
||||
err = Default.Build(ctx, build, api.Options{
|
||||
Target: runtimeTarget,
|
||||
Name: build.Binary,
|
||||
Path: filepath.Join(folder, "dist", runtimeTarget, build.Binary),
|
||||
Path: filepath.Join("dist", runtimeTarget, build.Binary),
|
||||
Ext: "",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@ -619,7 +619,7 @@ func TestBuildWithDotGoDir(t *testing.T) {
|
||||
require.NoError(t, Default.Build(ctx, build, api.Options{
|
||||
Target: runtimeTarget,
|
||||
Name: build.Binary,
|
||||
Path: filepath.Join(folder, "dist", runtimeTarget, build.Binary),
|
||||
Path: filepath.Join("dist", runtimeTarget, build.Binary),
|
||||
Ext: "",
|
||||
}))
|
||||
}
|
||||
|
@ -93,11 +93,10 @@ func (c *giteaClient) getDefaultBranch(_ *context.Context, repo Repo) (string, e
|
||||
projectID := repo.String()
|
||||
p, res, err := c.client.GetRepo(repo.Owner, repo.Name)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"projectID": projectID,
|
||||
"statusCode": res.StatusCode,
|
||||
"err": err.Error(),
|
||||
}).Warn("error checking for default branch")
|
||||
log.WithField("projectID", projectID).
|
||||
WithField("statusCode", res.StatusCode).
|
||||
WithError(err).
|
||||
Warn("error checking for default branch")
|
||||
return "", err
|
||||
}
|
||||
return p.DefaultBranch, nil
|
||||
@ -122,12 +121,11 @@ func (c *giteaClient) CreateFile(
|
||||
branch, err = c.getDefaultBranch(ctx, repo)
|
||||
if err != nil {
|
||||
// Fall back to 'master' 😭
|
||||
log.WithFields(log.Fields{
|
||||
"fileName": path,
|
||||
"projectID": repo.String(),
|
||||
"requestedBranch": branch,
|
||||
"err": err.Error(),
|
||||
}).Warn("error checking for default branch, using master")
|
||||
log.WithField("fileName", path).
|
||||
WithField("projectID", repo.String()).
|
||||
WithField("requestedBranch", branch).
|
||||
WithError(err).
|
||||
Warn("error checking for default branch, using master")
|
||||
}
|
||||
|
||||
}
|
||||
@ -183,9 +181,7 @@ func (c *giteaClient) createRelease(ctx *context.Context, title, body string) (*
|
||||
}
|
||||
release, _, err := c.client.CreateRelease(owner, repoName, opts)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"err": err.Error(),
|
||||
}).Debug("error creating Gitea release")
|
||||
log.WithError(err).Debug("error creating Gitea release")
|
||||
return nil, err
|
||||
}
|
||||
log.WithField("id", release.ID).Info("Gitea release created")
|
||||
@ -224,9 +220,7 @@ func (c *giteaClient) updateRelease(ctx *context.Context, title, body string, id
|
||||
|
||||
release, _, err := c.client.EditRelease(owner, repoName, id, opts)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"err": err.Error(),
|
||||
}).Debug("error updating Gitea release")
|
||||
log.WithError(err).Debug("error updating Gitea release")
|
||||
return nil, err
|
||||
}
|
||||
log.WithField("id", release.ID).Info("Gitea release updated")
|
||||
|
@ -105,11 +105,10 @@ func (c *githubClient) Changelog(ctx *context.Context, repo Repo, prev, current
|
||||
func (c *githubClient) getDefaultBranch(ctx *context.Context, repo Repo) (string, error) {
|
||||
p, res, err := c.client.Repositories.Get(ctx, repo.Owner, repo.Name)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"projectID": repo.String(),
|
||||
"statusCode": res.StatusCode,
|
||||
"err": err.Error(),
|
||||
}).Warn("error checking for default branch")
|
||||
log.WithField("projectID", repo.String()).
|
||||
WithField("statusCode", res.StatusCode).
|
||||
WithError(err).
|
||||
Warn("error checking for default branch")
|
||||
return "", err
|
||||
}
|
||||
return p.GetDefaultBranch(), nil
|
||||
@ -311,11 +310,10 @@ func (c *githubClient) createOrUpdateRelease(ctx *context.Context, data *github.
|
||||
data,
|
||||
)
|
||||
if err == nil {
|
||||
log.WithFields(log.Fields{
|
||||
"name": data.GetName(),
|
||||
"release-id": release.GetID(),
|
||||
"request-id": resp.Header.Get("X-GitHub-Request-Id"),
|
||||
}).Info("release created")
|
||||
log.WithField("name", data.GetName()).
|
||||
WithField("release-id", release.GetID()).
|
||||
WithField("request-id", resp.Header.Get("X-GitHub-Request-Id")).
|
||||
Info("release created")
|
||||
}
|
||||
return release, err
|
||||
}
|
||||
@ -333,11 +331,10 @@ func (c *githubClient) updateRelease(ctx *context.Context, id int64, data *githu
|
||||
data,
|
||||
)
|
||||
if err == nil {
|
||||
log.WithFields(log.Fields{
|
||||
"name": data.GetName(),
|
||||
"release-id": release.GetID(),
|
||||
"request-id": resp.Header.Get("X-GitHub-Request-Id"),
|
||||
}).Info("release updated")
|
||||
log.WithField("name", data.GetName()).
|
||||
WithField("release-id", release.GetID()).
|
||||
WithField("request-id", resp.Header.Get("X-GitHub-Request-Id")).
|
||||
Info("release updated")
|
||||
}
|
||||
return release, err
|
||||
}
|
||||
@ -381,11 +378,10 @@ func (c *githubClient) Upload(
|
||||
if resp != nil {
|
||||
requestID = resp.Header.Get("X-GitHub-Request-Id")
|
||||
}
|
||||
log.WithFields(log.Fields{
|
||||
"name": artifact.Name,
|
||||
"release-id": releaseID,
|
||||
"request-id": requestID,
|
||||
}).Warn("upload failed")
|
||||
log.WithField("name", artifact.Name).
|
||||
WithField("release-id", releaseID).
|
||||
WithField("request-id", requestID).
|
||||
Warn("upload failed")
|
||||
}
|
||||
if err == nil {
|
||||
return nil
|
||||
@ -482,11 +478,10 @@ func (c *githubClient) deleteExistingDraftRelease(ctx *context.Context, name str
|
||||
return fmt.Errorf("could not delete previous draft release: %w", err)
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"commit": r.GetTargetCommitish(),
|
||||
"tag": r.GetTagName(),
|
||||
"name": r.GetName(),
|
||||
}).Info("deleted previous draft release")
|
||||
log.WithField("commit", r.GetTargetCommitish()).
|
||||
WithField("tag", r.GetTagName()).
|
||||
WithField("name", r.GetName()).
|
||||
Info("deleted previous draft release")
|
||||
|
||||
// in theory, there should be only 1 release matching, so we can just return
|
||||
return nil
|
||||
|
@ -88,11 +88,11 @@ func (c *gitlabClient) getDefaultBranch(_ *context.Context, repo Repo) (string,
|
||||
projectID := repo.String()
|
||||
p, res, err := c.client.Projects.GetProject(projectID, nil)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"projectID": projectID,
|
||||
"statusCode": res.StatusCode,
|
||||
"err": err.Error(),
|
||||
}).Warn("error checking for default branch")
|
||||
log.
|
||||
WithField("projectID", projectID).
|
||||
WithField("statusCode", res.StatusCode).
|
||||
WithError(err).
|
||||
Warn("error checking for default branch")
|
||||
return "", err
|
||||
}
|
||||
return p.DefaultBranch, nil
|
||||
@ -153,12 +153,12 @@ func (c *gitlabClient) CreateFile(
|
||||
branch, err = c.getDefaultBranch(ctx, repo)
|
||||
if err != nil {
|
||||
// Fall back to 'master' 😭
|
||||
log.WithFields(log.Fields{
|
||||
"fileName": fileName,
|
||||
"projectID": repo.String(),
|
||||
"requestedBranch": branch,
|
||||
"err": err.Error(),
|
||||
}).Warn("error checking for default branch, using master")
|
||||
log.
|
||||
WithField("fileName", fileName).
|
||||
WithField("projectID", repo.String()).
|
||||
WithField("requestedBranch", branch).
|
||||
WithError(err).
|
||||
Warn("error checking for default branch, using master")
|
||||
ref = "master"
|
||||
branch = "master"
|
||||
}
|
||||
@ -167,37 +167,37 @@ func (c *gitlabClient) CreateFile(
|
||||
opts := &gitlab.GetFileOptions{Ref: &ref}
|
||||
castedContent := string(content)
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"owner": repo.Owner,
|
||||
"name": repo.Name,
|
||||
"ref": ref,
|
||||
"branch": branch,
|
||||
}).Debug("projectID at brew")
|
||||
log.
|
||||
WithField("owner", repo.Owner).
|
||||
WithField("name", repo.Name).
|
||||
WithField("ref", ref).
|
||||
WithField("branch", branch).
|
||||
Debug("projectID at brew")
|
||||
|
||||
_, res, err := c.client.RepositoryFiles.GetFile(repo.String(), fileName, opts)
|
||||
if err != nil && (res == nil || res.StatusCode != 404) {
|
||||
log.WithFields(log.Fields{
|
||||
"fileName": fileName,
|
||||
"ref": ref,
|
||||
"projectID": projectID,
|
||||
"statusCode": res.StatusCode,
|
||||
"err": err.Error(),
|
||||
}).Error("error getting file for brew formula")
|
||||
log.
|
||||
WithField("fileName", fileName).
|
||||
WithField("ref", ref).
|
||||
WithField("projectID", projectID).
|
||||
WithField("statusCode", res.StatusCode).
|
||||
WithError(err).
|
||||
Error("error getting file for brew formula")
|
||||
return err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"fileName": fileName,
|
||||
"branch": branch,
|
||||
"projectID": projectID,
|
||||
}).Debug("found already existing brew formula file")
|
||||
log.
|
||||
WithField("fileName", fileName).
|
||||
WithField("branch", branch).
|
||||
WithField("projectID", projectID).
|
||||
Debug("found already existing brew formula file")
|
||||
|
||||
if res.StatusCode == 404 {
|
||||
log.WithFields(log.Fields{
|
||||
"fileName": fileName,
|
||||
"ref": ref,
|
||||
"projectID": projectID,
|
||||
}).Debug("creating brew formula")
|
||||
log.
|
||||
WithField("fileName", fileName).
|
||||
WithField("ref", ref).
|
||||
WithField("projectID", projectID).
|
||||
Debug("creating brew formula")
|
||||
createOpts := &gitlab.CreateFileOptions{
|
||||
AuthorName: &commitAuthor.Name,
|
||||
AuthorEmail: &commitAuthor.Email,
|
||||
@ -207,30 +207,30 @@ func (c *gitlabClient) CreateFile(
|
||||
}
|
||||
fileInfo, res, err := c.client.RepositoryFiles.CreateFile(projectID, fileName, createOpts)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"fileName": fileName,
|
||||
"branch": branch,
|
||||
"projectID": projectID,
|
||||
"statusCode": res.StatusCode,
|
||||
"err": err.Error(),
|
||||
}).Error("error creating brew formula file")
|
||||
log.
|
||||
WithField("fileName", fileName).
|
||||
WithField("branch", branch).
|
||||
WithField("projectID", projectID).
|
||||
WithField("statusCode", res.StatusCode).
|
||||
WithError(err).
|
||||
Error("error creating brew formula file")
|
||||
return err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"fileName": fileName,
|
||||
"branch": branch,
|
||||
"projectID": projectID,
|
||||
"filePath": fileInfo.FilePath,
|
||||
}).Debug("created brew formula file")
|
||||
log.
|
||||
WithField("fileName", fileName).
|
||||
WithField("branch", branch).
|
||||
WithField("projectID", projectID).
|
||||
WithField("filePath", fileInfo.FilePath).
|
||||
Debug("created brew formula file")
|
||||
return nil
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"fileName": fileName,
|
||||
"ref": ref,
|
||||
"projectID": projectID,
|
||||
}).Debug("updating brew formula")
|
||||
log.
|
||||
WithField("fileName", fileName).
|
||||
WithField("ref", ref).
|
||||
WithField("projectID", projectID).
|
||||
Debug("updating brew formula")
|
||||
updateOpts := &gitlab.UpdateFileOptions{
|
||||
AuthorName: &commitAuthor.Name,
|
||||
AuthorEmail: &commitAuthor.Email,
|
||||
@ -241,23 +241,23 @@ func (c *gitlabClient) CreateFile(
|
||||
|
||||
updateFileInfo, res, err := c.client.RepositoryFiles.UpdateFile(projectID, fileName, updateOpts)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"fileName": fileName,
|
||||
"branch": branch,
|
||||
"projectID": projectID,
|
||||
"statusCode": res.StatusCode,
|
||||
"err": err.Error(),
|
||||
}).Error("error updating brew formula file")
|
||||
log.
|
||||
WithField("fileName", fileName).
|
||||
WithField("branch", branch).
|
||||
WithField("projectID", projectID).
|
||||
WithField("statusCode", res.StatusCode).
|
||||
WithError(err).
|
||||
Error("error updating brew formula file")
|
||||
return err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"fileName": fileName,
|
||||
"branch": branch,
|
||||
"projectID": projectID,
|
||||
"filePath": updateFileInfo.FilePath,
|
||||
"statusCode": res.StatusCode,
|
||||
}).Debug("updated brew formula file")
|
||||
log.
|
||||
WithField("fileName", fileName).
|
||||
WithField("branch", branch).
|
||||
WithField("projectID", projectID).
|
||||
WithField("filePath", updateFileInfo.FilePath).
|
||||
WithField("statusCode", res.StatusCode).
|
||||
Debug("updated brew formula file")
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -276,11 +276,11 @@ func (c *gitlabClient) CreateRelease(ctx *context.Context, body string) (release
|
||||
if ctx.Config.Release.GitLab.Owner != "" {
|
||||
projectID = ctx.Config.Release.GitLab.Owner + "/" + projectID
|
||||
}
|
||||
log.WithFields(log.Fields{
|
||||
"owner": ctx.Config.Release.GitLab.Owner,
|
||||
"name": gitlabName,
|
||||
"projectID": projectID,
|
||||
}).Debug("projectID")
|
||||
log.
|
||||
WithField("owner", ctx.Config.Release.GitLab.Owner).
|
||||
WithField("name", gitlabName).
|
||||
WithField("projectID", projectID).
|
||||
Debug("projectID")
|
||||
|
||||
name := title
|
||||
tagName := ctx.Git.CurrentTag
|
||||
@ -290,20 +290,18 @@ func (c *gitlabClient) CreateRelease(ctx *context.Context, body string) (release
|
||||
}
|
||||
|
||||
if resp.StatusCode == 403 || resp.StatusCode == 404 {
|
||||
log.WithFields(log.Fields{
|
||||
"err": err.Error(),
|
||||
}).Debug("get release")
|
||||
log.WithError(err).Debug("get release")
|
||||
|
||||
description := body
|
||||
ref := ctx.Git.Commit
|
||||
gitURL := ctx.Git.URL
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"name": name,
|
||||
"description": description,
|
||||
"ref": ref,
|
||||
"url": gitURL,
|
||||
}).Debug("creating release")
|
||||
log.
|
||||
WithField("name", name).
|
||||
WithField("description", description).
|
||||
WithField("ref", ref).
|
||||
WithField("url", gitURL).
|
||||
Debug("creating release")
|
||||
release, _, err = c.client.Releases.CreateRelease(projectID, &gitlab.CreateReleaseOptions{
|
||||
Name: &name,
|
||||
Description: &description,
|
||||
@ -312,9 +310,7 @@ func (c *gitlabClient) CreateRelease(ctx *context.Context, body string) (release
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"err": err.Error(),
|
||||
}).Debug("error create release")
|
||||
log.WithError(err).Debug("error creating release")
|
||||
return "", err
|
||||
}
|
||||
log.WithField("name", release.Name).Info("release created")
|
||||
@ -329,9 +325,7 @@ func (c *gitlabClient) CreateRelease(ctx *context.Context, body string) (release
|
||||
Description: &desc,
|
||||
})
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"err": err.Error(),
|
||||
}).Debug("error update release")
|
||||
log.WithError(err).Debug("error updating release")
|
||||
return "", err
|
||||
}
|
||||
|
||||
@ -438,10 +432,9 @@ func (c *gitlabClient) Upload(
|
||||
linkURL = gitlabBaseURL + "/" + projectDetails.PathWithNamespace + baseLinkURL
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"file": file.Name(),
|
||||
"url": baseLinkURL,
|
||||
}).Debug("uploaded file")
|
||||
log.WithField("file", file.Name()).
|
||||
WithField("url", baseLinkURL).
|
||||
Debug("uploaded file")
|
||||
|
||||
name := artifact.Name
|
||||
filename := "/" + name
|
||||
@ -457,10 +450,9 @@ func (c *gitlabClient) Upload(
|
||||
return RetriableError{err}
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"id": releaseLink.ID,
|
||||
"url": releaseLink.DirectAssetURL,
|
||||
}).Debug("created release link")
|
||||
log.WithField("id", releaseLink.ID).
|
||||
WithField("url", releaseLink.DirectAssetURL).
|
||||
Debug("created release link")
|
||||
|
||||
// for checksums.txt the field is nil, so we initialize it
|
||||
if artifact.Extra == nil {
|
||||
|
@ -91,21 +91,20 @@ func executeCommand(c *command, artifact *artifact.Artifact) error {
|
||||
cmd.Dir = c.Dir
|
||||
}
|
||||
|
||||
fields := log.Fields{
|
||||
"cmd": c.Args[0],
|
||||
"artifact": artifact.Name,
|
||||
}
|
||||
var b bytes.Buffer
|
||||
w := gio.Safe(&b)
|
||||
cmd.Stderr = io.MultiWriter(logext.NewWriter(), w)
|
||||
cmd.Stdout = io.MultiWriter(logext.NewWriter(), w)
|
||||
|
||||
log.WithFields(fields).Info("publishing")
|
||||
log := log.WithField("cmd", c.Args[0]).
|
||||
WithField("artifact", artifact.Name)
|
||||
|
||||
log.Info("publishing")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("publishing: %s failed: %w: %s", c.Args[0], err, b.String())
|
||||
}
|
||||
|
||||
log.WithFields(fields).Debugf("command %s finished successfully", c.Args[0])
|
||||
log.Debug("command finished successfully")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,7 @@ func CopyWithMode(src, dst string, mode os.FileMode) error {
|
||||
// - path = "a/b/c.txt"
|
||||
// So we join "a/b" with "c.txt" and use it as the destination.
|
||||
dst := filepath.ToSlash(filepath.Join(dst, strings.Replace(path, src, "", 1)))
|
||||
log.WithFields(log.Fields{
|
||||
"src": path,
|
||||
"dst": dst,
|
||||
}).Debug("copying file")
|
||||
log.WithField("src", path).WithField("dst", dst).Debug("copying file")
|
||||
if info.IsDir() {
|
||||
return os.MkdirAll(dst, info.Mode())
|
||||
}
|
||||
|
@ -177,12 +177,7 @@ func Upload(ctx *context.Context, uploads []config.Upload, kind string, check Re
|
||||
case ModeBinary:
|
||||
filters = append(filters, artifact.ByType(artifact.UploadableBinary))
|
||||
default:
|
||||
err := fmt.Errorf("%s: mode \"%s\" not supported", kind, v)
|
||||
log.WithFields(log.Fields{
|
||||
kind: upload.Name,
|
||||
"mode": v,
|
||||
}).Error(err.Error())
|
||||
return err
|
||||
return fmt.Errorf("%s: %s: mode \"%s\" not supported", upload.Name, kind, v)
|
||||
}
|
||||
|
||||
filter := artifact.Or(filters...)
|
||||
@ -223,9 +218,7 @@ func uploadAsset(ctx *context.Context, upload *config.Upload, artifact *artifact
|
||||
// Generate the target url
|
||||
targetURL, err := resolveTargetTemplate(ctx, upload, artifact)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("%s: error while building the target url", kind)
|
||||
log.WithField("instance", upload.Name).WithError(err).Error(msg)
|
||||
return fmt.Errorf("%s: %w", msg, err)
|
||||
return fmt.Errorf("%s: %s: error while building target URL: %w", upload.Name, kind, err)
|
||||
}
|
||||
|
||||
// Handle the artifact
|
||||
@ -250,13 +243,7 @@ func uploadAsset(ctx *context.Context, upload *config.Upload, artifact *artifact
|
||||
for name, value := range upload.CustomHeaders {
|
||||
resolvedValue, err := resolveHeaderTemplate(ctx, upload, artifact, value)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("%s: failed to resolve custom_headers template", kind)
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"instance": upload.Name,
|
||||
"header_name": name,
|
||||
"header_value": value,
|
||||
}).Error(msg)
|
||||
return fmt.Errorf("%s: %w", msg, err)
|
||||
return fmt.Errorf("%s: %s: failed to resolve custom_headers template: %w", upload.Name, kind, err)
|
||||
}
|
||||
headers[name] = resolvedValue
|
||||
}
|
||||
@ -271,20 +258,15 @@ func uploadAsset(ctx *context.Context, upload *config.Upload, artifact *artifact
|
||||
|
||||
res, err := uploadAssetToServer(ctx, upload, targetURL, username, secret, headers, asset, check)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("%s: upload failed", kind)
|
||||
log.WithError(err).WithFields(log.Fields{
|
||||
"instance": upload.Name,
|
||||
}).Error(msg)
|
||||
return fmt.Errorf("%s: %w", msg, err)
|
||||
return fmt.Errorf("%s: %s: upload failed: %w", upload.Name, kind, err)
|
||||
}
|
||||
if err := res.Body.Close(); err != nil {
|
||||
log.WithError(err).Warn("failed to close response body")
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"instance": upload.Name,
|
||||
"mode": upload.Mode,
|
||||
}).Info("uploaded successful")
|
||||
log.WithField("instance", upload.Name).
|
||||
WithField("mode", upload.Mode).
|
||||
Info("uploaded successful")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ func TestRunPipe_UnparsableErrorResponse(t *testing.T) {
|
||||
})
|
||||
|
||||
require.NoError(t, Pipe{}.Default(ctx))
|
||||
require.EqualError(t, Pipe{}.Publish(ctx), `artifactory: upload failed: unexpected error: invalid character '<' looking for beginning of value: <body><h1>error</h1></body>`)
|
||||
require.EqualError(t, Pipe{}.Publish(ctx), `production: artifactory: upload failed: unexpected error: invalid character '<' looking for beginning of value: <body><h1>error</h1></body>`)
|
||||
}
|
||||
|
||||
func TestRunPipe_FileNotFound(t *testing.T) {
|
||||
@ -531,7 +531,7 @@ func TestRunPipe_UnparsableTarget(t *testing.T) {
|
||||
})
|
||||
|
||||
require.NoError(t, Pipe{}.Default(ctx))
|
||||
require.EqualError(t, Pipe{}.Publish(ctx), `artifactory: upload failed: parse "://artifacts.company.com/example-repo-local/mybin/darwin/amd64/mybin": missing protocol scheme`)
|
||||
require.EqualError(t, Pipe{}.Publish(ctx), `production: artifactory: upload failed: parse "://artifacts.company.com/example-repo-local/mybin/darwin/amd64/mybin": missing protocol scheme`)
|
||||
}
|
||||
|
||||
func TestRunPipe_DirUpload(t *testing.T) {
|
||||
|
@ -42,11 +42,10 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
|
||||
var b bytes.Buffer
|
||||
w := gio.Safe(&b)
|
||||
fields := log.Fields{"hook": step}
|
||||
cmd.Stderr = io.MultiWriter(logext.NewWriter(), w)
|
||||
cmd.Stdout = io.MultiWriter(logext.NewWriter(), w)
|
||||
|
||||
log.WithFields(fields).Info("running")
|
||||
log.WithField("hook", step).Info("running")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("hook failed: %s: %w; output: %s", step, err, b.String())
|
||||
}
|
||||
|
@ -221,9 +221,7 @@ func (u *productionUploader) Close() error {
|
||||
}
|
||||
|
||||
func (u *productionUploader) Open(ctx *context.Context, bucket string) error {
|
||||
log.WithFields(log.Fields{
|
||||
"bucket": bucket,
|
||||
}).Debug("uploading")
|
||||
log.WithField("bucket", bucket).Debug("uploading")
|
||||
|
||||
conn, err := blob.OpenBucket(ctx, bucket)
|
||||
if err != nil {
|
||||
|
@ -45,11 +45,6 @@ type manifester interface {
|
||||
|
||||
// nolint: unparam
|
||||
func runCommand(ctx *context.Context, dir, binary string, args ...string) error {
|
||||
fields := log.Fields{
|
||||
"cmd": append([]string{binary}, args[0]),
|
||||
"cwd": dir,
|
||||
}
|
||||
|
||||
/* #nosec */
|
||||
cmd := exec.CommandContext(ctx, binary, args...)
|
||||
cmd.Dir = dir
|
||||
@ -60,7 +55,10 @@ func runCommand(ctx *context.Context, dir, binary string, args ...string) error
|
||||
cmd.Stderr = io.MultiWriter(logext.NewWriter(), w)
|
||||
cmd.Stdout = io.MultiWriter(logext.NewWriter(), w)
|
||||
|
||||
log.WithFields(fields).WithField("args", args[1:]).Debug("running")
|
||||
log.
|
||||
WithField("cmd", append([]string{binary}, args[0])).
|
||||
WithField("cwd", dir).
|
||||
WithField("args", args[1:]).Debug("running")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("%w: %s", err, b.String())
|
||||
}
|
||||
@ -68,11 +66,6 @@ func runCommand(ctx *context.Context, dir, binary string, args ...string) error
|
||||
}
|
||||
|
||||
func runCommandWithOutput(ctx *context.Context, dir, binary string, args ...string) ([]byte, error) {
|
||||
fields := log.Fields{
|
||||
"cmd": append([]string{binary}, args[0]),
|
||||
"cwd": dir,
|
||||
}
|
||||
|
||||
/* #nosec */
|
||||
cmd := exec.CommandContext(ctx, binary, args...)
|
||||
cmd.Dir = dir
|
||||
@ -82,7 +75,11 @@ func runCommandWithOutput(ctx *context.Context, dir, binary string, args ...stri
|
||||
w := gio.Safe(&b)
|
||||
cmd.Stderr = io.MultiWriter(logext.NewWriter(), w)
|
||||
|
||||
log.WithFields(fields).WithField("args", args[1:]).Debug("running")
|
||||
log.
|
||||
WithField("cmd", append([]string{binary}, args[0])).
|
||||
WithField("cwd", dir).
|
||||
WithField("args", args[1:]).
|
||||
Debug("running")
|
||||
out, err := cmd.Output()
|
||||
if out != nil {
|
||||
// regardless of command success, always print stdout for backward-compatibility with runCommand()
|
||||
|
@ -2,7 +2,6 @@ package reportsizes
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/caarlos0/log"
|
||||
"github.com/docker/go-units"
|
||||
@ -16,10 +15,6 @@ func (Pipe) Skip(ctx *context.Context) bool { return !ctx.Config.ReportSizes }
|
||||
func (Pipe) String() string { return "size reports" }
|
||||
|
||||
func (Pipe) Run(ctx *context.Context) error {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ctx.Artifacts.Filter(artifact.Or(
|
||||
artifact.ByType(artifact.Binary),
|
||||
artifact.ByType(artifact.UniversalBinary),
|
||||
@ -34,15 +29,9 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
relpath := a.Path
|
||||
if filepath.IsAbs(a.Path) {
|
||||
relpath, err = filepath.Rel(cwd, a.Path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
a.Extra[artifact.ExtraSize] = stat.Size()
|
||||
log.WithField("path", relpath).Info(units.BytesSize(float64(stat.Size())))
|
||||
log.WithField("path", a.Path).
|
||||
Info(units.BytesSize(float64(stat.Size())))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@ -181,8 +181,6 @@ func catalogArtifact(ctx *context.Context, cfg config.SBOM, a *artifact.Artifact
|
||||
names = append(names, filepath.Base(p))
|
||||
}
|
||||
|
||||
fields := log.Fields{"cmd": cfg.Cmd, "artifact": artifactDisplayName, "sboms": strings.Join(names, ", ")}
|
||||
|
||||
// The GoASTScanner flags this as a security risk.
|
||||
// However, this works as intended. The nosec annotation
|
||||
// tells the scanner to ignore this.
|
||||
@ -202,7 +200,10 @@ func catalogArtifact(ctx *context.Context, cfg config.SBOM, a *artifact.Artifact
|
||||
cmd.Stderr = io.MultiWriter(logext.NewWriter(), w)
|
||||
cmd.Stdout = io.MultiWriter(logext.NewWriter(), w)
|
||||
|
||||
log.WithFields(fields).Info("cataloging")
|
||||
log.WithField("cmd", cfg.Cmd).
|
||||
WithField("artifact", artifactDisplayName).
|
||||
WithField("sbom", names).
|
||||
Info("cataloging")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return nil, fmt.Errorf("cataloging artifacts: %s failed: %w: %s", cfg.Cmd, err, b.String())
|
||||
}
|
||||
|
@ -340,12 +340,12 @@ func dataFor(ctx *context.Context, scoop config.Scoop, cl client.ReleaserURLTemp
|
||||
return manifest, err
|
||||
}
|
||||
|
||||
log.WithFields(log.Fields{
|
||||
"artifactExtras": artifact.Extra,
|
||||
"fromURLTemplate": scoop.URLTemplate,
|
||||
"templatedBrewURL": url,
|
||||
"sum": sum,
|
||||
}).Debug("scoop url templating")
|
||||
log.
|
||||
WithField("artifactExtras", artifact.Extra).
|
||||
WithField("fromURLTemplate", scoop.URLTemplate).
|
||||
WithField("templatedBrewURL", url).
|
||||
WithField("sum", sum).
|
||||
Debug("scoop url templating")
|
||||
|
||||
binaries, err := binaries(*artifact)
|
||||
if err != nil {
|
||||
|
@ -225,12 +225,12 @@ func signone(ctx *context.Context, cfg config.Sign, art *artifact.Artifact) ([]*
|
||||
stdin = f
|
||||
}
|
||||
|
||||
fields := log.Fields{"cmd": cfg.Cmd, "artifact": art.Name}
|
||||
log := log.WithField("cmd", cfg.Cmd).WithField("artifact", art.Name)
|
||||
if name != "" {
|
||||
fields["signature"] = name
|
||||
log = log.WithField("signature", name)
|
||||
}
|
||||
if cert != "" {
|
||||
fields["certificate"] = cert
|
||||
log = log.WithField("certificate", cert)
|
||||
}
|
||||
|
||||
// The GoASTScanner flags this as a security risk.
|
||||
@ -246,7 +246,7 @@ func signone(ctx *context.Context, cfg config.Sign, art *artifact.Artifact) ([]*
|
||||
cmd.Stdin = stdin
|
||||
}
|
||||
cmd.Env = env.Strings()
|
||||
log.WithFields(fields).Info("signing")
|
||||
log.Info("signing")
|
||||
if err := cmd.Run(); err != nil {
|
||||
return nil, fmt.Errorf("sign: %s failed: %w: %s", cfg.Cmd, err, b.String())
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ func TestRunPipe_UnparsableTarget(t *testing.T) {
|
||||
Type: artifact.UploadableBinary,
|
||||
})
|
||||
|
||||
require.EqualError(t, Pipe{}.Publish(ctx), `upload: upload failed: parse "://artifacts.company.com/example-repo-local/mybin/darwin/amd64/mybin": missing protocol scheme`)
|
||||
require.EqualError(t, Pipe{}.Publish(ctx), `production: upload: upload failed: parse "://artifacts.company.com/example-repo-local/mybin/darwin/amd64/mybin": missing protocol scheme`)
|
||||
}
|
||||
|
||||
func TestRunPipe_DirUpload(t *testing.T) {
|
||||
|
@ -15,10 +15,9 @@ import (
|
||||
|
||||
// Run a shell command with given arguments and envs
|
||||
func Run(ctx *context.Context, dir string, command, env []string, output bool) error {
|
||||
fields := log.Fields{
|
||||
"cmd": command,
|
||||
"env": env,
|
||||
}
|
||||
log := log.
|
||||
WithField("cmd", command).
|
||||
WithField("env", env)
|
||||
|
||||
/* #nosec */
|
||||
cmd := exec.CommandContext(ctx, command[0], command[1:]...)
|
||||
@ -34,9 +33,9 @@ func Run(ctx *context.Context, dir string, command, env []string, output bool) e
|
||||
cmd.Dir = dir
|
||||
}
|
||||
|
||||
log.WithFields(fields).Debug("running")
|
||||
log.Debug("running")
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.WithFields(fields).WithError(err).Debug("failed")
|
||||
log.WithError(err).Debug("failed")
|
||||
return fmt.Errorf("failed to run '%s': %w", strings.Join(command, " "), err)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user