database

package
v1.23.11 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertPosition

type AlertPosition struct {
	AlertName string
	Namespace string

	ClusterID   uint
	ClusterName string

	TenantID   uint
	TenantName string

	ProjectID   uint
	ProjectName string

	EnvironmentID   uint
	EnvironmentName string

	From string // 告警来自哪里,monitor/logging
}

type Database

type Database struct {
	*DatabaseHelper
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(options *Options) (*Database, error)

func (*Database) DB

func (o *Database) DB() *gorm.DB

func (*Database) Options

func (o *Database) Options() *Options

type DatabaseHelper

type DatabaseHelper struct {
	DB *gorm.DB
}

func (*DatabaseHelper) ClusterNS2EnvMap

func (h *DatabaseHelper) ClusterNS2EnvMap() (map[string]EnvInfo, error)

func (*DatabaseHelper) EnvAdmins

func (h *DatabaseHelper) EnvAdmins(envIDs ...uint) []uint

func (*DatabaseHelper) EnvUsers

func (h *DatabaseHelper) EnvUsers(envIDs ...uint) []uint

func (*DatabaseHelper) FindPromqlTpl added in v1.22.0

func (h *DatabaseHelper) FindPromqlTpl(scope, resource, rule string) (*templates.PromqlTpl, error)

func (*DatabaseHelper) GetAlertPosition

func (h *DatabaseHelper) GetAlertPosition(cluster, namespace, name string, isMonitor bool) (AlertPosition, error)

func (*DatabaseHelper) NewPromqlTplMapperFromDB added in v1.22.0

func (h *DatabaseHelper) NewPromqlTplMapperFromDB() *templates.PromqlTplMapper

func (*DatabaseHelper) ProjectAdmins

func (h *DatabaseHelper) ProjectAdmins(projIDs ...uint) []uint

func (*DatabaseHelper) ProjectUsers

func (h *DatabaseHelper) ProjectUsers(projIDs ...uint) []uint

func (*DatabaseHelper) SystemAdmins

func (h *DatabaseHelper) SystemAdmins() []uint

func (*DatabaseHelper) SystemUsers

func (h *DatabaseHelper) SystemUsers() []uint

func (*DatabaseHelper) TenantAdmins

func (h *DatabaseHelper) TenantAdmins(tenantIDs ...uint) []uint

func (*DatabaseHelper) TenantUsers

func (h *DatabaseHelper) TenantUsers(tenantIDs ...uint) []uint

type EnvInfo

type EnvInfo struct {
	ClusterName string
	Namespace   string

	TenantName      string
	ProjectName     string
	EnvironmentName string
}

type Options

type Options struct {
	Addr      string `json:"addr" description:"mysql host addr"`
	Username  string `json:"username" description:"mysql username"`
	Password  string `json:"password" description:"mysql password"`
	Database  string `json:"database" description:"database to use"`
	Collation string `json:"collation" description:"collation to use"`
}

func NewDefaultOptions

func NewDefaultOptions() *Options

func (*Options) ToDriverConfig

func (opts *Options) ToDriverConfig() *driver.Config

func (*Options) ToDsn

func (opts *Options) ToDsn() string

func (*Options) ToDsnWithOutDB

func (opts *Options) ToDsnWithOutDB() (string, string)

Jump to

Keyboard shortcuts

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