Skip to content

Commit

Permalink
updated module_changeset.go
Browse files Browse the repository at this point in the history
  • Loading branch information
oakrizan committed Jul 25, 2024
1 parent 8820ab4 commit 721b9d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
44 changes: 22 additions & 22 deletions dev-tools/mage/module_changeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ package mage

import (
"fmt"
"github.com/magefile/mage/sh"
"log"
"os"
"os/exec"
"regexp"
"strings"
)

func DefineModules() {
beatPath := os.Getenv("BEAT_PATH")
if beatPath == "" {
panic(fmt.Errorf("argument required: beatPath"))
}
beatPath, err := os.Getwd()

Check failure on line 30 in dev-tools/mage/module_changeset.go

View workflow job for this annotation

GitHub Actions / lint (linux)

ineffectual assignment to err (ineffassign)
//beatPath := os.Getenv("BEAT_PATH")

var modulePattern string

Check failure on line 33 in dev-tools/mage/module_changeset.go

View workflow job for this annotation

GitHub Actions / lint (linux)

S1021: should merge variable declaration with assignment on next line (gosimple)
modulePattern = fmt.Sprintf("^%s\\/module\\/([^\\/]+)\\/.*", beatPath)
Expand All @@ -57,7 +55,14 @@ func DefineModules() {
i++
}

err = os.Setenv("MODULE", strings.Join(keys, ","))
moduleVar := strings.Join(keys, ",")

err = os.Setenv("MODULE", moduleVar)
if err != nil {
return
}

fmt.Fprintf(os.Stderr, "Detected changes on module(s) %s", moduleVar)
}

func isAsciiOrPng(file string) bool {
Expand All @@ -66,14 +71,8 @@ func isAsciiOrPng(file string) bool {

func getDiff() []string {
commitRange := getCommitRange()
cmd := exec.Command("git", "diff", "--name-only", commitRange)
output, err := cmd.Output()
if err != nil {
fmt.Printf("Failed to execute 'git diff --name-only %s': %s", commitRange, err)
os.Exit(1)
}

return strings.Split(string(output), "\n")
var output, _ = sh.Output("git", "diff", "--name-only", commitRange)
return strings.Split(output, "\n")
}

func getFromCommit() string {
Expand All @@ -98,14 +97,15 @@ func getFromCommit() string {
}

func getPreviousCommit() string {
cmd := exec.Command("git", "rev-parse", "HEAD^")
output, err := cmd.Output()
if err != nil {
fmt.Println("Failed to execute 'git rev-parse HEAD^': ", err)
os.Exit(1)
}

return strings.TrimSpace(string(output))
var output, _ = sh.Output("git", "rev-parse", "HEAD^")
//cmd := exec.Command("git", "rev-parse", "HEAD^")
//output, err := cmd.Output()
//if err != nil {
// fmt.Println("Failed to execute 'git rev-parse HEAD^': ", err)
// os.Exit(1)
//}

return strings.TrimSpace(output)
}

func getCommitRange() string {
Expand Down
1 change: 1 addition & 0 deletions x-pack/metricbeat/module/cloudfoundry/cloudfoundry.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
const ModuleName = "cloudfoundry"

func init() {
fmt.Println("DELETEME")

Check failure on line 21 in x-pack/metricbeat/module/cloudfoundry/cloudfoundry.go

View workflow job for this annotation

GitHub Actions / lint (linux)

use of `fmt.Println` forbidden by pattern `fmt.Print.*` (forbidigo)
if err := mb.Registry.AddModule(ModuleName, newModule); err != nil {
panic(err)
}
Expand Down

0 comments on commit 721b9d0

Please sign in to comment.