From 95d29b29c448c536ae77895298f4d44887a83b06 Mon Sep 17 00:00:00 2001 From: aliculPix4D Date: Wed, 25 Oct 2023 11:29:57 +0200 Subject: [PATCH] cogito: address review comments - revert logger changes --- cmd/cogito/main.go | 2 +- cogito/put.go | 7 ++++++- cogito/put_test.go | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/cogito/main.go b/cmd/cogito/main.go index 362205e1..c8403786 100644 --- a/cmd/cogito/main.go +++ b/cmd/cogito/main.go @@ -56,7 +56,7 @@ func mainErr(in io.Reader, out io.Writer, logOut io.Writer, args []string) error return cogito.Get(log, input, out, args[1:]) case "out": putter := cogito.NewPutter(log) - return cogito.Put(input, out, args[1:], putter) + return cogito.Put(log, input, out, args[1:], putter) default: return fmt.Errorf("cli wiring error; please report") } diff --git a/cogito/put.go b/cogito/put.go index 5060ca72..2bb750a7 100644 --- a/cogito/put.go +++ b/cogito/put.go @@ -4,6 +4,8 @@ import ( "fmt" "io" "strings" + + "github.com/hashicorp/go-hclog" ) // Putter represents the put step of a Concourse resource. @@ -38,7 +40,10 @@ type Sinker interface { // Additionally, the script may emit metadata as a list of key-value pairs. This data is // intended for public consumption and will make it upstream, intended to be shown on the // build's page. -func Put(input []byte, out io.Writer, args []string, putter Putter) error { +func Put(log hclog.Logger, input []byte, out io.Writer, args []string, putter Putter) error { + // log hclog.Logger variable is currently unused. + // We keep it to satisfy the Concourse resource interface functions signature. + if err := putter.LoadConfiguration(input, args); err != nil { return fmt.Errorf("put: %s", err) } diff --git a/cogito/put_test.go b/cogito/put_test.go index 811742ee..f54488e5 100644 --- a/cogito/put_test.go +++ b/cogito/put_test.go @@ -64,7 +64,7 @@ func (ms MockSinker) Send() error { func TestPutSuccess(t *testing.T) { putter := MockPutter{sinkers: []cogito.Sinker{MockSinker{}}} - err := cogito.Put(nil, nil, nil, putter) + err := cogito.Put(hclog.NewNullLogger(), nil, nil, nil, putter) assert.NilError(t, err) } @@ -77,7 +77,7 @@ func TestPutFailure(t *testing.T) { } test := func(t *testing.T, tc testCase) { - err := cogito.Put(nil, nil, nil, tc.putter) + err := cogito.Put(hclog.NewNullLogger(), nil, nil, nil, tc.putter) assert.ErrorContains(t, err, tc.wantErr) }