Skip to content

Commit

Permalink
cogito: address review comments
Browse files Browse the repository at this point in the history
- revert logger changes
  • Loading branch information
aliculPix4D committed Oct 25, 2023
1 parent 0e45ad9 commit 95d29b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/cogito/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
7 changes: 6 additions & 1 deletion cogito/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"io"
"strings"

"github.com/hashicorp/go-hclog"
)

// Putter represents the put step of a Concourse resource.
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions cogito/put_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down

0 comments on commit 95d29b2

Please sign in to comment.