bouncer/internal/setup/default_registry.go
William Petit 8d91f646c2
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
feat: refactor layers registration
2023-06-23 17:54:34 -06:00

44 lines
1.1 KiB
Go

package setup
import (
"context"
"forge.cadoles.com/cadoles/bouncer/internal/config"
"forge.cadoles.com/cadoles/bouncer/internal/proxy/director"
"forge.cadoles.com/cadoles/bouncer/internal/store"
"github.com/pkg/errors"
"github.com/qri-io/jsonschema"
)
var defaultRegistry = NewRegistry()
func RegisterLayer(layerType store.LayerType, setupFunc LayerSetupFunc, rawOptionsSchema []byte) {
defaultRegistry.RegisterLayer(layerType, setupFunc, rawOptionsSchema)
}
func GetLayerOptionsSchema(layerType store.LayerType) (*jsonschema.Schema, error) {
schema, err := defaultRegistry.GetLayerOptionsSchema(layerType)
if err != nil {
return nil, errors.WithStack(err)
}
return schema, nil
}
func GetLayers(ctx context.Context, conf *config.Config) ([]director.Layer, error) {
layers, err := defaultRegistry.GetLayers(ctx, conf)
if err != nil {
return nil, errors.WithStack(err)
}
return layers, nil
}
func GetLayerTypes() []store.LayerType {
return defaultRegistry.GetLayerTypes()
}
func LayerTypeExists(layerType store.LayerType) bool {
return defaultRegistry.LayerTypeExists(layerType)
}