Help us shape the future of Go! Take the 2026 Go Developer Survey

updater

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flavor

type Flavor struct {
	Name         string
	ProviderID   int
	ProviderName string
	CPU          int
	Mem          float64
	Disk         float64
	Bandwidth    int
	GPU          string
	GPUMem       int
	// GPUCount is the number of GPU devices the flavor exposes
	// (parsed from the "NxModel" prefix of GPU, e.g. "4xTesla K80"
	// → 4). 0 for CPU-only flavors. HasGPU == (GPUCount >= 1) is
	// maintained alongside for back-compat with the binary fit
	// predicate; new code reads GPUCount.
	GPUCount     int
	HasGPU       bool
	HasQuickDisk bool
}

Flavor represents a compute flavor.

type FlavorFilter added in v0.8.1

type FlavorFilter struct {
	Includes []*regexp.Regexp
	Excludes []*regexp.Regexp
}

FlavorFilter applies operator-configured include/exclude regex rules to flavor names at sync time. See memory/project_recruitment_followups.md for the design rationale.

Logic:

  • If `Includes` is empty: every name passes the include gate.
  • Otherwise: a name must match at least one Includes pattern.
  • If `Excludes` is empty: nothing is excluded.
  • Otherwise: a name matching ANY Excludes pattern is rejected.
  • Net: a name is allowed iff include-passes AND exclude-doesn't-match.

func CompileFlavorFilter added in v0.8.1

func CompileFlavorFilter(includes, excludes []string) (*FlavorFilter, error)

CompileFlavorFilter builds a FlavorFilter from the YAML pattern lists. Compilation errors are returned wrapped with which pattern failed and in which list, so the operator can spot a typo without grepping logs.

func (*FlavorFilter) Allows added in v0.8.1

func (f *FlavorFilter) Allows(name string) bool

Allows returns true if the flavor name passes the include/exclude gates. A nil filter allows everything (so callers can pass nil without a guard).

type FlavorMetrics

type FlavorMetrics struct {
	FlavorName string
	ProviderID int
	RegionName string
	Cost       float64
	Eviction   int
	Available  bool
}

FlavorMetrics holds regional or cost data for a Flavor.

type GenericProvider

type GenericProvider struct {
	Session      Session
	ProviderID   int32
	ProviderName string
	// contains filtered or unexported fields
}

GenericProvider holds a database session, provider name, a live flag, and a buffer for non-live output.

func NewGenericProvider

func NewGenericProvider(cfg config.Config, provider string) (*GenericProvider, error)

NewGenericProvider creates a new GenericProvider.

func (*GenericProvider) Close

func (gp *GenericProvider) Close() error

func (*GenericProvider) GetFlavorLastSeen

func (gp *GenericProvider) GetFlavorLastSeen(name string, providerID int32) time.Time

func (*GenericProvider) UpdateFlavorMetrics

func (gp *GenericProvider) UpdateFlavorMetrics(newMetrics []*FlavorMetrics) error

UpdateFlavorMetrics compares and updates flavor metrics (primary keys: Provider, FlavorName, RegionName).

func (*GenericProvider) UpdateFlavors

func (gp *GenericProvider) UpdateFlavors(newFlavors []*Flavor) error

UpdateFlavors compares the list of new flavors with what is stored in the DB and performs updates, deletions, and additions.

type PostgresSession

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

PostgresSession implements the Session interface using a PostgreSQL database. It wraps a *sql.Tx to support atomic operations.

func NewPostgresSession

func NewPostgresSession(cfg config.Config) (*PostgresSession, error)

NewPostgresSession begins a new transaction on the provided *sql.DB.

func (*PostgresSession) AddFlavor

func (ps *PostgresSession) AddFlavor(f *Flavor) error

AddFlavor inserts a new flavor into the database.

func (*PostgresSession) AddFlavorMetrics

func (ps *PostgresSession) AddFlavorMetrics(fm *FlavorMetrics) error

AddFlavorMetrics inserts new flavor metrics into the database.

func (*PostgresSession) Begin

func (ps *PostgresSession) Begin() error

func (*PostgresSession) Close

func (ps *PostgresSession) Close() error

func (*PostgresSession) Commit

func (ps *PostgresSession) Commit() error

Commit commits the underlying transaction.

func (*PostgresSession) DeleteFlavor

func (ps *PostgresSession) DeleteFlavor(f *Flavor) error

DeleteFlavor deletes a flavor given its name and provider.

func (*PostgresSession) DeleteFlavorMetrics

func (ps *PostgresSession) DeleteFlavorMetrics(fm *FlavorMetrics) error

DeleteFlavorMetrics deletes a flavor_metric entry based on flavor name, provider, and region.

func (*PostgresSession) GetProviderID

func (ps *PostgresSession) GetProviderID(provider string) (int32, error)

func (*PostgresSession) IsFlavorInUse

func (ps *PostgresSession) IsFlavorInUse(name string, providerID int32) (bool, error)

func (*PostgresSession) QueryFlavorMetrics

func (ps *PostgresSession) QueryFlavorMetrics(providerID int) ([]*FlavorMetrics, error)

QueryFlavorMetrics returns flavor metrics for a given provider.

func (*PostgresSession) QueryFlavors

func (ps *PostgresSession) QueryFlavors(providerID int32) ([]*Flavor, error)

QueryFlavors returns all flavors for a given provider.

func (*PostgresSession) Rollback

func (ps *PostgresSession) Rollback() error

func (*PostgresSession) UpdateFlavor

func (ps *PostgresSession) UpdateFlavor(f *Flavor) error

UpdateFlavor updates an existing flavor in the database.

func (*PostgresSession) UpdateFlavorMetrics

func (ps *PostgresSession) UpdateFlavorMetrics(fm *FlavorMetrics) error

UpdateFlavorMetrics inserts new flavor metrics into the database.

type Session

type Session interface {
	QueryFlavors(providerID int32) ([]*Flavor, error)
	DeleteFlavor(f *Flavor) error
	AddFlavor(f *Flavor) error
	UpdateFlavor(f *Flavor) error
	QueryFlavorMetrics(providerID int) ([]*FlavorMetrics, error)
	DeleteFlavorMetrics(fm *FlavorMetrics) error
	AddFlavorMetrics(fm *FlavorMetrics) error
	UpdateFlavorMetrics(fm *FlavorMetrics) error
	Commit() error
	Begin() error
	Rollback() error
	Close() error
	IsFlavorInUse(name string, providerID int32) (bool, error)
}

Session is an interface abstracting DB operations. In a real implementation, these methods would be implemented using your chosen database/ORM library.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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