Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateDynamicResourceName() string
- func ResourceTypeNotFoundMessage(rType string) string
- func ValidateConfig(config *BoskosConfig) error
- type BoskosConfig
- type CommaSeparatedStrings
- type ConfigType
- type DRLCByName
- type Duration
- type DynamicResourceLifeCycle
- type LeasedResources
- type Metric
- type Resource
- type ResourceByName
- type ResourceEntry
- type ResourceNeeds
- type TypeToResources
- type UserData
- func (ud *UserData) Extract(id string, out interface{}) error
- func (ud *UserData) FromMap(m UserDataMap)
- func (ud *UserData) MarshalJSON() ([]byte, error)
- func (ud *UserData) Set(id string, in interface{}) error
- func (ud *UserData) ToMap() UserDataMap
- func (ud *UserData) UnmarshalJSON(data []byte) error
- func (ud *UserData) Update(new *UserData) *UserData
- type UserDataMap
- type UserDataNotFound
Constants ¶
const ( // Busy state defines a resource being used. Busy = "busy" // Cleaning state defines a resource being cleaned Cleaning = "cleaning" // Dirty state defines a resource that needs cleaning Dirty = "dirty" // Free state defines a resource that is usable Free = "free" // Leased state defines a resource being leased in order to make a new resource Leased = "leased" // ToBeDeleted is used for resources about to be deleted, they will be verified by a cleaner which mark them as tombstone ToBeDeleted = "toBeDeleted" // Tombstone is the state in which a resource can safely be deleted Tombstone = "tombstone" // Other is used to agglomerate unspecified states for metrics reporting Other = "other" )
Variables ¶
var ( // KnownStates is the set of all known states, excluding "other". KnownStates = []string{ Busy, Cleaning, Dirty, Free, Leased, ToBeDeleted, Tombstone, } )
Functions ¶
func GenerateDynamicResourceName ¶
func GenerateDynamicResourceName() string
GenerateDynamicResourceName generates a unique name for dynamic resources
func ValidateConfig ¶
func ValidateConfig(config *BoskosConfig) error
ValidateConfig validates config with existing resources In: boskosConfig - a boskos config defining resources Out: nil on success, error on failure
Types ¶
type BoskosConfig ¶
type BoskosConfig struct {
Resources []ResourceEntry `json:"resources"`
}
BoskosConfig defines config used by boskos server
func ParseConfig ¶
func ParseConfig(configPath string) (*BoskosConfig, error)
ParseConfig reads in configPath and returns a list of resource objects on success.
type CommaSeparatedStrings ¶
type CommaSeparatedStrings []string
CommaSeparatedStrings is used to parse comma separated string flag into a list of strings
func (*CommaSeparatedStrings) Set ¶
func (r *CommaSeparatedStrings) Set(value string) error
Set parses the flag value into a CommaSeparatedStrings
func (*CommaSeparatedStrings) String ¶
func (r *CommaSeparatedStrings) String() string
func (*CommaSeparatedStrings) Type ¶
func (r *CommaSeparatedStrings) Type() string
type ConfigType ¶
type ConfigType struct { // Identifier of the struct this maps back to Type string `json:"type,omitempty"` // Marshaled JSON content Content string `json:"content,omitempty"` }
ConfigType gather the type of config to be applied by Mason in order to construct the resource
type DRLCByName ¶
type DRLCByName []DynamicResourceLifeCycle
DRLCByName helps sorting ResourcesConfig by name
func (DRLCByName) Len ¶
func (ut DRLCByName) Len() int
func (DRLCByName) Less ¶
func (ut DRLCByName) Less(i, j int) bool
func (DRLCByName) Swap ¶
func (ut DRLCByName) Swap(i, j int)
type Duration ¶
Duration is a wrapper around time.Duration that parses times in either 'integer number of nanoseconds' or 'duration string' formats and serializes to 'duration string' format.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implement the JSON Unmarshaler interface in order to be able parse string to time.Duration.
type DynamicResourceLifeCycle ¶
type DynamicResourceLifeCycle struct { Type string `json:"type"` // Initial state to be created as InitialState string `json:"state"` // Minimum number of resources to be use as a buffer. // Resources in the process of being deleted and cleaned up are included in this count. MinCount int `json:"min-count"` // Maximum number of resources expected. This maximum may be temporarily // exceeded while resources are in the process of being deleted, though this // is only expected when MaxCount is lowered. MaxCount int `json:"max-count"` // Lifespan of a resource, time after which the resource should be reset. LifeSpan *time.Duration `json:"lifespan,omitempty"` // Config information about how to create the object Config ConfigType `json:"config,omitempty"` // Needs define the resource needs to create the object Needs ResourceNeeds `json:"needs,omitempty"` }
DynamicResourceLifeCycle defines the life cycle of a dynamic resource. All Resource of a given type will be constructed using the same configuration
func NewDynamicResourceLifeCycleFromConfig ¶
func NewDynamicResourceLifeCycleFromConfig(e ResourceEntry) DynamicResourceLifeCycle
NewDynamicResourceLifeCycleFromConfig parse the a ResourceEntry into a DynamicResourceLifeCycle
type LeasedResources ¶
type LeasedResources []string
LeasedResources is a list of resources name that used in order to create another resource by Mason
type Metric ¶
type Metric struct { Type string `json:"type"` Current map[string]int `json:"current"` Owners map[string]int `json:"owner"` }
Metric contains analytics about a specific resource type
type Resource ¶
type Resource struct { Type string `json:"type"` Name string `json:"name"` State string `json:"state"` Owner string `json:"owner"` LastUpdate time.Time `json:"lastupdate"` // Customized UserData UserData *UserData `json:"userdata"` // Used to clean up dynamic resources ExpirationDate *time.Time `json:"expiration-date,omitempty"` }
Resource abstracts any resource type that can be tracked by boskos
func NewResource ¶
NewResource creates a new Boskos Resource.
func NewResourcesFromConfig ¶
func NewResourcesFromConfig(e ResourceEntry) []Resource
NewResourcesFromConfig parse the a ResourceEntry into a list of resources
type ResourceByName ¶
type ResourceByName []Resource
ResourceByName helps sorting resources by name
func (ResourceByName) Len ¶
func (ut ResourceByName) Len() int
func (ResourceByName) Less ¶
func (ut ResourceByName) Less(i, j int) bool
func (ResourceByName) Swap ¶
func (ut ResourceByName) Swap(i, j int)
type ResourceEntry ¶
type ResourceEntry struct { Type string `json:"type"` State string `json:"state"` Names []string `json:"names"` MaxCount int `json:"max-count,omitempty"` MinCount int `json:"min-count,omitempty"` LifeSpan *Duration `json:"lifespan,omitempty"` Config ConfigType `json:"config,omitempty"` Needs ResourceNeeds `json:"needs,omitempty"` }
ResourceEntry is resource config format defined from config.yaml
func (*ResourceEntry) IsDRLC ¶
func (re *ResourceEntry) IsDRLC() bool
type ResourceNeeds ¶
ResourceNeeds maps the type to count of resources types needed
type TypeToResources ¶
TypeToResources stores all the leased resources with the same type f
func (TypeToResources) Copy ¶
func (t TypeToResources) Copy() TypeToResources
Copy returns a copy of the TypeToResources
type UserData ¶
UserData is a map of Name to user defined interface, serialized into a string
func UserDataFromMap ¶
func UserDataFromMap(m UserDataMap) *UserData
UserDataFromMap returns a UserData from a map
func (*UserData) FromMap ¶
func (ud *UserData) FromMap(m UserDataMap)
FromMap feels updates user data from a map
func (*UserData) MarshalJSON ¶
MarshalJSON implements JSON Marshaler interface
func (*UserData) ToMap ¶
func (ud *UserData) ToMap() UserDataMap
ToMap converts a UserData to UserDataMap
func (*UserData) UnmarshalJSON ¶
UnmarshalJSON implements JSON Unmarshaler interface
type UserDataMap ¶
UserDataMap is the standard Map version of UserMap, it is used to ease UserMap creation.
type UserDataNotFound ¶
type UserDataNotFound struct {
ID string
}
UserDataNotFound will be returned if requested resource does not exist.
func (*UserDataNotFound) Error ¶
func (ud *UserDataNotFound) Error() string