castellum

package
v1.11.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// OperationStateDidNotExist is a bogus state for transitions where there is no
	// previous state.
	OperationStateDidNotExist OperationState = "none"
	// OperationStateCreated is a PendingOperation with ConfirmedAt == nil.
	OperationStateCreated OperationState = "created"
	// OperationStateConfirmed is a PendingOperation with ConfirmedAt != nil && GreenlitAt == nil.
	OperationStateConfirmed OperationState = "confirmed"
	// OperationStateGreenlit is a PendingOperation with ConfirmedAt != nil && GreenlitAt != nil.
	OperationStateGreenlit OperationState = "greenlit"
	// OperationStateCancelled is a FinishedOperation with OperationOutcomeCancelled.
	OperationStateCancelled = OperationState(OperationOutcomeCancelled)
	// OperationStateSucceeded is a FinishedOperation with OperationOutcomeSucceeded.
	OperationStateSucceeded = OperationState(OperationOutcomeSucceeded)
	// OperationStateFailed is a FinishedOperation with OperationOutcomeFailed.
	OperationStateFailed = OperationState(OperationOutcomeFailed)
	// OperationStateErrored is a FinishedOperation with OperationOutcomeErrored.
	OperationStateErrored = OperationState(OperationOutcomeErrored)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	UUID               string                 `json:"id"`
	Size               uint64                 `json:"size,omitempty"`
	UsagePercent       UsageValues            `json:"usage_percent"`
	MinimumSize        *uint64                `json:"min_size,omitempty"`
	MaximumSize        *uint64                `json:"max_size,omitempty"`
	Checked            *Checked               `json:"checked,omitempty"`
	Stale              bool                   `json:"stale"`
	PendingOperation   *StandaloneOperation   `json:"pending_operation,omitempty"`
	FinishedOperations *[]StandaloneOperation `json:"finished_operations,omitempty"`
}

Asset is the API representation of an asset.

type AssetResizeError

type AssetResizeError struct {
	AssetUUID   string           `json:"asset_id"`
	ProjectUUID string           `json:"project_id,omitempty"`
	DomainUUID  string           `json:"domain_id"`
	AssetType   string           `json:"asset_type"`
	OldSize     uint64           `json:"old_size,omitempty"`
	NewSize     uint64           `json:"new_size,omitempty"`
	Finished    *OperationFinish `json:"finished,omitempty"`
}

AssetResizeError is the API representation for an asset resize error.

type AssetScrapeError

type AssetScrapeError struct {
	AssetUUID   string   `json:"asset_id"`
	ProjectUUID string   `json:"project_id,omitempty"`
	DomainUUID  string   `json:"domain_id"`
	AssetType   string   `json:"asset_type"`
	Checked     *Checked `json:"checked,omitempty"`
}

AssetScrapeError is the API representation for an asset scrape error.

type Checked

type Checked struct {
	ErrorMessage string `json:"error,omitempty"`
}

Checked appears in type Asset and Resource.

type Operation

type Operation struct {
	State     OperationState         `json:"state"`
	Reason    OperationReason        `json:"reason"`
	OldSize   uint64                 `json:"old_size"`
	NewSize   uint64                 `json:"new_size"`
	Created   OperationCreation      `json:"created"`
	Confirmed *OperationConfirmation `json:"confirmed,omitempty"`
	Greenlit  *OperationGreenlight   `json:"greenlit,omitempty"`
	Finished  *OperationFinish       `json:"finished,omitempty"`
}

StandaloneOperation is the API representation for a pending or finished resize operation when the operation appears within its respective asset.

type OperationConfirmation

type OperationConfirmation struct {
	AtUnix int64 `json:"at"`
}

OperationConfirmation appears in type Operation.

type OperationCreation

type OperationCreation struct {
	AtUnix       int64       `json:"at"`
	UsagePercent UsageValues `json:"usage_percent"`
}

OperationCreation appears in type Operation.

type OperationFinish

type OperationFinish struct {
	AtUnix       int64  `json:"at"`
	ErrorMessage string `json:"error,omitempty"`
}

OperationFinish appears in type Operation.

type OperationGreenlight

type OperationGreenlight struct {
	AtUnix     int64   `json:"at"`
	ByUserUUID *string `json:"by_user,omitempty"`
}

OperationGreenlight appears in type Operation.

type OperationOutcome

type OperationOutcome string

OperationOutcome is an enumeration type for possible outcomes for a resize operation.

const (
	// OperationOutcomeSucceeded indicates that a resize operation was completed
	// successfully.
	OperationOutcomeSucceeded OperationOutcome = "succeeded"
	// OperationOutcomeFailed indicates that a resize operation failed because of a problem on the side of the user (e.g. insufficient quota).
	OperationOutcomeFailed OperationOutcome = "failed"
	// OperationOutcomeErrored indicates that a resize operation errored because of a problem in OpenStack.
	OperationOutcomeErrored OperationOutcome = "errored"
	// OperationOutcomeCancelled indicates that a resize operation was cancelled. This happens when usage falls back into normal
	OperationOutcomeCancelled OperationOutcome = "cancelled"
)

