Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- Remove username/password for fleet-server authentication. {pull-beats}[29458]

==== Bugfixes
- Fix race condition on `mage notice` {pull}[1108]
- Fix rename *ConfigChange to *PolicyChange to align on changes in the UI. {pull-beats}[20779]
- Thread safe sorted set {pull-beats}[21290]
- Copy Action store on upgrade {pull-beats}[21298]
Expand Down
41 changes: 37 additions & 4 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package main

import (
"bytes"
"context"
"fmt"
"io"
Expand Down Expand Up @@ -111,8 +112,22 @@ func Notice() error {
return errors.Wrap(err, "failed running go list, please fix the issues reported")
}
fmt.Println(">> fmt - go run")
cmd := exec.Command("go", "run", "go.elastic.co/go-licence-detector", "-includeIndirect", "-rules", "dev-tools/notice/rules.json", "-overrides", "dev-tools/notice/overrides.json", "-noticeTemplate", "dev-tools/notice/NOTICE.txt.tmpl",
"-noticeOut", "NOTICE.txt", "-depsOut", "\"\"")
goLicenceDetectorCMD := []string{"go",
"run",
"go.elastic.co/go-licence-detector",
"-includeIndirect",
"-rules",
"dev-tools/notice/rules.json",
"-overrides",
"dev-tools/notice/overrides.json",
"-noticeTemplate",
"dev-tools/notice/NOTICE.txt.tmpl",
"-noticeOut",
"NOTICE.txt",
"-depsOut",
"\"\""}
printCMD(goLicenceDetectorCMD)
cmd := exec.Command(goLicenceDetectorCMD[0], goLicenceDetectorCMD[1:]...)
stdin, err := cmd.StdinPipe()
if err != nil {
return errors.Wrap(err, "failed running go run, please fix the issues reported")
Expand All @@ -126,10 +141,10 @@ func Notice() error {
fmt.Println(err)
}
}()
out, err := cmd.CombinedOutput()
wg.Wait()
_, err = cmd.CombinedOutput()
if err != nil {
return errors.Wrap(err, "failed combined output, please fix the issues reported")
return fmt.Errorf("calling go-licence-detector returned an error: '%w'. Its output is: '%s'", err, string(out))
}
return nil
}
Expand Down Expand Up @@ -925,3 +940,21 @@ func majorMinor() string {
}
return ""
}

// printCMD prints the command in the same format than when
// using the functions from the `sh` package. It also respects
// the mage verbose flag
func printCMD(cmd []string) {
if !mg.Verbose() {
return
}

buff := &bytes.Buffer{}

fmt.Fprintf(buff, "exec: %s", cmd[0])
for _, arg := range cmd[1:] {
fmt.Fprintf(buff, " %q", arg)
}

fmt.Println(buff.String())
}