workermodel

package
v0.54.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoadOptions = struct {
	Default          LoadOptionFunc
	WithGroup        LoadOptionFunc
	WithCapabilities LoadOptionFunc
}{
	Default:          loadDefault,
	WithGroup:        loadGroup,
	WithCapabilities: loadCapabilities,
}

LoadOptions provides all options to load worker models.

Functions

func BookForRegister

func BookForRegister(store cache.Store, id int64, serviceID int64) error

BookForRegister books a worker model for register, used by hatcheries

func ComputeRegistrationNeeds

func ComputeRegistrationNeeds(db gorp.SqlExecutor, allBinaryReqs sdk.RequirementList, reqs sdk.RequirementList) error

ComputeRegistrationNeeds checks if worker models need to be register if requirements contains "binary" type: all workers model need to be registered again by setting flag need_registration to true in DB.

func CopyModelTypeData

func CopyModelTypeData(old, data *sdk.Model) error

CopyModelTypeData try to set missing type info for given model data.

func Create

Create returns a new worker model for given data.

func DeleteByID

func DeleteByID(db gorp.SqlExecutor, id int64) error

DeleteByID a worker model from database and all its capabilities.

func DeleteCapabilitiesByModelID

func DeleteCapabilitiesByModelID(db gorp.SqlExecutor, workerModelID int64) error

DeleteCapabilitiesByModelID removes all capabilities from database for given worker model id.

func DeletePatternByID

func DeletePatternByID(db gorp.SqlExecutor, patternID int64) error

DeletePatternByID removes from database the worker model pattern.

func DeleteSecretForModelID

func DeleteSecretForModelID(db gorp.SqlExecutor, workerModelID int64, field string) error

DeleteSecretForModelID remove registry secret from database for given model.

func Export

Export convert sdk.Model to an exportentities.WorkerModel, format and write into a io.Writer

func Initialize

func Initialize(c context.Context, DBFunc func() *gorp.DbMap, store cache.Store) error

Initialize worker model package.

func Insert

func Insert(ctx context.Context, db gorpmapper.SqlExecutorWithTx, model *sdk.Model) error

Insert a new worker model in database.

func InsertCapabilityForModelID

func InsertCapabilityForModelID(db gorp.SqlExecutor, workerModelID int64, r *sdk.Requirement) error

InsertCapabilityForModelID inserts given capability in database.

func InsertPattern

func InsertPattern(db gorp.SqlExecutor, modelPattern *sdk.ModelPattern) error

InsertPattern in database.

func InsertSecret

InsertSecret in database.

func KeyBookWorkerModel

func KeyBookWorkerModel(id int64) string

KeyBookWorkerModel returns cache key for given model id.

func LoadAll

func LoadAll(ctx context.Context, db gorp.SqlExecutor, filter *LoadFilter, opts ...LoadOptionFunc) ([]sdk.Model, error)

LoadAll retrieves worker models from database.

func LoadAllActiveAndNotDeprecatedForGroupIDs

func LoadAllActiveAndNotDeprecatedForGroupIDs(ctx context.Context, db gorp.SqlExecutor, groupIDs []int64, opts ...LoadOptionFunc) ([]sdk.Model, error)

LoadAllActiveAndNotDeprecatedForGroupIDs retrieves models for given group ids.

func LoadAllByGroupIDs

func LoadAllByGroupIDs(ctx context.Context, db gorp.SqlExecutor, groupIDs []int64, filter *LoadFilter, opts ...LoadOptionFunc) ([]sdk.Model, error)

LoadAllByGroupIDs returns worker models list for given group ids.

func LoadAllByNameAndGroupIDs

func LoadAllByNameAndGroupIDs(ctx context.Context, db gorp.SqlExecutor, name string, groupIDs []int64, opts ...LoadOptionFunc) ([]sdk.Model, error)

LoadAllByNameAndGroupIDs retrieves all worker model with given name for group ids in database.

func LoadAllUsableByGroupIDs

func LoadAllUsableByGroupIDs(ctx context.Context, db gorp.SqlExecutor, groupIDs []int64, opts ...LoadOptionFunc) ([]sdk.Model, error)

LoadAllUsableByGroupIDs returns usable worker models for given group ids.

func LoadByID

func LoadByID(ctx context.Context, db gorp.SqlExecutor, id int64, opts ...LoadOptionFunc) (*sdk.Model, error)

