Documentation
¶
Index ¶
- Constants
- Variables
- type MapSettings
- type RedisSettingsCache
- type SettingValue
- type Settings
- func (conf *Settings) DeleteValue(service, name string, envID uint) error
- func (conf *Settings) EmptyValue(service, name, typeValue string, envID uint) SettingValue
- func (conf *Settings) GetInteger(service, name string, envID uint) (int64, error)
- func (conf *Settings) GetMap(service string, envID uint) (MapSettings, error)
- func (conf *Settings) InactiveHours(envID uint) int64
- func (conf *Settings) IsValue(service, name string, envID uint) bool
- func (conf *Settings) NewBooleanValue(service, name string, value bool, envID uint) error
- func (conf *Settings) NewIntegerValue(service, name string, value int64, envID uint) error
- func (conf *Settings) NewStringValue(service, name, value string, envID uint) error
- func (conf *Settings) NewValue(service, name, typeValue string, value interface{}, envID uint) error
- func (conf *Settings) OnelinerExpiration(envID uint) bool
- func (conf *Settings) RefreshSettings(service string) int64
- func (conf *Settings) RetrieveAllValues() ([]SettingValue, error)
- func (conf *Settings) RetrieveValue(service, name string, envID uint) (SettingValue, error)
- func (conf *Settings) RetrieveValues(service string, envID uint) ([]SettingValue, error)
- func (conf *Settings) SetBoolean(boolValue bool, service, name string, envID uint) error
- func (conf *Settings) SetInfo(info string, service, name string, envID uint) error
- func (conf *Settings) SetInteger(intValue int64, service, name string, envID uint) error
- func (conf *Settings) SetString(strValue string, service, name string, envID uint) error
- func (conf *Settings) VerifyService(sType string) bool
Constants ¶
const ( TypeString string = "string" TypeBoolean string = "boolean" TypeInteger string = "integer" )
Types of settings values
const ( ScriptEnroll string = "enroll" ScriptRemove string = "remove" )
Types of script
const ( ActionExpire string = "expire" ActionExtend string = "extend" ActionRotate string = "rotate" ActionNotexpire string = "notexpire" SetMacPackage string = "set_pkg" SetMsiPackage string = "set_msi" SetDebPackage string = "set_deb" SetRpmPackage string = "set_rpm" )
Types of enroll/remove actions
const ( QueryDelete string = "delete" QueryExpire string = "expire" QueryComplete string = "complete" CarveDelete string = QueryDelete CarveExpire string = QueryExpire CarveComplete string = QueryComplete )
Types of query/carve actions
const ( PackageDeb string = "deb" PackageRpm string = "rpm" PackagePkg string = "pkg" PackageMsi string = "msi" )
Types of package
const ( DownloadSecret string = "secret" DownloadCert string = "cert" DownloadFlags string = "flags" DownloadFlagsMac string = "flagsMac" DownloadFlagsWin string = "flagsWindows" DownloadFlagsLinux string = "flagsLinux" DownloadFlagsFreeBSD string = "flagsFreeBSD" )
Types of download target
const ( PlatformDarwin string = "darwin" PlatformLinux string = "linux" PlatformWindows string = "windows" )
Types of platform
const ( RefreshSettings string = "refresh_settings" ServiceMetrics string = "service_metrics" InactiveHours string = "inactive_hours" AcceleratedSeconds string = "accelerated_seconds" OnelinerExpiration string = "oneliner_expiration" )
Names for all possible settings values for services
const DefaultInactiveHours int64 = 72
DefaultInactiveHours is the fallback threshold (in hours) for classifying nodes as active vs inactive when the inactive_hours setting is absent or invalid. Keeps every service — including the API, which does not seed the setting itself — from treating all nodes as inactive when the DB row is missing.
const (
NoEnvironmentID = iota
)
Values for generic IDs
Variables ¶
var ValidServices = map[string]struct{}{ config.ServiceTLS: {}, config.ServiceAPI: {}, }
ValidServices to check validity of settings service
Functions ¶
This section is empty.
Types ¶
type MapSettings ¶
type MapSettings map[string]SettingValue
MapSettings to hold all values by service
type RedisSettingsCache ¶ added in v0.5.5
type RedisSettingsCache struct {
// contains filtered or unexported fields
}
RedisSettingsCache caches a service/env settings map in Redis.
func NewRedisSettingsCache ¶ added in v0.5.5
func NewRedisSettingsCache(settings *Settings, client *redis.Client, service string, envID uint, ttl time.Duration) *RedisSettingsCache
NewRedisSettingsCache creates a Redis-backed cache for settings.GetMap.
func (*RedisSettingsCache) GetMap ¶ added in v0.5.5
func (c *RedisSettingsCache) GetMap(ctx context.Context) (MapSettings, error)
GetMap returns the cached settings map, refetching from DB on Redis miss/error.
func (*RedisSettingsCache) Invalidate ¶ added in v0.5.5
func (c *RedisSettingsCache) Invalidate(ctx context.Context) error
Invalidate removes the cached settings map.
func (*RedisSettingsCache) SetDBHealth ¶ added in v0.5.5
func (c *RedisSettingsCache) SetDBHealth(h backend.DegradedReader)
SetDBHealth wires a DB health monitor. When the monitor reports the database as degraded, GetMap serves a stale cached entry on a DB miss instead of returning an error, and writes during degradation use settingsCacheDegradedTTL. Pass nil to disable (the default).
type SettingValue ¶
type SettingValue struct {
gorm.Model
Name string `gorm:"index"`
Service string
EnvironmentID uint
Type string
String string
Boolean bool
Integer int64
Info string
}
SettingValue to hold each value for settings
type Settings ¶
Settings keeps all settings values
func NewSettings ¶
NewSettings to initialize the access to settings and table
func (*Settings) DeleteValue ¶
DeleteValue deletes an existing settings value
func (*Settings) EmptyValue ¶
func (conf *Settings) EmptyValue(service, name, typeValue string, envID uint) SettingValue
EmptyValue creates an empty value
func (*Settings) GetInteger ¶
GetInteger gets a numeric settings value by service and name
func (*Settings) GetMap ¶
func (conf *Settings) GetMap(service string, envID uint) (MapSettings, error)
GetMap returns the map of values by service
func (*Settings) InactiveHours ¶
InactiveHours gets the value in hours for a node to be inactive by service. Returns DefaultInactiveHours when the setting is absent or invalid so that callers never receive a zero threshold (which would make every node appear inactive).
func (*Settings) NewBooleanValue ¶
NewBooleanValue creates a new settings value
func (*Settings) NewIntegerValue ¶
NewIntegerValue creates a new settings value
func (*Settings) NewStringValue ¶
NewStringValue creates a new settings value
func (*Settings) NewValue ¶
func (conf *Settings) NewValue(service, name, typeValue string, value interface{}, envID uint) error
NewValue creates a new settings value
func (*Settings) OnelinerExpiration ¶
OnelinerExpiration checks if enrolling links will expire
func (*Settings) RefreshSettings ¶
RefreshSettings gets the interval in seconds to refresh settings by service
func (*Settings) RetrieveAllValues ¶
func (conf *Settings) RetrieveAllValues() ([]SettingValue, error)
RetrieveAllValues retrieves and returns all values from backend
func (*Settings) RetrieveValue ¶
func (conf *Settings) RetrieveValue(service, name string, envID uint) (SettingValue, error)
RetrieveValue retrieves one value from settings by service and name from backend
func (*Settings) RetrieveValues ¶
func (conf *Settings) RetrieveValues(service string, envID uint) ([]SettingValue, error)
RetrieveValues retrieves and returns all values from backend
func (*Settings) SetBoolean ¶
SetBoolean sets a boolean settings value by service and name
func (*Settings) SetInteger ¶
SetInteger sets a numeric settings value by service and name
func (*Settings) VerifyService ¶
VerifyService to make sure service is valid