Since go1.22 it is now in the standard library and is removed from a future versio from pkglib
38 lines
842 B
Go
38 lines
842 B
Go
package policy
|
|
|
|
import (
|
|
"context"
|
|
"reflect"
|
|
|
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth"
|
|
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/sql"
|
|
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Policy struct {
|
|
component.Base
|
|
|
|
dependencies struct {
|
|
SQL *sql.SQL
|
|
Auth *auth.Auth
|
|
}
|
|
}
|
|
|
|
var (
|
|
_ component.Provisionable = (*Policy)(nil)
|
|
_ component.UserDeleteHook = (*Policy)(nil)
|
|
_ component.Table = (*Policy)(nil)
|
|
)
|
|
|
|
func (pol *Policy) TableInfo() component.TableInfo {
|
|
return component.TableInfo{
|
|
Name: models.GrantTable,
|
|
Model: reflect.TypeFor[models.Grant](),
|
|
}
|
|
}
|
|
|
|
func (pol *Policy) table(ctx context.Context) (*gorm.DB, error) {
|
|
return pol.dependencies.SQL.QueryTable(ctx, pol)
|
|
}
|