bouncer/internal/setup/default_registry.go

53 lines
1.3 KiB
Go
Raw Permalink Normal View History

2023-06-23 19:08:35 +02:00
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"
2023-06-24 01:53:56 +02:00
"github.com/qri-io/jsonschema"
2023-06-23 19:08:35 +02:00
)
var defaultRegistry = NewRegistry()
2023-06-24 01:53:56 +02:00
func RegisterLayer(layerType store.LayerType, setupFunc LayerSetupFunc, rawOptionsSchema []byte) {
defaultRegistry.RegisterLayer(layerType, setupFunc, rawOptionsSchema)
2023-06-23 19:08:35 +02:00
}
2023-06-24 01:53:56 +02:00
func GetLayerOptionsSchema(layerType store.LayerType) (*jsonschema.Schema, error) {
schema, err := defaultRegistry.GetLayerOptionsSchema(layerType)
if err != nil {
return nil, errors.WithStack(err)
}
return schema, nil
}
2024-05-17 15:44:28 +02:00
func GetLayerOptionsRawSchema(layerType store.LayerType) ([]byte, error) {
schema, err := defaultRegistry.GetLayerOptionsRawSchema(layerType)
if err != nil {
return nil, errors.WithStack(err)
}
return schema, nil
}
2023-06-24 01:53:56 +02:00
func GetLayers(ctx context.Context, conf *config.Config) ([]director.Layer, error) {
layers, err := defaultRegistry.GetLayers(ctx, conf)
2023-06-23 19:08:35 +02:00
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)
}