LoadByID retrieves a specific worker model in database.

func LoadByNameAndGroupID

func LoadByNameAndGroupID(ctx context.Context, db gorp.SqlExecutor, name string, groupID int64, opts ...LoadOptionFunc) (*sdk.Model, error)

LoadByNameAndGroupID retrieves a specific worker model in database by name and group id.

func LoadCapabilitiesByModelID

func LoadCapabilitiesByModelID(ctx context.Context, db gorp.SqlExecutor, workerModelID int64) (sdk.RequirementList, error)

LoadCapabilitiesByModelID retrieves capabilities of given worker model.

func LoadPatternByNameAndType

func LoadPatternByNameAndType(ctx context.Context, db gorp.SqlExecutor, patternType, patternName string) (*sdk.ModelPattern, error)

LoadPatternByNameAndType retrieves model patterns from database given its name and type.

func LoadPatterns

func LoadPatterns(ctx context.Context, db gorp.SqlExecutor) ([]sdk.ModelPattern, error)

LoadPatterns retrieves model patterns from database.

func LoadSecretByModelIDAndName

func LoadSecretByModelIDAndName(ctx context.Context, db gorp.SqlExecutor, workerModelID int64, name string) (*sdk.WorkerModelSecret, error)

LoadSecretByModelIDAndName retrieves a worker model secret for given model id and secret name.

func LoadSecretsByModelID

func LoadSecretsByModelID(ctx context.Context, db gorp.SqlExecutor, workerModelID int64) (sdk.WorkerModelSecrets, error)

LoadSecretsByModelID retrieves all worker model secrets for given model id.

func Status

func Status(db *gorp.DbMap) sdk.MonitoringStatusLine

Status returns info about worker Model Status

func UnbookForRegister

func UnbookForRegister(ctx context.Context, store cache.Store, id int64)

UnbookForRegister release the book

func Update

func Update(ctx context.Context, db gorpmapper.SqlExecutorWithTx, old *sdk.Model, data sdk.Model) (*sdk.Model, error)

Update from given data.

func UpdateCapabilities

func UpdateCapabilities(ctx context.Context, db gorp.SqlExecutor, modelID int64, registrationForm sdk.WorkerRegistrationForm) error

UpdateCapabilities .

func UpdateDB

func UpdateDB(ctx context.Context, db gorpmapper.SqlExecutorWithTx, model *sdk.Model) error

UpdateDB a worker model if the worker model have SpawnErr -> clear them.

func UpdateOSAndArch

func UpdateOSAndArch(db gorp.SqlExecutor, modelID int64, OS, arch string) error

UpdateOSAndArch updates os and arch for a worker model.

func UpdatePattern

func UpdatePattern(db gorp.SqlExecutor, modelPattern *sdk.ModelPattern) error

UpdatePattern in database.

func UpdateRegistration

func UpdateRegistration(ctx context.Context, db gorp.SqlExecutor, store cache.Store, modelID int64) error

UpdateRegistration updates need_registration to false and last_registration time, reset err registration.

func UpdateSecret

UpdateSecret in database.

func UpdateSpawnErrorWorkerModel

func UpdateSpawnErrorWorkerModel(db gorp.SqlExecutor, modelID int64, spawnError sdk.SpawnErrorForm) error

UpdateSpawnErrorWorkerModel updates worker model error registration

Types

type LoadFilter

type LoadFilter struct {
	Binary string
	State  StateFilter
}

LoadFilter struct for worker model query.

func (LoadFilter) Args

func (l LoadFilter) Args() gorpmapper.ArgsMap

Args returns sql args for current filter.

func (LoadFilter) SQL

func (l LoadFilter) SQL() string

SQL returns the raw sql for current filter.

type LoadOptionFunc

type LoadOptionFunc func(context.Context, gorp.SqlExecutor, ...*sdk.Model) error

LoadOptionFunc for worker model.

type StateFilter

type StateFilter string

StateFilter for worker model.

const (
	StateError      StateFilter = "error"
	StateDisabled   StateFilter = "disabled"
	StateRegister   StateFilter = "register"
	StateDeprecated StateFilter = "deprecated"
	StateActive     StateFilter = "active"
	StateOfficial   StateFilter = "official"
)

List of const for state filter.

func (StateFilter) IsValid

func (s StateFilter) IsValid() error

IsValid returns an error if the state value is not valid.

Jump to

Keyboard shortcuts

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