Skip to content

Commit

Permalink
fix: remove redundant error check
Browse files Browse the repository at this point in the history
  • Loading branch information
aarmam committed Dec 8, 2021
1 parent 8b9a9d5 commit 5a6d5d3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 1 addition & 4 deletions driver/registry_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ func (m *RegistrySQL) Init(ctx context.Context) error {
}

if m.C.HsmEnabled() {
m.defaultKeyManager, err = hsm.NewKeyManager(m.HsmContext())
if err != nil {
return err
}
m.defaultKeyManager = hsm.NewKeyManager(m.HsmContext())
} else {
m.defaultKeyManager = m.persister
}
Expand Down
4 changes: 2 additions & 2 deletions hsm/manager_hsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ var ErrPreGeneratedKeys = &fosite.RFC6749Error{
DescriptionField: "Cannot add/update pre generated keys on Hardware Security Module",
}

func NewKeyManager(hsm Context) (*KeyManager, error) {
func NewKeyManager(hsm Context) *KeyManager {
return &KeyManager{
Context: hsm,
}, nil
}
}

func (m *KeyManager) GenerateKeySet(_ context.Context, set, kid, alg, use string) (*jose.JSONWebKeySet, error) {
Expand Down
7 changes: 4 additions & 3 deletions hsm/manager_nohsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ type KeyManager struct {

var _ jwk.Manager = &KeyManager{}

var ErrOpSysNotSupported = errors.New("Hardware Security Module is not supported on this platform (build tag 'hsm').")
var ErrOpSysNotSupported = errors.New("Hardware Security Module is not supported on this platform (build tag 'hsm')")

func NewContext(c *config.Provider, l *logrusx.Logger) Context {
l.Fatalf("Hardware Security Module is not supported on this platform (build tag 'hsm')")
return nil
}

func NewKeyManager(hsm Context) (*KeyManager, error) {
return nil, errors.WithStack(ErrOpSysNotSupported)
func NewKeyManager(hsm Context) *KeyManager {
return nil
}

func (m *KeyManager) GenerateKeySet(_ context.Context, set, kid, alg, use string) (*jose.JSONWebKeySet, error) {
Expand Down

0 comments on commit 5a6d5d3

Please sign in to comment.