Documentation
¶
Index ¶
- Constants
- Variables
- func APIToDevices(apiDevices map[string]map[string]string) (map[string]Device, error)
- func ActivateTLSIdentity(ctx context.Context, tx *sql.Tx, identifier uuid.UUID, cert *x509.Certificate) error
- func AuthGroupExists(ctx context.Context, tx *sql.Tx, groupName string) (bool, error)
- func ClearStaleOperationsFromNodes(ctx context.Context, tx *sql.Tx, nodeIDs ...int64) error
- func ClusterGroupExists(ctx context.Context, tx *sql.Tx, name string) (bool, error)
- func ClusterLinksConfigStore() *query.EntityConfigStore
- func CreateCertificateLegacy(ctx context.Context, tx *sql.Tx, object CertificateLegacy) (int64, error)
- func CreateCertificateLegacyWithProjects(ctx context.Context, tx *sql.Tx, cert CertificateLegacy, projectNames []string) (int64, error)
- func CreateClusterGroup(ctx context.Context, tx *sql.Tx, object ClusterGroup) (int64, error)
- func CreateClusterLink(ctx context.Context, tx *sql.Tx, object ClusterLinkRow) (int64, error)
- func CreateConfig(ctx context.Context, tx *sql.Tx, parent string, object Config) error
- func CreateDevices(ctx context.Context, tx *sql.Tx, parent string, objects map[string]Device) error
- func CreateIdentityProviderGroup(ctx context.Context, tx *sql.Tx, object IdentityProviderGroupsRow) (int64, error)
- func CreateInstance(ctx context.Context, tx *sql.Tx, object Instance) (int64, error)
- func CreateInstanceConfig(ctx context.Context, tx *sql.Tx, instanceID int64, config map[string]string) error
- func CreateInstanceDevices(ctx context.Context, tx *sql.Tx, instanceID int64, devices map[string]Device) error
- func CreateInstanceSnapshot(ctx context.Context, tx *sql.Tx, object InstanceSnapshot) (int64, error)
- func CreateInstanceSnapshotConfig(ctx context.Context, tx *sql.Tx, instanceSnapshotID int64, ...) error
- func CreateInstanceSnapshotDevices(ctx context.Context, tx *sql.Tx, instanceSnapshotID int64, ...) error
- func CreateOIDCSession(ctx context.Context, tx *sql.Tx, session OIDCSession) error
- func CreateOperationResources(ctx context.Context, tx *sql.Tx, opID int64, ...) error
- func CreateProfile(ctx context.Context, tx *sql.Tx, object Profile) (int64, error)
- func CreateProfileConfig(ctx context.Context, tx *sql.Tx, profileID int64, config map[string]string) error
- func CreateProfileDevices(ctx context.Context, tx *sql.Tx, profileID int64, devices map[string]Device) error
- func CreateProject(ctx context.Context, tx *sql.Tx, object Project) (int64, error)
- func CreateProjectConfig(ctx context.Context, tx *sql.Tx, projectID int64, config map[string]string) error
- func CreateReplicator(ctx context.Context, tx *sql.Tx, object ReplicatorRow) (int64, error)
- func CreateTLSIdentity(ctx context.Context, tx *sql.Tx, name string, idType string, ...) (int64, error)
- func DeleteBearerIdentitySigningKey(ctx context.Context, tx *sql.Tx, identityID int64) error
- func DeleteCertificateLegacy(ctx context.Context, tx *sql.Tx, fingerprint string) error
- func DeleteClusterGroup(ctx context.Context, tx *sql.Tx, name string) error
- func DeleteClusterLink(ctx context.Context, tx *sql.Tx, name string) error
- func DeleteConfig(ctx context.Context, tx *sql.Tx, parent string, referenceID int) error
- func DeleteDevices(ctx context.Context, tx *sql.Tx, parent string, referenceID int) error
- func DeleteIdentityByAuthenticationMethodAndIdentifier(ctx context.Context, tx *sql.Tx, authenticationMethod string, ...) error
- func DeleteIdentityByNameAndType(ctx context.Context, tx *sql.Tx, name string, identityType string) error
- func DeleteIdentityProviderGroup(ctx context.Context, tx *sql.Tx, name string) error
- func DeleteInstance(ctx context.Context, tx *sql.Tx, project string, name string) error
- func DeleteInstanceProfiles(ctx context.Context, tx *sql.Tx, instanceID int) error
- func DeleteInstanceSnapshot(ctx context.Context, tx *sql.Tx, project string, instance string, name string) error
- func DeleteNodesClusterGroupsByGroupID(ctx context.Context, tx *sql.Tx, groupID int64) error
- func DeleteOIDCSessionByUUID(ctx context.Context, tx *sql.Tx, sessionID uuid.UUID) error
- func DeleteOperation(ctx context.Context, tx *sql.Tx, operationUUID string) error
- func DeleteProfile(ctx context.Context, tx *sql.Tx, project string, name string) error
- func DeleteProject(ctx context.Context, tx *sql.Tx, name string) error
- func DeleteReplicator(ctx context.Context, tx *sql.Tx, name string, projectName string) error
- func DeleteWarning(ctx context.Context, tx *sql.Tx, uuid string) error
- func DeleteWarnings(ctx context.Context, tx *sql.Tx, entityType EntityType, entityID int) error
- func DevicesToAPI(devices map[string]Device) map[string]map[string]string
- func EnsureSchema(db *sql.DB, address string, dir string, serverUUID string) error
- func FreshSchema() string
- func GetAllBearerIdentitySigningKeys(ctx context.Context, tx *sql.Tx) (map[int64]AuthSecretValue, error)
- func GetAllIdentitiesByAuthGroupIDs(ctx context.Context, tx *sql.Tx) (map[int64][]IdentitiesRow, error)
- func GetAllIdentityProviderGroupsByGroupIDs(ctx context.Context, tx *sql.Tx) (map[int64][]IdentityProviderGroupsRow, error)
- func GetAllProjectsConfig(ctx context.Context, tx *sql.Tx) (map[string]map[string]string, error)
- func GetCertificateLegacyID(ctx context.Context, tx *sql.Tx, fingerprint string) (int64, error)
- func GetCertificateLegacyProjects(ctx context.Context, tx *sql.Tx, certificateID *int64) (map[int64][]string, error)
- func GetClusterGroupID(ctx context.Context, tx *sql.Tx, name string) (int64, error)
- func GetClusterLinksUsedBy(ctx context.Context, tx *sql.Tx, clusterLinkName *string, firstOnly bool) (map[string][]string, error)
- func GetConfig(ctx context.Context, tx *sql.Tx, parent string, filters ...ConfigFilter) (map[int]map[string]string, error)
- func GetDevices(ctx context.Context, tx *sql.Tx, parent string, filters ...DeviceFilter) (map[int][]Device, error)
- func GetDistinctAuthGroupNamesFromIDPGroupNames(ctx context.Context, tx *sql.Tx, idpGroupNames []string) ([]string, error)
- func GetEntityURL(ctx context.Context, tx *sql.Tx, entityType entity.Type, entityID int) (*api.URL, error)
- func GetEntityURLs(ctx context.Context, tx *sql.Tx, projectName string, ...) (map[entity.Type]map[int]*api.URL, error)
- func GetGroupPermissions(ctx context.Context, tx *sql.Tx) (map[string][]Permission, error)
- func GetIdentitiesPEMCertificates(ctx context.Context, tx *sql.Tx, identityID *int64) (map[int64][]string, error)
- func GetIdentityAndSessionDetailsFromSessionID(ctx context.Context, tx *sql.Tx, sessionID uuid.UUID) (*IdentitiesRow, *OIDCSession, error)
- func GetIdentityAuthGroupNames(ctx context.Context, tx *sql.Tx, identityID *int64, ...) (map[int64][]string, error)
- func GetImageSource(ctx context.Context, tx *sql.Tx, imageID int) (int, *api.ImageSource, error)
- func GetInstanceConfig(ctx context.Context, tx *sql.Tx, instanceID int, filters ...ConfigFilter) (map[string]string, error)
- func GetInstanceDevices(ctx context.Context, tx *sql.Tx, instanceID int, filters ...DeviceFilter) (map[string]Device, error)
- func GetInstanceID(ctx context.Context, tx *sql.Tx, project string, name string) (int64, error)
- func GetInstanceSnapshotConfig(ctx context.Context, tx *sql.Tx, instanceSnapshotID int, ...) (map[string]string, error)
- func GetInstanceSnapshotDevices(ctx context.Context, tx *sql.Tx, instanceSnapshotID int, ...) (map[string]Device, error)
- func GetInstanceSnapshotID(ctx context.Context, tx *sql.Tx, project string, instance string, name string) (int64, error)
- func GetInstancesInPlacementGroup(ctx context.Context, tx *sql.Tx, name string, projectName string, ...) (map[int64][]int64, error)
- func GetOperationResources(ctx context.Context, tx *sql.Tx, opID int64) (map[entity.Type][]api.URL, error)
- func GetPlacementGroupUsedBy(ctx context.Context, tx *sql.Tx, projectName string, placementGroupName string, ...) ([]string, error)
- func GetPlacementGroupsUsedBy(ctx context.Context, tx *sql.Tx, filter PlacementGroupFilter, firstOnly bool) (map[string]map[string][]string, error)
- func GetProfileConfig(ctx context.Context, tx *sql.Tx, profileID int, filters ...ConfigFilter) (map[string]string, error)
- func GetProfileDevices(ctx context.Context, tx *sql.Tx, profileID int, filters ...DeviceFilter) (map[string]Device, error)
- func GetProfileID(ctx context.Context, tx *sql.Tx, project string, name string) (int64, error)
- func GetProfileIDsByProjectAndName(ctx context.Context, tx *sql.Tx, projectNames []string, profileNames []string) ([]int64, error)
- func GetProjectConfig(ctx context.Context, tx *sql.Tx, projectName string) (map[string]string, error)
- func GetProjectID(ctx context.Context, tx *sql.Tx, name string) (int64, error)
- func GetProjectIDsToNames(ctx context.Context, tx *sql.Tx) (map[int64]string, error)
- func GetProjectNames(ctx context.Context, tx *sql.Tx) ([]string, error)
- func GetProjectsSharingDefaultImages(ctx context.Context, tx *sql.Tx) ([]string, error)
- func GetProjectsUsingRestrictedClusterGroups(ctx context.Context, tx *sql.Tx, groupName string) ([]string, error)
- func GetWarningID(ctx context.Context, tx *sql.Tx, uuid string) (int64, error)
- func InitProjectWithoutImages(ctx context.Context, tx *sql.Tx, project string) error
- func Open(name string, store driver.NodeStore, options ...driver.Option) (*sql.DB, error)
- func PlacementGroupsConfigStore() *query.EntityConfigStore
- func PopulateEntityReferencesFromURLs(ctx context.Context, tx *sql.Tx, entityURLMap map[*api.URL]*EntityRef) error
- func PrepareStmts(db *sql.DB, skipErrors bool) (map[int]*sql.Stmt, error)
- func ProjectHasImages(ctx context.Context, tx *sql.Tx, name string) (bool, error)
- func ProjectHasProfiles(ctx context.Context, tx *sql.Tx, name string) (bool, error)
- func RegisterStmt(sql string) int
- func RenameClusterGroup(ctx context.Context, tx *sql.Tx, name string, to string) error
- func RenameClusterLink(ctx context.Context, tx *sql.Tx, name string, to string) error
- func RenameIdentityProviderGroup(ctx context.Context, tx *sql.Tx, name string, to string) error
- func RenameInstance(ctx context.Context, tx *sql.Tx, project string, name string, to string) error
- func RenameInstanceSnapshot(ctx context.Context, tx *sql.Tx, project string, instance string, name string, ...) error
- func RenameProfile(ctx context.Context, tx *sql.Tx, project string, name string, to string) error
- func RenameProject(ctx context.Context, tx *sql.Tx, name string, to string) error
- func RenameReplicator(ctx context.Context, tx *sql.Tx, name string, projectName string, ...) error
- func ReplicatorsConfigStore() *query.EntityConfigStore
- func Schema() *schema.Schema
- func SchemaDotGo() error
- func SetAuthGroupPermissions(ctx context.Context, tx *sql.Tx, groupID int64, ...) error
- func SetIdentityAuthGroups(ctx context.Context, tx *sql.Tx, identityID int64, groupNames []string) error
- func SetIdentityProviderGroupMapping(ctx context.Context, tx *sql.Tx, identityProviderGroupID int64, ...) error
- func Stmt(tx *sql.Tx, code int) (*sql.Stmt, error)
- func StmtString(code int) (string, error)
- func UpdateCertificateLegacy(ctx context.Context, tx *sql.Tx, object CertificateLegacy) error
- func UpdateCertificateLegacyProjects(ctx context.Context, tx *sql.Tx, certificateID int64, projectNames []string) error
- func UpdateClusterGroup(ctx context.Context, tx *sql.Tx, name string, object ClusterGroup) error
- func UpdateClusterLink(ctx context.Context, tx *sql.Tx, object ClusterLinkRow) error
- func UpdateConfig(ctx context.Context, tx *sql.Tx, parent string, referenceID int, ...) error
- func UpdateDevices(ctx context.Context, tx *sql.Tx, parent string, referenceID int, ...) error
- func UpdateInstance(ctx context.Context, tx *sql.Tx, project string, name string, object Instance) error
- func UpdateInstanceConfig(ctx context.Context, tx *sql.Tx, instanceID int64, config map[string]string) error
- func UpdateInstanceDevices(ctx context.Context, tx *sql.Tx, instanceID int64, devices map[string]Device) error
- func UpdateInstanceProfiles(ctx context.Context, tx *sql.Tx, instanceID int, projectName string, ...) error
- func UpdateOperation(ctx context.Context, tx *sql.Tx, opUUID string, nodeID int64, ...) error
- func UpdateProfile(ctx context.Context, tx *sql.Tx, project string, name string, object Profile) error
- func UpdateProfileConfig(ctx context.Context, tx *sql.Tx, profileID int64, config map[string]string) error
- func UpdateProfileDevices(ctx context.Context, tx *sql.Tx, profileID int64, devices map[string]Device) error
- func UpdateProject(ctx context.Context, tx *sql.Tx, name string, object api.ProjectPut) error
- func UpdateProjectReplicaMode(ctx context.Context, tx *sql.Tx, projectName string, replicaMode string) error
- func UpdateReplicator(ctx context.Context, tx *sql.Tx, object ReplicatorRow) error
- func UpdateReplicatorLastRun(ctx context.Context, tx *sql.Tx, id int64, date time.Time, status string) error
- func UpdateReplicatorLastRunStatus(ctx context.Context, tx *sql.Tx, id int64, status string) error
- func UpdateTLSIdentity(ctx context.Context, tx *sql.Tx, identity IdentitiesRow, fingerprint string, ...) error
- func WarningExists(ctx context.Context, tx *sql.Tx, uuid string) (bool, error)
- type AuthGroupsRow
- func GetAuthGroup(ctx context.Context, tx *sql.Tx, groupName string) (*AuthGroupsRow, error)
- func GetAuthGroupsAndURLs(ctx context.Context, tx *sql.Tx, filter func(group AuthGroupsRow) bool) ([]AuthGroupsRow, []string, error)
- func GetAuthGroupsByIdentityID(ctx context.Context, tx *sql.Tx, identityID int64) ([]AuthGroupsRow, error)
- func GetAuthGroupsByIdentityProviderGroupID(ctx context.Context, tx *sql.Tx, idpGroupID int64) ([]AuthGroupsRow, error)
- func (AuthGroupsRow) APIName() string
- func (a AuthGroupsRow) CreateStmt() string
- func (a AuthGroupsRow) CreateValues() []any
- func (a AuthGroupsRow) Joins() []string
- func (a AuthGroupsRow) PKColumns() []string
- func (a AuthGroupsRow) PKValues() []any
- func (a *AuthGroupsRow) ScanArgs() []any
- func (a AuthGroupsRow) SelectColumns() []string
- func (a AuthGroupsRow) TableName() string
- func (g *AuthGroupsRow) ToAPI(ctx context.Context, tx *sql.Tx, canViewIdentity auth.PermissionChecker, ...) (*api.AuthGroup, error)
- func (a AuthGroupsRow) UpdateStmt() string
- func (a AuthGroupsRow) UpdateValues() []any
- type AuthMethod
- type AuthSecret
- type AuthSecretValue
- type AuthSecrets
- type CertificateLegacy
- func GetCertificateLegacy(ctx context.Context, tx *sql.Tx, fingerprint string) (*CertificateLegacy, error)
- func GetCertificateLegacyByFingerprintPrefix(ctx context.Context, tx *sql.Tx, fingerprintPrefix string) (*CertificateLegacy, error)
- func GetCertificatesAndURLsLegacy(ctx context.Context, tx *sql.Tx, filter func(legacy CertificateLegacy) bool) ([]CertificateLegacy, []string, error)
- type CertificatesRow
- func (CertificatesRow) APIName() string
- func (c CertificatesRow) CreateStmt() string
- func (c CertificatesRow) CreateValues() []any
- func (c CertificatesRow) Joins() []string
- func (c CertificatesRow) PKColumns() []string
- func (c CertificatesRow) PKValues() []any
- func (c *CertificatesRow) ScanArgs() []any
- func (c CertificatesRow) SelectColumns() []string
- func (c CertificatesRow) TableName() string
- func (c CertificatesRow) UpdateStmt() string
- func (c CertificatesRow) UpdateValues() []any
- type ClusterGroup
- type ClusterGroupFilter
- type ClusterGroupGenerated
- type ClusterLinkRow
- func GetClusterLink(ctx context.Context, tx *sql.Tx, name string) (*ClusterLinkRow, error)
- func GetClusterLinks(ctx context.Context, tx *sql.Tx) ([]ClusterLinkRow, error)
- func GetClusterLinksAndURLs(ctx context.Context, tx *sql.Tx, filter func(link ClusterLinkRow) bool) ([]ClusterLinkRow, []string, error)
- func (ClusterLinkRow) APIName() string
- func (c ClusterLinkRow) CreateStmt() string
- func (c ClusterLinkRow) CreateValues() []any
- func (c ClusterLinkRow) Joins() []string
- func (c ClusterLinkRow) PKColumns() []string
- func (c ClusterLinkRow) PKValues() []any
- func (c *ClusterLinkRow) ScanArgs() []any
- func (c ClusterLinkRow) SelectColumns() []string
- func (c ClusterLinkRow) TableName() string
- func (r *ClusterLinkRow) ToAPI(allConfigs map[int64]map[string]string) *api.ClusterLink
- func (c ClusterLinkRow) UpdateStmt() string
- func (c ClusterLinkRow) UpdateValues() []any
- type ClusterLinkType
- type Config
- type ConfigFilter
- type ConfigGenerated
- type Device
- type DeviceFilter
- type DeviceGenerated
- type DeviceType
- type EntityRef
- type EntityType
- type IdentitiesRow
- func GetIdentitiesAndURLs(ctx context.Context, tx *sql.Tx, authMethod *string, ...) ([]IdentitiesRow, []string, error)
- func GetIdentitiesByAuthGroupID(ctx context.Context, tx *sql.Tx, groupID int64) ([]IdentitiesRow, error)
- func GetIdentityByAuthenticationMethodAndIdentifier(ctx context.Context, tx *sql.Tx, authenticationMethod string, ...) (*IdentitiesRow, error)
- func GetIdentityByID(ctx context.Context, tx *sql.Tx, id int64) (*IdentitiesRow, error)
- func GetIdentityByNameOrIdentifier(ctx context.Context, tx *sql.Tx, authenticationMethod string, nameOrID string) (*IdentitiesRow, error)
- func GetPendingTLSIdentityByTokenSecret(ctx context.Context, tx *sql.Tx, secret string) (*IdentitiesRow, error)
- func (IdentitiesRow) APIName() string
- func (IdentitiesRow) APIPluralName() string
- func (i IdentitiesRow) CreateStmt() string
- func (i IdentitiesRow) CreateValues() []any
- func (i IdentitiesRow) Joins() []string
- func (i IdentitiesRow) OIDCMetadata() (*OIDCMetadata, error)
- func (i IdentitiesRow) PKColumns() []string
- func (i IdentitiesRow) PKValues() []any
- func (i IdentitiesRow) PendingTLSMetadata() (*PendingTLSMetadata, error)
- func (i *IdentitiesRow) ScanArgs() []any
- func (i IdentitiesRow) SelectColumns() []string
- func (i IdentitiesRow) TableName() string
- func (i *IdentitiesRow) ToAPI(idToGroups map[int64][]string, idToCertificates map[int64][]string) (*api.Identity, error)
- func (i IdentitiesRow) ToCertificate(idToCert map[int64][]string) (*CertificateLegacy, error)
- func (i IdentitiesRow) UpdateStmt() string
- func (i IdentitiesRow) UpdateValues() []any
- type IdentityCertificate
- type IdentityProviderGroupsRow
- func GetIdentityProviderGroup(ctx context.Context, tx *sql.Tx, name string) (*IdentityProviderGroupsRow, error)
- func GetIdentityProviderGroups(ctx context.Context, tx *sql.Tx) ([]IdentityProviderGroupsRow, error)
- func GetIdentityProviderGroupsByGroupID(ctx context.Context, tx *sql.Tx, groupID int64) ([]IdentityProviderGroupsRow, error)
- func (i IdentityProviderGroupsRow) APIName() string
- func (i IdentityProviderGroupsRow) CreateStmt() string
- func (i IdentityProviderGroupsRow) CreateValues() []any
- func (i IdentityProviderGroupsRow) Joins() []string
- func (i IdentityProviderGroupsRow) PKColumns() []string
- func (i IdentityProviderGroupsRow) PKValues() []any
- func (i *IdentityProviderGroupsRow) ScanArgs() []any
- func (i IdentityProviderGroupsRow) SelectColumns() []string
- func (i IdentityProviderGroupsRow) TableName() string
- func (i *IdentityProviderGroupsRow) ToAPI(ctx context.Context, tx *sql.Tx, canViewGroup auth.PermissionChecker) (*api.IdentityProviderGroup, error)
- func (i IdentityProviderGroupsRow) UpdateStmt() string
- func (i IdentityProviderGroupsRow) UpdateValues() []any
- type IdentityType
- type Image
- type ImageFilter
- type ImageGenerated
- type Instance
- type InstanceFilter
- type InstanceGenerated
- type InstanceSnapshot
- type InstanceSnapshotFilter
- type InstanceSnapshotGenerated
- type InstancesProfilesRow
- func (InstancesProfilesRow) APIName() string
- func (i InstancesProfilesRow) CreateStmt() string
- func (i InstancesProfilesRow) CreateValues() []any
- func (i InstancesProfilesRow) Joins() []string
- func (i InstancesProfilesRow) PKColumns() []string
- func (i InstancesProfilesRow) PKValues() []any
- func (i *InstancesProfilesRow) ScanArgs() []any
- func (i InstancesProfilesRow) SelectColumns() []string
- func (i InstancesProfilesRow) TableName() string
- func (i InstancesProfilesRow) UpdateStmt() string
- func (i InstancesProfilesRow) UpdateValues() []any
- type Node
- type NodeFilter
- type NodesClusterGroups
- type NodesClusterGroupsRow
- func (NodesClusterGroupsRow) APIName() string
- func (n NodesClusterGroupsRow) CreateStmt() string
- func (n NodesClusterGroupsRow) CreateValues() []any
- func (n NodesClusterGroupsRow) Joins() []string
- func (n NodesClusterGroupsRow) PKColumns() []string
- func (n NodesClusterGroupsRow) PKValues() []any
- func (n *NodesClusterGroupsRow) ScanArgs() []any
- func (n NodesClusterGroupsRow) SelectColumns() []string
- func (n NodesClusterGroupsRow) TableName() string
- func (n NodesClusterGroupsRow) UpdateStmt() string
- func (n NodesClusterGroupsRow) UpdateValues() []any
- type OIDCMetadata
- type OIDCSession
- type Operation
- func GetOperation(ctx context.Context, tx *sql.Tx, operationUUID string) (*Operation, error)
- func GetOperationsByNodeID(ctx context.Context, tx *sql.Tx, nodeID int64) ([]Operation, error)
- func GetOperationsByProjectAndType(ctx context.Context, tx *sql.Tx, projectName string, opType operationtype.Type) ([]Operation, error)
- func GetOperationsWithParent(ctx context.Context, tx *sql.Tx, parentID int64) ([]Operation, error)
- func GetParentOperations(ctx context.Context, tx *sql.Tx) ([]Operation, error)
- type OperationFilter
- type OperationsRow
- func (OperationsRow) APIName() string
- func (o OperationsRow) CreateStmt() string
- func (o OperationsRow) CreateValues() []any
- func (o OperationsRow) Joins() []string
- func (o OperationsRow) PKColumns() []string
- func (o OperationsRow) PKValues() []any
- func (o *OperationsRow) ScanArgs() []any
- func (o OperationsRow) SelectColumns() []string
- func (o OperationsRow) TableName() string
- func (o OperationsRow) UpdateStmt() string
- func (o OperationsRow) UpdateValues() []any
- type PendingTLSMetadata
- type Permission
- func GetDistinctPermissionsByGroupNames(ctx context.Context, tx *sql.Tx, groupNames []string) ([]Permission, error)
- func GetPermissionEntityURLs(ctx context.Context, tx *sql.Tx, permissions []Permission) ([]Permission, map[entity.Type]map[int]*api.URL, error)
- func GetPermissions(ctx context.Context, tx *sql.Tx) ([]Permission, error)
- func GetPermissionsByAuthGroupID(ctx context.Context, tx *sql.Tx, groupID int64) ([]Permission, error)
- type PlacementGroup
- func (p PlacementGroup) APIName() string
- func (p PlacementGroup) Joins() []string
- func (p *PlacementGroup) ScanArgs() []any
- func (p PlacementGroup) SelectColumns() []string
- func (p PlacementGroup) TableName() string
- func (p *PlacementGroup) ToAPI(configs map[int64]map[string]string) *api.PlacementGroup
- type PlacementGroupFilter
- type PlacementGroupsRow
- func (PlacementGroupsRow) APIName() string
- func (p PlacementGroupsRow) CreateStmt() string
- func (p PlacementGroupsRow) CreateValues() []any
- func (p PlacementGroupsRow) Joins() []string
- func (p PlacementGroupsRow) PKColumns() []string
- func (p PlacementGroupsRow) PKValues() []any
- func (p *PlacementGroupsRow) ScanArgs() []any
- func (p PlacementGroupsRow) SelectColumns() []string
- func (p PlacementGroupsRow) TableName() string
- func (p PlacementGroupsRow) UpdateStmt() string
- func (p PlacementGroupsRow) UpdateValues() []any
- type Profile
- func GetInstanceProfiles(ctx context.Context, tx *sql.Tx, instanceID int) ([]Profile, error)
- func GetProfile(ctx context.Context, tx *sql.Tx, project string, name string) (*Profile, error)
- func GetProfiles(ctx context.Context, tx *sql.Tx, filters ...ProfileFilter) ([]Profile, error)
- func GetProfilesIfEnabled(ctx context.Context, tx *sql.Tx, projectName string, names []string) ([]Profile, error)
- type ProfileFilter
- type ProfileGenerated
- type Project
- type ProjectFeature
- type ProjectFilter
- type ProjectGenerated
- type ProjectReplicaMode
- type Replicator
- type ReplicatorRow
- func (ReplicatorRow) APIName() string
- func (r ReplicatorRow) CreateStmt() string
- func (r ReplicatorRow) CreateValues() []any
- func (r ReplicatorRow) Joins() []string
- func (r ReplicatorRow) PKColumns() []string
- func (r ReplicatorRow) PKValues() []any
- func (r *ReplicatorRow) ScanArgs() []any
- func (r ReplicatorRow) SelectColumns() []string
- func (r ReplicatorRow) TableName() string
- func (r ReplicatorRow) UpdateStmt() string
- func (r ReplicatorRow) UpdateValues() []any
- type RequestorProtocol
- type SecretType
- type StoragePoolVolumeContentType
- type StoragePoolVolumeType
- type Warning
- type WarningFilter
- type WarningGenerated
Constants ¶
const ( TypeNone = DeviceType(0) TypeNIC = DeviceType(1) TypeDisk = DeviceType(2) TypeUnixChar = DeviceType(3) TypeUnixBlock = DeviceType(4) TypeUSB = DeviceType(5) TypeGPU = DeviceType(6) TypeInfiniband = DeviceType(7) TypeProxy = DeviceType(8) TypeUnixHotplug = DeviceType(9) TypeTPM = DeviceType(10) TypePCI = DeviceType(11) )
Supported device types.
const ( StoragePoolVolumeTypeNameContainer string = "container" StoragePoolVolumeTypeNameVM string = "virtual-machine" StoragePoolVolumeTypeNameImage string = "image" StoragePoolVolumeTypeNameCustom string = "custom" )
Leave the string type in here! This guarantees that go treats this is as a typed string constant. Removing it causes go to treat these as untyped string constants which is not what we want.
const ( StoragePoolVolumeContentTypeNameFS string = "filesystem" StoragePoolVolumeContentTypeNameBlock string = "block" StoragePoolVolumeContentTypeNameISO string = "iso" )
Content type names.
Variables ¶
var ImageSourceProtocol = map[int]string{
0: "lxd",
1: "direct",
2: "simplestreams",
}
ImageSourceProtocol maps image source protocol codes to human-readable names.
var PreparedStmts = map[int]*sql.Stmt{}
PreparedStmts is a placeholder for transitioning to package-scoped transaction functions.
var ProjectFeatures = map[string]ProjectFeature{ "features.images": { DefaultEnabled: true, }, "features.profiles": { DefaultEnabled: true, }, "features.storage.volumes": { DefaultEnabled: true, }, "features.storage.buckets": { DefaultEnabled: true, }, "features.networks": {}, "features.networks.zones": { CanEnableNonEmpty: true, }, }
ProjectFeatures lists available project features and their behaviours.
var SchemaVersion = len(updates)
SchemaVersion is the current version of the cluster database schema.
Functions ¶
func APIToDevices ¶
APIToDevices takes an API format devices map and converts it to a map of db.Device.
func ActivateTLSIdentity ¶
func ActivateTLSIdentity(ctx context.Context, tx *sql.Tx, identifier uuid.UUID, cert *x509.Certificate) error
ActivateTLSIdentity updates a TLS identity to make it valid by adding the fingerprint, PEM encoded certificate, and setting the type.
func AuthGroupExists ¶
AuthGroupExists returns true if an AuthGroup exists and false otherwise.
func ClearStaleOperationsFromNodes ¶
ClearStaleOperationsFromNodes clears all stale operation records from the database for the given node IDs. This includes: - Deleting ephemeral operations, which are operations that are normally cleared few seconds after they finish. - Marking running bulk operations as failed.
func ClusterGroupExists ¶
ClusterGroupExists checks if a cluster_group with the given key exists. generator: cluster_group Exists
func ClusterLinksConfigStore ¶
func ClusterLinksConfigStore() *query.EntityConfigStore
ClusterLinksConfigStore returns a query.EntityConfigStore for cluster links.
func CreateCertificateLegacy ¶
func CreateCertificateLegacy(ctx context.Context, tx *sql.Tx, object CertificateLegacy) (int64, error)
CreateCertificateLegacy adds a new certificate to the database.
func CreateCertificateLegacyWithProjects ¶
func CreateCertificateLegacyWithProjects(ctx context.Context, tx *sql.Tx, cert CertificateLegacy, projectNames []string) (int64, error)
CreateCertificateLegacyWithProjects stores a CertificateLegacy object in the db, and associates it to a list of project names. It will ignore the ID field from the CertificateLegacy.
func CreateClusterGroup ¶
CreateClusterGroup adds a new cluster_group to the database. generator: cluster_group Create
func CreateClusterLink ¶
CreateClusterLink adds a new cluster link to the database.
func CreateConfig ¶
CreateConfig adds a new config to the database. generator: config Create
func CreateDevices ¶
CreateDevices adds a new device to the database. generator: device Create
func CreateIdentityProviderGroup ¶
func CreateIdentityProviderGroup(ctx context.Context, tx *sql.Tx, object IdentityProviderGroupsRow) (int64, error)
CreateIdentityProviderGroup adds a new identity provider group to the database.
func CreateInstance ¶
CreateInstance adds a new instance to the database. generator: instance Create
func CreateInstanceConfig ¶
func CreateInstanceConfig(ctx context.Context, tx *sql.Tx, instanceID int64, config map[string]string) error
CreateInstanceConfig adds new instance Config to the database. generator: instance Create
func CreateInstanceDevices ¶
func CreateInstanceDevices(ctx context.Context, tx *sql.Tx, instanceID int64, devices map[string]Device) error
CreateInstanceDevices adds new instance Devices to the database. generator: instance Create
func CreateInstanceSnapshot ¶
func CreateInstanceSnapshot(ctx context.Context, tx *sql.Tx, object InstanceSnapshot) (int64, error)
CreateInstanceSnapshot adds a new instance_snapshot to the database. generator: instance_snapshot Create
func CreateInstanceSnapshotConfig ¶
func CreateInstanceSnapshotConfig(ctx context.Context, tx *sql.Tx, instanceSnapshotID int64, config map[string]string) error
CreateInstanceSnapshotConfig adds new instance_snapshot Config to the database. generator: instance_snapshot Create
func CreateInstanceSnapshotDevices ¶
func CreateInstanceSnapshotDevices(ctx context.Context, tx *sql.Tx, instanceSnapshotID int64, devices map[string]Device) error
CreateInstanceSnapshotDevices adds new instance_snapshot Devices to the database. generator: instance_snapshot Create
func CreateOIDCSession ¶
CreateOIDCSession creates an OIDC session.
func CreateOperationResources ¶
func CreateOperationResources(ctx context.Context, tx *sql.Tx, opID int64, resources map[entity.Type][]api.URL) error
CreateOperationResources registers operation resources in the cluster db.
func CreateProfile ¶
CreateProfile adds a new profile to the database. generator: profile Create
func CreateProfileConfig ¶
func CreateProfileConfig(ctx context.Context, tx *sql.Tx, profileID int64, config map[string]string) error
CreateProfileConfig adds new profile Config to the database. generator: profile Create
func CreateProfileDevices ¶
func CreateProfileDevices(ctx context.Context, tx *sql.Tx, profileID int64, devices map[string]Device) error
CreateProfileDevices adds new profile Devices to the database. generator: profile Create
func CreateProject ¶
CreateProject adds a new project to the database. generator: project Create
func CreateProjectConfig ¶
func CreateProjectConfig(ctx context.Context, tx *sql.Tx, projectID int64, config map[string]string) error
CreateProjectConfig adds new project Config to the database. generator: project Create
func CreateReplicator ¶
CreateReplicator adds a new replicator to the database.
func CreateTLSIdentity ¶
func CreateTLSIdentity(ctx context.Context, tx *sql.Tx, name string, idType string, fingerprint string, pemCert string) (int64, error)
CreateTLSIdentity creates an Identity and a Certificate, and then adds a row to their association table.
func DeleteBearerIdentitySigningKey ¶
DeleteBearerIdentitySigningKey deletes any signing keys for the identity. It returns an api.StatusError with http.StatusNotFound if no key exists.
func DeleteCertificateLegacy ¶
DeleteCertificateLegacy deletes the certificate matching the given key parameters.
func DeleteClusterGroup ¶
DeleteClusterGroup deletes the cluster_group matching the given key parameters. generator: cluster_group DeleteOne-by-Name
func DeleteClusterLink ¶
DeleteClusterLink deletes the cluster link with the given name.
func DeleteConfig ¶
DeleteConfig deletes the config matching the given key parameters. generator: config DeleteMany
func DeleteDevices ¶
DeleteDevices deletes the device matching the given key parameters. generator: device DeleteMany
func DeleteIdentityByAuthenticationMethodAndIdentifier ¶
func DeleteIdentityByAuthenticationMethodAndIdentifier(ctx context.Context, tx *sql.Tx, authenticationMethod string, identifier string) error
DeleteIdentityByAuthenticationMethodAndIdentifier deletes a single identity with the given authentication method and identifier.
func DeleteIdentityByNameAndType ¶
func DeleteIdentityByNameAndType(ctx context.Context, tx *sql.Tx, name string, identityType string) error
DeleteIdentityByNameAndType deletes a single identity with the given name and type. Note that the name of an identity is not guaranteed to be unique for OIDC identities.
func DeleteIdentityProviderGroup ¶
DeleteIdentityProviderGroup deletes the identity provider group matching the given name.
func DeleteInstance ¶
DeleteInstance deletes the instance matching the given key parameters. generator: instance DeleteOne-by-Project-and-Name
func DeleteInstanceProfiles ¶
DeleteInstanceProfiles deletes all instance profile associations for the given instance ID.
func DeleteInstanceSnapshot ¶
func DeleteInstanceSnapshot(ctx context.Context, tx *sql.Tx, project string, instance string, name string) error
DeleteInstanceSnapshot deletes the instance_snapshot matching the given key parameters. generator: instance_snapshot DeleteOne-by-Project-and-Instance-and-Name
func DeleteNodesClusterGroupsByGroupID ¶
DeleteNodesClusterGroupsByGroupID deletes all node cluster group associations for the given group ID.
func DeleteOIDCSessionByUUID ¶
DeleteOIDCSessionByUUID deletes a session by UUID.
func DeleteOperation ¶
DeleteOperation deletes an operation by UUID.
func DeleteProfile ¶
DeleteProfile deletes the profile matching the given key parameters. generator: profile DeleteOne-by-Project-and-Name
func DeleteProject ¶
DeleteProject deletes the project matching the given key parameters. generator: project DeleteOne-by-Name
func DeleteReplicator ¶
DeleteReplicator deletes the replicator with the given name and project.
func DeleteWarning ¶
DeleteWarning deletes the warning matching the given key parameters. generator: warning DeleteOne-by-UUID
func DeleteWarnings ¶
DeleteWarnings deletes the warning matching the given key parameters. generator: warning DeleteMany-by-EntityType-and-EntityID
func DevicesToAPI ¶
DevicesToAPI takes a map of devices and converts them to API format.
func EnsureSchema ¶
EnsureSchema applies all relevant schema updates to the cluster database.
Before actually doing anything, this function will make sure that all members in the cluster have a schema version and a number of API extensions that match our one. If it's not the case an api.StatusError with code http.StatusPreconditionFailed is returned, this indicates that this member should wait for them to become aligned.
func FreshSchema ¶
func FreshSchema() string
FreshSchema returns the fresh schema definition of the global database.
func GetAllBearerIdentitySigningKeys ¶
func GetAllBearerIdentitySigningKeys(ctx context.Context, tx *sql.Tx) (map[int64]AuthSecretValue, error)
GetAllBearerIdentitySigningKeys returns a map of identity ID to token signing keys. It should only be used to refresh the identity cache.
func GetAllIdentitiesByAuthGroupIDs ¶
func GetAllIdentitiesByAuthGroupIDs(ctx context.Context, tx *sql.Tx) (map[int64][]IdentitiesRow, error)
GetAllIdentitiesByAuthGroupIDs returns a map of group IDs to the identities that are members of the group with that ID.
func GetAllIdentityProviderGroupsByGroupIDs ¶
func GetAllIdentityProviderGroupsByGroupIDs(ctx context.Context, tx *sql.Tx) (map[int64][]IdentityProviderGroupsRow, error)
GetAllIdentityProviderGroupsByGroupIDs returns a map of group IDs to the IdentityProviderGroups that map to the group with that ID.
func GetAllProjectsConfig ¶
GetAllProjectsConfig returns a map of project name to config map.
func GetCertificateLegacyID ¶
GetCertificateLegacyID returns the ID of the certificate with the given fingerprint.
func GetCertificateLegacyProjects ¶
func GetCertificateLegacyProjects(ctx context.Context, tx *sql.Tx, certificateID *int64) (map[int64][]string, error)
GetCertificateLegacyProjects returns a map of certificate (identity) ID to list of (alphabetically sorted) project names. The output map should only contain IDs of restricted legacy certificates. If the optional certificate ID is passed, the result will only contain the given ID.
func GetClusterGroupID ¶
GetClusterGroupID return the ID of the cluster_group with the given key. generator: cluster_group ID
func GetClusterLinksUsedBy ¶
func GetClusterLinksUsedBy(ctx context.Context, tx *sql.Tx, clusterLinkName *string, firstOnly bool) (map[string][]string, error)
GetClusterLinksUsedBy returns a map of cluster link name to list of URLs of all entities that reference the cluster link via the 'cluster' config key. If clusterLinkName is non-nil, only references to that cluster link are returned. If firstOnly is true then the search stops after the first match overall (LIMIT 1 applied globally); only meaningful when clusterLinkName is non-nil.
func GetConfig ¶
func GetConfig(ctx context.Context, tx *sql.Tx, parent string, filters ...ConfigFilter) (map[int]map[string]string, error)
GetConfig returns all available config. generator: config GetMany
func GetDevices ¶
func GetDevices(ctx context.Context, tx *sql.Tx, parent string, filters ...DeviceFilter) (map[int][]Device, error)
GetDevices returns all available devices for the parent entity. generator: device GetMany
func GetDistinctAuthGroupNamesFromIDPGroupNames ¶
func GetDistinctAuthGroupNamesFromIDPGroupNames(ctx context.Context, tx *sql.Tx, idpGroupNames []string) ([]string, error)
GetDistinctAuthGroupNamesFromIDPGroupNames returns all of the distinct group names that are mapped to from the given list of identity provider group names.
func GetEntityURL ¶
func GetEntityURL(ctx context.Context, tx *sql.Tx, entityType entity.Type, entityID int) (*api.URL, error)
GetEntityURL returns the *api.URL of a single entity by its type and ID.
func GetEntityURLs ¶
func GetEntityURLs(ctx context.Context, tx *sql.Tx, projectName string, filteringEntityTypes ...entity.Type) (map[entity.Type]map[int]*api.URL, error)
GetEntityURLs accepts a project name and a variadic of entity types and returns a map of entity.Type to map of entity ID, to *api.URL. This method combines the above queries into a single query using the UNION operator. If no entity types are given, this function will return URLs for all entity types. If no project name is given, this function will return URLs for all projects. This may result in stupendously large queries, so use with caution!
func GetGroupPermissions ¶
GetGroupPermissions returns a map of group name to slice of permissions. This is used by the OpenFGADatastore implementation. It is pre-loaded into an openfga.RequestCache to reduce the total number of queries.
func GetIdentitiesPEMCertificates ¶
func GetIdentitiesPEMCertificates(ctx context.Context, tx *sql.Tx, identityID *int64) (map[int64][]string, error)
GetIdentitiesPEMCertificates returns a map of identity ID to list of PEM encoded certificates for each identity. The optional identity ID field can be used to filter the output (in which case the output map will contain only one key). The slice of certificates for each identity is ordered with the most recent certificate first.
func GetIdentityAndSessionDetailsFromSessionID ¶
func GetIdentityAndSessionDetailsFromSessionID(ctx context.Context, tx *sql.Tx, sessionID uuid.UUID) (*IdentitiesRow, *OIDCSession, error)
GetIdentityAndSessionDetailsFromSessionID gets both the IdentitiesRow and the OIDCSession from the given session ID.
func GetIdentityAuthGroupNames ¶
func GetIdentityAuthGroupNames(ctx context.Context, tx *sql.Tx, identityID *int64, filter func(AuthGroupsRow) (bool, error)) (map[int64][]string, error)
GetIdentityAuthGroupNames returns a map of identity ID to slice of (alphabetically sorted) group names that the identity with that ID is a member of. A filter can be passed in, which should return false to omit entries and true to include them. This is useful for filtering out groups that the caller cannot view. If the filter function returns a non-nil error, this function will abort scanning of rows and return the error unmodified. The optional identity ID field can be used to get authorization group names for only one identity, in which case the output map contains only one key.
func GetImageSource ¶
GetImageSource returns the image source with the given ID.
func GetInstanceConfig ¶
func GetInstanceConfig(ctx context.Context, tx *sql.Tx, instanceID int, filters ...ConfigFilter) (map[string]string, error)
GetInstanceConfig returns all available Instance Config generator: instance GetMany
func GetInstanceDevices ¶
func GetInstanceDevices(ctx context.Context, tx *sql.Tx, instanceID int, filters ...DeviceFilter) (map[string]Device, error)
GetInstanceDevices returns all available Instance Devices generator: instance GetMany
func GetInstanceID ¶
GetInstanceID return the ID of the instance with the given key. generator: instance ID
func GetInstanceSnapshotConfig ¶
func GetInstanceSnapshotConfig(ctx context.Context, tx *sql.Tx, instanceSnapshotID int, filters ...ConfigFilter) (map[string]string, error)
GetInstanceSnapshotConfig returns all available InstanceSnapshot Config generator: instance_snapshot GetMany
func GetInstanceSnapshotDevices ¶
func GetInstanceSnapshotDevices(ctx context.Context, tx *sql.Tx, instanceSnapshotID int, filters ...DeviceFilter) (map[string]Device, error)
GetInstanceSnapshotDevices returns all available InstanceSnapshot Devices generator: instance_snapshot GetMany
func GetInstanceSnapshotID ¶
func GetInstanceSnapshotID(ctx context.Context, tx *sql.Tx, project string, instance string, name string) (int64, error)
GetInstanceSnapshotID return the ID of the instance_snapshot with the given key. generator: instance_snapshot ID
func GetInstancesInPlacementGroup ¶
func GetInstancesInPlacementGroup(ctx context.Context, tx *sql.Tx, name string, projectName string, nodeID *int64) (map[int64][]int64, error)
GetInstancesInPlacementGroup returns a map of member (node) ID to a slice of instance IDs for all instances that reference the given placement group either directly or indirectly via a profile. The target placement group is specified with the given name and project name. Instances located on the optional node ID are excluded if the node ID is not nil.
func GetOperationResources ¶
func GetOperationResources(ctx context.Context, tx *sql.Tx, opID int64) (map[entity.Type][]api.URL, error)
GetOperationResources loads operation resources from the cluster db. The entity type is used as the key of the map, as the actual key is not stored in the DB.
func GetPlacementGroupUsedBy ¶
func GetPlacementGroupUsedBy(ctx context.Context, tx *sql.Tx, projectName string, placementGroupName string, firstOnly bool) ([]string, error)
GetPlacementGroupUsedBy returns a list of URLs of entities that reference the placement group with the given name and project.
func GetPlacementGroupsUsedBy ¶
func GetPlacementGroupsUsedBy(ctx context.Context, tx *sql.Tx, filter PlacementGroupFilter, firstOnly bool) (map[string]map[string][]string, error)
GetPlacementGroupsUsedBy returns a map of project name to map of placement group name (matching the given filter) to list of URLs of instances and profiles that reference the placement group.
func GetProfileConfig ¶
func GetProfileConfig(ctx context.Context, tx *sql.Tx, profileID int, filters ...ConfigFilter) (map[string]string, error)
GetProfileConfig returns all available Profile Config generator: profile GetMany
func GetProfileDevices ¶
func GetProfileDevices(ctx context.Context, tx *sql.Tx, profileID int, filters ...DeviceFilter) (map[string]Device, error)
GetProfileDevices returns all available Profile Devices generator: profile GetMany
func GetProfileID ¶
GetProfileID return the ID of the profile with the given key. generator: profile ID
func GetProfileIDsByProjectAndName ¶
func GetProfileIDsByProjectAndName(ctx context.Context, tx *sql.Tx, projectNames []string, profileNames []string) ([]int64, error)
GetProfileIDsByProjectAndName finds profile IDs matching specific names within a specific list of projects.
func GetProjectConfig ¶
func GetProjectConfig(ctx context.Context, tx *sql.Tx, projectName string) (map[string]string, error)
GetProjectConfig is a helper to return a config of a project.
func GetProjectID ¶
GetProjectID return the ID of the project with the given key. generator: project ID
func GetProjectIDsToNames ¶
GetProjectIDsToNames returns a map associating each project ID to its project name.
func GetProjectNames ¶
GetProjectNames returns the names of all available projects.
func GetProjectsSharingDefaultImages ¶
GetProjectsSharingDefaultImages returns the names of all projects using images stored in the "default" project. That is, it returns all projects with "features.images=false" and the "default" project itself.
func GetProjectsUsingRestrictedClusterGroups ¶
func GetProjectsUsingRestrictedClusterGroups(ctx context.Context, tx *sql.Tx, groupName string) ([]string, error)
GetProjectsUsingRestrictedClusterGroups returns project URLs for all projects whose "restricted.cluster.groups" project configuration includes the specified groupName.
func GetWarningID ¶
GetWarningID return the ID of the warning with the given key. generator: warning ID
func InitProjectWithoutImages ¶
InitProjectWithoutImages populates the images_profiles table with all images from the default project when a project is created with features.images=false.
func Open ¶
Open the cluster database object.
The name argument is the name of the cluster database. It defaults to 'db.bin', but can be overwritten for testing.
The dialer argument is a function that returns a gRPC dialer that can be used to connect to a database node using the gRPC SQL package.
func PlacementGroupsConfigStore ¶
func PlacementGroupsConfigStore() *query.EntityConfigStore
PlacementGroupsConfigStore returns a query.EntityConfigStore for placement groups.
func PopulateEntityReferencesFromURLs ¶
func PopulateEntityReferencesFromURLs(ctx context.Context, tx *sql.Tx, entityURLMap map[*api.URL]*EntityRef) error
PopulateEntityReferencesFromURLs populates the values in the given map with entity references corresponding to the api.URL keys. It will return an error if any of the given URLs do not correspond to a LXD entity.
func PrepareStmts ¶
PrepareStmts prepares all registered statements and returns an index from statement code to prepared statement object.
func ProjectHasImages ¶
ProjectHasImages is a helper to check if a project has the images feature enabled.
func ProjectHasProfiles ¶
ProjectHasProfiles is a helper to check if a project has the profiles feature enabled.
func RegisterStmt ¶
RegisterStmt register a SQL statement.
Registered statements will be prepared upfront and re-used, to speed up execution.
Return a unique registration code.
func RenameClusterGroup ¶
RenameClusterGroup renames the cluster_group matching the given key parameters. generator: cluster_group Rename
func RenameClusterLink ¶
RenameClusterLink renames the cluster link with the given name.
func RenameIdentityProviderGroup ¶
RenameIdentityProviderGroup renames the identity provider group matching the given name.
func RenameInstance ¶
RenameInstance renames the instance matching the given key parameters. generator: instance Rename
func RenameInstanceSnapshot ¶
func RenameInstanceSnapshot(ctx context.Context, tx *sql.Tx, project string, instance string, name string, to string) error
RenameInstanceSnapshot renames the instance_snapshot matching the given key parameters. generator: instance_snapshot Rename
func RenameProfile ¶
RenameProfile renames the profile matching the given key parameters. generator: profile Rename
func RenameProject ¶
RenameProject renames the project matching the given key parameters. generator: project Rename
func RenameReplicator ¶
func RenameReplicator(ctx context.Context, tx *sql.Tx, name string, projectName string, newName string) error
RenameReplicator renames the replicator with the given name in the given project.
func ReplicatorsConfigStore ¶
func ReplicatorsConfigStore() *query.EntityConfigStore
ReplicatorsConfigStore returns a query.EntityConfigStore for replicators.
func SchemaDotGo ¶
func SchemaDotGo() error
SchemaDotGo refreshes the schema.go file in this package, using the updates defined here.
func SetAuthGroupPermissions ¶
func SetAuthGroupPermissions(ctx context.Context, tx *sql.Tx, groupID int64, authGroupPermissions []Permission) error
SetAuthGroupPermissions deletes all auth_group -> permission mappings from the `auth_group_permissions` table where the group ID is equal to the given value. Then it inserts a new row for each given permission ID.
func SetIdentityAuthGroups ¶
func SetIdentityAuthGroups(ctx context.Context, tx *sql.Tx, identityID int64, groupNames []string) error
SetIdentityAuthGroups deletes all auth_group -> identity mappings from the `identities_auth_groups` table where the identity ID is equal to the given value. Then it inserts new associations into the table where the group IDs correspond to the given group names.
func SetIdentityProviderGroupMapping ¶
func SetIdentityProviderGroupMapping(ctx context.Context, tx *sql.Tx, identityProviderGroupID int64, groupNames []string) error
SetIdentityProviderGroupMapping deletes all auth_group -> identity_provider_group mappings from the `auth_groups_identity_provider_groups` table where the identity provider group ID is equal to the given value. Then it inserts new associations into the table where the group IDs correspond to the given group names.
func StmtString ¶
StmtString returns the in-memory query string with the given code.
func UpdateCertificateLegacy ¶
UpdateCertificateLegacy updates the certificate matching the given key parameters.
func UpdateCertificateLegacyProjects ¶
func UpdateCertificateLegacyProjects(ctx context.Context, tx *sql.Tx, certificateID int64, projectNames []string) error
UpdateCertificateLegacyProjects deletes and replaces any certificate to project associations.
func UpdateClusterGroup ¶
UpdateClusterGroup updates the cluster_group matching the given key parameters. generator: cluster_group Update
func UpdateClusterLink ¶
UpdateClusterLink updates the cluster link row by its ID.
func UpdateConfig ¶
func UpdateConfig(ctx context.Context, tx *sql.Tx, parent string, referenceID int, config map[string]string) error
UpdateConfig updates the config matching the given key parameters. generator: config Update
func UpdateDevices ¶
func UpdateDevices(ctx context.Context, tx *sql.Tx, parent string, referenceID int, devices map[string]Device) error
UpdateDevices updates the device matching the given key parameters. generator: device Update
func UpdateInstance ¶
func UpdateInstance(ctx context.Context, tx *sql.Tx, project string, name string, object Instance) error
UpdateInstance updates the instance matching the given key parameters. generator: instance Update
func UpdateInstanceConfig ¶
func UpdateInstanceConfig(ctx context.Context, tx *sql.Tx, instanceID int64, config map[string]string) error
UpdateInstanceConfig updates the instance Config matching the given key parameters. generator: instance Update
func UpdateInstanceDevices ¶
func UpdateInstanceDevices(ctx context.Context, tx *sql.Tx, instanceID int64, devices map[string]Device) error
UpdateInstanceDevices updates the instance Device matching the given key parameters. generator: instance Update
func UpdateInstanceProfiles ¶
func UpdateInstanceProfiles(ctx context.Context, tx *sql.Tx, instanceID int, projectName string, profiles []string) error
UpdateInstanceProfiles updates the profiles of an instance in the order they are given.
func UpdateOperation ¶
func UpdateOperation(ctx context.Context, tx *sql.Tx, opUUID string, nodeID int64, updatedAt time.Time, newStatus api.StatusCode, metadata map[string]any, opErr string, opErrCode int64) error
UpdateOperation updates operation status, metadata and error (if set) in the cluster db. This is used to keep DB in sync with the current status of the operation when the operation changes its status, or when calls to commit metadata explicitly. The caller is expected to pass in the current node ID. This guards against modification of the operation by other cluster members.
func UpdateProfile ¶
func UpdateProfile(ctx context.Context, tx *sql.Tx, project string, name string, object Profile) error
UpdateProfile updates the profile matching the given key parameters. generator: profile Update
func UpdateProfileConfig ¶
func UpdateProfileConfig(ctx context.Context, tx *sql.Tx, profileID int64, config map[string]string) error
UpdateProfileConfig updates the profile Config matching the given key parameters. generator: profile Update
func UpdateProfileDevices ¶
func UpdateProfileDevices(ctx context.Context, tx *sql.Tx, profileID int64, devices map[string]Device) error
UpdateProfileDevices updates the profile Device matching the given key parameters. generator: profile Update
func UpdateProject ¶
UpdateProject updates the project matching the given key parameters.
func UpdateProjectReplicaMode ¶
func UpdateProjectReplicaMode(ctx context.Context, tx *sql.Tx, projectName string, replicaMode string) error
UpdateProjectReplicaMode updates the replica_mode field for the project with the given name.
func UpdateReplicator ¶
UpdateReplicator updates the replicator by its ID.
func UpdateReplicatorLastRun ¶
func UpdateReplicatorLastRun(ctx context.Context, tx *sql.Tx, id int64, date time.Time, status string) error
UpdateReplicatorLastRun updates the last_run_date and last_run_status fields of the replicator with the given ID.
func UpdateReplicatorLastRunStatus ¶
UpdateReplicatorLastRunStatus updates only the last_run_status field of the replicator with the given ID.
func UpdateTLSIdentity ¶
func UpdateTLSIdentity(ctx context.Context, tx *sql.Tx, identity IdentitiesRow, fingerprint string, pemCert string) error
UpdateTLSIdentity updates the given IdentitiesRow (applying any prior modifications) by primary key. If the fingerprint and certificate are provided, the [IdentitiesRow.Identifier] is set to the fingerprint value, and a new CertificatesRow is added with any previous CertificatesRow entries associated with the identity deleted.
Types ¶
type AuthGroupsRow ¶
type AuthGroupsRow struct {
ID int64 `db:"id"`
Name string `db:"name"`
Description string `db:"description"`
}
AuthGroupsRow represents a single row of the auth_groups table. db:model auth_groups
func GetAuthGroup ¶
GetAuthGroup gets a single AuthGroup by name.
func GetAuthGroupsAndURLs ¶
func GetAuthGroupsAndURLs(ctx context.Context, tx *sql.Tx, filter func(group AuthGroupsRow) bool) ([]AuthGroupsRow, []string, error)
GetAuthGroupsAndURLs queries for all authorization groups and then applies the given filter to the result. This is useful when filtering by groups the caller is able to view. The filter must return true to include an entry, and false to reject an entry. A slice of (filtered) authorization group URLs is also returned for convenience.
func GetAuthGroupsByIdentityID ¶
func GetAuthGroupsByIdentityID(ctx context.Context, tx *sql.Tx, identityID int64) ([]AuthGroupsRow, error)
GetAuthGroupsByIdentityID returns a slice of groups that the identity with the given ID is a member of.
func GetAuthGroupsByIdentityProviderGroupID ¶
func GetAuthGroupsByIdentityProviderGroupID(ctx context.Context, tx *sql.Tx, idpGroupID int64) ([]AuthGroupsRow, error)
GetAuthGroupsByIdentityProviderGroupID returns a list of groups that the identity provider group with the given ID.
func (AuthGroupsRow) APIName ¶
func (AuthGroupsRow) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (AuthGroupsRow) CreateStmt ¶
func (a AuthGroupsRow) CreateStmt() string
CreateStmt returns a query that creates a AuthGroupsRow entity.
func (AuthGroupsRow) CreateValues ¶
func (a AuthGroupsRow) CreateValues() []any
CreateValues returns a list of values from AuthGroupsRow entities matching the bind arguments in [CreateStmt].
func (AuthGroupsRow) Joins ¶
func (a AuthGroupsRow) Joins() []string
Joins returns a slice of join expressions for AuthGroupsRow.
func (AuthGroupsRow) PKColumns ¶
func (a AuthGroupsRow) PKColumns() []string
PKColumns returns the column names for the primary key of a AuthGroupsRow entity used during an update. The returned slice must have the same number of elements as PKValues.
func (AuthGroupsRow) PKValues ¶
func (a AuthGroupsRow) PKValues() []any
PKValues returns the values for the primary key of a AuthGroupsRow entity used during an update. The returned slice must have the same number of elements as PKColumns.
func (*AuthGroupsRow) ScanArgs ¶
func (a *AuthGroupsRow) ScanArgs() []any
ScanArgs implements query.ScanArger for AuthGroupsRow. This returns references to struct fields in definition order.
func (AuthGroupsRow) SelectColumns ¶
func (a AuthGroupsRow) SelectColumns() []string
SelectColumns returns a slice of column names for AuthGroupsRow entities.
func (AuthGroupsRow) TableName ¶
func (a AuthGroupsRow) TableName() string
TableName returns the table name for AuthGroupsRow entities.
func (*AuthGroupsRow) ToAPI ¶
func (g *AuthGroupsRow) ToAPI(ctx context.Context, tx *sql.Tx, canViewIdentity auth.PermissionChecker, canViewIDPGroup auth.PermissionChecker) (*api.AuthGroup, error)
ToAPI converts the Group to an api.AuthGroup, making extra database queries as necessary.
func (AuthGroupsRow) UpdateStmt ¶
func (a AuthGroupsRow) UpdateStmt() string
UpdateStmt returns a query that updates a AuthGroupsRow by primary key.
func (AuthGroupsRow) UpdateValues ¶
func (a AuthGroupsRow) UpdateValues() []any
UpdateValues returns a list of values from AuthGroupsRow entities matching the columns in [UpdateStmt].
type AuthMethod ¶
type AuthMethod string
AuthMethod is a database representation of an authentication method.
AuthMethod is defined on string so that API constants can be converted by casting. The sql.Scanner and [driver.Valuer] interfaces are implemented on this type such that the string constants are converted into their int64 counterparts as they are written to the database, or converted back into an AuthMethod as they are read from the database. It is not possible to read/write an invalid authentication methods from/to the database when using this type.
func (*AuthMethod) Scan ¶
func (a *AuthMethod) Scan(value any) error
Scan implements sql.Scanner for AuthMethod. This converts the integer value back into the correct API constant or returns an error.
func (*AuthMethod) ScanInteger ¶
func (a *AuthMethod) ScanInteger(authMethodCode int64) error
ScanInteger implements query.IntegerScanner for AuthMethod. This simplifies the Scan implementation.
func (AuthMethod) Value ¶
func (a AuthMethod) Value() (driver.Value, error)
Value implements [driver.Valuer] for AuthMethod. This converts the API constant into an integer or throws an error.
type AuthSecret ¶
type AuthSecret struct {
ID int
Value AuthSecretValue
CreationDate time.Time
}
AuthSecret contains an AuthSecretValue and a creation time.
func (AuthSecret) Validate ¶
func (s AuthSecret) Validate(expiry string) error
Validate checks that the secret is of the correct length and has not expired.
type AuthSecretValue ¶
type AuthSecretValue []byte
AuthSecretValue is used to store byte slice of length authSecretLength in a text column as a base64 encoded string.
func RotateBearerIdentitySigningKey ¶
func RotateBearerIdentitySigningKey(ctx context.Context, tx *sql.Tx, identityID int64) (AuthSecretValue, error)
RotateBearerIdentitySigningKey deletes any existing signing keys for the identity and creates a new one.
func (*AuthSecretValue) Scan ¶
func (s *AuthSecretValue) Scan(value any) error
Scan implements sql.Scanner for AuthSecretValue.
func (*AuthSecretValue) ScanText ¶
func (s *AuthSecretValue) ScanText(str string) error
ScanText implements query.TextScanner for AuthSecretValue to simplify the sql.Scanner implementation.
Note: This method must have a pointer receiver so that e.g. `row.Scan(&secretVal)` will work, whereas the Value implementation does not require a pointer receiver. This is so that a non-pointer AuthSecretValue can be written to the database.
func (AuthSecretValue) String ¶
func (s AuthSecretValue) String() string
String implements fmt.Stringer for AuthSecretValue so that a human-readable format can be easily displayed. Note however that this is likely to contain sensitive information, and should never be logged.
func (AuthSecretValue) Validate ¶
func (s AuthSecretValue) Validate() error
Validate checks that the AuthSecretValue has length authSecretLength.
type AuthSecrets ¶
type AuthSecrets []AuthSecret
AuthSecrets is a concrete type for a slice of AuthSecret.
func GetCoreAuthSecrets ¶
GetCoreAuthSecrets returns a slice of AuthSecrets.
func (AuthSecrets) Rotate ¶
func (s AuthSecrets) Rotate(ctx context.Context, tx *sql.Tx) (AuthSecrets, error)
Rotate returns a new AuthSecrets, with a new AuthSecret prepended to the slice. The slice is always truncated to a maximum of two elements. The new AuthSecret is written to the database, and any AuthSecret values older than the new oldest in-memory value are deleted from the database.
func (AuthSecrets) Validate ¶
func (s AuthSecrets) Validate(expiry string) error
Validate checks that there is at least one secret in the slice, and that the first (most recent) is valid and has not expired.
type CertificateLegacy ¶
type CertificateLegacy struct {
ID int64
Fingerprint string
Type certificate.Type
Name string
Certificate string
Restricted bool
}
CertificateLegacy is the database representation of a legacy certificate in the /1.0/certificates API. There is no table directly representing these entities. They are a combination of data from the `identities` and `certificates` tables.
func GetCertificateLegacy ¶
func GetCertificateLegacy(ctx context.Context, tx *sql.Tx, fingerprint string) (*CertificateLegacy, error)
GetCertificateLegacy returns the certificate with the given fingerprint.
func GetCertificateLegacyByFingerprintPrefix ¶
func GetCertificateLegacyByFingerprintPrefix(ctx context.Context, tx *sql.Tx, fingerprintPrefix string) (*CertificateLegacy, error)
GetCertificateLegacyByFingerprintPrefix gets a CertificateLegacy from the database. The argument fingerprint will be queried with a LIKE query, means you can pass a shortform and will get the full fingerprint. There can never be more than one certificate with a given fingerprint, as it is enforced by a UNIQUE constraint in the schema.
func GetCertificatesAndURLsLegacy ¶
func GetCertificatesAndURLsLegacy(ctx context.Context, tx *sql.Tx, filter func(legacy CertificateLegacy) bool) ([]CertificateLegacy, []string, error)
GetCertificatesAndURLsLegacy returns all available certificates and their URLs. An optional filter function can be passed to filter the output. It should return true to include a certificate and false to omit it.
func (*CertificateLegacy) ToAPI ¶
func (cert *CertificateLegacy) ToAPI(certificateIDToProjects map[int64][]string) (*api.Certificate, error)
ToAPI converts the CertificateLegacy struct to an api.Certificate The certificateIDToProjects map must be provided and can be loaded via GetCertificateLegacyProjects.
func (*CertificateLegacy) ToAPIType ¶
func (cert *CertificateLegacy) ToAPIType() string
ToAPIType returns the API equivalent type.
func (CertificateLegacy) ToIdentity ¶
func (cert CertificateLegacy) ToIdentity() (*IdentitiesRow, error)
ToIdentity converts a CertificateLegacy to an IdentitiesRow.
func (*CertificateLegacy) ToIdentityType ¶
func (cert *CertificateLegacy) ToIdentityType() (IdentityType, error)
ToIdentityType returns a suitable IdentityType for the certificate.
type CertificatesRow ¶
type CertificatesRow struct {
ID int64 `db:"id"`
Fingerprint string `db:"fingerprint"`
Certificate string `db:"certificate"`
// CreationDate has a default value of the current timestamp.
// We want the database to set this, and we never want to update it.
// Omit the fields from create and update statements/values via the omit directive.
//
// db:omit create update
CreationDate time.Time `db:"creation_date"`
}
CertificatesRow represents a row of the certificates table. db:model certificates
func (CertificatesRow) APIName ¶
func (CertificatesRow) APIName() string
APIName implements query.APINamer for clear API error messages.
func (CertificatesRow) CreateStmt ¶
func (c CertificatesRow) CreateStmt() string
CreateStmt returns a query that creates a CertificatesRow entity.
func (CertificatesRow) CreateValues ¶
func (c CertificatesRow) CreateValues() []any
CreateValues returns a list of values from CertificatesRow entities matching the bind arguments in [CreateStmt].
func (CertificatesRow) Joins ¶
func (c CertificatesRow) Joins() []string
Joins returns a slice of join expressions for CertificatesRow.
func (CertificatesRow) PKColumns ¶
func (c CertificatesRow) PKColumns() []string
PKColumns returns the column names for the primary key of a CertificatesRow entity used during an update. The returned slice must have the same number of elements as PKValues.
func (CertificatesRow) PKValues ¶
func (c CertificatesRow) PKValues() []any
PKValues returns the values for the primary key of a CertificatesRow entity used during an update. The returned slice must have the same number of elements as PKColumns.
func (*CertificatesRow) ScanArgs ¶
func (c *CertificatesRow) ScanArgs() []any
ScanArgs implements query.ScanArger for CertificatesRow. This returns references to struct fields in definition order.
func (CertificatesRow) SelectColumns ¶
func (c CertificatesRow) SelectColumns() []string
SelectColumns returns a slice of column names for CertificatesRow entities.
func (CertificatesRow) TableName ¶
func (c CertificatesRow) TableName() string
TableName returns the table name for CertificatesRow entities.
func (CertificatesRow) UpdateStmt ¶
func (c CertificatesRow) UpdateStmt() string
UpdateStmt returns a query that updates a CertificatesRow by primary key.
func (CertificatesRow) UpdateValues ¶
func (c CertificatesRow) UpdateValues() []any
UpdateValues returns a list of values from CertificatesRow entities matching the columns in [UpdateStmt].
type ClusterGroup ¶
type ClusterGroup struct {
ID int
Name string
Description string `db:"coalesce=''"`
Nodes []string `db:"ignore"`
}
ClusterGroup is a value object holding db-related details about a cluster group.
func GetClusterGroup ¶
GetClusterGroup returns the cluster_group with the given key. generator: cluster_group GetOne
func GetClusterGroups ¶
func GetClusterGroups(ctx context.Context, tx *sql.Tx, filters ...ClusterGroupFilter) ([]ClusterGroup, error)
GetClusterGroups returns all available cluster_groups. generator: cluster_group GetMany
func (*ClusterGroup) ToAPI ¶
func (c *ClusterGroup) ToAPI(ctx context.Context, tx *sql.Tx) (*api.ClusterGroup, error)
ToAPI returns a LXD API entry.
type ClusterGroupFilter ¶
ClusterGroupFilter specifies potential query parameter fields.
type ClusterGroupGenerated ¶
type ClusterGroupGenerated interface {
// GetClusterGroups returns all available cluster_groups.
// generator: cluster_group GetMany
GetClusterGroups(ctx context.Context, tx *sql.Tx, filters ...ClusterGroupFilter) ([]ClusterGroup, error)
// GetClusterGroup returns the cluster_group with the given key.
// generator: cluster_group GetOne
GetClusterGroup(ctx context.Context, tx *sql.Tx, name string) (*ClusterGroup, error)
// GetClusterGroupID return the ID of the cluster_group with the given key.
// generator: cluster_group ID
GetClusterGroupID(ctx context.Context, tx *sql.Tx, name string) (int64, error)
// ClusterGroupExists checks if a cluster_group with the given key exists.
// generator: cluster_group Exists
ClusterGroupExists(ctx context.Context, tx *sql.Tx, name string) (bool, error)
// RenameClusterGroup renames the cluster_group matching the given key parameters.
// generator: cluster_group Rename
RenameClusterGroup(ctx context.Context, tx *sql.Tx, name string, to string) error
// CreateClusterGroup adds a new cluster_group to the database.
// generator: cluster_group Create
CreateClusterGroup(ctx context.Context, tx *sql.Tx, object ClusterGroup) (int64, error)
// UpdateClusterGroup updates the cluster_group matching the given key parameters.
// generator: cluster_group Update
UpdateClusterGroup(ctx context.Context, tx *sql.Tx, name string, object ClusterGroup) error
// DeleteClusterGroup deletes the cluster_group matching the given key parameters.
// generator: cluster_group DeleteOne-by-Name
DeleteClusterGroup(ctx context.Context, tx *sql.Tx, name string) error
}
ClusterGroupGenerated is an interface of generated methods for ClusterGroup.
type ClusterLinkRow ¶
type ClusterLinkRow struct {
ID int64 `db:"id"`
IdentityID int64 `db:"identity_id"`
Name string `db:"name"`
Description string `db:"description"`
Type ClusterLinkType `db:"type"`
}
ClusterLinkRow represents a single row of the cluster_links table. db:model cluster_links
func GetClusterLink ¶
GetClusterLink returns the cluster link with the given name.
func GetClusterLinks ¶
GetClusterLinks returns all cluster links.
func GetClusterLinksAndURLs ¶
func GetClusterLinksAndURLs(ctx context.Context, tx *sql.Tx, filter func(link ClusterLinkRow) bool) ([]ClusterLinkRow, []string, error)
GetClusterLinksAndURLs returns all cluster links that pass the given filter, along with their entity URLs.
func (ClusterLinkRow) APIName ¶
func (ClusterLinkRow) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (ClusterLinkRow) CreateStmt ¶
func (c ClusterLinkRow) CreateStmt() string
CreateStmt returns a query that creates a ClusterLinkRow entity.
func (ClusterLinkRow) CreateValues ¶
func (c ClusterLinkRow) CreateValues() []any
CreateValues returns a list of values from ClusterLinkRow entities matching the bind arguments in [CreateStmt].
func (ClusterLinkRow) Joins ¶
func (c ClusterLinkRow) Joins() []string
Joins returns a slice of join expressions for ClusterLinkRow.
func (ClusterLinkRow) PKColumns ¶
func (c ClusterLinkRow) PKColumns() []string
PKColumns returns the column names for the primary key of a ClusterLinkRow entity used during an update. The returned slice must have the same number of elements as PKValues.
func (ClusterLinkRow) PKValues ¶
func (c ClusterLinkRow) PKValues() []any
PKValues returns the values for the primary key of a ClusterLinkRow entity used during an update. The returned slice must have the same number of elements as PKColumns.
func (*ClusterLinkRow) ScanArgs ¶
func (c *ClusterLinkRow) ScanArgs() []any
ScanArgs implements query.ScanArger for ClusterLinkRow. This returns references to struct fields in definition order.
func (ClusterLinkRow) SelectColumns ¶
func (c ClusterLinkRow) SelectColumns() []string
SelectColumns returns a slice of column names for ClusterLinkRow entities.
func (ClusterLinkRow) TableName ¶
func (c ClusterLinkRow) TableName() string
TableName returns the table name for ClusterLinkRow entities.
func (*ClusterLinkRow) ToAPI ¶
func (r *ClusterLinkRow) ToAPI(allConfigs map[int64]map[string]string) *api.ClusterLink
ToAPI converts the database ClusterLinkRow struct to API type api.ClusterLink.
func (ClusterLinkRow) UpdateStmt ¶
func (c ClusterLinkRow) UpdateStmt() string
UpdateStmt returns a query that updates a ClusterLinkRow by primary key.
func (ClusterLinkRow) UpdateValues ¶
func (c ClusterLinkRow) UpdateValues() []any
UpdateValues returns a list of values from ClusterLinkRow entities matching the columns in [UpdateStmt].
type ClusterLinkType ¶
type ClusterLinkType string
ClusterLinkType represents the type of a cluster link stored as a string in the database.
This type implements the sql.Scanner and [driver.Value] interfaces to automatically handle conversion between API constants and their int64 representation in the database. When reading from the database, int64 values are converted back to their constant type. When writing to the database, API constants are converted to their int64 representation.
func (*ClusterLinkType) Scan ¶
func (c *ClusterLinkType) Scan(value any) error
Scan implements sql.Scanner for ClusterLinkType. This converts the database integer value back into the correct API constant or returns an error.
func (*ClusterLinkType) ScanInteger ¶
func (c *ClusterLinkType) ScanInteger(clusterLinkTypeCode int64) error
ScanInteger implements query.IntegerScanner for ClusterLinkType.
func (ClusterLinkType) Value ¶
func (c ClusterLinkType) Value() (driver.Value, error)
Value implements [driver.Value] for ClusterLinkType. This converts the API constant into its integer database representation or throws an error.
type ConfigFilter ¶
ConfigFilter specifies potential query parameter fields.
type ConfigGenerated ¶
type ConfigGenerated interface {
// GetConfig returns all available config.
// generator: config GetMany
GetConfig(ctx context.Context, tx *sql.Tx, parent string, filters ...ConfigFilter) (map[int]map[string]string, error)
// CreateConfig adds a new config to the database.
// generator: config Create
CreateConfig(ctx context.Context, tx *sql.Tx, parent string, object Config) error
// UpdateConfig updates the config matching the given key parameters.
// generator: config Update
UpdateConfig(ctx context.Context, tx *sql.Tx, parent string, referenceID int, config map[string]string) error
// DeleteConfig deletes the config matching the given key parameters.
// generator: config DeleteMany
DeleteConfig(ctx context.Context, tx *sql.Tx, parent string, referenceID int) error
}
ConfigGenerated is an interface of generated methods for Config.
type DeviceFilter ¶
type DeviceFilter struct {
Name *string
Type *DeviceType
Config *ConfigFilter
}
DeviceFilter specifies potential query parameter fields.
type DeviceGenerated ¶
type DeviceGenerated interface {
// GetDevices returns all available devices for the parent entity.
// generator: device GetMany
GetDevices(ctx context.Context, tx *sql.Tx, parent string, filters ...DeviceFilter) (map[int][]Device, error)
// CreateDevices adds a new device to the database.
// generator: device Create
CreateDevices(ctx context.Context, tx *sql.Tx, parent string, objects map[string]Device) error
// UpdateDevices updates the device matching the given key parameters.
// generator: device Update
UpdateDevices(ctx context.Context, tx *sql.Tx, parent string, referenceID int, devices map[string]Device) error
// DeleteDevices deletes the device matching the given key parameters.
// generator: device DeleteMany
DeleteDevices(ctx context.Context, tx *sql.Tx, parent string, referenceID int) error
}
DeviceGenerated is an interface of generated methods for Device.
type DeviceType ¶
type DeviceType int
DeviceType represents the types of supported devices.
func NewDeviceType ¶
func NewDeviceType(t string) (DeviceType, error)
NewDeviceType determines the device type from the given string, if supported.
func (DeviceType) String ¶
func (t DeviceType) String() string
type EntityRef ¶
type EntityRef struct {
EntityType EntityType
EntityID int
entity.Reference
}
EntityRef represents the expected format of entity URL queries.
func GetEntityReferenceFromURL ¶
func GetEntityReferenceFromURL(ctx context.Context, tx *sql.Tx, entityURL *api.URL) (*EntityRef, error)
GetEntityReferenceFromURL gets a single EntityRef by parsing the given api.URL and finding the ID of the entity. It is used by the OpenFGA datastore implementation to find permissions for the entity with the given URL.
type EntityType ¶
type EntityType string
EntityType is a database representation of an entity type.
EntityType is defined on string so that entity.Type constants can be converted by casting. The sql.Scanner and driver.Valuer interfaces are implemented on this type such that the string constants are converted into their int64 counterparts as they are written to the database, or converted back into an EntityType as they are read from the database. It is not possible to read/write invalid entity types from/to the database when using this type.
func (*EntityType) Scan ¶
func (e *EntityType) Scan(value any) error
Scan implements sql.Scanner for EntityType. This converts the integer value back into the correct entity.Type constant or returns an error.
func (*EntityType) ScanInteger ¶
func (e *EntityType) ScanInteger(entityTypeCode int64) error
ScanInteger implements query.IntegerScanner for EntityType. This simplifies the Scan implementation.
type IdentitiesRow ¶
type IdentitiesRow struct {
ID int64 `db:"id"`
AuthMethod AuthMethod `db:"auth_method"`
Type IdentityType `db:"type"`
Identifier string `db:"identifier"`
Name string `db:"name"`
Metadata string `db:"metadata"`
}
IdentitiesRow is a database representation of any authenticated party. db:model identities
func GetIdentitiesAndURLs ¶
func GetIdentitiesAndURLs(ctx context.Context, tx *sql.Tx, authMethod *string, filter func(row IdentitiesRow) bool) ([]IdentitiesRow, []string, error)
GetIdentitiesAndURLs returns a list of identities and their URLs, filtered by optional authentication method and filter function. The filter function should return true to include the identity and false to omit it.
func GetIdentitiesByAuthGroupID ¶
func GetIdentitiesByAuthGroupID(ctx context.Context, tx *sql.Tx, groupID int64) ([]IdentitiesRow, error)
GetIdentitiesByAuthGroupID returns the identities that are members of the group with the given ID.
func GetIdentityByAuthenticationMethodAndIdentifier ¶
func GetIdentityByAuthenticationMethodAndIdentifier(ctx context.Context, tx *sql.Tx, authenticationMethod string, identifier string) (*IdentitiesRow, error)
GetIdentityByAuthenticationMethodAndIdentifier gets a single identity by authentication method and identifier.
func GetIdentityByID ¶
GetIdentityByID gets a single identity with the given ID.
func GetIdentityByNameOrIdentifier ¶
func GetIdentityByNameOrIdentifier(ctx context.Context, tx *sql.Tx, authenticationMethod string, nameOrID string) (*IdentitiesRow, error)
GetIdentityByNameOrIdentifier attempts to get an identity by the authentication method and identifier. If that fails it will try to use the nameOrID argument as a name and will return the result only if the query matches a single IdentitiesRow. It will return an api.StatusError with http.StatusNotFound if none are found or http.StatusBadRequest if multiple are found.
func GetPendingTLSIdentityByTokenSecret ¶
func GetPendingTLSIdentityByTokenSecret(ctx context.Context, tx *sql.Tx, secret string) (*IdentitiesRow, error)
GetPendingTLSIdentityByTokenSecret gets a single identity of type [identityTypeCertificateClientPending] or [identityTypeCertificateClusterLinkPending] with the given secret in its metadata. If no pending identity is found, an api.StatusError is returned with http.StatusNotFound.
func (IdentitiesRow) APIName ¶
func (IdentitiesRow) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (IdentitiesRow) APIPluralName ¶
func (IdentitiesRow) APIPluralName() string
APIPluralName implements query.APIPluralNamer for IdentitiesRow to override default pluralisation behaviour for error messages (which simply appends an "s").
func (IdentitiesRow) CreateStmt ¶
func (i IdentitiesRow) CreateStmt() string
CreateStmt returns a query that creates a IdentitiesRow entity.
func (IdentitiesRow) CreateValues ¶
func (i IdentitiesRow) CreateValues() []any
CreateValues returns a list of values from IdentitiesRow entities matching the bind arguments in [CreateStmt].
func (IdentitiesRow) Joins ¶
func (i IdentitiesRow) Joins() []string
Joins returns a slice of join expressions for IdentitiesRow.
func (IdentitiesRow) OIDCMetadata ¶
func (i IdentitiesRow) OIDCMetadata() (*OIDCMetadata, error)
OIDCMetadata returns the identity metadata as OIDCMetadata. The AuthMethod of the IdentitiesRow must be api.AuthenticationMethodOIDC.
func (IdentitiesRow) PKColumns ¶
func (i IdentitiesRow) PKColumns() []string
PKColumns returns the column names for the primary key of a IdentitiesRow entity used during an update. The returned slice must have the same number of elements as PKValues.
func (IdentitiesRow) PKValues ¶
func (i IdentitiesRow) PKValues() []any
PKValues returns the values for the primary key of a IdentitiesRow entity used during an update. The returned slice must have the same number of elements as PKColumns.
func (IdentitiesRow) PendingTLSMetadata ¶
func (i IdentitiesRow) PendingTLSMetadata() (*PendingTLSMetadata, error)
PendingTLSMetadata returns the pending TLS identity metadata.
func (*IdentitiesRow) ScanArgs ¶
func (i *IdentitiesRow) ScanArgs() []any
ScanArgs implements query.ScanArger for IdentitiesRow. This returns references to struct fields in definition order.
func (IdentitiesRow) SelectColumns ¶
func (i IdentitiesRow) SelectColumns() []string
SelectColumns returns a slice of column names for IdentitiesRow entities.
func (IdentitiesRow) TableName ¶
func (i IdentitiesRow) TableName() string
TableName returns the table name for IdentitiesRow entities.
func (*IdentitiesRow) ToAPI ¶
func (i *IdentitiesRow) ToAPI(idToGroups map[int64][]string, idToCertificates map[int64][]string) (*api.Identity, error)
ToAPI converts an IdentitiesRow to an api.Identity, executing database queries as necessary.
func (IdentitiesRow) ToCertificate ¶
func (i IdentitiesRow) ToCertificate(idToCert map[int64][]string) (*CertificateLegacy, error)
ToCertificate converts an IdentitiesRow to a CertificateLegacy.
func (IdentitiesRow) UpdateStmt ¶
func (i IdentitiesRow) UpdateStmt() string
UpdateStmt returns a query that updates a IdentitiesRow by primary key.
func (IdentitiesRow) UpdateValues ¶
func (i IdentitiesRow) UpdateValues() []any
UpdateValues returns a list of values from IdentitiesRow entities matching the columns in [UpdateStmt].
type IdentityCertificate ¶
type IdentityCertificate struct {
Row CertificatesRow
// db:join JOIN identities_certificates ON certificates.id = identities_certificates.certificate_id
IdentityID int64 `db:"identities_certificates.identity_id"`
}
IdentityCertificate represents a certificate that is associated with an IdentitiesRow. db:model certificates
func (IdentityCertificate) APIName ¶
func (i IdentityCertificate) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (IdentityCertificate) Joins ¶
func (i IdentityCertificate) Joins() []string
Joins returns a slice of join expressions for IdentityCertificate.
func (*IdentityCertificate) ScanArgs ¶
func (i *IdentityCertificate) ScanArgs() []any
ScanArgs implements query.ScanArger for IdentityCertificate. This returns references to struct fields in definition order.
func (IdentityCertificate) SelectColumns ¶
func (i IdentityCertificate) SelectColumns() []string
SelectColumns returns a slice of column names for IdentityCertificate entities.
func (IdentityCertificate) TableName ¶
func (i IdentityCertificate) TableName() string
TableName returns the table name for IdentityCertificate entities.
type IdentityProviderGroupsRow ¶
IdentityProviderGroupsRow is the database representation of an identity provider group. db:model identity_provider_groups
func GetIdentityProviderGroup ¶
func GetIdentityProviderGroup(ctx context.Context, tx *sql.Tx, name string) (*IdentityProviderGroupsRow, error)
GetIdentityProviderGroup returns the identity provider group with the given name.
func GetIdentityProviderGroups ¶
func GetIdentityProviderGroups(ctx context.Context, tx *sql.Tx) ([]IdentityProviderGroupsRow, error)
GetIdentityProviderGroups returns all identity provider groups.
func GetIdentityProviderGroupsByGroupID ¶
func GetIdentityProviderGroupsByGroupID(ctx context.Context, tx *sql.Tx, groupID int64) ([]IdentityProviderGroupsRow, error)
GetIdentityProviderGroupsByGroupID returns the identity provider groups that map to the group with the given ID.
func (IdentityProviderGroupsRow) APIName ¶
func (i IdentityProviderGroupsRow) APIName() string
APIName returns a human-readable name for the entity.
func (IdentityProviderGroupsRow) CreateStmt ¶
func (i IdentityProviderGroupsRow) CreateStmt() string
CreateStmt returns a query that creates a IdentityProviderGroupsRow entity.
func (IdentityProviderGroupsRow) CreateValues ¶
func (i IdentityProviderGroupsRow) CreateValues() []any
CreateValues returns a list of values from IdentityProviderGroupsRow entities matching the bind arguments in [CreateStmt].
func (IdentityProviderGroupsRow) Joins ¶
func (i IdentityProviderGroupsRow) Joins() []string
Joins returns a slice of join expressions for IdentityProviderGroupsRow.
func (IdentityProviderGroupsRow) PKColumns ¶
func (i IdentityProviderGroupsRow) PKColumns() []string
PKColumns returns the column names for the primary key of a IdentityProviderGroupsRow entity used during an update. The returned slice must have the same number of elements as PKValues.
func (IdentityProviderGroupsRow) PKValues ¶
func (i IdentityProviderGroupsRow) PKValues() []any
PKValues returns the values for the primary key of a IdentityProviderGroupsRow entity used during an update. The returned slice must have the same number of elements as PKColumns.
func (*IdentityProviderGroupsRow) ScanArgs ¶
func (i *IdentityProviderGroupsRow) ScanArgs() []any
ScanArgs implements query.ScanArger for IdentityProviderGroupsRow. This returns references to struct fields in definition order.
func (IdentityProviderGroupsRow) SelectColumns ¶
func (i IdentityProviderGroupsRow) SelectColumns() []string
SelectColumns returns a slice of column names for IdentityProviderGroupsRow entities.
func (IdentityProviderGroupsRow) TableName ¶
func (i IdentityProviderGroupsRow) TableName() string
TableName returns the table name for IdentityProviderGroupsRow entities.
func (*IdentityProviderGroupsRow) ToAPI ¶
func (i *IdentityProviderGroupsRow) ToAPI(ctx context.Context, tx *sql.Tx, canViewGroup auth.PermissionChecker) (*api.IdentityProviderGroup, error)
ToAPI converts the IdentityProviderGroupsRow to an api.IdentityProviderGroup, making more database calls as necessary.
func (IdentityProviderGroupsRow) UpdateStmt ¶
func (i IdentityProviderGroupsRow) UpdateStmt() string
UpdateStmt returns a query that updates a IdentityProviderGroupsRow by primary key.
func (IdentityProviderGroupsRow) UpdateValues ¶
func (i IdentityProviderGroupsRow) UpdateValues() []any
UpdateValues returns a list of values from IdentityProviderGroupsRow entities matching the columns in [UpdateStmt].
type IdentityType ¶
type IdentityType string
IdentityType indicates the type of the identity.
IdentityType is defined on string so that API constants can be converted by casting. The sql.Scanner and [driver.Valuer] interfaces are implemented on this type such that the string constants are converted into their int64 counterparts as they are written to the database, or converted back into an IdentityType as they are read from the database. It is not possible to read/write an invalid identity types from/to the database when using this type.
func (IdentityType) ActiveType ¶
func (i IdentityType) ActiveType() (IdentityType, error)
ActiveType returns the active version of the identity type.
func (*IdentityType) Scan ¶
func (i *IdentityType) Scan(value any) error
Scan implements sql.Scanner for IdentityType. This converts the integer value back into the correct API constant or returns an error.
func (*IdentityType) ScanInteger ¶
func (i *IdentityType) ScanInteger(identityTypeCode int64) error
ScanInteger implements query.IntegerScanner for IdentityType. This simplifies the Scan implementation.
func (IdentityType) Value ¶
func (i IdentityType) Value() (driver.Value, error)
Value implements [driver.Valuer] for IdentityType. This converts the API constant into an integer or throws an error.
type Image ¶
type Image struct {
ID int
Project string `db:"primary=yes&join=projects.name"`
Fingerprint string `db:"primary=yes"`
Type int
Filename string
Size int64
Public bool
Architecture int
CreationDate sql.NullTime
ExpiryDate sql.NullTime
UploadDate time.Time
Cached bool
LastUseDate sql.NullTime
AutoUpdate bool
}
Image is a value object holding db-related details about an image.
type ImageFilter ¶
type ImageFilter struct {
ID *int
Project *string
Fingerprint *string
Public *bool
Cached *bool
AutoUpdate *bool
}
ImageFilter can be used to filter results yielded by GetImages.
type ImageGenerated ¶
type ImageGenerated interface {
// GetImages returns all available images.
// generator: image GetMany
GetImages(ctx context.Context, tx *sql.Tx, filters ...ImageFilter) ([]Image, error)
// GetImage returns the image with the given key.
// generator: image GetOne
GetImage(ctx context.Context, tx *sql.Tx, project string, fingerprint string) (*Image, error)
}
ImageGenerated is an interface of generated methods for Image.
type Instance ¶
type Instance struct {
ID int
Project string `db:"primary=yes&join=projects.name"`
Name string `db:"primary=yes"`
Node string `db:"join=nodes.name"`
Type instancetype.Type
Snapshot bool `db:"ignore"`
Architecture int
Ephemeral bool
CreationDate time.Time
Stateful bool
LastUseDate sql.NullTime
Description string `db:"coalesce=''"`
ExpiryDate sql.NullTime
}
Instance is a value object holding db-related details about an instance.
func GetInstance ¶
GetInstance returns the instance with the given key. generator: instance GetOne
func GetInstances ¶
GetInstances returns all available instances. generator: instance GetMany
type InstanceFilter ¶
type InstanceFilter struct {
ID *int
Project *string
Name *string
Node *string
Type *instancetype.Type
}
InstanceFilter specifies potential query parameter fields.
type InstanceGenerated ¶
type InstanceGenerated interface {
// GetInstanceConfig returns all available Instance Config
// generator: instance GetMany
GetInstanceConfig(ctx context.Context, tx *sql.Tx, instanceID int, filters ...ConfigFilter) (map[string]string, error)
// GetInstanceDevices returns all available Instance Devices
// generator: instance GetMany
GetInstanceDevices(ctx context.Context, tx *sql.Tx, instanceID int, filters ...DeviceFilter) (map[string]Device, error)
// GetInstances returns all available instances.
// generator: instance GetMany
GetInstances(ctx context.Context, tx *sql.Tx, filters ...InstanceFilter) ([]Instance, error)
// GetInstance returns the instance with the given key.
// generator: instance GetOne
GetInstance(ctx context.Context, tx *sql.Tx, project string, name string) (*Instance, error)
// GetInstanceID return the ID of the instance with the given key.
// generator: instance ID
GetInstanceID(ctx context.Context, tx *sql.Tx, project string, name string) (int64, error)
// CreateInstanceConfig adds new instance Config to the database.
// generator: instance Create
CreateInstanceConfig(ctx context.Context, tx *sql.Tx, instanceID int64, config map[string]string) error
// CreateInstanceDevices adds new instance Devices to the database.
// generator: instance Create
CreateInstanceDevices(ctx context.Context, tx *sql.Tx, instanceID int64, devices map[string]Device) error
// CreateInstance adds a new instance to the database.
// generator: instance Create
CreateInstance(ctx context.Context, tx *sql.Tx, object Instance) (int64, error)
// RenameInstance renames the instance matching the given key parameters.
// generator: instance Rename
RenameInstance(ctx context.Context, tx *sql.Tx, project string, name string, to string) error
// DeleteInstance deletes the instance matching the given key parameters.
// generator: instance DeleteOne-by-Project-and-Name
DeleteInstance(ctx context.Context, tx *sql.Tx, project string, name string) error
// UpdateInstanceConfig updates the instance Config matching the given key parameters.
// generator: instance Update
UpdateInstanceConfig(ctx context.Context, tx *sql.Tx, instanceID int64, config map[string]string) error
// UpdateInstanceDevices updates the instance Device matching the given key parameters.
// generator: instance Update
UpdateInstanceDevices(ctx context.Context, tx *sql.Tx, instanceID int64, devices map[string]Device) error
// UpdateInstance updates the instance matching the given key parameters.
// generator: instance Update
UpdateInstance(ctx context.Context, tx *sql.Tx, project string, name string, object Instance) error
}
InstanceGenerated is an interface of generated methods for Instance.
type InstanceSnapshot ¶
type InstanceSnapshot struct {
ID int
Project string `db:"primary=yes&join=projects.name&joinon=instances.project_id"`
Instance string `db:"primary=yes&join=instances.name"`
Name string `db:"primary=yes"`
CreationDate time.Time
Stateful bool
Description string `db:"coalesce=''"`
ExpiryDate sql.NullTime
}
InstanceSnapshot is a value object holding db-related details about a snapshot.
func GetInstanceSnapshot ¶
func GetInstanceSnapshot(ctx context.Context, tx *sql.Tx, project string, instance string, name string) (*InstanceSnapshot, error)
GetInstanceSnapshot returns the instance_snapshot with the given key. generator: instance_snapshot GetOne
func GetInstanceSnapshots ¶
func GetInstanceSnapshots(ctx context.Context, tx *sql.Tx, filters ...InstanceSnapshotFilter) ([]InstanceSnapshot, error)
GetInstanceSnapshots returns all available instance_snapshots. generator: instance_snapshot GetMany
func (*InstanceSnapshot) ToInstance ¶
func (s *InstanceSnapshot) ToInstance(parentName string, parentNode string, parentType instancetype.Type, parentArch int) Instance
ToInstance converts an instance snapshot to a database Instance, filling in extra fields from the parent instance.
type InstanceSnapshotFilter ¶
InstanceSnapshotFilter specifies potential query parameter fields.
type InstanceSnapshotGenerated ¶
type InstanceSnapshotGenerated interface {
// GetInstanceSnapshotConfig returns all available InstanceSnapshot Config
// generator: instance_snapshot GetMany
GetInstanceSnapshotConfig(ctx context.Context, tx *sql.Tx, instanceSnapshotID int, filters ...ConfigFilter) (map[string]string, error)
// GetInstanceSnapshotDevices returns all available InstanceSnapshot Devices
// generator: instance_snapshot GetMany
GetInstanceSnapshotDevices(ctx context.Context, tx *sql.Tx, instanceSnapshotID int, filters ...DeviceFilter) (map[string]Device, error)
// GetInstanceSnapshots returns all available instance_snapshots.
// generator: instance_snapshot GetMany
GetInstanceSnapshots(ctx context.Context, tx *sql.Tx, filters ...InstanceSnapshotFilter) ([]InstanceSnapshot, error)
// GetInstanceSnapshot returns the instance_snapshot with the given key.
// generator: instance_snapshot GetOne
GetInstanceSnapshot(ctx context.Context, tx *sql.Tx, project string, instance string, name string) (*InstanceSnapshot, error)
// GetInstanceSnapshotID return the ID of the instance_snapshot with the given key.
// generator: instance_snapshot ID
GetInstanceSnapshotID(ctx context.Context, tx *sql.Tx, project string, instance string, name string) (int64, error)
// CreateInstanceSnapshotConfig adds new instance_snapshot Config to the database.
// generator: instance_snapshot Create
CreateInstanceSnapshotConfig(ctx context.Context, tx *sql.Tx, instanceSnapshotID int64, config map[string]string) error
// CreateInstanceSnapshotDevices adds new instance_snapshot Devices to the database.
// generator: instance_snapshot Create
CreateInstanceSnapshotDevices(ctx context.Context, tx *sql.Tx, instanceSnapshotID int64, devices map[string]Device) error
// CreateInstanceSnapshot adds a new instance_snapshot to the database.
// generator: instance_snapshot Create
CreateInstanceSnapshot(ctx context.Context, tx *sql.Tx, object InstanceSnapshot) (int64, error)
// RenameInstanceSnapshot renames the instance_snapshot matching the given key parameters.
// generator: instance_snapshot Rename
RenameInstanceSnapshot(ctx context.Context, tx *sql.Tx, project string, instance string, name string, to string) error
// DeleteInstanceSnapshot deletes the instance_snapshot matching the given key parameters.
// generator: instance_snapshot DeleteOne-by-Project-and-Instance-and-Name
DeleteInstanceSnapshot(ctx context.Context, tx *sql.Tx, project string, instance string, name string) error
}
InstanceSnapshotGenerated is an interface of generated methods for InstanceSnapshot.
type InstancesProfilesRow ¶
type InstancesProfilesRow struct {
ID int64 `db:"id"`
InstanceID int64 `db:"instance_id"`
ProfileID int64 `db:"profile_id"`
ApplyOrder int64 `db:"apply_order"`
}
InstancesProfilesRow represents a single row of the instances_profiles table. db:model instances_profiles
func (InstancesProfilesRow) APIName ¶
func (InstancesProfilesRow) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (InstancesProfilesRow) CreateStmt ¶
func (i InstancesProfilesRow) CreateStmt() string
CreateStmt returns a query that creates a InstancesProfilesRow entity.
func (InstancesProfilesRow) CreateValues ¶
func (i InstancesProfilesRow) CreateValues() []any
CreateValues returns a list of values from InstancesProfilesRow entities matching the bind arguments in [CreateStmt].
func (InstancesProfilesRow) Joins ¶
func (i InstancesProfilesRow) Joins() []string
Joins returns a slice of join expressions for InstancesProfilesRow.
func (InstancesProfilesRow) PKColumns ¶
func (i InstancesProfilesRow) PKColumns() []string
PKColumns returns the column names for the primary key of a InstancesProfilesRow entity used during an update. The returned slice must have the same number of elements as PKValues.
func (InstancesProfilesRow) PKValues ¶
func (i InstancesProfilesRow) PKValues() []any
PKValues returns the values for the primary key of a InstancesProfilesRow entity used during an update. The returned slice must have the same number of elements as PKColumns.
func (*InstancesProfilesRow) ScanArgs ¶
func (i *InstancesProfilesRow) ScanArgs() []any
ScanArgs implements query.ScanArger for InstancesProfilesRow. This returns references to struct fields in definition order.
func (InstancesProfilesRow) SelectColumns ¶
func (i InstancesProfilesRow) SelectColumns() []string
SelectColumns returns a slice of column names for InstancesProfilesRow entities.
func (InstancesProfilesRow) TableName ¶
func (i InstancesProfilesRow) TableName() string
TableName returns the table name for InstancesProfilesRow entities.
func (InstancesProfilesRow) UpdateStmt ¶
func (i InstancesProfilesRow) UpdateStmt() string
UpdateStmt returns a query that updates a InstancesProfilesRow by primary key.
func (InstancesProfilesRow) UpdateValues ¶
func (i InstancesProfilesRow) UpdateValues() []any
UpdateValues returns a list of values from InstancesProfilesRow entities matching the columns in [UpdateStmt].
type NodeFilter ¶
type NodeFilter struct {
Name *string
}
NodeFilter specifies potential query parameter fields.
type NodesClusterGroups ¶
type NodesClusterGroups struct {
Row NodesClusterGroupsRow
// db:join JOIN nodes ON nodes_cluster_groups.node_id = nodes.id
NodeName string `db:"nodes.name"`
}
NodesClusterGroups contains NodesClusterGroupsRow with additional joins. db:model nodes_cluster_groups
func GetNodesClusterGroupsByGroupID ¶
func GetNodesClusterGroupsByGroupID(ctx context.Context, tx *sql.Tx, groupID int64) ([]NodesClusterGroups, error)
GetNodesClusterGroupsByGroupID returns node cluster group associations for a given group ID.
func (NodesClusterGroups) APIName ¶
func (n NodesClusterGroups) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (NodesClusterGroups) Joins ¶
func (n NodesClusterGroups) Joins() []string
Joins returns a slice of join expressions for NodesClusterGroups.
func (*NodesClusterGroups) ScanArgs ¶
func (n *NodesClusterGroups) ScanArgs() []any
ScanArgs implements query.ScanArger for NodesClusterGroups. This returns references to struct fields in definition order.
func (NodesClusterGroups) SelectColumns ¶
func (n NodesClusterGroups) SelectColumns() []string
SelectColumns returns a slice of column names for NodesClusterGroups entities.
func (NodesClusterGroups) TableName ¶
func (n NodesClusterGroups) TableName() string
TableName returns the table name for NodesClusterGroups entities.
type NodesClusterGroupsRow ¶
type NodesClusterGroupsRow struct {
ID int64 `db:"id"`
NodeID int64 `db:"node_id"`
GroupID int64 `db:"group_id"`
}
NodesClusterGroupsRow represents a single row of the nodes_cluster_groups table. db:model nodes_cluster_groups
func (NodesClusterGroupsRow) APIName ¶
func (NodesClusterGroupsRow) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (NodesClusterGroupsRow) CreateStmt ¶
func (n NodesClusterGroupsRow) CreateStmt() string
CreateStmt returns a query that creates a NodesClusterGroupsRow entity.
func (NodesClusterGroupsRow) CreateValues ¶
func (n NodesClusterGroupsRow) CreateValues() []any
CreateValues returns a list of values from NodesClusterGroupsRow entities matching the bind arguments in [CreateStmt].
func (NodesClusterGroupsRow) Joins ¶
func (n NodesClusterGroupsRow) Joins() []string
Joins returns a slice of join expressions for NodesClusterGroupsRow.
func (NodesClusterGroupsRow) PKColumns ¶
func (n NodesClusterGroupsRow) PKColumns() []string
PKColumns returns the column names for the primary key of a NodesClusterGroupsRow entity used during an update. The returned slice must have the same number of elements as PKValues.
func (NodesClusterGroupsRow) PKValues ¶
func (n NodesClusterGroupsRow) PKValues() []any
PKValues returns the values for the primary key of a NodesClusterGroupsRow entity used during an update. The returned slice must have the same number of elements as PKColumns.
func (*NodesClusterGroupsRow) ScanArgs ¶
func (n *NodesClusterGroupsRow) ScanArgs() []any
ScanArgs implements query.ScanArger for NodesClusterGroupsRow. This returns references to struct fields in definition order.
func (NodesClusterGroupsRow) SelectColumns ¶
func (n NodesClusterGroupsRow) SelectColumns() []string
SelectColumns returns a slice of column names for NodesClusterGroupsRow entities.
func (NodesClusterGroupsRow) TableName ¶
func (n NodesClusterGroupsRow) TableName() string
TableName returns the table name for NodesClusterGroupsRow entities.
func (NodesClusterGroupsRow) UpdateStmt ¶
func (n NodesClusterGroupsRow) UpdateStmt() string
UpdateStmt returns a query that updates a NodesClusterGroupsRow by primary key.
func (NodesClusterGroupsRow) UpdateValues ¶
func (n NodesClusterGroupsRow) UpdateValues() []any
UpdateValues returns a list of values from NodesClusterGroupsRow entities matching the columns in [UpdateStmt].
type OIDCMetadata ¶
type OIDCMetadata struct {
Subject string `json:"subject"`
IdentityProviderGroups []string `json:"identity_provider_groups"`
}
OIDCMetadata contains metadata for OIDC identities.
func (OIDCMetadata) Equals ¶
func (o OIDCMetadata) Equals(m OIDCMetadata) bool
Equals returns true if the given OIDCMetadata is equal to the receiver.
type OIDCSession ¶
type OIDCSession struct {
ID int
UUID uuid.UUID
IdentityID int64
Email string
Username string
IDToken string
AccessToken string
RefreshToken string
IP string
UserAgent string
ExpiryDate time.Time
}
OIDCSession represents an OIDC session.
func GetAllOIDCSessions ¶
GetAllOIDCSessions gets all OIDC sessions.
func GetOIDCSessionByUUID ¶
GetOIDCSessionByUUID gets a session by UUID.
func GetOIDCSessionsByEmail ¶
GetOIDCSessionsByEmail gets all sessions for the identity with the given email.
func (OIDCSession) ToAPI ¶
func (s OIDCSession) ToAPI() api.OIDCSession
ToAPI returns an api.OIDCSession from the OIDCSession.
type Operation ¶
type Operation struct {
Row OperationsRow
// db:join LEFT JOIN projects ON operations.project_id = projects.id
ProjectName string `db:"coalesce(projects.name, '')"`
// db:join JOIN nodes ON operations.node_id = nodes.id
NodeAddress string `db:"nodes.address"`
NodeName string `db:"nodes.name"`
// db:join LEFT JOIN identities ON operations.requestor_identity_id = identities.id
IdentityIdentifier string `db:"coalesce(identities.identifier, '')"`
}
Operation enriches an OperationsRow with project, node, and identity information. db:model operations
func GetOperation ¶
GetOperation gets an Operation by UUID.
func GetOperationsByNodeID ¶
GetOperationsByNodeID gets all operations on the given node ID.
func GetOperationsByProjectAndType ¶
func GetOperationsByProjectAndType(ctx context.Context, tx *sql.Tx, projectName string, opType operationtype.Type) ([]Operation, error)
GetOperationsByProjectAndType returns a slice of Operation with the given project and type.
func GetOperationsWithParent ¶
GetOperationsWithParent gets all operations whose parent operation has the given ID.
func GetParentOperations ¶
GetParentOperations returns all parent operation, that is all operations that don't have a parent.
func (Operation) APIName ¶
APIName implements query.APINamer for API friendly error messages.
func (*Operation) ScanArgs ¶
ScanArgs implements query.ScanArger for Operation. This returns references to struct fields in definition order.
func (Operation) SelectColumns ¶
SelectColumns returns a slice of column names for Operation entities.
type OperationFilter ¶
OperationFilter specifies potential query parameter fields.
type OperationsRow ¶
type OperationsRow struct {
ID int64 `db:"id"`
// db:omit update
UUID string `db:"uuid"`
NodeID int64 `db:"node_id"`
// db:omit update
Type operationtype.Type `db:"type"`
// db:omit update
ProjectID *int64 `db:"project_id"`
// db:omit update
RequestorProtocol *RequestorProtocol `db:"requestor_protocol"`
// db:omit update
RequestorIdentityID *int64 `db:"requestor_identity_id"`
// db:omit update
EntityID int64 `db:"entity_id"`
Metadata string `db:"metadata"`
// db:omit update
Class int64 `db:"class"`
// db:omit update
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
// db:omit update
Inputs string `db:"inputs"`
StatusCode int64 `db:"status_code"`
Error string `db:"error"`
// db:omit update
ConflictReference string `db:"conflict_reference"`
// db:omit update
Parent *int64 `db:"parent"`
// db:omit update
Stage int64 `db:"stage"`
ErrorCode int64 `db:"error_code"`
}
OperationsRow is a row of the operations table. db:model operations
func (OperationsRow) APIName ¶
func (OperationsRow) APIName() string
APIName implements query.APINamer for OperationsRow for API friendly error messages.
func (OperationsRow) CreateStmt ¶
func (o OperationsRow) CreateStmt() string
CreateStmt returns a query that creates a OperationsRow entity.
func (OperationsRow) CreateValues ¶
func (o OperationsRow) CreateValues() []any
CreateValues returns a list of values from OperationsRow entities matching the bind arguments in [CreateStmt].
func (OperationsRow) Joins ¶
func (o OperationsRow) Joins() []string
Joins returns a slice of join expressions for OperationsRow.
func (OperationsRow) PKColumns ¶
func (o OperationsRow) PKColumns() []string
PKColumns returns the column names for the primary key of a OperationsRow entity used during an update. The returned slice must have the same number of elements as PKValues.
func (OperationsRow) PKValues ¶
func (o OperationsRow) PKValues() []any
PKValues returns the values for the primary key of a OperationsRow entity used during an update. The returned slice must have the same number of elements as PKColumns.
func (*OperationsRow) ScanArgs ¶
func (o *OperationsRow) ScanArgs() []any
ScanArgs implements query.ScanArger for OperationsRow. This returns references to struct fields in definition order.
func (OperationsRow) SelectColumns ¶
func (o OperationsRow) SelectColumns() []string
SelectColumns returns a slice of column names for OperationsRow entities.
func (OperationsRow) TableName ¶
func (o OperationsRow) TableName() string
TableName returns the table name for OperationsRow entities.
func (OperationsRow) UpdateStmt ¶
func (o OperationsRow) UpdateStmt() string
UpdateStmt returns a query that updates a OperationsRow by primary key.
func (OperationsRow) UpdateValues ¶
func (o OperationsRow) UpdateValues() []any
UpdateValues returns a list of values from OperationsRow entities matching the columns in [UpdateStmt].
type PendingTLSMetadata ¶
PendingTLSMetadata contains metadata for the pending TLS certificate identity type.
type Permission ¶
type Permission struct {
ID int
GroupID int64
Entitlement auth.Entitlement
EntityType EntityType
EntityID int
}
Permission is the database representation of an api.Permission.
func GetDistinctPermissionsByGroupNames ¶
func GetDistinctPermissionsByGroupNames(ctx context.Context, tx *sql.Tx, groupNames []string) ([]Permission, error)
GetDistinctPermissionsByGroupNames gets all distinct permissions that the groups with the given names have been granted.
func GetPermissionEntityURLs ¶
func GetPermissionEntityURLs(ctx context.Context, tx *sql.Tx, permissions []Permission) ([]Permission, map[entity.Type]map[int]*api.URL, error)
GetPermissionEntityURLs accepts a slice of Permission as input. The input Permission slice may include permissions that are no longer valid because the entity against which they are defined no longer exists. This method determines which permissions are valid and which are not valid by attempting to retrieve their entity URL. It uses as few queries as possible to do this. It returns a slice of valid permissions and a map of entity.Type, to entity ID, to api.URL. The returned map contains the URL of the entity of each returned valid permission. It is used for populating api.Permission. A warning is logged if any invalid permissions are found. And error is returned if any query returns unexpected error.
func GetPermissions ¶
GetPermissions returns a map of group ID to the permissions that belong to the auth group with that ID.
func GetPermissionsByAuthGroupID ¶
func GetPermissionsByAuthGroupID(ctx context.Context, tx *sql.Tx, groupID int64) ([]Permission, error)
GetPermissionsByAuthGroupID returns the permissions that belong to the group with the given ID.
type PlacementGroup ¶
type PlacementGroup struct {
Row PlacementGroupsRow
// db:join JOIN projects ON placement_groups.project_id = projects.id
ProjectName string `db:"projects.name"`
}
PlacementGroup contains PlacementGroupsRow with additional joins. db:model placement_groups
func GetPlacementGroup ¶
func GetPlacementGroup(ctx context.Context, tx *sql.Tx, name string, projectName string) (*PlacementGroup, error)
GetPlacementGroup gets a PlacementGroup by name and project.
func GetPlacementGroupsAndURLs ¶
func GetPlacementGroupsAndURLs(ctx context.Context, tx *sql.Tx, projectName *string, filter func(group PlacementGroup) bool) ([]PlacementGroup, []string, error)
GetPlacementGroupsAndURLs queries for all placement groups and then applies the given filter to the result. This is useful when filtering by groups the caller is able to view. The filter must return true to include an entry, and false to reject an entry. A slice of (filtered) placement group URLs is also returned for convenience. If the project name argument is non-nil, only placement groups in that project are returned. If the project name is nil, placement groups from all projects are returned.
func (PlacementGroup) APIName ¶
func (p PlacementGroup) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (PlacementGroup) Joins ¶
func (p PlacementGroup) Joins() []string
Joins returns a slice of join expressions for PlacementGroup.
func (*PlacementGroup) ScanArgs ¶
func (p *PlacementGroup) ScanArgs() []any
ScanArgs implements query.ScanArger for PlacementGroup. This returns references to struct fields in definition order.
func (PlacementGroup) SelectColumns ¶
func (p PlacementGroup) SelectColumns() []string
SelectColumns returns a slice of column names for PlacementGroup entities.
func (PlacementGroup) TableName ¶
func (p PlacementGroup) TableName() string
TableName returns the table name for PlacementGroup entities.
func (*PlacementGroup) ToAPI ¶
func (p *PlacementGroup) ToAPI(configs map[int64]map[string]string) *api.PlacementGroup
ToAPI converts the PlacementGroup to an api.PlacementGroup, querying for extra data as necessary.
type PlacementGroupFilter ¶
PlacementGroupFilter contains fields that can be used to filter results when getting placement groups.
type PlacementGroupsRow ¶
type PlacementGroupsRow struct {
ID int64 `db:"id"`
Name string `db:"name"`
Description string `db:"description"`
ProjectID int64 `db:"project_id"`
}
PlacementGroupsRow represents a single row of the placement_groups table. db:model placement_groups
func (PlacementGroupsRow) APIName ¶
func (PlacementGroupsRow) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (PlacementGroupsRow) CreateStmt ¶
func (p PlacementGroupsRow) CreateStmt() string
CreateStmt returns a query that creates a PlacementGroupsRow entity.
func (PlacementGroupsRow) CreateValues ¶
func (p PlacementGroupsRow) CreateValues() []any
CreateValues returns a list of values from PlacementGroupsRow entities matching the bind arguments in [CreateStmt].
func (PlacementGroupsRow) Joins ¶
func (p PlacementGroupsRow) Joins() []string
Joins returns a slice of join expressions for PlacementGroupsRow.
func (PlacementGroupsRow) PKColumns ¶
func (p PlacementGroupsRow) PKColumns() []string
PKColumns returns the column names for the primary key of a PlacementGroupsRow entity used during an update. The returned slice must have the same number of elements as PKValues.
func (PlacementGroupsRow) PKValues ¶
func (p PlacementGroupsRow) PKValues() []any
PKValues returns the values for the primary key of a PlacementGroupsRow entity used during an update. The returned slice must have the same number of elements as PKColumns.
func (*PlacementGroupsRow) ScanArgs ¶
func (p *PlacementGroupsRow) ScanArgs() []any
ScanArgs implements query.ScanArger for PlacementGroupsRow. This returns references to struct fields in definition order.
func (PlacementGroupsRow) SelectColumns ¶
func (p PlacementGroupsRow) SelectColumns() []string
SelectColumns returns a slice of column names for PlacementGroupsRow entities.
func (PlacementGroupsRow) TableName ¶
func (p PlacementGroupsRow) TableName() string
TableName returns the table name for PlacementGroupsRow entities.
func (PlacementGroupsRow) UpdateStmt ¶
func (p PlacementGroupsRow) UpdateStmt() string
UpdateStmt returns a query that updates a PlacementGroupsRow by primary key.
func (PlacementGroupsRow) UpdateValues ¶
func (p PlacementGroupsRow) UpdateValues() []any
UpdateValues returns a list of values from PlacementGroupsRow entities matching the columns in [UpdateStmt].
type Profile ¶
type Profile struct {
ID int
ProjectID int `db:"omit=create,update"`
Project string `db:"primary=yes&join=projects.name"`
Name string `db:"primary=yes"`
Description string `db:"coalesce=''"`
}
Profile is a value object holding db-related details about a profile.
func GetInstanceProfiles ¶
GetInstanceProfiles returns all available Profiles for the Instance.
func GetProfile ¶
GetProfile returns the profile with the given key. generator: profile GetOne
func GetProfiles ¶
GetProfiles returns all available profiles. generator: profile GetMany
type ProfileFilter ¶
ProfileFilter specifies potential query parameter fields.
type ProfileGenerated ¶
type ProfileGenerated interface {
// GetProfileID return the ID of the profile with the given key.
// generator: profile ID
GetProfileID(ctx context.Context, tx *sql.Tx, project string, name string) (int64, error)
// GetProfileConfig returns all available Profile Config
// generator: profile GetMany
GetProfileConfig(ctx context.Context, tx *sql.Tx, profileID int, filters ...ConfigFilter) (map[string]string, error)
// GetProfileDevices returns all available Profile Devices
// generator: profile GetMany
GetProfileDevices(ctx context.Context, tx *sql.Tx, profileID int, filters ...DeviceFilter) (map[string]Device, error)
// GetProfiles returns all available profiles.
// generator: profile GetMany
GetProfiles(ctx context.Context, tx *sql.Tx, filters ...ProfileFilter) ([]Profile, error)
// GetProfile returns the profile with the given key.
// generator: profile GetOne
GetProfile(ctx context.Context, tx *sql.Tx, project string, name string) (*Profile, error)
// CreateProfileConfig adds new profile Config to the database.
// generator: profile Create
CreateProfileConfig(ctx context.Context, tx *sql.Tx, profileID int64, config map[string]string) error
// CreateProfileDevices adds new profile Devices to the database.
// generator: profile Create
CreateProfileDevices(ctx context.Context, tx *sql.Tx, profileID int64, devices map[string]Device) error
// CreateProfile adds a new profile to the database.
// generator: profile Create
CreateProfile(ctx context.Context, tx *sql.Tx, object Profile) (int64, error)
// RenameProfile renames the profile matching the given key parameters.
// generator: profile Rename
RenameProfile(ctx context.Context, tx *sql.Tx, project string, name string, to string) error
// UpdateProfileConfig updates the profile Config matching the given key parameters.
// generator: profile Update
UpdateProfileConfig(ctx context.Context, tx *sql.Tx, profileID int64, config map[string]string) error
// UpdateProfileDevices updates the profile Device matching the given key parameters.
// generator: profile Update
UpdateProfileDevices(ctx context.Context, tx *sql.Tx, profileID int64, devices map[string]Device) error
// UpdateProfile updates the profile matching the given key parameters.
// generator: profile Update
UpdateProfile(ctx context.Context, tx *sql.Tx, project string, name string, object Profile) error
// DeleteProfile deletes the profile matching the given key parameters.
// generator: profile DeleteOne-by-Project-and-Name
DeleteProfile(ctx context.Context, tx *sql.Tx, project string, name string) error
}
ProfileGenerated is an interface of generated methods for Profile.
type Project ¶
type Project struct {
ID int
Description string
Name string `db:"omit=update"`
ReplicaMode ProjectReplicaMode `db:"omit=update"`
}
Project represents a LXD project.
func GetProject ¶
GetProject returns the project with the given key. generator: project GetOne
func GetProjectByID ¶
GetProjectByID returns the project with the given ID.
func GetProjects ¶
GetProjects returns all available projects. generator: project GetMany
type ProjectFeature ¶
type ProjectFeature struct {
// DefaultEnabled
// Whether the feature should be enabled by default on new projects.
DefaultEnabled bool
// CanEnableNonEmpty
// Whether or not the feature can be changed to enabled on a non-empty project.
CanEnableNonEmpty bool
}
ProjectFeature indicates the behaviour of a project feature.
type ProjectFilter ¶
type ProjectFilter struct {
ID *int
Name *string `db:"omit=update"` // If non-empty, return only the project with this name.
}
ProjectFilter specifies potential query parameter fields.
type ProjectGenerated ¶
type ProjectGenerated interface {
// GetProjects returns all available projects.
// generator: project GetMany
GetProjects(ctx context.Context, tx *sql.Tx, filters ...ProjectFilter) ([]Project, error)
// GetProject returns the project with the given key.
// generator: project GetOne
GetProject(ctx context.Context, tx *sql.Tx, name string) (*Project, error)
// CreateProjectConfig adds new project Config to the database.
// generator: project Create
CreateProjectConfig(ctx context.Context, tx *sql.Tx, projectID int64, config map[string]string) error
// CreateProject adds a new project to the database.
// generator: project Create
CreateProject(ctx context.Context, tx *sql.Tx, object Project) (int64, error)
// GetProjectID return the ID of the project with the given key.
// generator: project ID
GetProjectID(ctx context.Context, tx *sql.Tx, name string) (int64, error)
// RenameProject renames the project matching the given key parameters.
// generator: project Rename
RenameProject(ctx context.Context, tx *sql.Tx, name string, to string) error
// DeleteProject deletes the project matching the given key parameters.
// generator: project DeleteOne-by-Name
DeleteProject(ctx context.Context, tx *sql.Tx, name string) error
}
ProjectGenerated is an interface of generated methods for Project.
type ProjectReplicaMode ¶
type ProjectReplicaMode string
ProjectReplicaMode represents the replica mode of a project stored as an integer in the database.
This type implements the sql.Scanner and [driver.Valuer] interfaces to automatically handle conversion between API constants and their int64 representation in the database. When reading from the database, int64 values are converted back to their API constant. When writing to the database, API constants are converted to their int64 representation.
func (*ProjectReplicaMode) Scan ¶
func (p *ProjectReplicaMode) Scan(value any) error
Scan implements sql.Scanner for ProjectReplicaMode. This converts the database integer value back into the correct API constant or returns an error.
func (*ProjectReplicaMode) ScanInteger ¶
func (p *ProjectReplicaMode) ScanInteger(code int64) error
ScanInteger implements query.IntegerScanner for ProjectReplicaMode.
func (ProjectReplicaMode) Value ¶
func (p ProjectReplicaMode) Value() (driver.Value, error)
Value implements [driver.Valuer] for ProjectReplicaMode. This converts the API constant into its integer database representation or returns an error.
type Replicator ¶
type Replicator struct {
Row ReplicatorRow
// db:join JOIN projects ON replicators.project_id = projects.id
ProjectName string `db:"projects.name"`
}
Replicator contains ReplicatorRow with additional joins. db:model replicators
func GetReplicator ¶
func GetReplicator(ctx context.Context, tx *sql.Tx, name string, projectName string) (*Replicator, error)
GetReplicator returns the replicator with the given name and project.
func GetReplicatorsAndURLs ¶
func GetReplicatorsAndURLs(ctx context.Context, tx *sql.Tx, projectName *string, filter func(replicator Replicator) bool) ([]Replicator, []string, error)
GetReplicatorsAndURLs returns all replicators that pass the given filter, along with their entity URLs.
func (Replicator) APIName ¶
func (r Replicator) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (Replicator) Joins ¶
func (r Replicator) Joins() []string
Joins returns a slice of join expressions for Replicator.
func (*Replicator) ScanArgs ¶
func (r *Replicator) ScanArgs() []any
ScanArgs implements query.ScanArger for Replicator. This returns references to struct fields in definition order.
func (Replicator) SelectColumns ¶
func (r Replicator) SelectColumns() []string
SelectColumns returns a slice of column names for Replicator entities.
func (Replicator) TableName ¶
func (r Replicator) TableName() string
TableName returns the table name for Replicator entities.
func (*Replicator) ToAPI ¶
func (r *Replicator) ToAPI(allConfigs map[int64]map[string]string) *api.Replicator
ToAPI converts the Replicator to an api.Replicator.
type ReplicatorRow ¶
type ReplicatorRow struct {
ID int64 `db:"id"`
Name string `db:"name"`
ProjectID int64 `db:"project_id"`
Description string `db:"description"`
LastRunDate sql.NullTime `db:"last_run_date"`
LastRunStatus string `db:"last_run_status"`
}
ReplicatorRow represents a single row of the replicators table. db:model replicators
func (ReplicatorRow) APIName ¶
func (ReplicatorRow) APIName() string
APIName implements query.APINamer for API friendly error messages.
func (ReplicatorRow) CreateStmt ¶
func (r ReplicatorRow) CreateStmt() string
CreateStmt returns a query that creates a ReplicatorRow entity.
func (ReplicatorRow) CreateValues ¶
func (r ReplicatorRow) CreateValues() []any
CreateValues returns a list of values from ReplicatorRow entities matching the bind arguments in [CreateStmt].
func (ReplicatorRow) Joins ¶
func (r ReplicatorRow) Joins() []string
Joins returns a slice of join expressions for ReplicatorRow.
func (ReplicatorRow) PKColumns ¶
func (r ReplicatorRow) PKColumns() []string
PKColumns returns the column names for the primary key of a ReplicatorRow entity used during an update. The returned slice must have the same number of elements as PKValues.
func (ReplicatorRow) PKValues ¶
func (r ReplicatorRow) PKValues() []any
PKValues returns the values for the primary key of a ReplicatorRow entity used during an update. The returned slice must have the same number of elements as PKColumns.
func (*ReplicatorRow) ScanArgs ¶
func (r *ReplicatorRow) ScanArgs() []any
ScanArgs implements query.ScanArger for ReplicatorRow. This returns references to struct fields in definition order.
func (ReplicatorRow) SelectColumns ¶
func (r ReplicatorRow) SelectColumns() []string
SelectColumns returns a slice of column names for ReplicatorRow entities.
func (ReplicatorRow) TableName ¶
func (r ReplicatorRow) TableName() string
TableName returns the table name for ReplicatorRow entities.
func (ReplicatorRow) UpdateStmt ¶
func (r ReplicatorRow) UpdateStmt() string
UpdateStmt returns a query that updates a ReplicatorRow by primary key.
func (ReplicatorRow) UpdateValues ¶
func (r ReplicatorRow) UpdateValues() []any
UpdateValues returns a list of values from ReplicatorRow entities matching the columns in [UpdateStmt].
type RequestorProtocol ¶
type RequestorProtocol string
RequestorProtocol is the database representation of the Requestor Protocol.
RequestorProtocol is defined on string so that constants can be converted by casting. The sql.Scanner and [driver.Valuer] interfaces are implemented on this type such that the string constants are converted into their int64 counterparts as they are written to the database, or converted back into an RequestorProtocol as they are read from the database. It is not possible to read/write an invalid requestor protocol from/to the database when using this type.
func (*RequestorProtocol) Scan ¶
func (r *RequestorProtocol) Scan(value any) error
Scan implements sql.Scanner for RequestorProtocol. This converts the integer value back into the correct constant or returns an error.
func (*RequestorProtocol) ScanInteger ¶
func (r *RequestorProtocol) ScanInteger(requestorProtocolCode int64) error
ScanInteger implements query.IntegerScanner for RequestorProtocol. This simplifies the Scan implementation.
func (*RequestorProtocol) Value ¶
func (r *RequestorProtocol) Value() (driver.Value, error)
Value implements [driver.Valuer] for RequestorProtocol. This converts the API constant into an integer or throws an error.
type SecretType ¶
type SecretType string
SecretType represents the "type" column in the secrets table.
const ( // SecretTypeCoreAuth is the SecretType for core auth secrets. SecretTypeCoreAuth SecretType = "core_auth" // SecretTypeBearerSigningKey is the SecretType for bearer identity signing keys. SecretTypeBearerSigningKey SecretType = "bearer_signing_key" )
func (*SecretType) Scan ¶
func (s *SecretType) Scan(value any) error
Scan implements sql.Scanner for SecretType.
Note: This method must have a pointer receiver because only a pointer to a SecretType implements query.IntegerScanner. The Value implementation does not require a pointer receiver. This is so that a non-pointer SecretType can be written to the database.
func (*SecretType) ScanInteger ¶
func (s *SecretType) ScanInteger(code int64) error
ScanInteger implements query.IntegerScanner for SecretType to simplify the sql.Scanner implementation.
type StoragePoolVolumeContentType ¶
type StoragePoolVolumeContentType int
StoragePoolVolumeContentType records a volume's content-type in the database.
# Type Safety Funtions using this type should assume that a StoragePoolVolumeContentType is always a valid value; i.e. that it is type safe. Use the parsing methods below when converting to StoragePoolVolumeContentType.
const ( StoragePoolVolumeContentTypeFS StoragePoolVolumeContentType = iota StoragePoolVolumeContentTypeBlock StoragePoolVolumeContentTypeISO )
Content types.
func StoragePoolVolumeContentTypeFromInt ¶
func StoragePoolVolumeContentTypeFromInt(contentType int) (StoragePoolVolumeContentType, error)
StoragePoolVolumeContentTypeFromInt is a checked conversion to StoragePoolVolumeContentType.
func StoragePoolVolumeContentTypeFromName ¶
func StoragePoolVolumeContentTypeFromName(contentTypeName string) (StoragePoolVolumeContentType, error)
StoragePoolVolumeContentTypeFromName is a checked conversion to StoragePoolVolumeContentType.
func (StoragePoolVolumeContentType) String ¶
func (t StoragePoolVolumeContentType) String() string
String gives the name of a StoragePoolVolumeContentType.
# Safety This function assumes that `t` is one of the StoragePoolVolumeContentType enums defined above.
type StoragePoolVolumeType ¶
type StoragePoolVolumeType int
StoragePoolVolumeType records a volume's type in the database.
# Type Safety Funtions using this type should assume that a StoragePoolVolumeType is always a valid value; i.e. that it is type safe. Use the parsing methods below when converting to StoragePoolVolumeType.
const ( StoragePoolVolumeTypeContainer StoragePoolVolumeType = iota StoragePoolVolumeTypeImage StoragePoolVolumeTypeCustom StoragePoolVolumeTypeVM )
XXX: this was extracted from lxd/storage_volume_utils.go, we find a way to factor it independently from both the db and main packages.
func StoragePoolVolumeTypeFromInt ¶
func StoragePoolVolumeTypeFromInt(volType int) (StoragePoolVolumeType, error)
StoragePoolVolumeTypeFromInt is a checked conversion to StoragePoolVolumeType.
func StoragePoolVolumeTypeFromName ¶
func StoragePoolVolumeTypeFromName(volTypeName string) (StoragePoolVolumeType, error)
StoragePoolVolumeTypeFromName is a checked conversion to StoragePoolVolumeType.
func (StoragePoolVolumeType) String ¶
func (t StoragePoolVolumeType) String() string
String gives the name of a StoragePoolVolumeType.
# Safety This function assumes that `t` is one of the StoragePoolVolumeType enums defined above.
type Warning ¶
type Warning struct {
ID int
Node string `db:"coalesce=''&leftjoin=nodes.name"`
Project string `db:"coalesce=''&leftjoin=projects.name"`
EntityType EntityType `db:"coalesce=-1&sql=warnings.entity_type_code"`
EntityID int `db:"coalesce=-1"`
UUID string `db:"primary=yes"`
TypeCode warningtype.Type
Status warningtype.Status
FirstSeenDate time.Time
LastSeenDate time.Time
UpdatedDate time.Time
LastMessage string
Count int
}
Warning is a value object holding db-related details about a warning.
func GetWarning ¶
GetWarning returns the warning with the given key. generator: warning GetOne-by-UUID
func GetWarnings ¶
GetWarnings returns all available warnings. generator: warning GetMany
type WarningFilter ¶
type WarningFilter struct {
ID *int
UUID *string
Project *string
Node *string
TypeCode *warningtype.Type
EntityType *EntityType
EntityID *int
Status *warningtype.Status
}
WarningFilter specifies potential query parameter fields.
type WarningGenerated ¶
type WarningGenerated interface {
// GetWarnings returns all available warnings.
// generator: warning GetMany
GetWarnings(ctx context.Context, tx *sql.Tx, filters ...WarningFilter) ([]Warning, error)
// GetWarning returns the warning with the given key.
// generator: warning GetOne-by-UUID
GetWarning(ctx context.Context, tx *sql.Tx, uuid string) (*Warning, error)
// DeleteWarning deletes the warning matching the given key parameters.
// generator: warning DeleteOne-by-UUID
DeleteWarning(ctx context.Context, tx *sql.Tx, uuid string) error
// DeleteWarnings deletes the warning matching the given key parameters.
// generator: warning DeleteMany-by-EntityType-and-EntityID
DeleteWarnings(ctx context.Context, tx *sql.Tx, entityType EntityType, entityID int) error
// GetWarningID return the ID of the warning with the given key.
// generator: warning ID
GetWarningID(ctx context.Context, tx *sql.Tx, uuid string) (int64, error)
// WarningExists checks if a warning with the given key exists.
// generator: warning Exists
WarningExists(ctx context.Context, tx *sql.Tx, uuid string) (bool, error)
}
WarningGenerated is an interface of generated methods for Warning.
Source Files
¶
- auth_groups.go
- certificates.go
- certificates_legacy.go
- cluster_groups.go
- cluster_groups.interface.mapper.go
- cluster_groups.mapper.go
- cluster_links.go
- config.go
- config.interface.mapper.go
- config.mapper.go
- devices.go
- devices.interface.mapper.go
- devices.mapper.go
- entities.go
- entity_type_auth_group.go
- entity_type_certificate.go
- entity_type_cluster_group.go
- entity_type_cluster_link.go
- entity_type_cluster_member.go
- entity_type_common.go
- entity_type_container.go
- entity_type_identity.go
- entity_type_identity_provider_group.go
- entity_type_image.go
- entity_type_image_alias.go
- entity_type_instance.go
- entity_type_instance_backup.go
- entity_type_instance_snapshot.go
- entity_type_network.go
- entity_type_network_acl.go
- entity_type_network_zone.go
- entity_type_placement_group.go
- entity_type_profile.go
- entity_type_project.go
- entity_type_replicator.go
- entity_type_server.go
- entity_type_storage_bucket.go
- entity_type_storage_pool.go
- entity_type_storage_volume.go
- entity_type_storage_volume_backup.go
- entity_type_storage_volume_snapshot.go
- generated.go
- identities.go
- identity_provider_groups.go
- images.go
- images.interface.mapper.go
- images.mapper.go
- instance_profiles.go
- instances.go
- instances.interface.mapper.go
- instances.mapper.go
- nodes.go
- nodes.interface.mapper.go
- nodes.mapper.go
- nodes_cluster_groups.go
- oidc_sessions.go
- open.go
- operations.go
- permissions.go
- placement_groups.go
- profiles.go
- profiles.interface.mapper.go
- profiles.mapper.go
- projects.go
- projects.interface.mapper.go
- projects.mapper.go
- query.go
- replicators.go
- schema.go
- secrets.go
- snapshots.go
- snapshots.interface.mapper.go
- snapshots.mapper.go
- stmt.go
- storage_volume_type.go
- triggers.go
- update.go
- warnings.go
- warnings.interface.mapper.go
- warnings.mapper.go