avs

package
v0.0.0-...-f7d1ac2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusActive      = "ACTIVE"
	StatusMaintenance = "MAINTENANCE"
	StatusInactive    = "INACTIVE"
	StatusRetired     = "RETIRED"
	StatusDeleted     = "DELETED"
)
View Source
const (
	DefinitionType = "BASIC"
)

Variables

This section is empty.

Functions

func FixMockAvsServer

func FixMockAvsServer(srv *MockAvsServer) *httptest.Server

func NewAvsError

func NewAvsError(format string, args ...interface{}) kebError.ErrorReporter

func ValidStatus

func ValidStatus(status string) bool

Types

type BasicEvaluationCreateRequest

type BasicEvaluationCreateRequest struct {
	DefinitionType   string `json:"definition_type"`
	Name             string `json:"name"`
	Description      string `json:"description"`
	Service          string `json:"service"`
	URL              string `json:"url"`
	CheckType        string `json:"check_type"`
	Interval         int32  `json:"interval"`
	TesterAccessId   int64  `json:"tester_access_id"`
	Timeout          int    `json:"timeout"`
	ReadOnly         bool   `json:"read_only"`
	ContentCheck     string `json:"content_check"`
	ContentCheckType string `json:"content_check_type"`
	Threshold        string `json:"threshold"`
	GroupId          int64  `json:"group_id"`
	Visibility       string `json:"visibility"`
	ParentId         int64  `json:"parent_id"`
	Tags             []*Tag `json:"tags"`
}

type BasicEvaluationCreateResponse

type BasicEvaluationCreateResponse struct {
	DefinitionType   string `json:"definition_type"`
	Name             string `json:"name"`
	Description      string `json:"description"`
	Service          string `json:"service"`
	URL              string `json:"url"`
	CheckType        string `json:"check_type"`
	Interval         int32  `json:"interval"`
	TesterAccessId   int64  `json:"tester_access_id"`
	Timeout          int    `json:"timeout"`
	ReadOnly         bool   `json:"read_only"`
	ContentCheck     string `json:"content_check"`
	ContentCheckType string `json:"content_check_type"`
	Threshold        int64  `json:"threshold"`
	GroupId          int64  `json:"group_id"`
	Visibility       string `json:"visibility"`

	DateCreated                int64  `json:"dateCreated"`
	DateChanged                int64  `json:"dateChanged"`
	Owner                      string `json:"owner"`
	Status                     string `json:"status"`
	Alerts                     []int  `json:"alerts"`
	Tags                       []*Tag `json:"tags"`
	Id                         int64  `json:"id"`
	LegacyCheckId              int64  `json:"legacy_check_id"`
	InternalInterval           int64  `json:"internal_interval"`
	AuthType                   string `json:"auth_type"`
	IndividualOutageEventsOnly bool   `json:"individual_outage_events_only"`
	IdOnTester                 string `json:"id_on_tester"`
}

type Client

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

func NewClient

func NewClient(ctx context.Context, avsConfig Config, log logrus.FieldLogger) (*Client, error)

func (*Client) AddTag

func (c *Client) AddTag(evaluationID int64, tag *Tag) (*BasicEvaluationCreateResponse, error)

func (*Client) CreateEvaluation

func (c *Client) CreateEvaluation(evaluationRequest *BasicEvaluationCreateRequest) (*BasicEvaluationCreateResponse, error)

func (*Client) DeleteEvaluation

func (c *Client) DeleteEvaluation(evaluationId int64) (err error)

func (*Client) GetEvaluation

func (c *Client) GetEvaluation(evaluationID int64) (*BasicEvaluationCreateResponse, error)

func (*Client) RemoveReferenceFromParentEval

func (c *Client) RemoveReferenceFromParentEval(parentID, evaluationID int64) (err error)

func (*Client) SetStatus

func (c *Client) SetStatus(evaluationID int64, status string) (*BasicEvaluationCreateResponse, error)

type Config

