Skip to content

Commit

Permalink
fix(cmd/tracerunner): change program path before than writing
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Fontana <lo@linux.com>
  • Loading branch information
fntlnz committed Dec 24, 2018
1 parent 38922d3 commit 4108ab0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GO ?= go
DOCKER ?= docker

COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),"${COMMIT_NO}-dirty","${COMMIT_NO}")
GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")

Expand Down
5 changes: 4 additions & 1 deletion pkg/cmd/tracerunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ func (o *TraceRunnerOptions) Run() error {
return fmt.Errorf("invalid pid found")
}
f, err := ioutil.ReadFile(programPath)
if err != nil {
return err
}
programPath = path.Join(os.TempDir(), "program-container.bt")
r := strings.Replace(string(f), "$container_pid", *pid, -1)
if err := ioutil.WriteFile(programPath, []byte(r), 0755); err != nil {
return err
}
programPath = path.Join(os.TempDir(), "program-container.bt")
}

c := exec.Command(o.bpftraceBinaryPath, o.programPath)
Expand Down
4 changes: 4 additions & 0 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ func GitCommit() string {
}

func ImageNameTag() string {
commit := GitCommit()
if len(commit) == 0 {
return fmt.Sprintf(imageNameTagFormat, "latest")
}
return fmt.Sprintf(imageNameTagFormat, GitCommit())
}

Expand Down

0 comments on commit 4108ab0

Please sign in to comment.