Skip to content

Commit

Permalink
Make Connect function check if signing tools are available
Browse files Browse the repository at this point in the history
Signed-off-by: Kim Christensen <kimworking@gmail.com>
  • Loading branch information
kichristensen committed Apr 30, 2024
1 parent 203f916 commit fb6eaa0
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 35 deletions.
4 changes: 4 additions & 0 deletions pkg/signing/plugin_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ func (a PluginAdapter) Sign(ctx context.Context, ref string) error {
func (a PluginAdapter) Verify(ctx context.Context, ref string) error {
return a.plugin.Verify(ctx, ref)
}

func (a PluginAdapter) Connect(ctx context.Context) error {
return a.plugin.Connect(ctx)
}
6 changes: 4 additions & 2 deletions pkg/signing/plugins/cosign/cosign.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cosign

import (
"context"
"errors"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -35,13 +36,14 @@ func NewSigner(c *portercontext.Context, cfg PluginConfig) *Cosign {
return s
}

// TODO: we should get the certificate... here?
func (s *Cosign) Connect(ctx context.Context) error {
//lint:ignore SA4006 ignore unused ctx for now
ctx, log := tracing.StartSpan(ctx)
defer log.EndSpan()

log.Debug("Running cosign signer")
if err := exec.Command("cosign", "version").Run(); err != nil {
return errors.New("cosign was not found")
}

return nil
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/signing/plugins/notation/notation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package notation

import (
"context"
"errors"
"fmt"
"os/exec"

Expand Down Expand Up @@ -33,7 +34,9 @@ func (s *Signer) Connect(ctx context.Context) error {
ctx, log := tracing.StartSpan(ctx)
defer log.EndSpan()

log.Debug("Running notation signer")
if err := exec.Command("notation", "version").Run(); err != nil {
return errors.New("notation was not found")
}

return nil
}
Expand Down
174 changes: 142 additions & 32 deletions pkg/signing/plugins/proto/signing_protocol.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/signing/plugins/proto/signing_protocol.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ message VerifyRequest {
string Ref = 1;
}

message ConnectRequest {}

message SignResponse {}

message VerifyResponse {}

message ConnectResponse {}

service SigningProtocol {
rpc Sign(SignRequest) returns (SignResponse);
rpc Verify(VerifyRequest) returns (VerifyResponse);
rpc Connect(ConnectRequest) returns (ConnectResponse);
}
Loading

0 comments on commit fb6eaa0

Please sign in to comment.