statemanager

package
v0.0.0-...-028f1de Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Cron schedule type, expression format is defined in https://help.aliyun.com/document_detail/169784.html
	Cron = "cron"
	// Rate schedule type, expression format examples: "5 minutes" "1 hour"
	Rate = "rate"

	// Cron is triggered with a drift, after the expected time
	// This helps to reduce concurrency
	MaxCronDriftSeconds = 15 * 60
)
View Source
const (
	// DefaultRefreshIntervalSeconds is the default interval of refresh state configurations in seconds
	DefaultRefreshIntervalSeconds = 1800
	// MaxInitTimerDriftSeconds is the default max seconds to delay when initializing state manager timer
	MaxInitTimerDriftSeconds = 3 * 60
)
View Source
const (
	// Agent applies the configuration and does nothing further
	// unless the configuration (template and parameters) is updated.
	// After initial application of a new configuration,
	// agent does not check for drift from a previously configured state.
	// Agent will attempt to apply the configuration until it is successful before ApplyOnly takes effect.
	ApplyOnly = "ApplyOnly"
	// Agent applies any new configurations.
	// After initial application of a new configuration, if the instance drifts from the desired state,
	// reports the discrepancy to server.
	// Agent will attempt to apply the configuration until it is successful before ApplyAndMonitor takes effect.
	ApplyAndMonitor = "ApplyAndMonitor"
	// Agent applies any new configurations. After initial application of a new configuration,
	// if the instance drifts from the desired state, reports the discrepancy to server,
	// and then re-applies the current configuration.
	ApplyAndAutoCorrect = "ApplyAndAutoCorrect"
)
View Source
const (
	Apply   = "Apply"
	Monitor = "Monitor"
	Skip    = "Skip"
)
View Source
const (
	Compliant    = "Compliant"
	NotCompliant = "NotCompliant"
	Failed       = "Failed"
)

Variables

This section is empty.

Functions

func CancelStateManagerTimer

func CancelStateManagerTimer() error

func ConfigCacheFilePath

func ConfigCacheFilePath() (path string, err error)

func GetRateInSeconds

func GetRateInSeconds(expr string) (seconds int, err error)

func InitStateManagerTimer

func InitStateManagerTimer() error

InitStateManagerTimer starts timer for state manage feature

func IsStateConfigTimerRunning

func IsStateConfigTimerRunning() bool

func IsStateManagerTimerRunning

func IsStateManagerTimerRunning() bool

func LastCheckpoint

func LastCheckpoint() string

func LoadTemplateCache

func LoadTemplateCache(name string, version string) (content []byte, err error)

func NewResourceState

func NewResourceState(state StateDef) (rs resources.ResourceState, err error)

func ParseResourceState

func ParseResourceState(data []byte, userParameters string) (rs []resources.ResourceState, err error)

func PutInstanceStateReport

func PutInstanceStateReport(stateConfigurationId, status, extraInfo, mode, clientToken string) error

func Resolve

func Resolve(orig string, paramMap map[string]interface{}) (v interface{})

Resolve resolves final value for string contains parameter reference for example, "ecs.{{ regionId }}.aliyuncs.com" with parameter regionId="cn-zhangjiakou" will get ecs.cn-zhangjiakou.aliyuncs.com

"{{id}}" with parameter id=1 will get number 1

func ResolveParameterValue

func ResolveParameterValue(params map[string]ParamProp, userParams map[string]interface{}) (result map[string]interface{})

func TemplateCachePath

func TemplateCachePath(name string, version string) (p string, err error)

func WriteConfigCache

func WriteConfigCache(config *ListInstanceStateConfigurationsResult) error

WriteConfigCache saves state configurations to local cache file

func WriteTemplateCache

func WriteTemplateCache(name string, version string, data []byte) (err error)

Types

type ApiResponse

type ApiResponse struct {
	ErrCode string `json:"errCode"`
	ErrMsg  string `json:"errMsg"`
}

type GetTemplateResponse

type GetTemplateResponse struct {
	ApiResponse
	Result *GetTemplateResult `json:"result"`
}

func GetTemplate

func GetTemplate(templateName, templateVersion string) (*GetTemplateResponse, error)

type GetTemplateResult

type GetTemplateResult struct {
	RequestId       string
	TemplateName    string
	TemplateVersion string
	Content         string
}

type ListInstanceStateConfigurationsResp

type ListInstanceStateConfigurationsResp struct {
	ApiResponse
	Result *ListInstanceStateConfigurationsResult `json:"result"`
}

func ListInstanceStateConfigurations

func ListInstanceStateConfigurations(lastCheckpoint, agentName, agentVersion, computerName,
	platformName, platformType, platformVersion, ipAddress, ramRole string) (*ListInstanceStateConfigurationsResp, error)

ListInstanceStateConfigurations lists state configurations from server and report agent info

type ListInstanceStateConfigurationsResult

type ListInstanceStateConfigurationsResult struct {
	RequestId           string
	Interval            int
	Changed             bool
	Checkpoint          string
	StateConfigurations []StateConfiguration
}

func LoadConfigCache

func LoadConfigCache() (r *ListInstanceStateConfigurationsResult, err error)

LoadConfigCache loads state configurations from local cache files

type ParamDef

type ParamDef struct {
	Name    string
	Default interface{}
	Value   interface{}
}

type ParamProp

type ParamProp struct {
	Type    string
	Default interface{}
}

type StateConfigTimer

type StateConfigTimer struct {
	// contains filtered or unexported fields
}

type StateConfiguration

type StateConfiguration struct {
	StateConfigurationId string
	TemplateName         string
	TemplateVersion      string
	Parameters           string
	ConfigureMode        string
	ScheduleType         string
	ScheduleExpression   string
	SuccessfulApplyTime  string
	DefinitionUpdateTime string
}

type StateDef

type StateDef struct {
	ResourceType string
	Properties   map[string]interface{}
}

type StateTemplate

type StateTemplate struct {
	FormatVersion string
	Parameters    map[string]ParamProp
	States        []StateDef
}

func ParseStateTemplate

func ParseStateTemplate(data []byte) (t StateTemplate, err error)

ParseStateTemplate parses template data to state and parameter definitions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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