github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/integration/testutil/signer.go (about) 1 // Copyright (c) 2023, R.I. Pienaar and the Choria Project contributors 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package testutil 6 7 import ( 8 "context" 9 10 "github.com/choria-io/go-choria/inter" 11 ) 12 13 type funcSigner struct { 14 fn func(context.Context, []byte, inter.RequestSignerConfig) ([]byte, error) 15 } 16 17 func NewFuncSigner(fn func(context.Context, []byte, inter.RequestSignerConfig) ([]byte, error)) *funcSigner { 18 return &funcSigner{fn: fn} 19 } 20 21 func (s *funcSigner) Kind() string { return "Integration Signer" } 22 func (s *funcSigner) Sign(ctx context.Context, request []byte, cfg inter.RequestSignerConfig) ([]byte, error) { 23 return s.fn(ctx, request, cfg) 24 }