Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type MetaSchema
- type Repository
- type Service
- func (s *Service) Close() error
- func (s *Service) Create(ctx context.Context, toCreate MetaSchema) (MetaSchema, error)
- func (s *Service) Delete(ctx context.Context, id string) error
- func (s *Service) Get(ctx context.Context, idOrName string) (MetaSchema, error)
- func (s *Service) Init(ctx context.Context) error
- func (s *Service) List(ctx context.Context) ([]MetaSchema, error)
- func (s *Service) MigrateDefault(ctx context.Context) error
- func (s *Service) Update(ctx context.Context, id string, toUpdate MetaSchema) (MetaSchema, error)
- func (s *Service) Validate(mdata metadata.Metadata, name string) error
Constants ¶
const ( NameUser = "user" NameGroup = "group" NameOrg = "organization" NameRole = "role" NameProspect = "prospect" )
Built-in metaschema names. These are the schemas the server validates entity metadata against, and the set the MetaSchema reconcile kind manages.
Variables ¶
var ( ErrInvalidID = errors.New("metaschema id is invalid") ErrNotExist = errors.New("metaschema doesn't exist") ErrConflict = errors.New("metaschema already exist") ErrInvalidDetail = errors.New("invalid metadata detail") ErrInvalidMetaSchema = errors.New("metadata schema validation failed") ErrInvalidSchema = errors.New("metaschema schema must be a JSON object") )
var Defaults = map[string]string{ NameUser: string(defaultUser), NameGroup: string(defaultGroup), NameOrg: string(defaultOrg), NameRole: string(defaultRole), NameProspect: string(defaultProspect), }
Defaults maps each built-in metaschema name to its shipped JSON schema. It is the one source for both the server seeding (MigrateDefaults) and the MetaSchema reconcile kind, so adding a metaschema for a new resource is a single edit here.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.115.0
type Config struct {
// RefreshInterval is how often each server reloads the metaschema cache from
// the database, so a change made on one pod reaches the others. A value of 0
// disables the background refresh; the cache is still primed once at startup.
RefreshInterval time.Duration `yaml:"refresh_interval" mapstructure:"refresh_interval" default:"1m"`
}
Config holds runtime configuration for the metaschema service.
type MetaSchema ¶
type MetaSchema struct {
ID string
Name string
Schema string
CreatedAt time.Time
UpdatedAt time.Time
}
MetaSchema represents metadata schema to be validated for users/ groups/ organisations / roles
type Repository ¶
type Repository interface {
Create(ctx context.Context, metaschema MetaSchema) (MetaSchema, error)
Get(ctx context.Context, id string) (MetaSchema, error)
Update(ctx context.Context, id string, metaschema MetaSchema) (MetaSchema, error)
List(ctx context.Context) ([]MetaSchema, error)
Delete(ctx context.Context, id string) (string, error)
MigrateDefaults(ctx context.Context) error
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) Close ¶ added in v0.115.0
Close stops the background refresh job. It is safe to call when none started.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, toCreate MetaSchema) (MetaSchema, error)
func (*Service) Init ¶ added in v0.115.0
Init primes the cache from the database and, when refreshInterval is greater than zero, starts a background job that reloads it on that interval so a change made on one pod reaches the others.
func (*Service) Update ¶
func (s *Service) Update(ctx context.Context, id string, toUpdate MetaSchema) (MetaSchema, error)