type Config struct {
	OauthTokenEndpoint                              string
	OauthUsername                                   string
	OauthPassword                                   string
	OauthClientId                                   string
	ApiEndpoint                                     string
	DefinitionType                                  string `envconfig:"default=BASIC"`
	Disabled                                        bool   `envconfig:"default=false"`
	InternalTesterAccessId                          int64
	InternalTesterService                           string `envconfig:"optional"`
	InternalTesterTags                              []*Tag `envconfig:"optional"`
	GroupId                                         int64
	ExternalTesterAccessId                          int64
	ExternalTesterService                           string `envconfig:"optional"`
	ExternalTesterTags                              []*Tag `envconfig:"optional"`
	ParentId                                        int64
	AdditionalTagsEnabled                           bool
	GardenerShootNameTagClassId                     int
	GardenerSeedNameTagClassId                      int
	RegionTagClassId                                int
	TrialInternalTesterAccessId                     int64    `envconfig:"optional"`
	TrialParentId                                   int64    `envconfig:"optional"`
	TrialGroupId                                    int64    `envconfig:"optional"`
	MaintenanceModeDuringUpgradeDisabled            bool     `envconfig:"default=false"`
	MaintenanceModeDuringUpgradeAlwaysDisabledGAIDs []string `envconfig:"-"`
}

func (*Config) IsTrialConfigured

func (c *Config) IsTrialConfigured() bool

func (*Config) ReadMaintenanceModeDuringUpgradeAlwaysDisabledGAIDsFromYaml

func (c *Config) ReadMaintenanceModeDuringUpgradeAlwaysDisabledGAIDsFromYaml(yamlFilePath string) error

type Delegator

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

func NewDelegator

func NewDelegator(client *Client, avsConfig Config, os storage.Operations) *Delegator

func (*Delegator) AddTags

func (del *Delegator) AddTags(log logrus.FieldLogger, operation internal.Operation, evalAssistant EvalAssistant, tags []*Tag) (internal.Operation, time.Duration, error)

func (*Delegator) CreateEvaluation

func (del *Delegator) CreateEvaluation(log logrus.FieldLogger, operation internal.Operation, evalAssistant EvalAssistant, url string) (internal.Operation, time.Duration, error)

func (*Delegator) DeleteAvsEvaluation

func (del *Delegator) DeleteAvsEvaluation(deProvisioningOperation internal.Operation, logger logrus.FieldLogger, assistant EvalAssistant) (internal.Operation, error)

func (*Delegator) RefreshStatus

func (del *Delegator) RefreshStatus(log logrus.FieldLogger, lifecycleData *internal.AvsLifecycleData, evalAssistant EvalAssistant) string

RefreshStatus ensures that operation AVS lifecycle data is fetched from Avs API

func (*Delegator) ResetStatus

func (del *Delegator) ResetStatus(log logrus.FieldLogger, lifecycleData *internal.AvsLifecycleData, evalAssistant EvalAssistant) error

func (*Delegator) SetStatus

func (del *Delegator) SetStatus(log logrus.FieldLogger, lifecycleData *internal.AvsLifecycleData, evalAssistant EvalAssistant, status string) error

type EvalAssistant

type EvalAssistant interface {
	CreateBasicEvaluationRequest(operations internal.Operation, url string) (*BasicEvaluationCreateRequest, error)
	IsAlreadyCreated(lifecycleData internal.AvsLifecycleData) bool
	IsValid(lifecycleData internal.AvsLifecycleData) bool
	IsInMaintenance(lifecycleData internal.AvsLifecycleData) bool
	SetEvalId(lifecycleData *internal.AvsLifecycleData, evalId int64)
	SetEvalStatus(lifecycleData *internal.AvsLifecycleData, status string)
	GetEvalStatus(lifecycleData internal.AvsLifecycleData) string
	GetOriginalEvalStatus(lifecycleData internal.AvsLifecycleData) string
	IsAlreadyDeletedOrEmpty(lifecycleData internal.AvsLifecycleData) bool
	GetEvaluationId(lifecycleData internal.AvsLifecycleData) int64
	ProvideParentId(pp internal.ProvisioningParameters) int64
	SetDeleted(lifecycleData *internal.AvsLifecycleData, deleted bool)
	// contains filtered or unexported methods
}

type EvaluationManager

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

func NewEvaluationManager

func NewEvaluationManager(delegator *Delegator, config Config) *EvaluationManager

func (*EvaluationManager) HasMonitors

func (em *EvaluationManager) HasMonitors(avsData internal.AvsLifecycleData) bool

func (*EvaluationManager) InMaintenance

func (em *EvaluationManager) InMaintenance(avsData internal.AvsLifecycleData) bool

func (*EvaluationManager) IsMaintenanceModeApplicableForGAID

