Skip to content

Commit

Permalink
sops/keyservice: handle nil key requests
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <hello@hidde.co>
  • Loading branch information
hiddeco committed Mar 31, 2022
1 parent 3500a99 commit 95a1829
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/sops/keyservice/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

"go.mozilla.org/sops/v3/keyservice"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/fluxcd/kustomize-controller/internal/sops/age"
"github.com/fluxcd/kustomize-controller/internal/sops/azkv"
Expand Down Expand Up @@ -94,6 +96,8 @@ func (ks Server) Encrypt(ctx context.Context, req *keyservice.EncryptRequest) (*
Ciphertext: ciphertext,
}, nil
}
case nil:
return nil, status.Errorf(codes.NotFound, "must provide a key")
}
// Fallback to default server for any other request.
return ks.defaultServer.Encrypt(ctx, req)
Expand Down Expand Up @@ -140,6 +144,8 @@ func (ks Server) Decrypt(ctx context.Context, req *keyservice.DecryptRequest) (*
Plaintext: plaintext,
}, nil
}
case nil:
return nil, status.Errorf(codes.NotFound, "must provide a key")
}
// Fallback to default server for any other request.
return ks.defaultServer.Decrypt(ctx, req)
Expand Down

0 comments on commit 95a1829

Please sign in to comment.