type OperationReason

type OperationReason string

OperationReason is an enumeration type for possible reasons for a resize operation.

const (
	// OperationReasonCritical indicates that the resize operation was triggered
	// because the asset's usage exceeded the critical threshold.
	OperationReasonCritical OperationReason = "critical"
	// OperationReasonHigh indicates that the resize operation was triggered
	// because the asset's usage exceeded the high threshold.
	OperationReasonHigh OperationReason = "high"
	// OperationReasonLow indicates that the resize operation was triggered
	// because the asset's usage deceeded the low threshold.
	OperationReasonLow OperationReason = "low"
)

type OperationState

type OperationState string

OperationState is an enumeration type for all possible states of an operation.

type Resource

type Resource struct {
	// fields that only appear in GET responses
	Checked    *Checked `json:"checked,omitempty" yaml:"-"`
	AssetCount int64    `json:"asset_count" yaml:"-"`

	// fields that are also allowed in PUT requests
	ConfigJSON        *json.RawMessage `json:"config,omitempty" yaml:"config,omitempty"`
	LowThreshold      *Threshold       `json:"low_threshold,omitempty" yaml:"low_threshold,omitempty"`
	HighThreshold     *Threshold       `json:"high_threshold,omitempty" yaml:"high_threshold,omitempty"`
	CriticalThreshold *Threshold       `json:"critical_threshold,omitempty" yaml:"critical_threshold,omitempty"`
	SizeConstraints   *SizeConstraints `json:"size_constraints,omitempty" yaml:"size_constraints,omitempty"`
	SizeSteps         SizeSteps        `json:"size_steps" yaml:"size_steps"`
}

Resource is the API representation of a resource.

This type also has YAML annotations because it appears in Castellum's configuration file.

type ResourceScrapeError

type ResourceScrapeError struct {
	ProjectUUID string  `json:"project_id,omitempty"`
	DomainUUID  string  `json:"domain_id"`
	AssetType   string  `json:"asset_type"`
	Checked     Checked `json:"checked"`
}

ResourceScrapeError is the API representation for a resource scrape error.

type SizeConstraints

type SizeConstraints struct {
	Minimum     *uint64 `json:"minimum,omitempty" yaml:"minimum,omitempty"`
	Maximum     *uint64 `json:"maximum,omitempty" yaml:"maximum,omitempty"`
	MinimumFree *uint64 `json:"minimum_free,omitempty" yaml:"minimum_free,omitempty"`
}

SizeConstraints appears in type Resource.

type SizeSteps

type SizeSteps struct {
	Percent float64 `json:"percent,omitempty" yaml:"percent,omitempty"`
	Single  bool    `json:"single,omitempty" yaml:"single,omitempty"`
}

SizeSteps appears in type Resource.

type StandaloneOperation

type StandaloneOperation struct {
	Operation
	ProjectUUID string `json:"project_id,omitempty"`
	AssetType   string `json:"asset_type,omitempty"`
	AssetID     string `json:"asset_id,omitempty"`
}

StandaloneOperation is the API representation for a pending or finished resize operation when the operation stands on its one or within a larger list of operations.

type Threshold

type Threshold struct {
	UsagePercent UsageValues `json:"usage_percent" yaml:"usage_percent"`
	DelaySeconds uint32      `json:"delay_seconds,omitempty" yaml:"delay_seconds,omitempty"`
}

Threshold appears in type Resource.

type UsageMetric

type UsageMetric string

UsageMetric identifies a particular usage value for an asset.

const SingularUsageMetric UsageMetric = "singular"

SingularUsageMetric is the UsageMetric value for assets that have only one usage metric. For example, project-quota assets only have a single usage value reported by Limes, so the only key in type UsageValues will be SingularUsageMetric. By contrast, server group assets have two usage values (for CPU and RAM usage, respectively), so SingularUsageMetric is not used.

type UsageValues

type UsageValues map[UsageMetric]float64

UsageValues contains all usage values for an asset at a particular point in time.

func (UsageValues) IsNonZero

func (u UsageValues) IsNonZero() bool

IsNonZero returns true if any usage value in this set is not zero.

func (UsageValues) MarshalJSON

func (u UsageValues) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

This marshalling is only used in API responses. Serialization into the database bypasses it and always marshals a map, even for singular values.

func (*UsageValues) Scan

func (u *UsageValues) Scan(src any) error

Scan implements the sql.Scanner interface.

func (*UsageValues) UnmarshalJSON

func (u *UsageValues) UnmarshalJSON(buf []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

This unmarshalling is only used in API requests. Deserialization from the database bypasses it and always requires a map-shaped input, even for singular values.

func (UsageValues) Value

func (u UsageValues) Value() (driver.Value, error)

Value implements the sql/driver.Valuer interface.

Jump to

Keyboard shortcuts

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