Skip to content

Commit

Permalink
fix logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Cole Kennedy authored and Cole Kennedy committed Jun 20, 2023
1 parent 883dc71 commit 7ea8984
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
Binary file added cmd/entrypoint/entrypoint
Binary file not shown.
4 changes: 4 additions & 0 deletions cmd/entrypoint/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (

"github.com/tektoncd/pipeline/pkg/entrypoint"
"github.com/tektoncd/pipeline/pkg/pod"
"github.com/testifysec/go-witness/log"
)

const ENABLE_WITNESS = true
Expand Down Expand Up @@ -85,10 +86,13 @@ func (rr *realRunner) Run(ctx context.Context, args ...string) error {
defer signal.Reset()

if ENABLE_WITNESS {
log.SetLogger(StdoutStderrLogger{})

err := withWitness(ctx, append([]string{name}, args...))
if err != nil {
return err
}

} else {
cmd := exec.CommandContext(ctx, name, args...)

Expand Down
1 change: 0 additions & 1 deletion cmd/entrypoint/term

This file was deleted.

3 changes: 3 additions & 0 deletions cmd/entrypoint/test.sh
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#!/bin/bash

export TEKTON_RESOURCE_NAME=test
./entrypoint -post_file .out -termination_path ./term -entrypoint echo hello
36 changes: 36 additions & 0 deletions cmd/entrypoint/witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,39 @@ func withWitness(ctx context.Context, args []string) error {

return nil
}

//Witness Logger

type StdoutStderrLogger struct{}

func (l StdoutStderrLogger) Errorf(format string, args ...interface{}) {
fmt.Fprintf(os.Stderr, format+"\n", args...)
}

func (l StdoutStderrLogger) Error(args ...interface{}) {
fmt.Fprintln(os.Stderr, args...)
}

func (l StdoutStderrLogger) Warnf(format string, args ...interface{}) {
fmt.Fprintf(os.Stdout, format+"\n", args...)
}

func (l StdoutStderrLogger) Warn(args ...interface{}) {
fmt.Fprintln(os.Stdout, args...)
}

func (l StdoutStderrLogger) Debugf(format string, args ...interface{}) {
fmt.Fprintf(os.Stdout, format+"\n", args...)
}

func (l StdoutStderrLogger) Debug(args ...interface{}) {
fmt.Fprintln(os.Stdout, args...)
}

func (l StdoutStderrLogger) Infof(format string, args ...interface{}) {
fmt.Fprintf(os.Stdout, format+"\n", args...)
}

func (l StdoutStderrLogger) Info(args ...interface{}) {
fmt.Fprintln(os.Stdout, args...)
}

0 comments on commit 7ea8984

Please sign in to comment.