Documentation ¶
Index ¶
- Constants
- func HasAnyPrefixPerm(db *sql.DB, permType int, appID int64, groupIDs []int64, needWrite bool, ...) (bool, error)
- func InsertApp(db *sql.DB, app *App) error
- func InsertConfigItem(db *sql.DB, item *ConfigItem) (bool, error)
- func InsertGroup(db *sql.DB, group *Group) error
- func InsertPerm(db *sql.DB, perm *Perm) error
- func NewGroupMember(db *sql.DB, groupID, appID int64) error
- type App
- func GetAppByName(db *sql.DB, name string) (*App, error)
- func GetAppGroupByName(db *sql.DB, name string) (*App, []int64, error)
- func GetAppList(db *sql.DB) (apps []App, err error)
- func GetGroupMembers(db *sql.DB, groupID int64) (apps []App, err error)
- func ListApp(db *sql.DB, skip, limit int) ([]App, error)
- type AppCtrl
- func (ctrl *AppCtrl) AddGroupMember(groupID, appID int64) error
- func (ctrl *AppCtrl) GetAppByName(name string) (*App, error)
- func (ctrl *AppCtrl) GetAppCertPool() *x509.CertPool
- func (ctrl *AppCtrl) GetAppGroupByName(name string) (*App, []int64, error)
- func (ctrl *AppCtrl) GetGroupByName(name string) (*Group, error)
- func (ctrl *AppCtrl) GetGroupMembers(groupID int64) ([]App, error)
- func (ctrl *AppCtrl) GetPerms(typ int, appName *string, groupName *string, canWrite *bool, prefix *string) ([]Perm, error)
- func (ctrl *AppCtrl) HasAnyPrefixPerm(typ int, appID int64, groupIDs []int64, needWrite bool, content string) (bool, error)
- func (ctrl *AppCtrl) IsAppNodeOnline(ctx context.Context, name, label, key string) (bool, error)
- func (ctrl *AppCtrl) ListApp(skip, limit int) ([]App, error)
- func (ctrl *AppCtrl) NewApp(app *App, key crypto.Signer, dnsNames []string, ips []net.IP, days int) (crypto.Signer, error)
- func (ctrl *AppCtrl) NewAppPerm(permType int, appID int64, canWrite bool, content string) (int64, error)
- func (ctrl *AppCtrl) NewGroup(group *Group) error
- func (ctrl *AppCtrl) NewGroupPerm(permType int, groupID int64, canWrite bool, content string) (int64, error)
- func (ctrl *AppCtrl) PlugAppNode(ctx context.Context, appName string, node *AppNode, leaseID clientv3.LeaseID) (bool, error)
- func (ctrl *AppCtrl) RemoveAppNode(ctx context.Context, name, label, key string) error
- func (ctrl *AppCtrl) WatchAppNodes(ctx context.Context, name, label string, revision int64) (*AppNodes, error)
- type AppNode
- type AppNodes
- type CertsConfig
- type CertsCtrl
- type Config
- type ConfigItem
- type Group
- type GroupMember
- type Perm
- type SerialGenerator
Constants ¶
const ( // PermTypeConfig perm type config PermTypeConfig = 0 // PermTypeService perm type service PermTypeService = 1 // PermTypeApp perm type app PermTypeApp = 2 // PermTargetApp perm target app PermTargetApp = 0 // PermTargetGroup perm target group PermTargetGroup = 1 // PermPublicTargetID perm public target id PermPublicTargetID = 0 )
Variables ¶
This section is empty.
Functions ¶
func HasAnyPrefixPerm ¶
func HasAnyPrefixPerm(db *sql.DB, permType int, appID int64, groupIDs []int64, needWrite bool, content string) (bool, error)
HasAnyPrefixPerm has any prefix perm
func InsertConfigItem ¶
func InsertConfigItem(db *sql.DB, item *ConfigItem) (bool, error)
InsertConfigItem insert config item
Types ¶
type App ¶
type App struct { ID int64 `json:"-"` Status int `json:"status"` Name string `json:"name"` Description string `json:"description,omitempty"` PrivateKey string `json:"-"` Cert string `json:"cert"` CreateTime time.Time `json:"create_time"` ModifyTime time.Time `json:"modify_time"` // contains filtered or unexported fields }
App app table
func GetAppByName ¶
GetAppByName get app by name
func GetAppGroupByName ¶
GetAppGroupByName get app group by name
func GetGroupMembers ¶
GetGroupMembers get group members
type AppCtrl ¶
type AppCtrl struct { CertsManager *CertsCtrl // contains filtered or unexported fields }
AppCtrl app ctrl
func NewAppCtrl ¶
NewAppCtrl new app ctrl
func (*AppCtrl) AddGroupMember ¶
AddGroupMember add group member
func (*AppCtrl) GetAppByName ¶
GetAppByName get app byname
func (*AppCtrl) GetAppCertPool ¶
GetAppCertPool get app certPool
func (*AppCtrl) GetAppGroupByName ¶
GetAppGroupByName get app group byname
func (*AppCtrl) GetGroupByName ¶
GetGroupByName get group byname
func (*AppCtrl) GetGroupMembers ¶
GetGroupMembers get group members
func (*AppCtrl) GetPerms ¶
func (ctrl *AppCtrl) GetPerms(typ int, appName *string, groupName *string, canWrite *bool, prefix *string) ([]Perm, error)
GetPerms get perms
func (*AppCtrl) HasAnyPrefixPerm ¶
func (ctrl *AppCtrl) HasAnyPrefixPerm(typ int, appID int64, groupIDs []int64, needWrite bool, content string) (bool, error)
HasAnyPrefixPerm has any prefix perm
func (*AppCtrl) IsAppNodeOnline ¶
IsAppNodeOnline is app node online
func (*AppCtrl) NewApp ¶
func (ctrl *AppCtrl) NewApp(app *App, key crypto.Signer, dnsNames []string, ips []net.IP, days int) (crypto.Signer, error)
NewApp new app
func (*AppCtrl) NewAppPerm ¶
func (ctrl *AppCtrl) NewAppPerm(permType int, appID int64, canWrite bool, content string) (int64, error)
NewAppPerm new app perm
func (*AppCtrl) NewGroupPerm ¶
func (ctrl *AppCtrl) NewGroupPerm(permType int, groupID int64, canWrite bool, content string) (int64, error)
NewGroupPerm new group perm
func (*AppCtrl) PlugAppNode ¶
func (ctrl *AppCtrl) PlugAppNode(ctx context.Context, appName string, node *AppNode, leaseID clientv3.LeaseID) (bool, error)
PlugAppNode plug app node
func (*AppCtrl) RemoveAppNode ¶
RemoveAppNode remove app node
type AppNode ¶
type AppNode struct { Label string `json:"label"` Key string `json:"key"` Config string `json:"config"` }
AppNode app node
type CertsConfig ¶
type CertsConfig struct { RootCert string `default:"rootcert.pem"` RootKey string `default:"rootkey.pem"` }
CertsConfig certs config
type CertsCtrl ¶
type CertsCtrl struct {
// contains filtered or unexported fields
}
CertsCtrl certs ctrl
func NewCertsCtrl ¶
func NewCertsCtrl(config *CertsConfig, serialGenerator SerialGenerator) (*CertsCtrl, error)
NewCertsCtrl new certs ctrl
type Config ¶
type Config struct { Cert CertsConfig EcdsaCruve string RSABits int `default:"2048"` Organization string `default:"XBus"` KeyPrefix string `default:"/apps" yaml:"key_prefix"` DumpKeyCertDir string `yaml:"dump_keycert_dir"` DumpKeyCertWithAppDir bool `default:"true" yaml:"dump_keycert_with_appdir"` }
Config module config
type ConfigItem ¶
type ConfigItem struct { ID int64 Name string Value string Ver int64 CreateTime time.Time ModifyTime time.Time }
ConfigItem config item table
func GetConfigItem ¶
func GetConfigItem(db *sql.DB, name string) (*ConfigItem, error)
GetConfigItem get config item
func (*ConfigItem) GetIntValue ¶
func (m *ConfigItem) GetIntValue() (int64, error)
GetIntValue get int value
func (*ConfigItem) SetIntValue ¶
func (m *ConfigItem) SetIntValue(n int64)
SetIntValue set int value
func (*ConfigItem) UpdateValue ¶
func (m *ConfigItem) UpdateValue(db *sql.DB) error
UpdateValue update value
type Group ¶
type Group struct { ID int64 `json:"-"` Status int `json:"status"` Name string `json:"name"` Description string `json:"description,omitempty"` CreateTime time.Time `json:"create_time"` ModifyTime time.Time `json:"modify_time"` }
Group group table
func GetGroupByName ¶
GetGroupByName get group by name
type GroupMember ¶
GroupMember group member
type Perm ¶
type Perm struct { ID int64 PermType int TargetType int TargetID int64 CanWrite bool Content string CreateTime time.Time }
Perm perm table
type SerialGenerator ¶
SerialGenerator serial generator