config

package
v1.0.0-beta.20240501 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadYaml

func LoadYaml(configFile string)

load config from file

func ServerListToMap

func ServerListToMap(s []Server) map[string]Server

ToMap convert to map with privateIp

Types

type Config

type Config struct {
	Profiles     []db.CreateProfileRequest `mapstructure:"profiles"`     // 云账号配置,用来自动同步云服务器信息
	Proxys       []db.CreateProxyRequest   `mapstructure:"proxies"`      // ssh代理
	Keys         Keys                      `mapstructure:"keys"`         // ssh key pair 不启用数据库时使用
	WithVideo    WithVideo                 `mapstructure:"withVideo"`    // 视频存储
	WithLdap     WithLdap                  `mapstructure:"withLdap"`     // 配置ldap
	WithSSHCheck WithSSHCheck              `mapstructure:"withSSHCheck"` // 配置服务器SSH可连接性告警
	WithDB       WithPolicy                `mapstructure:"withDB"`       // 需要进行权限管理则启用该配置,启用后会使用数据库进行权限管理
	WithDingtalk WithDingtalk              `mapstructure:"withDingtalk"` // 配置钉钉审批流程
}

Config config

var Conf *Config

type Keys

type Keys []db.AddKeyRequest

func (Keys) ToMap

func (k Keys) ToMap() map[string]db.AddKeyRequest

ToMap convert to map with keyID

func (Keys) ToMapWithName

func (k Keys) ToMapWithName() map[string]db.AddKeyRequest

type PGConfig

type PGConfig struct {
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	Database string `mapstructure:"database"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
}

func (*PGConfig) GetUrl

func (c *PGConfig) GetUrl() string

type SSHAlert

type SSHAlert struct {
	RobotToken string `mapstructure:"robotToken"`
}

目前只支持钉钉机器人群告警

type SSHUser

type SSHUser struct {
	SSHUsername string
	KeyName     string // pem file name, 这里是支持本地读取内容的
	Base64Pem   string // base64 pem
	Password    string
}

SSHUser ssh user

type Server

type Server struct {
	ID       string
	Name     string
	Host     string // 默认取私有 IP 第一个
	Port     int
	KeyPairs []*string // key pair name
	// Proxy    *db.CreateProxyRequest
	Profile  string
	Region   string
	Tags     model.Tags
	Status   model.InstanceStatus
	SSHUsers []SSHUser
}

Server server

type Servers

type Servers []Server

func (Servers) SortByName

func (s Servers) SortByName()

按名称排序

type User

type User struct {
	Username   string `yaml:"username"`
	HashPasswd string `yaml:"hashPasswd"`
	Admin      bool   `yaml:"admin"`
	PublicKey  string `yaml:"publickey"`
}

type WithDingtalk

type WithDingtalk struct {
	Enable      bool   `mapstructure:"enable"`
	AppKey      string `mapstructure:"appKey"`
	AppSecret   string `mapstructure:"appSecret"`
	ProcessCode string `mapstructure:"processCode"` // 审批流程编码
}

type WithLdap

type WithLdap struct {
	Enable           bool     `mapstructure:"enable"`
	BindUser         string   `mapstructure:"bindUser"`
	BindPassword     string   `mapstructure:"bindPassword"`
	Host             string   `mapstructure:"host"`
	Port             int      `mapstructure:"port"`
	BaseDN           string   `mapstructure:"baseDN"`
	UserSearchFilter string   `mapstructure:"userSearchFilter"`
	Attributes       []string `mapstructure:"attributes"`
}

type WithPolicy

type WithPolicy struct {
	Enable bool     `mapstructure:"enable"`
	DBFile string   `mapstructure:"dbFile"`
	PG     PGConfig `mapstructure:"pg"`
}

type WithSSHCheck

type WithSSHCheck struct {
	Enable bool     `mapstructure:"enable"`
	Alert  SSHAlert `mapstructure:"alert"`
	IPS    []string `mapstructure:"ips"`
}

type WithVideo

type WithVideo struct {
	Enable   bool   `mapstructure:"enable"`
	Cron     string `mapstructure:"cron"`     // 定时任务默认 "0 0 3 * * *" 表示每天凌晨 3 点触发
	Dir      string `mapstructure:"dir"`      // 日志目录,默认/opt/jms/audit/
	KeepDays int    `mapstructure:"keepDays"` // 保留天数,默认 3 个月
}

Jump to

Keyboard shortcuts

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