From ddd49d0e0b1f89e2fb16182b8e657c4afd6b2e60 Mon Sep 17 00:00:00 2001 From: Kim Christensen Date: Wed, 1 May 2024 00:13:42 +0200 Subject: [PATCH] Close plugin connection Signed-off-by: Kim Christensen --- pkg/porter/porter.go | 5 +++++ pkg/signing/pluginstore/signer.go | 8 ++++++++ pkg/signing/signer.go | 2 ++ 3 files changed, 15 insertions(+) diff --git a/pkg/porter/porter.go b/pkg/porter/porter.go index 0da41f0d6..7d1ff9876 100644 --- a/pkg/porter/porter.go +++ b/pkg/porter/porter.go @@ -139,6 +139,11 @@ func (p *Porter) Close() error { bigErr = multierror.Append(bigErr, err) } + err = p.Signer.Close() + if err != nil { + bigErr = multierror.Append(bigErr, err) + } + return bigErr.ErrorOrNil() } diff --git a/pkg/signing/pluginstore/signer.go b/pkg/signing/pluginstore/signer.go index d2ed83482..390370c59 100644 --- a/pkg/signing/pluginstore/signer.go +++ b/pkg/signing/pluginstore/signer.go @@ -111,3 +111,11 @@ func (s *Signer) Connect(ctx context.Context) error { return nil } + +func (s *Signer) Close() error { + if s.conn != nil { + s.conn.Close(context.Background()) + s.conn = nil + } + return nil +} diff --git a/pkg/signing/signer.go b/pkg/signing/signer.go index 599135d26..a4b50e6bf 100644 --- a/pkg/signing/signer.go +++ b/pkg/signing/signer.go @@ -5,6 +5,8 @@ import "context" // Signer is an interface for signing and verifying Porter // bundles and invocation images. type Signer interface { + Close() error + // Sign generates a signature for the specified reference, which // can be a Porter bundle or an invocation image. Sign(ctx context.Context, ref string) error