func (em *EvaluationManager) IsMaintenanceModeApplicableForGAID(gaID string) bool

func (*EvaluationManager) IsMaintenanceModeDisabled

func (em *EvaluationManager) IsMaintenanceModeDisabled() bool

func (*EvaluationManager) RestoreStatus

func (em *EvaluationManager) RestoreStatus(avsData *internal.AvsLifecycleData, logger logrus.FieldLogger) error

RestoreStatus reverts previously set evaluation monitors status. On error, parent method should fail the operation progress. On delay, parent method should retry.

func (*EvaluationManager) SetMaintenanceStatus

func (em *EvaluationManager) SetMaintenanceStatus(avsData *internal.AvsLifecycleData, logger logrus.FieldLogger) error

func (*EvaluationManager) SetStatus

func (em *EvaluationManager) SetStatus(status string, avsData *internal.AvsLifecycleData, logger logrus.FieldLogger) error

SetStatus updates evaluation monitors (internal and external) status.

type ExternalEvalAssistant

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

func NewExternalEvalAssistant

func NewExternalEvalAssistant(avsConfig Config) *ExternalEvalAssistant

func (*ExternalEvalAssistant) CreateBasicEvaluationRequest

func (eea *ExternalEvalAssistant) CreateBasicEvaluationRequest(operations internal.Operation, url string) (*BasicEvaluationCreateRequest, error)

func (*ExternalEvalAssistant) GetEvalStatus

func (eea *ExternalEvalAssistant) GetEvalStatus(lifecycleData internal.AvsLifecycleData) string

func (*ExternalEvalAssistant) GetEvaluationId

func (eea *ExternalEvalAssistant) GetEvaluationId(lifecycleData internal.AvsLifecycleData) int64

func (*ExternalEvalAssistant) GetOriginalEvalStatus

func (eea *ExternalEvalAssistant) GetOriginalEvalStatus(lifecycleData internal.AvsLifecycleData) string

func (*ExternalEvalAssistant) IsAlreadyCreated

func (eea *ExternalEvalAssistant) IsAlreadyCreated(lifecycleData internal.AvsLifecycleData) bool

func (*ExternalEvalAssistant) IsAlreadyDeletedOrEmpty

func (eea *ExternalEvalAssistant) IsAlreadyDeletedOrEmpty(lifecycleData internal.AvsLifecycleData) bool

func (*ExternalEvalAssistant) IsInMaintenance

func (eea *ExternalEvalAssistant) IsInMaintenance(lifecycleData internal.AvsLifecycleData) bool

func (*ExternalEvalAssistant) IsValid

func (eea *ExternalEvalAssistant) IsValid(lifecycleData internal.AvsLifecycleData) bool

func (*ExternalEvalAssistant) ProvideCheckType

func (eea *ExternalEvalAssistant) ProvideCheckType() string

func (*ExternalEvalAssistant) ProvideGroupId

func (*ExternalEvalAssistant) ProvideNewOrDefaultServiceName

func (eea *ExternalEvalAssistant) ProvideNewOrDefaultServiceName(defaultServiceName string) string

func (*ExternalEvalAssistant) ProvideParentId

func (*ExternalEvalAssistant) ProvideSuffix

func (eea *ExternalEvalAssistant) ProvideSuffix() string

func (*ExternalEvalAssistant) ProvideTags

func (eea *ExternalEvalAssistant) ProvideTags() []*Tag

func (*ExternalEvalAssistant) ProvideTesterAccessId

func (eea *ExternalEvalAssistant) ProvideTesterAccessId(_ internal.ProvisioningParameters) int64

func (*ExternalEvalAssistant) SetDeleted

func (eea *ExternalEvalAssistant) SetDeleted(lifecycleData *internal.AvsLifecycleData, deleted bool)

func (*ExternalEvalAssistant) SetEvalId

func (eea *ExternalEvalAssistant) SetEvalId(lifecycleData *internal.AvsLifecycleData, evalId int64)

func (*ExternalEvalAssistant) SetEvalStatus

func (eea *ExternalEvalAssistant) SetEvalStatus(lifecycleData *internal.AvsLifecycleData, status string)

type InternalEvalAssistant

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

func NewInternalEvalAssistant

func NewInternalEvalAssistant(avsConfig Config) *InternalEvalAssistant

func (*InternalEvalAssistant) CreateBasicEvaluationRequest

func (iec *InternalEvalAssistant) CreateBasicEvaluationRequest(operations internal.Operation, url string) (*BasicEvaluationCreateRequest, error)

func (*InternalEvalAssistant) GetEvalStatus

func (iec *InternalEvalAssistant) GetEvalStatus(lifecycleData internal.AvsLifecycleData) string

func (*InternalEvalAssistant) GetEvaluationId

func (iec *InternalEvalAssistant) GetEvaluationId(lifecycleData internal.AvsLifecycleData) int64

func (*InternalEvalAssistant) GetOriginalEvalStatus

func (iec *InternalEvalAssistant) GetOriginalEvalStatus(lifecycleData internal.AvsLifecycleData) string

func (*InternalEvalAssistant) IsAlreadyCreated

func (iec *InternalEvalAssistant) IsAlreadyCreated(lifecycleData internal.AvsLifecycleData) bool

func (*InternalEvalAssistant) IsAlreadyDeletedOrEmpty

func (iec *InternalEvalAssistant) IsAlreadyDeletedOrEmpty(lifecycleData internal.AvsLifecycleData) bool

func (*InternalEvalAssistant) IsInMaintenance

func (iec *InternalEvalAssistant) IsInMaintenance(lifecycleData internal.AvsLifecycleData) bool

func (*InternalEvalAssistant) IsValid

func (iec *InternalEvalAssistant) IsValid(lifecycleData internal.AvsLifecycleData) bool

func (*InternalEvalAssistant) ProvideCheckType

func (iec *InternalEvalAssistant) ProvideCheckType() string

func (*InternalEvalAssistant) ProvideGroupId

func (*InternalEvalAssistant) ProvideNewOrDefaultServiceName

func (iec *InternalEvalAssistant) ProvideNewOrDefaultServiceName(defaultServiceName string) string

func (*InternalEvalAssistant) ProvideParentId

func (*InternalEvalAssistant) ProvideSuffix

func (iec *InternalEvalAssistant) ProvideSuffix() string

func (*InternalEvalAssistant) ProvideTags

func (iec *InternalEvalAssistant) ProvideTags() []*Tag

func (*InternalEvalAssistant) ProvideTesterAccessId

func (iec *InternalEvalAssistant) ProvideTesterAccessId(pp internal.ProvisioningParameters) int64

func (*InternalEvalAssistant) SetDeleted

func (iec *InternalEvalAssistant) SetDeleted(lifecycleData *internal.AvsLifecycleData, deleted bool)

func (*InternalEvalAssistant) SetEvalId

func (iec *InternalEvalAssistant) SetEvalId(lifecycleData *internal.AvsLifecycleData, evalId int64)

func (*InternalEvalAssistant) SetEvalStatus

func (iec *InternalEvalAssistant) SetEvalStatus(lifecycleData *internal.AvsLifecycleData, status string)

type MockAvsEvaluationRepository

type MockAvsEvaluationRepository struct {
	BasicEvals   map[int64]*BasicEvaluationCreateResponse
	EvalSet      map[int64]bool
	ParentIDrefs map[int64][]int64
}

MockAvsEvaluationRepository represents BasicEvaluations in AVS where BasicEvals is mapping BasicEvaluation ID to BasicEvaluation (Subevaluation) definition and ParentIDrefs is mapping CompoundEvaluation ID (parentID) to BasicEvaluations (Subevaluations) IDs

type MockAvsServer

type MockAvsServer struct {
	T            *testing.T
	Evaluations  *MockAvsEvaluationRepository
	TokenExpired int
}

func NewMockAvsServer

func NewMockAvsServer(t *testing.T) *MockAvsServer

type ModelConfigurator

type ModelConfigurator interface {
	ProvideSuffix() string
	ProvideTesterAccessId(pp internal.ProvisioningParameters) int64
	ProvideGroupId(pp internal.ProvisioningParameters) int64
	ProvideParentId(pp internal.ProvisioningParameters) int64
	ProvideTags() []*Tag
	ProvideNewOrDefaultServiceName(defaultServiceName string) string
	ProvideCheckType() string
}

type RetryConfig

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

type Tag

type Tag struct {
	Content      string `json:"content"`
	TagClassId   int    `json:"tag_class_id"`
	TagClassName string `json:"tag_class_name"`
}

func FixTag

func FixTag() *Tag

Jump to

Keyboard shortcuts

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