feat(k8s): use secret as shared source for admin private key
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
This commit is contained in:
@ -3,6 +3,7 @@ package integration
|
||||
import (
|
||||
"context"
|
||||
|
||||
"forge.cadoles.com/cadoles/bouncer/internal/jwk"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@ -15,6 +16,11 @@ type OnStartup interface {
|
||||
OnStartup(ctx context.Context) error
|
||||
}
|
||||
|
||||
type OnKeyLoad interface {
|
||||
Integration
|
||||
OnKeyLoad(ctx context.Context) (jwk.Key, error)
|
||||
}
|
||||
|
||||
func RunOnStartup(ctx context.Context, integrations []Integration) error {
|
||||
for _, it := range integrations {
|
||||
onStartup, ok := it.(OnStartup)
|
||||
@ -29,3 +35,23 @@ func RunOnStartup(ctx context.Context, integrations []Integration) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func RunOnKeyLoad(ctx context.Context, integrations []Integration) (jwk.Key, error) {
|
||||
for _, it := range integrations {
|
||||
onKeyLoad, ok := it.(OnKeyLoad)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
key, err := onKeyLoad.OnKeyLoad(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
if key != nil {
|
||||
return key, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user