service

package
v0.13.4 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceTypeAgent     string = "agent"
	SourceTypeInventory string = "inventory"
	SourceTypeRvtools   string = "rvtools"
)
View Source
const (
	// TargetCapacityPercent leaves 20% headroom for over-commitment
	TargetCapacityPercent = 80.0
	// CapacityMultiplier is the decimal representation of TargetCapacityPercent
	CapacityMultiplier = TargetCapacityPercent / 100.0

	DefaultPlatform = "BAREMETAL"

	// MaxBatches - if exceeded, recommend larger nodes
	MaxBatches = 200

	// MinBatchCPU prevents tiny batches
	MinBatchCPU = 1.0

	// MinBatchMemory prevents tiny batches
	MinBatchMemory = 2.0

	// MaxNodeCount - if exceeded, recommend larger nodes
	MaxNodeCount = 100

	// MaxVMsPerWorkerNode - maximum VMs allowed per worker node
	MaxVMsPerWorkerNode = 200

	// MachineSetNumberOfDisks is the number of disks for both worker and control plane machine sets
	MachineSetNumberOfDisks = 24

	// ControlPlaneReservedCPU is the CPU reserved for control plane services
	ControlPlaneReservedCPU = 3.5
	// ControlPlaneReservedMemory is the memory (GB) reserved for control plane services
	ControlPlaneReservedMemory = 13.39

	// MinFallbackNodeCPU is the minimum fallback CPU when inputs are invalid
	MinFallbackNodeCPU = 2
	// MinFallbackNodeMemory is the minimum fallback memory (GB) when inputs are invalid
	MinFallbackNodeMemory = 4

	// MaxRecommendedNodeCPU is the maximum recommended CPU for nodes
	MaxRecommendedNodeCPU = 200
	// MaxRecommendedNodeMemory is the maximum recommended memory (GB) for nodes
	MaxRecommendedNodeMemory = 512

	// MinFailoverNodes is the minimum number of failover nodes
	MinFailoverNodes = 2
	// FailoverCapacityPercent is the percentage of worker nodes for failover
	FailoverCapacityPercent = 10.0
)

Variables

This section is empty.

Functions

func BuildServiceAvoidLists added in v0.9.0

func BuildServiceAvoidLists(services []BatchedService) [][]string

BuildServiceAvoidLists enforces MaxVMsPerWorkerNode via avoid lists.

Assumption: when limiting how many batches may share a node, we use maxVMsPerBatch = max(VMCount per batch)—i.e. we assume each batch on that node could be as large as the worst batch. Then maxServicesPerNode = MaxVMsPerWorkerNode/maxVMsPerBatch is a safe cap on batch count per node. That stays correct when VMCount differs across batches.

func CalculateEffectiveCPU added in v0.5.0

func CalculateEffectiveCPU(physicalCores, threads int) float64

CalculateEffectiveCPU calculates SMT-adjusted effective CPU cores Formula: effectiveCPU = physicalCores + ((threads - physicalCores) * 0.5) If threads == 0 or threads == cores, returns cores (no SMT)

func CheckAgentVersionWarning added in v0.8.0

func CheckAgentVersionWarning(imageInfra *model.ImageInfra) *string

CheckAgentVersionWarning compares stored agent version with current and returns warning if they differ.

Types

type AccountsService added in v0.11.0

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

func NewAccountsService added in v0.11.0

func NewAccountsService(store store.Store) *AccountsService

func (*AccountsService) CreateGroup added in v0.11.0

func (s *AccountsService) CreateGroup(ctx context.Context, group model.Group) (model.Group, error)

func (*AccountsService) CreateMember added in v0.11.0

func (s *AccountsService) CreateMember(ctx context.Context, member model.Member) (model.Member, error)

CreateMember creates a new member. Verifies the group exists.

func (*AccountsService) DeleteGroup added in v0.11.0

func (s *AccountsService) DeleteGroup(ctx context.Context, id uuid.UUID) error

func (*AccountsService) GetGroup added in v0.11.0

func (s *AccountsService) GetGroup(ctx context.Context, id uuid.UUID) (model.Group, error)

func (*AccountsService) GetIdentity added in v0.11.0

func (s *AccountsService) GetIdentity(ctx context.Context, authUser auth.User) (Identity, error)

func (*AccountsService) GetMember added in v0.11.0

func (s *AccountsService) GetMember(ctx context.Context, username string) (model.Member, error)

func (*AccountsService) Initialize added in v0.13.4

func (s *AccountsService) Initialize(ctx context.Context, adminGroup AdminGroup) (retErr error)

func (*AccountsService) IsKind added in v0.12.0

func (s *AccountsService) IsKind(ctx context.Context, user auth.User, kind IdentityKind) (bool, error)

func (*AccountsService) ListGroupMembers added in v0.11.0

func (s *AccountsService) ListGroupMembers(ctx context.Context, groupID uuid.UUID) (model.MemberList, error)

ListGroupMembers lists all members belonging to the specified group.

func (*AccountsService) ListGroups added in v0.11.0

func (s *AccountsService) ListGroups(ctx context.Context, filter *store.GroupQueryFilter) (model.GroupList, error)

func (*AccountsService) RemoveGroupMember added in v0.11.0

func (s *AccountsService) RemoveGroupMember(ctx context.Context, groupID uuid.UUID, username string) error

RemoveGroupMember removes a member from the specified group. Since a backend member must always belong to a group, this deletes the member.

func (*AccountsService) UpdateGroup added in v0.11.0

func (s *AccountsService) UpdateGroup(ctx context.Context, group model.Group) (model.Group, error)

func (*AccountsService) UpdateGroupMember added in v0.11.0

func (s *AccountsService) UpdateGroupMember(ctx context.Context, groupID uuid.UUID, username string, member model.Member) (model.Member, error)

UpdateGroupMember updates a member within the specified group. The username is immutable; only other fields (e.g. email) are updated.

type AccountsServicer added in v0.13.4

type AccountsServicer interface {
	Initialize(ctx context.Context, adminGroup AdminGroup) error
	GetIdentity(ctx context.Context, authUser auth.User) (Identity, error)
	ListGroups(ctx context.Context, filter *store.GroupQueryFilter) (model.GroupList, error)
	GetGroup(ctx context.Context, id uuid.UUID) (model.Group, error)
	CreateGroup(ctx context.Context, group model.Group) (model.Group, error)
	UpdateGroup(ctx context.Context, group model.Group) (model.Group, error)
	DeleteGroup(ctx context.Context, id uuid.UUID) error
	GetMember(ctx context.Context, username string) (model.Member, error)
	ListGroupMembers(ctx context.Context, groupID uuid.UUID) (model.MemberList, error)
	CreateMember(ctx context.Context, member model.Member) (model.Member, error)
	UpdateGroupMember(ctx context.Context, groupID uuid.UUID, username string, member model.Member) (model.Member, error)
	RemoveGroupMember(ctx context.Context, groupID uuid.UUID, username string) error
}

func NewAccountsServicer added in v0.13.4

func NewAccountsServicer(store store.Store) AccountsServicer

func NewAuthzAccountsService added in v0.13.4

func NewAuthzAccountsService(inner AccountsServicer) AccountsServicer

type AdminGroup added in v0.13.4

type AdminGroup struct {
	Name    string             `yaml:"name"`
	Members []AdminGroupMember `yaml:"members"`
}

func ParseAdminGroupFile added in v0.13.4

func ParseAdminGroupFile(path string) (*AdminGroup, error)

type AdminGroupMember added in v0.13.4

type AdminGroupMember struct {
	Username string `yaml:"username"`
	Email    string `yaml:"email"`
}

type AgentService

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

func NewAgentService

func NewAgentService(store store.Store) *AgentService

func (*AgentService) UpdateAgentStatus

func (as *AgentService) UpdateAgentStatus(ctx context.Context, updateForm mappers.AgentUpdateForm) (*model.Agent, bool, error)

UpdateAgentStatus updates or creates a new agent resource If the source has not agent than the agent is created.

func (*AgentService) UpdateSourceInventory

func (as *AgentService) UpdateSourceInventory(ctx context.Context, updateForm mappers.InventoryUpdateForm) (*model.Source, error)

UpdateSourceInventory updates source inventory

This implements the SingleModel logic: - Only updates for a single vCenterID are allowed - allow two agents trying to update the source with same vCenterID - don't allow updates from agents not belonging to the source - don't allow updates if source is missing. (i.g the source is created as per MultiSource logic). It fails anyway because an agent always has a source. - if the source has no inventory yet, set the vCenterID and AssociatedAgentID to this source.

type AssessmentFilter

type AssessmentFilter struct {
	OrgID    string
	Username string
	Source   string
	SourceID string
	NameLike string
	IDs      []uuid.UUID
	Limit    int
	Offset   int
}

AssessmentFilter represents filtering options for listing assessments

func NewAssessmentFilter

func NewAssessmentFilter(username, orgID string) *AssessmentFilter

func (*AssessmentFilter) WithLimit

func (f *AssessmentFilter) WithLimit(limit int) *AssessmentFilter

func (*AssessmentFilter) WithNameLike

func (f *AssessmentFilter) WithNameLike(pattern string) *AssessmentFilter

func (*AssessmentFilter) WithOffset

func (f *AssessmentFilter) WithOffset(offset int) *AssessmentFilter

func (*AssessmentFilter) WithSource

func (f *AssessmentFilter) WithSource(source string) *AssessmentFilter

func (*AssessmentFilter) WithSourceID

func (f *AssessmentFilter) WithSourceID(sourceID string) *AssessmentFilter

type AssessmentService

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

func NewAssessmentService

func NewAssessmentService(store store.Store, opaValidator *opa.Validator, accountsSvc *AccountsService) *AssessmentService

func (*AssessmentService) CreateAssessment

func (as *AssessmentService) CreateAssessment(ctx context.Context, createForm mappers.AssessmentCreateForm) (*model.Assessment, error)

func (*AssessmentService) DeleteAssessment

func (as *AssessmentService) DeleteAssessment(ctx context.Context, id uuid.UUID) error

func (*AssessmentService) GetAssessment

func (as *AssessmentService) GetAssessment(ctx context.Context, id uuid.UUID) (*model.Assessment, error)

func (*AssessmentService) ListAssessments

func (as *AssessmentService) ListAssessments(ctx context.Context, filter *AssessmentFilter) ([]model.Assessment, error)

func (*AssessmentService) ShareAssessment added in v0.12.0

func (as *AssessmentService) ShareAssessment(ctx context.Context, id uuid.UUID) error

func (*AssessmentService) UnshareAssessment added in v0.12.0

func (as *AssessmentService) UnshareAssessment(ctx context.Context, id uuid.UUID) error

func (*AssessmentService) UpdateAssessment

func (as *AssessmentService) UpdateAssessment(ctx context.Context, id uuid.UUID, name *string) (*model.Assessment, error)

type AssessmentServicer added in v0.10.0

type AssessmentServicer interface {
	ListAssessments(ctx context.Context, filter *AssessmentFilter) ([]model.Assessment, error)
	GetAssessment(ctx context.Context, id uuid.UUID) (*model.Assessment, error)
	CreateAssessment(ctx context.Context, createForm mappers.AssessmentCreateForm) (*model.Assessment, error)
	UpdateAssessment(ctx context.Context, id uuid.UUID, name *string) (*model.Assessment, error)
	DeleteAssessment(ctx context.Context, id uuid.UUID) error
	ShareAssessment(ctx context.Context, id uuid.UUID) error
	UnshareAssessment(ctx context.Context, id uuid.UUID) error
}

func NewAuthzAssessmentService added in v0.10.0

func NewAuthzAssessmentService(inner AssessmentServicer, s store.Store, accountsSrv *AccountsService) AssessmentServicer

type AuthzAccountsService added in v0.13.4

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

func (*AuthzAccountsService) CreateGroup added in v0.13.4

func (a *AuthzAccountsService) CreateGroup(ctx context.Context, group model.Group) (model.Group, error)

func (*AuthzAccountsService) CreateMember added in v0.13.4

func (a *AuthzAccountsService) CreateMember(ctx context.Context, member model.Member) (model.Member, error)

func (*AuthzAccountsService) DeleteGroup added in v0.13.4

func (a *AuthzAccountsService) DeleteGroup(ctx context.Context, id uuid.UUID) error

func (*AuthzAccountsService) GetGroup added in v0.13.4

func (a *AuthzAccountsService) GetGroup(ctx context.Context, id uuid.UUID) (model.Group, error)

func (*AuthzAccountsService) GetIdentity added in v0.13.4

func (a *AuthzAccountsService) GetIdentity(ctx context.Context, authUser auth.User) (Identity, error)

func (*AuthzAccountsService) GetMember added in v0.13.4

func (a *AuthzAccountsService) GetMember(ctx context.Context, username string) (model.Member, error)

func (*AuthzAccountsService) Initialize added in v0.13.4

func (a *AuthzAccountsService) Initialize(ctx context.Context, adminGroup AdminGroup) error

Initialize is bootstrap-only — called from api_server.Run before HTTP serving starts. It intentionally skips authz because no authenticated user exists at boot time. Must not be called from request handlers; use innerAccountsSvc.Initialize directly.

func (*AuthzAccountsService) ListGroupMembers added in v0.13.4

func (a *AuthzAccountsService) ListGroupMembers(ctx context.Context, groupID uuid.UUID) (model.MemberList, error)

func (*AuthzAccountsService) ListGroups added in v0.13.4

func (*AuthzAccountsService) RemoveGroupMember added in v0.13.4

func (a *AuthzAccountsService) RemoveGroupMember(ctx context.Context, groupID uuid.UUID, username string) error

func (*AuthzAccountsService) UpdateGroup added in v0.13.4

func (a *AuthzAccountsService) UpdateGroup(ctx context.Context, group model.Group) (model.Group, error)

func (*AuthzAccountsService) UpdateGroupMember added in v0.13.4

func (a *AuthzAccountsService) UpdateGroupMember(ctx context.Context, groupID uuid.UUID, username string, member model.Member) (model.Member, error)

type AuthzAssessmentService added in v0.10.0

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

func (*AuthzAssessmentService) CreateAssessment added in v0.10.0

func (a *AuthzAssessmentService) CreateAssessment(ctx context.Context, createForm mappers.AssessmentCreateForm) (*model.Assessment, error)

func (*AuthzAssessmentService) DeleteAssessment added in v0.10.0

func (a *AuthzAssessmentService) DeleteAssessment(ctx context.Context, id uuid.UUID) error

func (*AuthzAssessmentService) GetAssessment added in v0.10.0

func (a *AuthzAssessmentService) GetAssessment(ctx context.Context, id uuid.UUID) (*model.Assessment, error)

func (*AuthzAssessmentService) ListAssessments added in v0.10.0

func (a *AuthzAssessmentService) ListAssessments(ctx context.Context, filter *AssessmentFilter) ([]model.Assessment, error)

func (*AuthzAssessmentService) ShareAssessment added in v0.12.0

func (a *AuthzAssessmentService) ShareAssessment(ctx context.Context, id uuid.UUID) error

func (*AuthzAssessmentService) UnshareAssessment added in v0.12.0

func (a *AuthzAssessmentService) UnshareAssessment(ctx context.Context, id uuid.UUID) error

func (*AuthzAssessmentService) UpdateAssessment added in v0.10.0

func (a *AuthzAssessmentService) UpdateAssessment(ctx context.Context, id uuid.UUID, name *string) (*model.Assessment, error)

type AuthzPartnerService added in v0.12.0

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

func (*AuthzPartnerService) CancelRequest added in v0.12.0

func (a *AuthzPartnerService) CancelRequest(ctx context.Context, user auth.User, requestID uuid.UUID) error

func (*AuthzPartnerService) CreateRequest added in v0.12.0

func (a *AuthzPartnerService) CreateRequest(ctx context.Context, user auth.User, partnerID string, pc model.PartnerCustomer) (*model.PartnerCustomer, error)

func (*AuthzPartnerService) GetPartner added in v0.12.0

func (a *AuthzPartnerService) GetPartner(ctx context.Context, user auth.User, partnerID string) (model.Group, error)

func (*AuthzPartnerService) LeavePartner added in v0.12.0

func (a *AuthzPartnerService) LeavePartner(ctx context.Context, user auth.User, partnerID string) error

func (*AuthzPartnerService) ListCustomers added in v0.12.0

func (a *AuthzPartnerService) ListCustomers(ctx context.Context, user auth.User) (model.PartnerCustomerList, error)

func (*AuthzPartnerService) ListPartners added in v0.12.0

func (a *AuthzPartnerService) ListPartners(ctx context.Context) (model.GroupList, error)

func (*AuthzPartnerService) ListRequests added in v0.12.0

func (*AuthzPartnerService) RemoveCustomer added in v0.12.0

func (a *AuthzPartnerService) RemoveCustomer(ctx context.Context, user auth.User, username string) error

func (*AuthzPartnerService) UpdateRequest added in v0.12.0

func (a *AuthzPartnerService) UpdateRequest(ctx context.Context, user auth.User, requestID uuid.UUID, req model.Request) (*model.PartnerCustomer, error)

type BatchedService added in v0.4.0

type BatchedService struct {
	Name           string
	RequiredCPU    float64
	RequiredMemory float64
	LimitCPU       float64
	LimitMemory    float64
	VMCount        int // Number of VMs in this batch
}

BatchedService represents an aggregated service workload for the sizer API. It contains the resource requirements for a single batch of VMs that will be scheduled as a service on the cluster.

Fields:

  • Name: Unique identifier for the batch (e.g., "vms-batch-1-services")
  • RequiredCPU: CPU cores requested for this batch (after applying over-commit ratio)
  • RequiredMemory: Memory (GB) requested for this batch (after applying over-commit ratio)
  • LimitCPU: Maximum CPU cores allowed for this batch (before over-commit)
  • LimitMemory: Maximum memory (GB) allowed for this batch (before over-commit)

The Required values represent Kubernetes resource requests, while Limit values represent Kubernetes resource limits. The over-commit ratio determines the relationship between them.

type ErrActiveRequestExists added in v0.12.0

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

func NewErrActiveRequestExists added in v0.12.0

func NewErrActiveRequestExists(username string) *ErrActiveRequestExists

type ErrAgentUpdateForbidden

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

func NewErrAgentUpdateForbidden

func NewErrAgentUpdateForbidden(sourceID, agentID uuid.UUID) *ErrAgentUpdateForbidden

type ErrAssessmentCreationForbidden

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

func NewErrAssessmentCreationForbidden

func NewErrAssessmentCreationForbidden(sourceID uuid.UUID) *ErrAssessmentCreationForbidden

type ErrDuplicateKey added in v0.3.0

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

func NewErrAssessmentDuplicateName added in v0.3.0

func NewErrAssessmentDuplicateName(name string) *ErrDuplicateKey

func NewErrDuplicateKey added in v0.3.0

func NewErrDuplicateKey(resourceType, name string) *ErrDuplicateKey

func NewErrSourceDuplicateName added in v0.6.0

func NewErrSourceDuplicateName(name string) *ErrDuplicateKey

type ErrFileCorrupted added in v0.3.0

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

func NewErrFileCorrupted added in v0.3.0

func NewErrFileCorrupted(message string) *ErrFileCorrupted

func NewErrRVToolsFileCorrupted added in v0.3.0

func NewErrRVToolsFileCorrupted(message string) *ErrFileCorrupted

type ErrForbidden added in v0.10.0

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

func NewErrForbidden added in v0.10.0

func NewErrForbidden(resource string, id string) *ErrForbidden

type ErrInvalidClusterInventory added in v0.4.0

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

func NewErrInvalidClusterInventory added in v0.4.0

func NewErrInvalidClusterInventory(clusterID string, reason string) *ErrInvalidClusterInventory

type ErrInvalidEstimationParam added in v0.11.0

type ErrInvalidEstimationParam struct{ Msg string }

func (*ErrInvalidEstimationParam) Error added in v0.11.0

func (e *ErrInvalidEstimationParam) Error() string

type ErrInvalidRequest added in v0.4.0

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

func NewErrInvalidRequest added in v0.4.0

func NewErrInvalidRequest(message string) *ErrInvalidRequest

type ErrInvalidSchema added in v0.9.0

type ErrInvalidSchema struct{ Msg string }

func (*ErrInvalidSchema) Error added in v0.9.0

func (e *ErrInvalidSchema) Error() string

type ErrInvalidVCenterID

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

func NewErrInvalidVCenterID

func NewErrInvalidVCenterID(sourceID uuid.UUID, vCenterID string) *ErrInvalidVCenterID

type ErrInventoryHasNoVMs added in v0.4.0

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

func NewErrInventoryHasNoVMs added in v0.4.0

func NewErrInventoryHasNoVMs() *ErrInventoryHasNoVMs

type ErrJobForbidden added in v0.3.0

type ErrJobForbidden struct {
	JobID int64
}

func NewErrJobForbidden added in v0.3.0

func NewErrJobForbidden(jobID int64) *ErrJobForbidden

func (*ErrJobForbidden) Error added in v0.3.0

func (e *ErrJobForbidden) Error() string

type ErrJobNotFound added in v0.3.0

type ErrJobNotFound struct {
	JobID int64
}

func NewErrJobNotFound added in v0.3.0

func NewErrJobNotFound(jobID int64) *ErrJobNotFound

func (*ErrJobNotFound) Error added in v0.3.0

func (e *ErrJobNotFound) Error() string

type ErrMembershipMismatch added in v0.11.0

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

func NewErrMembershipMismatch added in v0.11.0

func NewErrMembershipMismatch(username string, groupID uuid.UUID) *ErrMembershipMismatch

type ErrNotACustomer added in v0.12.0

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

func NewErrNotACustomer added in v0.12.0

func NewErrNotACustomer(username string) *ErrNotACustomer

type ErrResourceNotFound

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

func NewErrAgentNotFound

func NewErrAgentNotFound(id uuid.UUID) *ErrResourceNotFound

func NewErrAssessmentNotFound

func NewErrAssessmentNotFound(id uuid.UUID) *ErrResourceNotFound

func NewErrClusterNotFound added in v0.5.1

func NewErrClusterNotFound(clusterID string, assessmentID uuid.UUID) *ErrResourceNotFound

func NewErrClusterRequirementsNotFound added in v0.12.0

func NewErrClusterRequirementsNotFound(clusterID string, assessmentID uuid.UUID) *ErrResourceNotFound

func NewErrMemberNotFound added in v0.11.0

func NewErrMemberNotFound(username string) *ErrResourceNotFound

func NewErrResourceNotFound

func NewErrResourceNotFound(id uuid.UUID, resourceType string) *ErrResourceNotFound

func NewErrResourceNotFoundByStr added in v0.12.0

func NewErrResourceNotFoundByStr(id string, resourceType string) *ErrResourceNotFound

func NewErrSourceNotFound

func NewErrSourceNotFound(id uuid.UUID) *ErrResourceNotFound

type ErrSourceHasNoInventory

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

func NewErrSourceHasNoInventory

func NewErrSourceHasNoInventory(sourceID uuid.UUID) *ErrSourceHasNoInventory

type EstimationContext added in v0.10.0

type EstimationContext struct {
	Schemas    []engines.Schema
	BaseParams []estimation.Param // scalar params only; excludes per-bucket vmCount/diskGB
}

EstimationContext carries the parameters used to compute per-bucket estimates.

type EstimationService added in v0.5.1

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

EstimationService orchestrates the migration time estimation workflow. It retrieves assessment and inventory data from the store and runs them through the estimation Engine to produce a MigrationAssessmentResult.

func NewEstimationService added in v0.5.1

func NewEstimationService(store store.Store) *EstimationService

NewEstimationService creates an EstimationService.

func (*EstimationService) BuildBaseParams added in v0.10.0

func (es *EstimationService) BuildBaseParams(userParams []estimation.Param) []estimation.Param

BuildBaseParams returns the merged base params (defaults + user overrides), without any per-bucket inventory values.

func (*EstimationService) BuildBucketParams added in v0.10.0

func (es *EstimationService) BuildBucketParams(baseParams []estimation.Param, vmCount int, diskGB float64) []estimation.Param

BuildBucketParams returns params for a single complexity bucket. diskGB = bucket.TotalSizeTB * 1024 (TiB → GiB; matches DiskGB.Total unit in the regular path).

func (*EstimationService) CalculateMigrationComplexity added in v0.7.0

func (es *EstimationService) CalculateMigrationComplexity(
	ctx context.Context,
	assessmentID uuid.UUID,
	clusterID string,
) (*MigrationComplexityResult, error)

CalculateMigrationComplexity calculates OS and disk complexity breakdowns for the given cluster within the assessment's inventory.

func (*EstimationService) CalculateMigrationEstimation added in v0.5.1

func (es *EstimationService) CalculateMigrationEstimation(
	ctx context.Context,
	assessmentID uuid.UUID,
	clusterID string,
	schemas []engines.Schema,
	userParams []estimation.Param,
) (map[engines.Schema]*MigrationAssessmentResult, error)

CalculateMigrationEstimation calculates migration time estimation for a given assessment and cluster

func (*EstimationService) CalculateOsDiskComplexity added in v0.10.0

func (es *EstimationService) CalculateOsDiskComplexity(
	ctx context.Context,
	assessmentID uuid.UUID,
	clusterID string,
) (*OsDiskComplexityResult, error)

CalculateOsDiskComplexity fetches the cluster inventory and returns the combined OS+Disk complexity distribution. Used by the by-complexity handler.

func (*EstimationService) RunEstimation added in v0.10.0

func (es *EstimationService) RunEstimation(schemas []engines.Schema, params []estimation.Param) (map[engines.Schema]*MigrationAssessmentResult, error)

RunEstimation builds engines from schemas and runs them with the provided fully-merged params. Performs no store access. When schemas is empty, engines.BuildEngines uses all known schemas.

func (*EstimationService) ValidateParams added in v0.11.0

func (es *EstimationService) ValidateParams(userParams []estimation.Param) error

ValidateParams checks each user-supplied param against estimationParamDefs. It returns ErrInvalidEstimationParam for unknown keys, non-numeric values, fractional values on integer params, and values outside the Min/Max bounds.

type Identity added in v0.11.0

type Identity struct {
	Username  string
	Kind      IdentityKind
	GroupID   *string
	PartnerID *string
}

type IdentityKind added in v0.12.0

type IdentityKind string
const (
	KindRegular  IdentityKind = "regular"
	KindCustomer IdentityKind = "customer"
	KindPartner  IdentityKind = "partner"
	KindAdmin    IdentityKind = "admin"
)

type JobService added in v0.3.0

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

JobService handles job-related operations.

func NewJobService added in v0.3.0

func NewJobService(s store.Store, riverClient *river.Client[pgx.Tx], pool *pgxpool.Pool) *JobService

NewJobService creates a new job service.

func (*JobService) CancelJob added in v0.3.0

func (s *JobService) CancelJob(ctx context.Context, jobID int64, orgID, username string) (*v1alpha1.Job, error)

CancelJob cancels a job by ID.

func (*JobService) CreateRVToolsJob added in v0.3.0

func (s *JobService) CreateRVToolsJob(ctx context.Context, args jobs.RVToolsJobArgs, fileContent []byte) (*v1alpha1.Job, error)

CreateRVToolsJob stores the file content and creates a River job atomically within a single transaction.

func (*JobService) GetJob added in v0.3.0

func (s *JobService) GetJob(ctx context.Context, jobID int64, orgID, username string) (*v1alpha1.Job, error)

GetJob retrieves a job by ID.

type MigrationAssessmentResult added in v0.5.1

type MigrationAssessmentResult struct {
	MinTotalDuration time.Duration
	MaxTotalDuration time.Duration
	Breakdown        map[string]estimation.Estimation
}

MigrationAssessmentResult represents the result of a migration assessment calculation

type MigrationComplexityResult added in v0.7.0

type MigrationComplexityResult struct {
	ComplexityByDisk   []complexity.DiskComplexityEntry // scores 1–4, always 4 entries
	ComplexityByOS     []complexity.OSDifficultyEntry   // scores 0–4, always 5 entries
	ComplexityByOSName []complexity.OSNameEntry         // one entry per distinct OS name
	DiskSizeRatings    map[string]complexity.Score      // static tier label → score lookup
	OSRatings          map[string]complexity.Score      // per-inventory OS name → score
}

MigrationComplexityResult holds the output of a complexity estimation run.

type OsDiskComplexityResult added in v0.10.0

type OsDiskComplexityResult struct {
	Buckets []complexity.OSDiskEntry
}

OsDiskComplexityResult holds the OsDisk complexity buckets for one cluster.

type ParamDefinition added in v0.9.0

type ParamDefinition struct {
	Key         string           // matches estimation.Param.Key and the calculator constant
	DisplayName string           // human-readable label for UI forms
	Type        string           // "number" or "integer"
	Unit        string           // e.g. "Mbps", "hours", "minutes", "" if unitless
	Min         *float64         // inclusive lower bound, nil if unbounded
	Max         *float64         // inclusive upper bound, nil if unbounded
	Default     any              // value used when neither inventory nor user supplies this key
	Schemas     []engines.Schema // schemas that use this parameter; nil means all schemas
}

ParamDefinition describes a single calculator parameter that can be supplied by the user to override the default or inventory-derived value.

This slice is the single source of truth for two things:

  1. defaultParams() — derives the baseline []estimation.Param from it, so adding a new parameter here automatically makes it part of the merge.
  2. A future metadata endpoint (e.g. GET /api/v1/estimation/params) that lets the UI render dynamic input forms with correct display names, types, units, and valid ranges without hard-coding any of that in the frontend.

When adding a new calculator parameter, add its definition here first.

type PartnerService added in v0.12.0

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

func (*PartnerService) CancelRequest added in v0.12.0

func (s *PartnerService) CancelRequest(ctx context.Context, user auth.User, requestID uuid.UUID) error

CancelRequest cancels a pending partner request.

func (*PartnerService) CreateRequest added in v0.12.0

func (s *PartnerService) CreateRequest(ctx context.Context, user auth.User, partnerID string, pc model.PartnerCustomer) (*model.PartnerCustomer, error)

CreateRequest creates a new partner request. Returns ErrInvalidRequest if the user is not a regular user. Returns ErrActiveRequestExists if the user already has a pending or accepted request.

func (*PartnerService) GetPartner added in v0.12.0

func (s *PartnerService) GetPartner(ctx context.Context, user auth.User, partnerID string) (model.Group, error)

GetPartner returns the partner group for a customer.

func (*PartnerService) LeavePartner added in v0.12.0

func (s *PartnerService) LeavePartner(ctx context.Context, user auth.User, partnerID string) error

LeavePartner removes the customer relationship with a partner.

func (*PartnerService) ListCustomers added in v0.12.0

func (s *PartnerService) ListCustomers(ctx context.Context, user auth.User) (model.PartnerCustomerList, error)

ListCustomers returns all customer requests for the partner's group.

func (*PartnerService) ListPartners added in v0.12.0

func (s *PartnerService) ListPartners(ctx context.Context) (model.GroupList, error)

ListPartners returns all partner groups.

func (*PartnerService) ListRequests added in v0.12.0

func (s *PartnerService) ListRequests(ctx context.Context, user auth.User) (model.PartnerCustomerList, error)

ListRequests returns partner requests. For regular users, it returns their own requests. For partners, it returns all requests for their group.

func (*PartnerService) RemoveCustomer added in v0.12.0

func (s *PartnerService) RemoveCustomer(ctx context.Context, user auth.User, username string) error

RemoveCustomer removes a customer from the partner's group.

func (*PartnerService) UpdateRequest added in v0.12.0

func (s *PartnerService) UpdateRequest(ctx context.Context, user auth.User, requestID uuid.UUID, req model.Request) (*model.PartnerCustomer, error)

UpdateRequest accepts or rejects a customer request.

type PartnerServicer added in v0.12.0

type PartnerServicer interface {
	// Regular user
	ListPartners(ctx context.Context) (model.GroupList, error)
	ListRequests(ctx context.Context, user auth.User) (model.PartnerCustomerList, error)
	CreateRequest(ctx context.Context, user auth.User, partnerID string, pc model.PartnerCustomer) (*model.PartnerCustomer, error)
	CancelRequest(ctx context.Context, user auth.User, requestID uuid.UUID) error

	// Customer
	GetPartner(ctx context.Context, user auth.User, partnerID string) (model.Group, error)
	LeavePartner(ctx context.Context, user auth.User, partnerID string) error

	// Partner
	ListCustomers(ctx context.Context, user auth.User) (model.PartnerCustomerList, error)
	UpdateRequest(ctx context.Context, user auth.User, requestID uuid.UUID, req model.Request) (*model.PartnerCustomer, error)
	RemoveCustomer(ctx context.Context, user auth.User, username string) error
}

func NewAuthzPartnerService added in v0.12.0

func NewAuthzPartnerService(inner PartnerServicer, accounts *AccountsService, s store.Store) PartnerServicer

func NewPartnerService added in v0.12.0

func NewPartnerService(store store.Store, accounts *AccountsService) PartnerServicer

type SizerService added in v0.4.0

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

SizerService handles cluster sizing calculations

func NewSizerService added in v0.4.0

func NewSizerService(sizerClient *client.SizerClient, store store.Store) *SizerService

func (*SizerService) CalculateClusterRequirements added in v0.4.0

func (s *SizerService) CalculateClusterRequirements(
	ctx context.Context,
	assessmentID uuid.UUID,
	req *mappers.ClusterRequirementsRequestForm,
) (*mappers.ClusterRequirementsResponseForm, error)

CalculateClusterRequirements calculates cluster requirements for an assessment

func (*SizerService) CalculateStandaloneClusterRequirements added in v0.13.4

CalculateStandaloneClusterRequirements calculates cluster sizing for inline inventory.

func (*SizerService) GetClusterRequirementsInput added in v0.12.0

func (s *SizerService) GetClusterRequirementsInput(
	ctx context.Context,
	assessmentID uuid.UUID,
	clusterID string,
) (*mappers.ClusterRequirementsInputForm, error)

func (*SizerService) Health added in v0.4.0

func (s *SizerService) Health(ctx context.Context) error

Health checks if the sizer service is healthy

type SourceFilter

type SourceFilter struct {
	Username string
	OrgID    string
	ID       uuid.UUID
}

func NewSourceFilter

func NewSourceFilter(filters ...SourceFilterFunc) *SourceFilter

func (*SourceFilter) WithOption

func (s *SourceFilter) WithOption(o SourceFilterFunc) *SourceFilter

type SourceFilterFunc

type SourceFilterFunc func(s *SourceFilter)

func WithOrgID

func WithOrgID(orgID string) SourceFilterFunc

func WithSourceID

func WithSourceID(id uuid.UUID) SourceFilterFunc

func WithUsername added in v0.3.0

func WithUsername(username string) SourceFilterFunc

type SourceService

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

func NewSourceService

func NewSourceService(store store.Store, opaValidator *opa.Validator) *SourceService

func (*SourceService) CreateSource

func (s *SourceService) CreateSource(ctx context.Context, sourceForm mappers.SourceCreateForm) (model.Source, error)

func (*SourceService) DeleteSource

func (s *SourceService) DeleteSource(ctx context.Context, id uuid.UUID) error

func (*SourceService) DeleteSources

func (s *SourceService) DeleteSources(ctx context.Context) error

func (*SourceService) GetSource

func (s *SourceService) GetSource(ctx context.Context, id uuid.UUID) (*model.Source, error)

func (*SourceService) GetSourceDownloadURL

func (s *SourceService) GetSourceDownloadURL(ctx context.Context, id uuid.UUID) (string, time.Time, error)

TODO should be moved to ImageService (to be created)

func (*SourceService) ListSources

func (s *SourceService) ListSources(ctx context.Context, filter *SourceFilter) ([]model.Source, error)

func (*SourceService) UpdateInventory

func (s *SourceService) UpdateInventory(ctx context.Context, form mappers.InventoryUpdateForm) (model.Source, error)

func (*SourceService) UpdateSource

func (s *SourceService) UpdateSource(ctx context.Context, id uuid.UUID, form mappers.SourceUpdateForm) (*model.Source, error)

type TransformedSizerResponse added in v0.4.0

type TransformedSizerResponse struct {
	ClusterSizing       mappers.ClusterSizingForm
	ResourceConsumption mappers.ResourceConsumptionForm
}

TransformedSizerResponse represents the transformed response from the sizer service after mapping it to the domain model format.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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