service

package
v0.1.0-alpha.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEntityNotFound      = errors.New("entity not found")
	ErrPolicyNotFound      = errors.New("policy not found")
	ErrPolicyAlreadyExists = errors.New("policy already exists")
)
View Source
var (
	ErrEntityAlreadyExists = errors.New("entity already exists")
)

Functions

func NewBaderStore

func NewBaderStore(db *badger.DB) *badgerDataStore

func NewSqlDatastore

func NewSqlDatastore(db *bun.DB) *sqlDataStore

func Validate

func Validate()

Types

type Base

type Base struct {
	CreatedAt time.Time `bun:"created_at,nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:"updated_at,nullzero,notnull,default:current_timestamp"`
}

type DataStore

type DataStore interface {
	// contains filtered or unexported methods
}

type Entity

type Entity struct {
	bun.BaseModel `bun:"table:entities,alias:e"`
	ID            string       `bun:",pk"`
	Type          string       `bun:"type,pk"`
	Parents       []UID        `bun:"parents,type:json"`
	Attributes    cedar.Record `bun:"attributes,type:json"`
	Tags          cedar.Record `bun:"tags,type:json"`
	Base
}

func (*Entity) ToProto

func (e *Entity) ToProto() *fencev1.Entity

type MockDataStore

type MockDataStore struct {
	mock.Mock
}

MockDataStore is an autogenerated mock type for the DataStore type

func NewMockDataStore

func NewMockDataStore(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockDataStore

NewMockDataStore creates a new instance of MockDataStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockDataStore) EXPECT

func (_m *MockDataStore) EXPECT() *MockDataStore_Expecter

type MockDataStore_Expecter

type MockDataStore_Expecter struct {
	// contains filtered or unexported fields
}

type MockDataStore_addEntity_Call

type MockDataStore_addEntity_Call struct {
	*mock.Call
}

MockDataStore_addEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'addEntity'

func (*MockDataStore_addEntity_Call) Return

func (*MockDataStore_addEntity_Call) Run

func (_c *MockDataStore_addEntity_Call) Run(run func(ctx context.Context, entity *fencev1.Entity)) *MockDataStore_addEntity_Call

func (*MockDataStore_addEntity_Call) RunAndReturn

func (_c *MockDataStore_addEntity_Call) RunAndReturn(run func(ctx context.Context, entity *fencev1.Entity) error) *MockDataStore_addEntity_Call

type MockDataStore_addPolicy_Call

type MockDataStore_addPolicy_Call struct {
	*mock.Call
}

MockDataStore_addPolicy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'addPolicy'

func (*MockDataStore_addPolicy_Call) Return

func (*MockDataStore_addPolicy_Call) Run

func (*MockDataStore_addPolicy_Call) RunAndReturn

func (_c *MockDataStore_addPolicy_Call) RunAndReturn(run func(ctx context.Context, id string, content string) error) *MockDataStore_addPolicy_Call

type MockDataStore_deleteEntity_Call

type MockDataStore_deleteEntity_Call struct {
	*mock.Call
}

MockDataStore_deleteEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'deleteEntity'

func (*MockDataStore_deleteEntity_Call) Return

func (*MockDataStore_deleteEntity_Call) Run

func (_c *MockDataStore_deleteEntity_Call) Run(run func(ctx context.Context, uid *fencev1.UID)) *MockDataStore_deleteEntity_Call

func (*MockDataStore_deleteEntity_Call) RunAndReturn

func (_c *MockDataStore_deleteEntity_Call) RunAndReturn(run func(ctx context.Context, uid *fencev1.UID) error) *MockDataStore_deleteEntity_Call

type MockDataStore_deletePolicy_Call

type MockDataStore_deletePolicy_Call struct {
	*mock.Call
}

MockDataStore_deletePolicy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'deletePolicy'

func (*MockDataStore_deletePolicy_Call) Return

func (*MockDataStore_deletePolicy_Call) Run

func (*MockDataStore_deletePolicy_Call) RunAndReturn

type MockDataStore_getEntities_Call

type MockDataStore_getEntities_Call struct {
	*mock.Call
}

MockDataStore_getEntities_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'getEntities'

func (*MockDataStore_getEntities_Call) Return

func (_c *MockDataStore_getEntities_Call) Return(entitys []*fencev1.Entity, err error) *MockDataStore_getEntities_Call

func (*MockDataStore_getEntities_Call) Run

func (*MockDataStore_getEntities_Call) RunAndReturn

func (_c *MockDataStore_getEntities_Call) RunAndReturn(run func(ctx context.Context) ([]*fencev1.Entity, error)) *MockDataStore_getEntities_Call

type MockDataStore_getEntityMap_Call

type MockDataStore_getEntityMap_Call struct {
	*mock.Call
}

MockDataStore_getEntityMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'getEntityMap'

func (*MockDataStore_getEntityMap_Call) Return

func (*MockDataStore_getEntityMap_Call) Run

func (*MockDataStore_getEntityMap_Call) RunAndReturn

type MockDataStore_getPolicies_Call

type MockDataStore_getPolicies_Call struct {
	*mock.Call
}

MockDataStore_getPolicies_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'getPolicies'

func (*MockDataStore_getPolicies_Call) Return

func (_c *MockDataStore_getPolicies_Call) Return(policys []*fencev1.Policy, err error) *MockDataStore_getPolicies_Call

func (*MockDataStore_getPolicies_Call) Run

func (*MockDataStore_getPolicies_Call) RunAndReturn

func (_c *MockDataStore_getPolicies_Call) RunAndReturn(run func(ctx context.Context) ([]*fencev1.Policy, error)) *MockDataStore_getPolicies_Call

type MockDataStore_getPolicySet_Call

type MockDataStore_getPolicySet_Call struct {
	*mock.Call
}

MockDataStore_getPolicySet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'getPolicySet'

func (*MockDataStore_getPolicySet_Call) Return

func (*MockDataStore_getPolicySet_Call) Run

func (*MockDataStore_getPolicySet_Call) RunAndReturn

type MockDataStore_getPolicy_Call

type MockDataStore_getPolicy_Call struct {
	*mock.Call
}

MockDataStore_getPolicy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'getPolicy'

func (*MockDataStore_getPolicy_Call) Return

func (*MockDataStore_getPolicy_Call) Run

func (*MockDataStore_getPolicy_Call) RunAndReturn

type Policy

type Policy struct {
	bun.BaseModel `bun:"table:policies,alias:p"`
	ID            string `bun:"id,pk"`
	Content       string `bun:"content"`
	Base
}

func (*Policy) ToProto

func (p *Policy) ToProto() *fencev1.Policy

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(ds DataStore) *Service

func (*Service) CreateEntities

func (*Service) CreatePolicies

func (*Service) DeleteEntity

func (*Service) DeletePolicy

func (*Service) GetPolicy

func (*Service) IsAllowed

func (*Service) ListEntities

func (*Service) ListPolicies

type UID

type UID struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL