Documentation
¶
Index ¶
- Constants
- Variables
- func AddToValidationErrors(errs validation.Errors, key string, err error)
- func CheckMachinesForInstanceTypeAllocation(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, logger zerolog.Logger, ...) (bool, error)
- func ExecuteBringUpRackWorkflow(ctx context.Context, c echo.Context, logger zerolog.Logger, stc tclient.Client, ...) (*rlav1.SubmitTaskResponse, error)
- func ExecuteFirmwareUpdateWorkflow(ctx context.Context, c echo.Context, logger zerolog.Logger, stc tclient.Client, ...) (*rlav1.SubmitTaskResponse, error)
- func ExecutePowerControlWorkflow(ctx context.Context, c echo.Context, logger zerolog.Logger, stc tclient.Client, ...) (*rlav1.SubmitTaskResponse, error)
- func ExecuteSyncWorkflow(ctx context.Context, logger zerolog.Logger, tpClient tclient.Client, ...) *cutil.APIError
- func GenerateAccountNumber() string
- func GetAllAllocationConstraintsForInstanceType(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, ...) ([]cdbm.AllocationConstraint, int, error)
- func GetAllInstanceTypeAllocationStats(ctx context.Context, dbSession *cdb.Session, siteID *uuid.UUID, ...) (map[uuid.UUID]*cam.APIAllocationStats, *cutil.APIError)
- func GetAllocationConstraintsForInstanceType(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, tenantID uuid.UUID, ...) ([]cdbm.AllocationConstraint, error)
- func GetAllocationIDsForTenantAtSite(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, ipID uuid.UUID, ...) ([]uuid.UUID, error)
- func GetAllocationResourceTypeMaps(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, ...) (map[uuid.UUID]*cdbm.InstanceType, map[uuid.UUID]*cdbm.IPBlock, *cutil.APIError)
- func GetAndValidateQueryRelations(qParams url.Values, relatedEntities map[string]bool) ([]string, string)
- func GetCountOfMachinesForInstanceType(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, ...) (int, error)
- func GetDomainFromIDString(ctx context.Context, tx *cdb.Tx, domainID string, dbSession *cdb.Session) (*cdbm.Domain, error)
- func GetIPBlockFromIDString(ctx context.Context, tx *cdb.Tx, idStr string, dbSession *cdb.Session) (*cdbm.IPBlock, error)
- func GetInfrastructureProviderForOrg(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, org string) (*cdbm.InfrastructureProvider, error)
- func GetInstanceFromIDString(ctx context.Context, tx *cdb.Tx, instanceID string, dbSession *cdb.Session) (*cdbm.Instance, error)
- func GetInstanceTypeAllocationStats(ctx context.Context, dbSession *cdb.Session, logger zerolog.Logger, ...) (*cam.APIAllocationStats, *cutil.APIError)
- func GetInstanceTypeFromIDString(ctx context.Context, tx *cdb.Tx, idStr string, dbSession *cdb.Session) (*cdbm.InstanceType, error)
- func GetInstanceTypeIDsFromAllocationConstraints(ctx context.Context, acs []cdbm.AllocationConstraint, constraintType string) []uuid.UUID
- func GetIsProviderRequest(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, org string, ...) (isProviderRequest bool, provider *cdbm.InfrastructureProvider, ...)
- func GetNVLinkLogicalPartitionCountStats(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, logger zerolog.Logger, ...) (map[uuid.UUID]*cam.APINVLinkLogicalPartitionStats, error)
- func GetSSHKeyFromIDString(ctx context.Context, tx *cdb.Tx, sshkeyID string, dbSession *cdb.Session) (*cdbm.SSHKey, error)
- func GetSSHKeyGroupFromIDString(ctx context.Context, tx *cdb.Tx, sshkeyGroupID string, dbSession *cdb.Session, ...) (*cdbm.SSHKeyGroup, error)
- func GetSiteFromIDString(ctx context.Context, tx *cdb.Tx, siteID string, dbSession *cdb.Session) (*cdbm.Site, error)
- func GetSiteInstanceID(i *cdbm.Instance) *uuid.UUID
- func GetSiteMachineCountStats(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, logger zerolog.Logger, ...) (map[uuid.UUID]*cam.APISiteMachineStats, error)
- func GetSiteNetworkSegmentID(s *cdbm.Subnet) *uuid.UUID
- func GetSiteOperatingSystemtID(o *cdbm.OperatingSystem) *uuid.UUID
- func GetSiteVpcID(v *cdbm.Vpc) *uuid.UUID
- func GetTenantForOrg(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, org string) (*cdbm.Tenant, error)
- func GetTenantFromIDString(ctx context.Context, tx *cdb.Tx, tenantID string, dbSession *cdb.Session) (*cdbm.Tenant, error)
- func GetTenantFromTenantIDOrOrg(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, tenantID, org *string) (*cdbm.Tenant, error)
- func GetTestConfig() *config.Config
- func GetTotalAllocationConstraintValueForInstanceType(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, ...) (int, error)
- func GetUnallocatedMachineForInstanceType(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, ...) (*cdbm.Machine, error)
- func GetUserAndEnrichLogger(c echo.Context, logger zerolog.Logger, tracerSpan *cutil.TracerSpan, ...) (*cdbm.User, zerolog.Logger, error)
- func GetVpcFromIDString(ctx context.Context, tx *cdb.Tx, vpcID string, includeRelations []string, ...) (*cdbm.Vpc, error)
- func IsProvider(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, org string, ...) (*cdbm.InfrastructureProvider, *cutil.APIError)
- func IsProviderOrTenant(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, org string, ...) (infrastructureProvider *cdbm.InfrastructureProvider, tenant *cdbm.Tenant, ...)
- func IsTenant(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, org string, ...) (*cdbm.Tenant, *cutil.APIError)
- func MatchInstanceTypeCapabilitiesForMachines(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, ...) (bool, *string, *cutil.APIError)
- func QueryParamHash(params url.Values) string
- func QueryTagsFor(v any) []string
- func RequestHash(v interface{}) string
- func RollbackTx(ctx context.Context, tx *cdb.Tx, committed *bool)
- func SetupHandler(modelName, handlerName string, c echo.Context, s *cutil.TracerSpan) (org string, user *cdbm.User, ctx context.Context, logger zerolog.Logger, ...)
- func TerminateWorkflowOnTimeOut(echoCtx echo.Context, logger zerolog.Logger, temporalClient tclient.Client, ...) error
- func TestBuildAllocation(t *testing.T, dbSession *cdb.Session, st *cdbm.Site, tn *cdbm.Tenant, ...) *cdbm.Allocation
- func TestBuildAllocationConstraint(t *testing.T, dbSession *cdb.Session, al *cdbm.Allocation, ...) *cdbm.AllocationConstraint
- func TestBuildAuditEntry(t *testing.T, dbSession *cdb.Session, orgName string, userID *uuid.UUID, ...) *cdbm.AuditEntry
- func TestBuildDpuExtensionService(t *testing.T, dbSession *cdb.Session, name string, serviceType string, ...) *cdbm.DpuExtensionService
- func TestBuildDpuExtensionServiceDeployment(t *testing.T, dbSession *cdb.Session, ...) *cdbm.DpuExtensionServiceDeployment
- func TestBuildDpuExtensionServiceUpdateActiveVersions(t *testing.T, dbSession *cdb.Session, ...) *cdbm.DpuExtensionService
- func TestBuildIPBlock(t *testing.T, dbSession *cdb.Session, name string, site *cdbm.Site, ...) *cdbm.IPBlock
- func TestBuildInfrastructureProvider(t *testing.T, dbSession *cdb.Session, name string, org string, user *cdbm.User) *cdbm.InfrastructureProvider
- func TestBuildInstance(t *testing.T, dbSession *cdb.Session, name string, alID uuid.UUID, ...) *cdbm.Instance
- func TestBuildInstanceType(t *testing.T, dbSession *cdb.Session, name string, ...) *cdbm.InstanceType
- func TestBuildInterface(t *testing.T, dbSession *cdb.Session, instanceID uuid.UUID, ...) *cdbm.Interface
- func TestBuildMachine(t *testing.T, dbSession *cdb.Session, ip *cdbm.InfrastructureProvider, ...) *cdbm.Machine
- func TestBuildMachineCapability(t *testing.T, dbSession *cdb.Session, mID *string, itID *uuid.UUID, ...) *cdbm.MachineCapability
- func TestBuildMachineInstanceType(t *testing.T, dbSession *cdb.Session, m *cdbm.Machine, it *cdbm.InstanceType) *cdbm.MachineInstanceType
- func TestBuildNetworkSecurityGroup(t *testing.T, dbSession *cdb.Session, name string, siteID, tenantID uuid.UUID, ...) *cdbm.NetworkSecurityGroup
- func TestBuildOperatingSystem(t *testing.T, dbSession *cdb.Session, name string, tn *cdbm.Tenant, ...) *cdbm.OperatingSystem
- func TestBuildOperatingSystemSiteAssociation(t *testing.T, dbSession *cdb.Session, osID uuid.UUID, siteID uuid.UUID, ...) *cdbm.OperatingSystemSiteAssociation
- func TestBuildSite(t *testing.T, dbSession *cdb.Session, ip *cdbm.InfrastructureProvider, ...) *cdbm.Site
- func TestBuildStatusDetail(t *testing.T, dbSession *cdb.Session, entityID string, status string, ...)
- func TestBuildSubnet(t *testing.T, dbSession *cdb.Session, name string, tn *cdbm.Tenant, ...) *cdbm.Subnet
- func TestBuildTenant(t *testing.T, dbSession *cdb.Session, name string, org string, user *cdbm.User) *cdbm.Tenant
- func TestBuildTenantAccount(t *testing.T, dbSession *cdb.Session, ip *cdbm.InfrastructureProvider, ...) *cdbm.TenantAccount
- func TestBuildTenantSite(t *testing.T, dbSession *cdb.Session, tn *cdbm.Tenant, st *cdbm.Site, ...) *cdbm.TenantSite
- func TestBuildTenantWithDisplayName(t *testing.T, dbSession *cdb.Session, name string, org string, user *cdbm.User, ...) *cdbm.Tenant
- func TestBuildUser(t *testing.T, dbSession *cdb.Session, starfleetID string, org string, ...) *cdbm.User
- func TestBuildVPC(t *testing.T, dbSession *cdb.Session, name string, ...) *cdbm.Vpc
- func TestBuildVPCPrefix(t *testing.T, dbSession *cdb.Session, name string, st *cdbm.Site, ...) *cdbm.VpcPrefix
- func TestBuildVpcPeering(t *testing.T, dbSession *cdb.Session, vpc1ID, vpc2ID uuid.UUID, ...) *cdbm.VpcPeering
- func TestBuildVpcPrefixIPBlock(t *testing.T, dbSession *cdb.Session, name string, site *cdbm.Site, ...) *cdbm.IPBlock
- func TestCommonBuildMachineCapability(t *testing.T, dbSession *cdb.Session, machineID *string, ...) *cdbm.MachineCapability
- func TestCommonTraceProviderSetup(t *testing.T, ctx context.Context) (trace.Tracer, trace.SpanContext, context.Context)
- func TestInitDB(t *testing.T) *cdb.Session
- func TestSetupSchema(t *testing.T, dbSession *cdb.Session)
- func UnwrapWorkflowError(err error) (code int, unwrappedError error)
- func ValidateKnownQueryParams(rawParams url.Values, structs ...any) error
- type QueryOverride
- type UniqueChecker
Constants ¶
const ( // RECENT_STATUS_DETAIL_COUNT defines how many recent status detail records to retrieve when retrieving them as part of other records (e.g. allocation, instance, etc.) RECENT_STATUS_DETAIL_COUNT = 20 DefaultIpxeScript = "#ipxe\ndefault" // Likely to be moved into cloud-db later, similar // to machine status. MachineHealthStatusHealthy = "healthy" MachineHealthStatusUnhealthy = "unhealthy" )
Variables ¶
var ( // ErrOrgInstrastructureProviderNotFound is returned when the org does not have an infrastructure provider ErrOrgInstrastructureProviderNotFound = errors.New("Org does not have an Infrastructure Provider") // ErrOrgTenantNotFound is returned when the org does not have a tenant ErrOrgTenantNotFound = errors.New("Org does not have a Tenant") // ErrAllocationConstraintNotFound ErrAllocationConstraintNotFound = errors.New("Allocation does not have an associated Constraint") // ErrInstanceTypeMachineNotFound ErrInstanceTypeMachineNotFound = errors.New("Instance Type does not have a Machine available for allocation") // ErrInvalidFunctionParams ErrInvalidFunctionParams = errors.New("invalid function parameters") // ErrMsgProviderOrTenantIDQueryRequired is returned when the provider or tenant id query param is not specified ErrMsgProviderOrTenantIDQueryRequired = "Either infrastructureProviderId or tenantId query param must be specified" // ErrInvalidID ErrInvalidID = errors.New("invalid id") // RequestAsProvider indicates that the request is being made as a provider RequestAsInfrastructureProvider = "InfrastructureProvider" // RequestAsTenant indicates that the request is being made as a tenant RequestAsTenant = "Tenant" )
Functions ¶
func AddToValidationErrors ¶
func AddToValidationErrors(errs validation.Errors, key string, err error)
AddToValidationError adds a new error entry or augments an existing one into a validation.Errors{} map
func CheckMachinesForInstanceTypeAllocation ¶
func CheckMachinesForInstanceTypeAllocation(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, logger zerolog.Logger, instanceTypeID uuid.UUID, value int) (bool, error)
CheckMachinesForInstanceTypeAllocation checks the available machines against existing reserved allocations, and the new constraint value - returns true if the constraint value is feasible, false otherwise
func ExecuteBringUpRackWorkflow ¶
func ExecuteBringUpRackWorkflow( ctx context.Context, c echo.Context, logger zerolog.Logger, stc tclient.Client, targetSpec *rlav1.OperationTargetSpec, description string, workflowID string, entityName string, ) (*rlav1.SubmitTaskResponse, error)
ExecuteBringUpRackWorkflow builds a BringUpRackRequest, executes the BringUpRack workflow via Temporal, and returns the raw SubmitTaskResponse.
func ExecuteFirmwareUpdateWorkflow ¶
func ExecuteFirmwareUpdateWorkflow( ctx context.Context, c echo.Context, logger zerolog.Logger, stc tclient.Client, targetSpec *rlav1.OperationTargetSpec, version *string, workflowID string, entityName string, ) (*rlav1.SubmitTaskResponse, error)
ExecuteFirmwareUpdateWorkflow builds an UpgradeFirmwareRequest, executes the UpgradeFirmware workflow via Temporal, and returns the raw SubmitTaskResponse.
func ExecutePowerControlWorkflow ¶
func ExecutePowerControlWorkflow( ctx context.Context, c echo.Context, logger zerolog.Logger, stc tclient.Client, targetSpec *rlav1.OperationTargetSpec, state string, workflowID string, entityName string, ) (*rlav1.SubmitTaskResponse, error)
ExecutePowerControlWorkflow determines the appropriate power control workflow based on state, executes it via Temporal, and returns the raw SubmitTaskResponse.
func ExecuteSyncWorkflow ¶
func ExecuteSyncWorkflow(ctx context.Context, logger zerolog.Logger, tpClient tclient.Client, name string, options tclient.StartWorkflowOptions, request interface{}) *cutil.APIError
ExecuteSyncWorkflow is a utility function to execute a Temporal workflow synchronously from a Handler. This function can be used across handlers to reduce duplication of workflow execution logic.
func GenerateAccountNumber ¶
func GenerateAccountNumber() string
GenerateAccountNumber will generate a unique account number this will be deprecated - for now, use a uuid
func GetAllAllocationConstraintsForInstanceType ¶
func GetAllAllocationConstraintsForInstanceType(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, ip *cdbm.InfrastructureProvider, site *cdbm.Site, tenant *cdbm.Tenant, resourceTypeID *uuid.UUID) ([]cdbm.AllocationConstraint, int, error)
GetAllAllocationConstraintsForInstanceType is a utility function to return allocation constraints of type instance type for the tenant at the site a specific instance type ID could be specified as a filter, otherwise, the count is across all instancetypes. NOTE: This could be optimized with better db query..
func GetAllInstanceTypeAllocationStats ¶
func GetAllInstanceTypeAllocationStats(ctx context.Context, dbSession *cdb.Session, siteID *uuid.UUID, instanceTypeIDs []uuid.UUID, logger zerolog.Logger, tenantID *uuid.UUID) (map[uuid.UUID]*cam.APIAllocationStats, *cutil.APIError)
GetAllInstanceTypeAllocationStats is a utility function to get all instance type allocation stats
func GetAllocationConstraintsForInstanceType ¶
func GetAllocationConstraintsForInstanceType(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, tenantID uuid.UUID, instancetype *cdbm.InstanceType, allocations []cdbm.Allocation) ([]cdbm.AllocationConstraint, error)
GetAllocationConstraintsForInstanceType gets allocation constraints for instance type allocation
func GetAllocationIDsForTenantAtSite ¶
func GetAllocationIDsForTenantAtSite(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, ipID uuid.UUID, tenantID uuid.UUID, siteID uuid.UUID) ([]uuid.UUID, error)
GetAllocationIDsForTenantAtSite will return all allocation IDs for the tenant at a site
func GetAllocationResourceTypeMaps ¶
func GetAllocationResourceTypeMaps(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, acs []cdbm.AllocationConstraint) ( map[uuid.UUID]*cdbm.InstanceType, map[uuid.UUID]*cdbm.IPBlock, *cutil.APIError)
GetAllocationResourceTypeMaps is a utility function to get resource info based on resource type in allocation constraints currently its only supports Instance Type and IPBlock
func GetAndValidateQueryRelations ¶
func GetAndValidateQueryRelations(qParams url.Values, relatedEntities map[string]bool) ([]string, string)
GetAndValidateQueryRelations is a utility function to get and validate the query parameters for include relations get/getall request
func GetCountOfMachinesForInstanceType ¶
func GetCountOfMachinesForInstanceType(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, instanceTypeID uuid.UUID) (int, error)
GetCountOfMachinesForInstanceType is a utility function to return count of machines for instance type
func GetDomainFromIDString ¶
func GetDomainFromIDString(ctx context.Context, tx *cdb.Tx, domainID string, dbSession *cdb.Session) (*cdbm.Domain, error)
GetDomainFromIDString gets the domain DB model from the id string
func GetIPBlockFromIDString ¶
func GetIPBlockFromIDString(ctx context.Context, tx *cdb.Tx, idStr string, dbSession *cdb.Session) (*cdbm.IPBlock, error)
GetIPBlockFromIDString gets the ip block from the ip block id string
func GetInfrastructureProviderForOrg ¶
func GetInfrastructureProviderForOrg(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, org string) (*cdbm.InfrastructureProvider, error)
GetInfrastructureProviderForOrg gets the infrastructureProvider for org
func GetInstanceFromIDString ¶
func GetInstanceFromIDString(ctx context.Context, tx *cdb.Tx, instanceID string, dbSession *cdb.Session) (*cdbm.Instance, error)
GetInstanceFromIDString gets the site DB model from the id string
func GetInstanceTypeAllocationStats ¶
func GetInstanceTypeAllocationStats(ctx context.Context, dbSession *cdb.Session, logger zerolog.Logger, it cdbm.InstanceType, tenantID *uuid.UUID) (*cam.APIAllocationStats, *cutil.APIError)
GetInstanceTypeAllocationStats is a utility function to get the allocation stats from allocation constraints and instances based on instancetype
func GetInstanceTypeFromIDString ¶
func GetInstanceTypeFromIDString(ctx context.Context, tx *cdb.Tx, idStr string, dbSession *cdb.Session) (*cdbm.InstanceType, error)
GetInstanceTypeFromIDString gets the instance type from the instance type id string
func GetInstanceTypeIDsFromAllocationConstraints ¶
func GetInstanceTypeIDsFromAllocationConstraints(ctx context.Context, acs []cdbm.AllocationConstraint, constraintType string) []uuid.UUID
GetInstanceTypeIDsFromAllocationConstraints is a utility function to get the instanceTypeIDs from a slice of allocation constraints
func GetIsProviderRequest ¶
func GetIsProviderRequest(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, org string, user *cdbm.User, providerRoles []string, tenantRoles []string, queryParams url.Values) (isProviderRequest bool, provider *cdbm.InfrastructureProvider, tenant *cdbm.Tenant, apiError *cutil.APIError)
GetIsProviderRequest is a utility function to check if the request is made from a Provider or Tenant perspective If user only has Provider admin role then we can deduce they are acting as a Provider If user only has Tenant admin role then we can deduce they are acting as a Tenant If user has both Provider and Tenant admin role then we expect the user to specify the query param indicating which role they are acting on This function supports both NGC and Keycloak authentication systems automatically
func GetNVLinkLogicalPartitionCountStats ¶
func GetNVLinkLogicalPartitionCountStats(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, logger zerolog.Logger, nvllpIDs []uuid.UUID) (map[uuid.UUID]*cam.APINVLinkLogicalPartitionStats, error)
GetNVLinkLogicalPartitionCountStats is a utility function to return count of gpus and instances broken down by NVLinkLogicalPartition.
func GetSSHKeyFromIDString ¶
func GetSSHKeyFromIDString(ctx context.Context, tx *cdb.Tx, sshkeyID string, dbSession *cdb.Session) (*cdbm.SSHKey, error)
GetSSHKeyFromIDString gets the sshkey DB model from the id string
func GetSSHKeyGroupFromIDString ¶
func GetSSHKeyGroupFromIDString(ctx context.Context, tx *cdb.Tx, sshkeyGroupID string, dbSession *cdb.Session, includeRelations []string) (*cdbm.SSHKeyGroup, error)
GetSSHKeyGroupFromIDString gets the sshkeygroup DB model from the id string
func GetSiteFromIDString ¶
func GetSiteFromIDString(ctx context.Context, tx *cdb.Tx, siteID string, dbSession *cdb.Session) (*cdbm.Site, error)
GetSiteFromIDString gets the site DB model from the id string
func GetSiteMachineCountStats ¶
func GetSiteMachineCountStats(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, logger zerolog.Logger, infrastructureProviderID *uuid.UUID, siteID *uuid.UUID) (map[uuid.UUID]*cam.APISiteMachineStats, error)
GetSiteMachineCountStats is a utility function to return count of machines broken down by site and machine status.
func GetSiteOperatingSystemtID ¶
func GetSiteOperatingSystemtID(o *cdbm.OperatingSystem) *uuid.UUID
func GetTenantForOrg ¶
func GetTenantForOrg(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, org string) (*cdbm.Tenant, error)
GetTenantForOrg gets the tenant for org
func GetTenantFromIDString ¶
func GetTenantFromIDString(ctx context.Context, tx *cdb.Tx, tenantID string, dbSession *cdb.Session) (*cdbm.Tenant, error)
GetTenantFromIDString gets the tenant from the tenant id string
func GetTenantFromTenantIDOrOrg ¶
func GetTenantFromTenantIDOrOrg(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, tenantID, org *string) (*cdbm.Tenant, error)
GetTenantFromTenantIDOrOrg gets the tenant from the tenant id or org
func GetTestConfig ¶
GetTestConfig returns a config for tests - each instance of config consumes file descriptors via viper and there is no easy way to clean the file descriptors during tests. hence using this to create once config instance for tests
func GetTotalAllocationConstraintValueForInstanceType ¶
func GetTotalAllocationConstraintValueForInstanceType(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, allocationIDs []uuid.UUID, instanceTypeID *uuid.UUID, constraintType *string) (int, error)
GetTotalAllocationConstraintValueForInstanceType is a utility function to return total constraint value for all allocation constraints for all specified allocations
func GetUnallocatedMachineForInstanceType ¶
func GetUnallocatedMachineForInstanceType(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Session, instancetype *cdbm.InstanceType) (*cdbm.Machine, error)
GetUnallocatedMachineForInstanceType provides unallocatd machine based on instancetype
func GetUserAndEnrichLogger ¶
func GetUserAndEnrichLogger(c echo.Context, logger zerolog.Logger, tracerSpan *cutil.TracerSpan, handlerSpan trace.Span) (*cdbm.User, zerolog.Logger, error)
GetUserAndEnrichLogger retrieves the user from the echo context and enriches the logger and tracer span with user ID information (StarfleetID or AuxiliaryID). This eliminates the repetitive if-else block for user ID logging across handlers. The tracerSpan and handlerSpan parameters are optional and can be nil if tracing is not needed.
func GetVpcFromIDString ¶
func GetVpcFromIDString(ctx context.Context, tx *cdb.Tx, vpcID string, includeRelations []string, dbSession *cdb.Session) (*cdbm.Vpc, error)
GetVpcFromIDString gets the vpc DB model from the id string
func IsProvider ¶
func IsProvider(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, org string, user *cdbm.User, allowViewerRole bool) (*cdbm.InfrastructureProvider, *cutil.APIError)
IsProvider ensures that user is authorized to act as a Provider Admin for the org
func IsProviderOrTenant ¶
func IsProviderOrTenant(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, org string, user *cdbm.User, allowViewerRole bool, requirePrivilegedTenant bool) (infrastructureProvider *cdbm.InfrastructureProvider, tenant *cdbm.Tenant, apiError *cutil.APIError)
IsProviderOrTenant ensures that user is authorized to act as a Provider Admin or/and Tenant Admin for the org. if authorized it returns the tenant otherwise a relevant error.
func IsTenant ¶
func IsTenant(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, org string, user *cdbm.User, requirePrivileged bool) (*cdbm.Tenant, *cutil.APIError)
IsTenant ensures that user is authorized to act as a Tenant Admin for the org. if authorized it returns the tenant otherwise a relevant error.
func MatchInstanceTypeCapabilitiesForMachines ¶
func MatchInstanceTypeCapabilitiesForMachines(ctx context.Context, logger zerolog.Logger, dbSession *cdb.Session, instanceTypeID uuid.UUID, machineIds []string) (bool, *string, *cutil.APIError)
MatchInstanceTypeCapabilitiesForMachines is a utility function to check if Instance Type Capabilities are present in the Capabilities of Machines
func QueryParamHash ¶
QueryParamHash builds a deterministic hash from the given query params for workflow ID dedup. Accepts url.Values so callers can pass only the known/valid parameters, preventing unknown query params from polluting the workflow ID.
func QueryTagsFor ¶
QueryTagsFor returns the `query` struct tag values for all fields of the given struct. Results are cached per type.
func RequestHash ¶
func RequestHash(v interface{}) string
RequestHash builds a deterministic hash from any struct by JSON-marshaling it. Used for workflow ID deduplication when request data comes from JSON body instead of query params.
func RollbackTx ¶
RollbackTx is called deferred in functions that create a transaction if transaction was committed, this will do nothing
func SetupHandler ¶
func SetupHandler(modelName, handlerName string, c echo.Context, s *cutil.TracerSpan) (org string, user *cdbm.User, ctx context.Context, logger zerolog.Logger, hs oteltrace.Span)
SetupHandler sets up common tasks for handlers not requiring error handling. WARNING: caller MUST defer handlerSpan.End() if handlerSpan is not nil!!! This function can be used across handlers to reduce duplication of initialization logic.
func TestBuildAllocation ¶
func TestBuildAllocation(t *testing.T, dbSession *cdb.Session, st *cdbm.Site, tn *cdbm.Tenant, name string, user *cdbm.User) *cdbm.Allocation
TestBuildAllocation creates a test Allocation
func TestBuildAllocationConstraint ¶
func TestBuildAllocationConstraint(t *testing.T, dbSession *cdb.Session, al *cdbm.Allocation, it *cdbm.InstanceType, ipb *cdbm.IPBlock, constraintValue int, user *cdbm.User) *cdbm.AllocationConstraint
TestBuildAllocationConstraint creates a test Allocation Constraint of Instance Type
func TestBuildAuditEntry ¶
func TestBuildDpuExtensionServiceUpdateActiveVersions ¶
func TestBuildDpuExtensionServiceUpdateActiveVersions(t *testing.T, dbSession *cdb.Session, dpuExtensionService *cdbm.DpuExtensionService, versions []string) *cdbm.DpuExtensionService
func TestBuildIPBlock ¶
func TestBuildIPBlock(t *testing.T, dbSession *cdb.Session, name string, site *cdbm.Site, tenantID *uuid.UUID, routingType, prefix string, blockSize int, protocolVersion string, user *cdbm.User) *cdbm.IPBlock
TestBuildIPBlock creates a test IP Block
func TestBuildInfrastructureProvider ¶
func TestBuildInfrastructureProvider(t *testing.T, dbSession *cdb.Session, name string, org string, user *cdbm.User) *cdbm.InfrastructureProvider
TestBuildInfrastructureProvider creates a test Infrastructure Provider
func TestBuildInstance ¶
func TestBuildInstance(t *testing.T, dbSession *cdb.Session, name string, alID uuid.UUID, acID uuid.UUID, tnID uuid.UUID, ipID uuid.UUID, stID uuid.UUID, itID uuid.UUID, vpcID uuid.UUID, mID *string, osID uuid.UUID) *cdbm.Instance
TestBuildInstance creates a test instance
func TestBuildInstanceType ¶
func TestBuildInstanceType(t *testing.T, dbSession *cdb.Session, name string, infinityResourceTypeID *uuid.UUID, st *cdbm.Site, labels map[string]string, user *cdbm.User) *cdbm.InstanceType
TestBuildInstanceType creates a test Instance Type
func TestBuildInterface ¶ added in v1.2.0
func TestBuildMachine ¶
func TestBuildMachine(t *testing.T, dbSession *cdb.Session, ip *cdbm.InfrastructureProvider, site *cdbm.Site, itID *uuid.UUID, controllerMachineType *string, status string) *cdbm.Machine
TestBuildMachine creates a test Machine
func TestBuildMachineCapability ¶
func TestBuildMachineCapability(t *testing.T, dbSession *cdb.Session, mID *string, itID *uuid.UUID, capabilityType string, name string, frequency *string, capacity *string, vendor *string, count *int, deviceType *string, inactiveDevices []int) *cdbm.MachineCapability
TestBuildMachineCapability creates a test Machine Capability
func TestBuildMachineInstanceType ¶
func TestBuildMachineInstanceType(t *testing.T, dbSession *cdb.Session, m *cdbm.Machine, it *cdbm.InstanceType) *cdbm.MachineInstanceType
TestBuildMachineInstanceType creates a test Machine Instance Type
func TestBuildNetworkSecurityGroup ¶
func TestBuildNetworkSecurityGroup(t *testing.T, dbSession *cdb.Session, name string, siteID, tenantID uuid.UUID, status string) *cdbm.NetworkSecurityGroup
TestBuildNetworkSecurityGroup creates a test security group
func TestBuildOperatingSystem ¶
func TestBuildOperatingSystem(t *testing.T, dbSession *cdb.Session, name string, tn *cdbm.Tenant, status string, user *cdbm.User) *cdbm.OperatingSystem
TestBuildOperatingSystem creates a test os
func TestBuildSite ¶
func TestBuildSite(t *testing.T, dbSession *cdb.Session, ip *cdbm.InfrastructureProvider, name string, user *cdbm.User) *cdbm.Site
TestBuildSite creates a test Site
func TestBuildStatusDetail ¶
func TestBuildStatusDetail(t *testing.T, dbSession *cdb.Session, entityID string, status string, message *string)
TestBuildStatusDetail creates a test status detail
func TestBuildSubnet ¶
func TestBuildSubnet(t *testing.T, dbSession *cdb.Session, name string, tn *cdbm.Tenant, vpc *cdbm.Vpc, cnsID *uuid.UUID, status string, user *cdbm.User) *cdbm.Subnet
TestBuildSubnet creates a test subnet
func TestBuildTenant ¶
func TestBuildTenant(t *testing.T, dbSession *cdb.Session, name string, org string, user *cdbm.User) *cdbm.Tenant
TestBuildTenant creates a test Tenant
func TestBuildTenantAccount ¶
func TestBuildTenantSite ¶
func TestBuildTenantSite(t *testing.T, dbSession *cdb.Session, tn *cdbm.Tenant, st *cdbm.Site, user *cdbm.User) *cdbm.TenantSite
TestBuildTenantSite creates a test Tenant/Site association
func TestBuildUser ¶
func TestBuildUser(t *testing.T, dbSession *cdb.Session, starfleetID string, org string, roles []string) *cdbm.User
TestBuildUser creates a test User
func TestBuildVPC ¶
func TestBuildVPC(t *testing.T, dbSession *cdb.Session, name string, ip *cdbm.InfrastructureProvider, tn *cdbm.Tenant, st *cdbm.Site, cnvID *uuid.UUID, labels map[string]string, status string, user *cdbm.User) *cdbm.Vpc
TestBuildVPC creates a test VPC
func TestBuildVPCPrefix ¶
func TestBuildVpcPeering ¶ added in v1.2.0
func TestBuildVpcPeering(t *testing.T, dbSession *cdb.Session, vpc1ID, vpc2ID uuid.UUID, siteID uuid.UUID, infrastructureProviderID *uuid.UUID, tenantID *uuid.UUID, isMultiTenant bool, createdByID uuid.UUID) *cdbm.VpcPeering
TestBuildVpcPeering creates a test VPC peering between two VPCs
func TestCommonBuildMachineCapability ¶
func TestCommonBuildMachineCapability(t *testing.T, dbSession *cdb.Session, machineID *string, instanceTypeID *uuid.UUID, cptype string, name string, freq *string, cap *string, vendor *string, count *int, deviceType *string, info map[string]interface{}) *cdbm.MachineCapability
TestCommonBuildMachineCapability creates a machine capability
func TestCommonTraceProviderSetup ¶
func TestCommonTraceProviderSetup(t *testing.T, ctx context.Context) (trace.Tracer, trace.SpanContext, context.Context)
TestCommonTraceProviderSetup creates a test provider and spanner
func TestSetupSchema ¶
TestSetupSchema creates/resets the schema
func UnwrapWorkflowError ¶
Types ¶
type QueryOverride ¶
QueryOverride provides values that override query params when delegating from path-scoped endpoints (e.g. instance/{instanceId}/interface, instance/{instanceId}/nvlink-interface) to more general endpoints. When set, error messages in general endpoints will be modulated
type UniqueChecker ¶
type UniqueChecker[T comparable] struct { // contains filtered or unexported fields }
UniqueChecker is a generic struct for tracking uniqueness of values and detecting duplicates. It's designed to validate uniqueness constraints in batch operations (create/update handlers). T is the type of the reference unique ID being checked (usually UUID).
func NewUniqueChecker ¶
func NewUniqueChecker[T comparable]() *UniqueChecker[T]
NewUniqueChecker creates and initializes a new UniqueChecker
func (*UniqueChecker[T]) DoesIDHaveConflict ¶
func (uc *UniqueChecker[T]) DoesIDHaveConflict(id T) bool
func (*UniqueChecker[T]) GetDuplicates ¶
func (uc *UniqueChecker[T]) GetDuplicates() []string
GetDuplicates returns an array of duplicates values. Note: values are in lowercase.
func (*UniqueChecker[T]) HasDuplicates ¶
func (uc *UniqueChecker[T]) HasDuplicates() bool
HasDuplicates returns true if any duplicates have been detected
func (*UniqueChecker[T]) Update ¶
func (uc *UniqueChecker[T]) Update(id T, uniqueValue string)
Update updates or adds a unique value associated with a principal ID, allowing overwrites.