Skip to content

Commit ceccbca

Browse files
Cole KennedyCole Kennedy
Cole Kennedy
authored and
Cole Kennedy
committed
fix logging
fix logging
1 parent 883dc71 commit ceccbca

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

cmd/entrypoint/runner.go

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
"github.com/tektoncd/pipeline/pkg/entrypoint"
3434
"github.com/tektoncd/pipeline/pkg/pod"
35+
"github.com/testifysec/go-witness/log"
3536
)
3637

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

8788
if ENABLE_WITNESS {
89+
log.SetLogger(StdoutStderrLogger{})
90+
8891
err := withWitness(ctx, append([]string{name}, args...))
8992
if err != nil {
9093
return err
9194
}
95+
9296
} else {
9397
cmd := exec.CommandContext(ctx, name, args...)
9498

cmd/entrypoint/term

-1
This file was deleted.

cmd/entrypoint/test.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
#!/bin/bash
2+
3+
export TEKTON_RESOURCE_NAME=test
14
./entrypoint -post_file .out -termination_path ./term -entrypoint echo hello

cmd/entrypoint/witness.go

+36
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,39 @@ func withWitness(ctx context.Context, args []string) error {
8383

8484
return nil
8585
}
86+
87+
//Witness Logger
88+
89+
type StdoutStderrLogger struct{}
90+
91+
func (l StdoutStderrLogger) Errorf(format string, args ...interface{}) {
92+
fmt.Fprintf(os.Stderr, format+"\n", args...)
93+
}
94+
95+
func (l StdoutStderrLogger) Error(args ...interface{}) {
96+
fmt.Fprintln(os.Stderr, args...)
97+
}
98+
99+
func (l StdoutStderrLogger) Warnf(format string, args ...interface{}) {
100+
fmt.Fprintf(os.Stdout, format+"\n", args...)
101+
}
102+
103+
func (l StdoutStderrLogger) Warn(args ...interface{}) {
104+
fmt.Fprintln(os.Stdout, args...)
105+
}
106+
107+
func (l StdoutStderrLogger) Debugf(format string, args ...interface{}) {
108+
fmt.Fprintf(os.Stdout, format+"\n", args...)
109+
}
110+
111+
func (l StdoutStderrLogger) Debug(args ...interface{}) {
112+
fmt.Fprintln(os.Stdout, args...)
113+
}
114+
115+
func (l StdoutStderrLogger) Infof(format string, args ...interface{}) {
116+
fmt.Fprintf(os.Stdout, format+"\n", args...)
117+
}
118+
119+
func (l StdoutStderrLogger) Info(args ...interface{}) {
120+
fmt.Fprintln(os.Stdout, args...)
121+
}

0 commit comments

Comments
 (0)