model

package
v0.0.0-...-19d8e19 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessScopePod       = "pod"
	AccessScopeNamespace = "namespace"
	AccessScopeIP        = "ip"
	AccessScopeToken     = "token"
	AccessScopePublic    = "public"
)
View Source
const (
	EditPermissionAnyone     = "anyone"
	EditPermisionOwner       = "owner"
	EditPermissionDepartment = "department"
)
View Source
const (
	AutoRefreshConfigMap = "configmap"
	AutoRefreshHook      = "hook"
	AutoRefreshPassive   = "passive"
)

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(dsn string, debug bool) (err error)

func DeleteAccessScope

func DeleteAccessScope(ctx context.Context, scope *AccessScope) error

func DeleteApp

func DeleteApp(ctx context.Context, app App) error

func DeleteDepartment

func DeleteDepartment(ctx context.Context, id uint) error

func DeleteNamespace

func DeleteNamespace(ctx context.Context, namespace Namespace) error

func DeleteUser

func DeleteUser(ctx context.Context, id uint) error

func GetSettings

func GetSettings(ctx context.Context, key string) (string, error)

func ImportNamespaceFromK8s

func ImportNamespaceFromK8s(ctx context.Context, namespaces []string) error

func InitSettings

func InitSettings(ctx context.Context) error

func InsertAccessScope

func InsertAccessScope(ctx context.Context, scope *AccessScope) (uint, error)

func InsertApp

func InsertApp(ctx context.Context, app App) error

func InsertDepartment

func InsertDepartment(ctx context.Context, department *Department) (uint, error)

func InsertNamespace

func InsertNamespace(ctx context.Context, namespace Namespace) error

func InsertUser

func InsertUser(ctx context.Context, user *User) error

func SetSettings

func SetSettings(ctx context.Context, key string, value string) error

func UpdateAccessScope

func UpdateAccessScope(ctx context.Context, scope *AccessScope) error

func UpdateApp

func UpdateApp(ctx context.Context, app App) error

func UpdateConfig

func UpdateConfig(ctx context.Context, config *Config) error

func UpdateNamespace

func UpdateNamespace(ctx context.Context, namespace Namespace) error

func UpdateUser

func UpdateUser(ctx context.Context, user *User) error

Types

type AccessScope

type AccessScope struct {
	gorm.Model

	Scope string `gorm:"type:enum('pod', 'namespace', 'ip', 'token', 'public', 'inherited')"`
	Value string `gorm:"type:text"`
}

type App

type App struct {
	gorm.Model

	Name             string
	Namespace        Namespace
	Owner            User
	EditPermission   string `gorm:"type:enum('anyone', 'owner', 'department')"`
	Department       Department
	Scopes           []AccessScope
	AutoRefresh      string `gorm:"type:enum('configmap', 'hook', 'passive')"`
	AutoRefreshParam string // configmap name or hook url
}

func GetAppByName

func GetAppByName(ctx context.Context, name string) (*App, error)

type Config

type Config struct {
	gorm.Model

	App     App        `gorm:"foreignKey:Name"`
	Type    ConfigType `gorm:"type:enum('string', 'number', 'bool', 'Json')"`
	Key     string
	Value   string `gorm:"type:text"`
	Comment string `gorm:"type:text"`
}

func GetConfig

func GetConfig(ctx context.Context, appName, configKey string) (*Config, error)

type ConfigType

type ConfigType string
const (
	ConfigTypeString ConfigType = "string"
	ConfigTypeNumber ConfigType = "number"
	ConfigTypeBool   ConfigType = "bool"
	ConfigTypeJson   ConfigType = "Json"
)

type Department

type Department struct {
	gorm.Model

	Name string `gorm:"uniqueIndex"`
}

func (*Department) Members

func (d *Department) Members(ctx context.Context) []User

type Namespace

type Namespace struct {
	gorm.Model

	Name        string
	InClusterDB bool `gorm:"default:false"`
}

func GetNamespace

func GetNamespace(ctx context.Context, id uint) (Namespace, error)

func GetNamespaces

func GetNamespaces(ctx context.Context) ([]Namespace, error)

func (*Namespace) InCluster

func (ns *Namespace) InCluster(ctx context.Context) (bool, error)

type Settings

type Settings struct {
	Key   string `gorm:"primaryKey"`
	Value string
}

type User

type User struct {
	gorm.Model

	Sub        string     `gorm:"uniqueIndex"` // OIDC sub or username
	Password   string     // password when not using OIDC
	Department Department `gorm:"foreignKey:name"`
	Role       string     `gorm:"type:enum('admin', 'user')"` // admin or user
}

func GetUserBySub

func GetUserBySub(ctx context.Context, sub string) (*User, error)

func GetUsers

func GetUsers(ctx context.Context, isAdmin bool, dept string) ([]User, error)

Jump to

Keyboard shortcuts

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