{"modulePath":"github.com/chainloop-dev/chainloop","version":"v1.138.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package data\n\n## Variables\n\n```go\nvar ProviderSet = wire.NewSet(\n\tNewData,\n\tNewWorkflowRepo,\n\tNewUserRepo,\n\tNewRobotAccountRepo,\n\tNewWorkflowRunRepo,\n\tNewOrganizationRepo,\n\tNewWorkflowContractRepo,\n\tNewCASBackendRepo,\n\tNewOrgMetricsRepo,\n\tNewIntegrationRepo,\n\tNewIntegrationAttachmentRepo,\n\tNewCASMappingRepo,\n\tNewMembershipRepo,\n\tNewOrgInvitation,\n\tNewReferrerRepo,\n\tNewAPITokenRepo,\n\tNewAttestationStateRepo,\n\tNewProjectVersionRepo,\n\tNewProjectsRepo,\n\tNewGroupRepo,\n\tNewLoginHandoffRepo,\n\tNewPostgresLock,\n)\n```\nProviderSet is data providers.\n\n## Functions\n\n```go\nfunc NewAPITokenRepo(data *Data, logger log.Logger) biz.APITokenRepo\n```\n\n```go\nfunc NewAttestationStateRepo(data *Data, logger log.Logger) biz.AttestationStateRepo\n```\n\n```go\nfunc NewCASBackendRepo(data *Data, logger log.Logger) biz.CASBackendRepo\n```\n\n```go\nfunc NewCASMappingRepo(data *Data, cbRepo biz.CASBackendRepo, logger log.Logger) biz.CASMappingRepo\n```\n\n```go\nfunc NewGroupRepo(data *Data, logger log.Logger) biz.GroupRepo\n```\n\n```go\nfunc NewIntegrationAttachmentRepo(data *Data, logger log.Logger) biz.IntegrationAttachmentRepo\n```\n\n```go\nfunc NewIntegrationRepo(data *Data, logger log.Logger) biz.IntegrationRepo\n```\n\n```go\nfunc NewLoginHandoffRepo(data *Data, logger log.Logger) biz.LoginHandoffRepo\n```\n\n```go\nfunc NewMembershipRepo(data *Data, groupRepo biz.GroupRepo, logger log.Logger) biz.MembershipRepo\n```\n\n```go\nfunc NewOrgInvitation(data *Data, logger log.Logger) biz.OrgInvitationRepo\n```\n\n```go\nfunc NewOrgMetricsRepo(data *Data, l log.Logger) biz.OrgMetricsRepo\n```\n\n```go\nfunc NewOrganizationRepo(data *Data, logger log.Logger) biz.OrganizationRepo\n```\n\n```go\nfunc NewPostgresLock(d *Data, logger log.Logger) biz.DistributedLock\n```\n\n```go\nfunc NewProjectVersionRepo(data *Data, logger log.Logger) biz.ProjectVersionRepo\n```\n\n```go\nfunc NewProjectsRepo(data *Data, logger log.Logger) biz.ProjectsRepo\n```\n\n```go\nfunc NewReferrerRepo(data *Data, wfRepo biz.WorkflowRepo, logger log.Logger) biz.ReferrerRepo\n```\n\n```go\nfunc NewRobotAccountRepo(data *Data) biz.RobotAccountRepo\n```\n\n```go\nfunc NewUserRepo(data *Data, logger log.Logger) biz.UserRepo\n```\n\n```go\nfunc NewWorkflowContractRepo(data *Data, logger log.Logger) biz.WorkflowContractRepo\n```\n\n```go\nfunc NewWorkflowRepo(data *Data, logger log.Logger) biz.WorkflowRepo\n```\n\n```go\nfunc NewWorkflowRunRepo(data *Data, logger log.Logger) biz.WorkflowRunRepo\n```\n\n```go\nfunc WithTx(ctx context.Context, client *ent.Client, fn func(tx *ent.Tx) error) error\n```\nWithTx initiates a transaction and wraps the DB function\n\n## Types\n\n```go\ntype APITokenRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *APITokenRepo) Create(ctx context.Context, opts *biz.APITokenCreateOpts) (*biz.APIToken, error)\n```\nPersist the APIToken to the database.\n\n```go\nfunc (r *APITokenRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.APIToken, error)\n```\n\n```go\nfunc (r *APITokenRepo) FindByIDInOrg(ctx context.Context, orgID uuid.UUID, id uuid.UUID) (*biz.APIToken, error)\n```\n\n```go\nfunc (r *APITokenRepo) FindByNameInOrg(ctx context.Context, orgID uuid.UUID, name string) (*biz.APIToken, error)\n```\n\n```go\nfunc (r *APITokenRepo) FindInactive(ctx context.Context, orgID uuid.UUID, inactiveSince time.Time) ([]*biz.APIToken, error)\n```\nFindInactive returns tokens that have been inactive since the given cutoff.\n\n```go\nfunc (r *APITokenRepo) List(ctx context.Context, orgID *uuid.UUID, filters *biz.APITokenListFilters) ([]*biz.APIToken, error)\n```\n\n```go\nfunc (r *APITokenRepo) Revoke(ctx context.Context, orgID *uuid.UUID, id uuid.UUID) error\n```\n\n```go\nfunc (r *APITokenRepo) UpdateExpiration(ctx context.Context, id uuid.UUID, expiresAt time.Time) error\n```\n\n```go\nfunc (r *APITokenRepo) UpdateLastUsedAt(ctx context.Context, id uuid.UUID, lastUsedAt time.Time) error\n```\n\n```go\ntype AttestationStateRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *AttestationStateRepo) Initialized(ctx context.Context, runID uuid.UUID) (bool, error)\n```\nfind the workflow run by its ID and check that it has attestation state\n\n```go\nfunc (r *AttestationStateRepo) Read(ctx context.Context, runID uuid.UUID) ([]byte, string, error)\n```\n\n```go\nfunc (r *AttestationStateRepo) Reset(ctx context.Context, runID uuid.UUID) error\n```\n\n```go\nfunc (r *AttestationStateRepo) Save(ctx context.Context, runID uuid.UUID, state []byte, baseDigest string) (string, error)\n```\nbaseDigest, when provided will be used to check that it matches the digest of the state currently in the DB if the digests do not match, the state has been modified and the caller should retry. It returns the digest of the newly saved state.\n\n```go\ntype CASBackendRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *CASBackendRepo) Create(ctx context.Context, opts *biz.CASBackendCreateOpts) (*biz.CASBackend, error)\n```\nCreate creates a new CAS backend in the given organization If it's set as default, it will unset the previous default backend\n\n```go\nfunc (r *CASBackendRepo) Delete(ctx context.Context, id uuid.UUID) error\n```\nDelete deletes a CAS backend from the DB\n\n```go\nfunc (r *CASBackendRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.CASBackend, error)\n```\nFindByID finds a CAS backend by ID If not found, returns nil and no error\n\n```go\nfunc (r *CASBackendRepo) FindByIDInOrg(ctx context.Context, orgID, id uuid.UUID) (*biz.CASBackend, error)\n```\nFindByIDInOrg finds a CAS backend by ID in the given organization. If not found, returns nil and no error\n\n```go\nfunc (r *CASBackendRepo) FindByNameInOrg(ctx context.Context, orgID uuid.UUID, name string) (*biz.CASBackend, error)\n```\n\n```go\nfunc (r *CASBackendRepo) FindDefaultBackend(ctx context.Context, orgID uuid.UUID) (*biz.CASBackend, error)\n```\nFindDefaultBackend finds the CAS backend that's set as default for the given organization\n\n```go\nfunc (r *CASBackendRepo) FindFallbackBackend(ctx context.Context, orgID uuid.UUID) (*biz.CASBackend, error)\n```\nFindFallbackBackend finds the CAS backend that's set as fallback for the given organization\n\n```go\nfunc (r *CASBackendRepo) FindInlineBackend(ctx context.Context, orgID uuid.UUID) (*biz.CASBackend, error)\n```\nFindInlineBackend finds the inline CAS backend for the given organization\n\n```go\nfunc (r *CASBackendRepo) FindManagedBackend(ctx context.Context, orgID uuid.UUID) (*biz.CASBackend, error)\n```\nFindManagedBackend finds the managed CAS backend for the given organization. Managed backends are provisioned and operated by Chainloop. Only one is expected per organization.\n\n```go\nfunc (r *CASBackendRepo) List(ctx context.Context, orgID uuid.UUID) ([]*biz.CASBackend, error)\n```\n\n```go\nfunc (r *CASBackendRepo) ListBackends(ctx context.Context, defaultsOrFallbacks bool) ([]*biz.CASBackend, error)\n```\nListBackends returns CAS backends across all organizations. Only not inline backends are returned If defaultsOrFallbacks is true, only default and fallback backends are returned\n\n```go\nfunc (r *CASBackendRepo) SoftDelete(ctx context.Context, id uuid.UUID) error\n```\nSet deleted at instead of actually deleting the backend\n\n```go\nfunc (r *CASBackendRepo) Update(ctx context.Context, opts *biz.CASBackendUpdateOpts) (*biz.CASBackend, error)\n```\n\n```go\nfunc (r *CASBackendRepo) UpdateValidationStatus(ctx context.Context, id uuid.UUID, status biz.CASBackendValidationStatus, validationError *string) error\n```\nUpdateValidationStatus updates the validation status of a CAS backend\n\n```go\ntype CASMappingRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *CASMappingRepo) Create(ctx context.Context, digest string, casBackendID uuid.UUID, opts *biz.CASMappingCreateOpts) (*biz.CASMapping, error)\n```\n\n```go\nfunc (r *CASMappingRepo) FindByDigestInOrgs(ctx context.Context, digest string, orgs []uuid.UUID, scopes biz.RBACScopes) (*biz.CASMapping, error)\n```\nFindByDigestInOrgs returns a single CAS mapping for the digest that is reachable through one of the given organizations, honouring resource-level RBAC when a scope is provided for an org. The mapping stored in the default backend is preferred; ties break on the oldest mapping for a stable result. It returns (nil, nil) when no accessible mapping exists.\n\nThe selection is performed entirely in the database with a LIMIT 1, so the cost is independent of how many mappings a digest accumulates (e.g. the same artifact pushed across thousands of runs).\n\n```go\nfunc (r *CASMappingRepo) ListByDigestInOrg(ctx context.Context, digest string, orgID uuid.UUID) ([]*biz.CASMapping, error)\n```\nListByDigestInOrg returns every CAS mapping for the digest within the given organization, with no RBAC filtering applied. Mappings pointing to a (soft) deleted backend are left out, as they can no longer serve the artifact.\n\n```go\ntype Data struct {\n\tDB *ent.Client\n\t// Exposed for code paths that need raw SQL features ent doesn't surface,\n\t// e.g. session-scoped advisory locks (pg_try_advisory_lock).\n\tSQLDB *sql.DB\n}\n```\nData .\n\n```go\nfunc NewData(c *config.DatabaseConfig, tp trace.TracerProvider, logger log.Logger) (*Data, func(), error)\n```\nNewData .\n\n```go\nfunc (data *Data) SchemaLoad() error\n```\nLoad DB schema NOTE: this is different than running migrations this method is used to load the schema into the DB for TESTING!\n\n```go\ntype GroupRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (g GroupRepo) AddMemberToGroup(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, userID uuid.UUID, maintainer bool) (*biz.GroupMembership, error)\n```\nAddMemberToGroup adds a user to a group, creating a new membership if they are not already a member.\n\n```go\nfunc (g GroupRepo) Create(ctx context.Context, orgID uuid.UUID, opts *biz.CreateGroupOpts) (*biz.Group, error)\n```\nCreate creates a new group in the specified organization.\n\n```go\nfunc (g GroupRepo) FindByOrgAndID(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID) (*biz.Group, error)\n```\nFindByOrgAndID retrieves a group by its ID and org, ensuring it is not deleted.\n\n```go\nfunc (g GroupRepo) FindByOrgAndName(ctx context.Context, orgID uuid.UUID, name string) (*biz.Group, error)\n```\n\n```go\nfunc (g GroupRepo) FindGroupMembershipByGroupAndID(ctx context.Context, groupID uuid.UUID, userID uuid.UUID) (*biz.GroupMembership, error)\n```\nFindGroupMembershipByGroupAndID retrieves a group membership for a specific user in a group.\n\n```go\nfunc (g GroupRepo) List(ctx context.Context, orgID uuid.UUID, filterOpts *biz.ListGroupOpts, paginationOpts *pagination.OffsetPaginationOpts) ([]*biz.Group, int, error)\n```\n\n```go\nfunc (g GroupRepo) ListMembers(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, opts *biz.ListMembersOpts, paginationOpts *pagination.OffsetPaginationOpts) ([]*biz.GroupMembership, int, error)\n```\nListMembers retrieves the members of a group, optionally filtering by maintainers.\n\n```go\nfunc (g GroupRepo) ListPendingInvitationsByGroup(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, paginationOpts *pagination.OffsetPaginationOpts) ([]*biz.OrgInvitation, int, error)\n```\nListPendingInvitationsByGroup retrieves pending invitations for a specific group in an organization.\n\n```go\nfunc (g GroupRepo) ListProjectsByGroup(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, visibleProjectIDs []uuid.UUID, paginationOpts *pagination.OffsetPaginationOpts) ([]*biz.GroupProjectInfo, int, error)\n```\nListProjectsByGroup retrieves a list of projects that a group is a member of with pagination.\n\n```go\nfunc (g GroupRepo) RemoveMemberFromGroup(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, userID uuid.UUID) error\n```\nRemoveMemberFromGroup removes a user from a group.\n\n```go\nfunc (g GroupRepo) SoftDelete(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID) error\n```\nSoftDelete soft-deletes a group by setting the DeletedAt field to the current time. It also marks all group memberships as deleted and removes any pending invitations related to the group.\n\n```go\nfunc (g GroupRepo) Update(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, opts *biz.UpdateGroupOpts) (*biz.Group, error)\n```\nUpdate updates an existing group in the specified organization.\n\n```go\nfunc (g GroupRepo) UpdateGroupMemberCount(ctx context.Context, groupID uuid.UUID) error\n```\nUpdateGroupMemberCount updates the member count of a group based on an actual count query This should be called after membership changes have been committed.\n\n```go\nfunc (g GroupRepo) UpdateMemberMaintainerStatus(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, userID uuid.UUID, isMaintainer bool) error\n```\nUpdateMemberMaintainerStatus updates the maintainer status of a group member.\n\n```go\ntype IntegrationAttachmentRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *IntegrationAttachmentRepo) Create(ctx context.Context, integrationID, workflowID uuid.UUID, config []byte) (*biz.IntegrationAttachment, error)\n```\n\n```go\nfunc (r *IntegrationAttachmentRepo) FindByIDInOrg(ctx context.Context, orgID, id uuid.UUID) (*biz.IntegrationAttachment, error)\n```\n\n```go\nfunc (r *IntegrationAttachmentRepo) List(ctx context.Context, orgID uuid.UUID, opts *biz.ListAttachmentsOpts) ([]*biz.IntegrationAndAttachment, error)\n```\n\n```go\nfunc (r *IntegrationAttachmentRepo) SoftDelete(ctx context.Context, id uuid.UUID) error\n```\n\n```go\ntype IntegrationRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *IntegrationRepo) Create(ctx context.Context, opts *biz.IntegrationCreateOpts) (*biz.Integration, error)\n```\n\n```go\nfunc (r *IntegrationRepo) FindByIDInOrg(ctx context.Context, orgID, id uuid.UUID) (*biz.Integration, error)\n```\n\n```go\nfunc (r *IntegrationRepo) FindByNameInOrg(ctx context.Context, orgID uuid.UUID, name string) (*biz.Integration, error)\n```\n\n```go\nfunc (r *IntegrationRepo) List(ctx context.Context, orgID uuid.UUID) ([]*biz.Integration, error)\n```\n\n```go\nfunc (r *IntegrationRepo) SoftDelete(ctx context.Context, id uuid.UUID) error\n```\n\n```go\ntype LoginHandoffRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *LoginHandoffRepo) Consume(ctx context.Context, codeHash string, at time.Time) (*biz.LoginHandoff, bool, error)\n```\n\n```go\nfunc (r *LoginHandoffRepo) Create(ctx context.Context, codeHash string, h *biz.LoginHandoff) error\n```\n\n```go\nfunc (r *LoginHandoffRepo) DeleteExpired(ctx context.Context, before time.Time) (int, error)\n```\n\n```go\ntype MembershipRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *MembershipRepo) AddResourceRole(ctx context.Context, orgID uuid.UUID, resourceType authz.ResourceType, resID uuid.UUID, mType authz.MembershipType, memberID uuid.UUID, role authz.Role, parentID *uuid.UUID) error\n```\n\n```go\nfunc (r *MembershipRepo) Create(ctx context.Context, orgID, userID uuid.UUID, current bool, role authz.Role) (*biz.Membership, error)\n```\n\n```go\nfunc (r *MembershipRepo) Delete(ctx context.Context, id uuid.UUID) error\n```\nDelete deletes a membership by ID. When deleting a membership, it's important to ensure we're not leaving any dangling references.\n\n```go\nfunc (r *MembershipRepo) FindByIDInOrg(ctx context.Context, orgID, membershipID uuid.UUID) (*biz.Membership, error)\n```\n\n```go\nfunc (r *MembershipRepo) FindByIDInUser(ctx context.Context, userID, membershipID uuid.UUID) (*biz.Membership, error)\n```\n\n```go\nfunc (r *MembershipRepo) FindByOrg(ctx context.Context, orgID uuid.UUID, opts *biz.ListByOrgOpts, paginationOpts *pagination.OffsetPaginationOpts) ([]*biz.Membership, int, error)\n```\nFindByOrg finds all memberships for a given organization\n\n```go\nfunc (r *MembershipRepo) FindByOrgAndUser(ctx context.Context, orgID, userID uuid.UUID) (*biz.Membership, error)\n```\nFindByOrgAndUser finds the membership for a given organization and user\n\n```go\nfunc (r *MembershipRepo) FindByOrgIDAndUserEmail(ctx context.Context, orgID uuid.UUID, userEmail string) (*biz.Membership, error)\n```\nFindByOrgIDAndUserEmail finds the membership for a given organization and user email.\n\n```go\nfunc (r *MembershipRepo) FindByOrgNameAndUser(ctx context.Context, orgName string, userID uuid.UUID) (*biz.Membership, error)\n```\n\n```go\nfunc (r *MembershipRepo) FindByUser(ctx context.Context, userID uuid.UUID) ([]*biz.Membership, error)\n```\n\n```go\nfunc (r *MembershipRepo) FindByUserAndResourceID(ctx context.Context, userID, resourceID uuid.UUID) (*biz.Membership, error)\n```\nFindByUserAndResourceID finds a membership by user ID and resource ID.\n\n```go\nfunc (r *MembershipRepo) ListAllByResource(ctx context.Context, rt authz.ResourceType, id uuid.UUID) ([]*biz.Membership, error)\n```\n\n```go\nfunc (r *MembershipRepo) ListAllByUser(ctx context.Context, userID uuid.UUID) ([]*biz.Membership, error)\n```\n\n```go\nfunc (r *MembershipRepo) ListGroupMembershipsByUser(ctx context.Context, userID uuid.UUID) ([]*biz.Membership, error)\n```\nListGroupMembershipsByUser returns all memberships of the users inherited from groups\n\n```go\nfunc (r *MembershipRepo) SetCurrent(ctx context.Context, membershipID uuid.UUID) (mr *biz.Membership, err error)\n```\n\n```go\nfunc (r *MembershipRepo) SetRole(ctx context.Context, membershipID uuid.UUID, role authz.Role) (*biz.Membership, error)\n```\n\n```go\ntype OrgInvitation struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *OrgInvitation) ChangeStatus(ctx context.Context, id uuid.UUID, status biz.OrgInvitationStatus) error\n```\n\n```go\nfunc (r *OrgInvitation) Create(ctx context.Context, orgID uuid.UUID, senderID *uuid.UUID, receiverEmail string, role authz.Role, invCtx *biz.OrgInvitationContext) (*biz.OrgInvitation, error)\n```\n\n```go\nfunc (r *OrgInvitation) FindByID(ctx context.Context, id uuid.UUID) (*biz.OrgInvitation, error)\n```\n\n```go\nfunc (r *OrgInvitation) ListByOrg(ctx context.Context, orgID uuid.UUID) ([]*biz.OrgInvitation, error)\n```\n\n```go\nfunc (r *OrgInvitation) PendingInvitation(ctx context.Context, orgID uuid.UUID, receiverEmail string) (*biz.OrgInvitation, error)\n```\n\n```go\nfunc (r *OrgInvitation) PendingInvitations(ctx context.Context, receiverEmail string) ([]*biz.OrgInvitation, error)\n```\n\n```go\nfunc (r *OrgInvitation) SoftDelete(ctx context.Context, id uuid.UUID) error\n```\n\n```go\ntype OrgMetricsRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (repo *OrgMetricsRepo) DailyRunsCount(ctx context.Context, orgID, workflowID uuid.UUID, tw *biz.TimeWindow, projectIDs []uuid.UUID) ([]*biz.DayRunsCount, error)\n```\n\n```go\nfunc (repo *OrgMetricsRepo) RunsByRunnerTypeTotal(ctx context.Context, orgID uuid.UUID, tw *biz.TimeWindow, projectIDs []uuid.UUID) (map[string]int32, error)\n```\n\n```go\nfunc (repo *OrgMetricsRepo) RunsByStatusTotal(ctx context.Context, orgID uuid.UUID, tw *biz.TimeWindow, projectIDs []uuid.UUID) (map[string]int32, error)\n```\n\n```go\nfunc (repo *OrgMetricsRepo) RunsTotal(ctx context.Context, orgID uuid.UUID, tw *biz.TimeWindow, projectIDs []uuid.UUID) (int32, error)\n```\n\n```go\nfunc (repo *OrgMetricsRepo) TopWorkflowsByRunsCount(ctx context.Context, orgID uuid.UUID, numWorkflows int, tw *biz.TimeWindow, projectIDs []uuid.UUID) ([]*biz.TopWorkflowsByRunsCountItem, error)\n```\n\n```go\ntype OrganizationRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *OrganizationRepo) Create(ctx context.Context, name string) (*biz.Organization, error)\n```\n\n```go\nfunc (r *OrganizationRepo) Delete(ctx context.Context, id uuid.UUID) error\n```\nDelete soft-deletes an organization by ID.\n\n```go\nfunc (r *OrganizationRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.Organization, error)\n```\n\n```go\nfunc (r *OrganizationRepo) FindByName(ctx context.Context, name string) (*biz.Organization, error)\n```\nFindByName finds an organization by name.\n\n```go\nfunc (r *OrganizationRepo) FindWithTokenInactivityThreshold(ctx context.Context) ([]*biz.Organization, error)\n```\nFindWithTokenInactivityThreshold returns organizations that have the api\\_token\\_inactivity\\_threshold\\_days set.\n\n```go\nfunc (r *OrganizationRepo) SetSuspended(ctx context.Context, id uuid.UUID, suspended bool) error\n```\nSetSuspended sets or clears the suspended flag on an organization.\n\n```go\nfunc (r *OrganizationRepo) Update(ctx context.Context, id uuid.UUID, updateOpts *biz.OrganizationUpdateOpts) (*biz.Organization, error)\n```\n\n```go\ntype PostgresLock struct {\n\t// contains filtered or unexported fields\n}\n```\nPostgresLock implements biz.DistributedLock using Postgres session-level advisory locks (pg\\_try\\_advisory\\_lock / pg\\_advisory\\_unlock).\n\nPostgres is the only piece of infrastructure that's mandatory for the control plane — NATS is optional (used for distributed caches when present). Using advisory locks lets us coordinate background jobs across replicas without adding a new dependency (a NATS KV lease or a dedicated queue) that wouldn't be available in every deployment.\n\nEach lock holds a dedicated connection for its lifetime; releasing the lock returns the connection to the pool. If the pod crashes mid-run the connection drops and Postgres releases the lock automatically.\n\n```go\nfunc (l *PostgresLock) TryAcquire(ctx context.Context, key string) (bool, func(), error)\n```\n\n```go\ntype ProjectRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *ProjectRepo) AddMemberToProject(ctx context.Context, orgID uuid.UUID, projectID uuid.UUID, memberID uuid.UUID, membershipType authz.MembershipType, role authz.Role) (*biz.ProjectMembership, error)\n```\nAddMemberToProject adds a user or group to a project with a specific role\n\n```go\nfunc (r *ProjectRepo) Create(ctx context.Context, orgID uuid.UUID, name string) (*biz.Project, error)\n```\n\n```go\nfunc (r *ProjectRepo) FindProjectByOrgIDAndID(ctx context.Context, orgID uuid.UUID, projectID uuid.UUID) (*biz.Project, error)\n```\nFindProjectByOrgIDAndID gets a project by organization ID and project ID\n\n```go\nfunc (r *ProjectRepo) FindProjectByOrgIDAndName(ctx context.Context, orgID uuid.UUID, projectName string) (*biz.Project, error)\n```\nFindProjectByOrgIDAndName gets a project by organization ID and project name\n\n```go\nfunc (r *ProjectRepo) FindProjectMembershipByProjectAndID(ctx context.Context, orgID uuid.UUID, projectID uuid.UUID, memberID uuid.UUID, membershipType authz.MembershipType) (*biz.ProjectMembership, error)\n```\nFindProjectMembershipByProjectAndID finds a project membership by project ID and member ID (user or group)\n\n```go\nfunc (r *ProjectRepo) List(ctx context.Context, filterOpts *biz.ProjectListOpts, paginationOpts *pagination.OffsetPaginationOpts) ([]*biz.Project, int, error)\n```\nList returns the projects of an organization matching filterOpts, ordered by name, plus the total number of matches before pagination.\n\n```go\nfunc (r *ProjectRepo) ListMembers(ctx context.Context, orgID uuid.UUID, projectID uuid.UUID, paginationOpts *pagination.OffsetPaginationOpts) ([]*biz.ProjectMembership, int, error)\n```\nListMembers lists all members of a project (both users and groups)\n\n```go\nfunc (r *ProjectRepo) ListPendingInvitationsByProject(ctx context.Context, orgID uuid.UUID, projectID uuid.UUID, paginationOpts *pagination.OffsetPaginationOpts) ([]*biz.OrgInvitation, int, error)\n```\nListPendingInvitationsByProject retrieves pending invitations for a specific project in an organization.\n\n```go\nfunc (r *ProjectRepo) ListProjectsByOrgID(ctx context.Context, orgID uuid.UUID) ([]*biz.Project, error)\n```\n\n```go\nfunc (r *ProjectRepo) RemoveMemberFromProject(ctx context.Context, orgID uuid.UUID, projectID uuid.UUID, memberID uuid.UUID, membershipType authz.MembershipType) error\n```\nRemoveMemberFromProject removes a user or group from a project\n\n```go\nfunc (r *ProjectRepo) UpdateMemberRoleInProject(ctx context.Context, orgID uuid.UUID, projectID uuid.UUID, memberID uuid.UUID, membershipType authz.MembershipType, newRole authz.Role) (*biz.ProjectMembership, error)\n```\nUpdateMemberRoleInProject updates the role of a member in a project\n\n```go\ntype ProjectVersionRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *ProjectVersionRepo) Create(ctx context.Context, projectID uuid.UUID, version string, prerelease bool) (*biz.ProjectVersion, error)\n```\n\n```go\nfunc (r *ProjectVersionRepo) FindByProjectAndVersion(ctx context.Context, projectID uuid.UUID, version string) (*biz.ProjectVersion, error)\n```\n\n```go\nfunc (r *ProjectVersionRepo) MarkAsLatest(ctx context.Context, projectID, versionID uuid.UUID) (*biz.ProjectVersionPromotion, error)\n```\n\n```go\nfunc (r *ProjectVersionRepo) Update(ctx context.Context, id uuid.UUID, updates *biz.ProjectVersionUpdateOpts) (*biz.ProjectVersion, error)\n```\n\n```go\ntype ReferrerRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *ReferrerRepo) Exist(ctx context.Context, digest string, filters ...biz.GetFromRootFilter) (bool, error)\n```\nCheck if a given referrer by digest exist. The query can be scoped further down if needed by providing the kind or visibility status\n\n```go\nfunc (r *ReferrerRepo) GetFromRoot(ctx context.Context, digest string, orgIDs []uuid.UUID, p *pagination.CursorOptions, filters ...biz.GetFromRootFilter) (*biz.StoredReferrer, string, error)\n```\n\n```go\nfunc (r *ReferrerRepo) Save(ctx context.Context, referrers []*biz.Referrer, workflowID uuid.UUID) (err error)\n```\n\n```go\ntype RobotAccountRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *RobotAccountRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.RobotAccount, error)\n```\n\n```go\ntype WorkflowContractRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *WorkflowContractRepo) Create(ctx context.Context, opts *biz.ContractCreateOpts) (*biz.WorkflowContract, error)\n```\n\n```go\nfunc (r *WorkflowContractRepo) Describe(ctx context.Context, orgID, contractID uuid.UUID, revision int, opts ...biz.ContractQueryOpt) (*biz.WorkflowContractWithVersion, error)\n```\n\n```go\nfunc (r *WorkflowContractRepo) FindByIDInOrg(ctx context.Context, orgID, contractID uuid.UUID) (*biz.WorkflowContract, error)\n```\n\n```go\nfunc (r *WorkflowContractRepo) FindByNameInOrg(ctx context.Context, orgID uuid.UUID, name string, opts ...biz.ContractQueryOpt) (*biz.WorkflowContract, error)\n```\n\n```go\nfunc (r *WorkflowContractRepo) FindVersionByID(ctx context.Context, versionID uuid.UUID) (*biz.WorkflowContractWithVersion, error)\n```\n\n```go\nfunc (r *WorkflowContractRepo) List(ctx context.Context, orgID uuid.UUID, filter *biz.WorkflowContractListFilters) ([]*biz.WorkflowContract, error)\n```\nList returns a list of workflow contracts for a given organization If no project filters are provided, we return all the contracts scoped to the organization otherwise we return the global contracts alongside the org scoped projects\n\n```go\nfunc (r *WorkflowContractRepo) SoftDelete(ctx context.Context, id uuid.UUID) error\n```\n\n```go\nfunc (r *WorkflowContractRepo) Update(ctx context.Context, orgID uuid.UUID, name string, opts *biz.ContractUpdateOpts, queryOpts ...biz.ContractQueryOpt) (*biz.WorkflowContractWithVersion, error)\n```\nUpdate will add a new version of the contract. NOTE: ContractVersions are immutable\n\n```go\ntype WorkflowRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *WorkflowRepo) Create(ctx context.Context, opts *biz.WorkflowCreateOpts) (wf *biz.Workflow, err error)\n```\n\n```go\nfunc (r *WorkflowRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.Workflow, error)\n```\n\n```go\nfunc (r *WorkflowRepo) GetOrgScoped(ctx context.Context, orgID, workflowID uuid.UUID) (*biz.Workflow, error)\n```\nGetOrgScoped Gets a workflow making sure it belongs to a given org\n\n```go\nfunc (r *WorkflowRepo) GetOrgScopedByProjectAndName(ctx context.Context, orgID uuid.UUID, projectName, workflowName string) (*biz.Workflow, error)\n```\nGetOrgScopedByProjectAndName Gets a workflow by name making sure it belongs to a given org\n\n```go\nfunc (r *WorkflowRepo) IncRunsCounter(ctx context.Context, workflowID uuid.UUID) error\n```\n\n```go\nfunc (r *WorkflowRepo) List(ctx context.Context, orgID uuid.UUID, filter *biz.WorkflowListOpts, pagination *pagination.OffsetPaginationOpts) ([]*biz.Workflow, int, error)\n```\n\n```go\nfunc (r *WorkflowRepo) SoftDelete(ctx context.Context, id uuid.UUID) (err error)\n```\nSoft delete workflow, attachments and related projects (if applicable)\n\n```go\nfunc (r *WorkflowRepo) Update(ctx context.Context, id uuid.UUID, opts *biz.WorkflowUpdateOpts) (*biz.Workflow, error)\n```\n\n```go\ntype WorkflowRunRepo struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *WorkflowRunRepo) Create(ctx context.Context, opts *biz.WorkflowRunRepoCreateOpts) (*biz.WorkflowRunRepoCreateResult, error)\n```\n\n```go\nfunc (r *WorkflowRunRepo) Expire(ctx context.Context, id uuid.UUID) error\n```\n\n```go\nfunc (r *WorkflowRunRepo) FindByAttestationDigest(ctx context.Context, digest string) (*biz.WorkflowRun, error)\n```\n\n```go\nfunc (r *WorkflowRunRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.WorkflowRun, error)\n```\n\n```go\nfunc (r *WorkflowRunRepo) FindByIDInOrg(ctx context.Context, orgID, id uuid.UUID) (*biz.WorkflowRun, error)\n```\n\n```go\nfunc (r *WorkflowRunRepo) GetBundle(ctx context.Context, wrID uuid.UUID) ([]byte, error)\n```\n\n```go\nfunc (r *WorkflowRunRepo) List(ctx context.Context, orgID uuid.UUID, filters *biz.RunListFilters, p *pagination.CursorOptions) (result []*biz.WorkflowRun, cursor string, err error)\n```\nList the runs in an organization, optionally filtered out by workflow\n\n```go\nfunc (r *WorkflowRunRepo) ListNotFinishedOlderThan(ctx context.Context, olderThan time.Time, limit int) ([]*biz.WorkflowRun, error)\n```\n\n```go\nfunc (r *WorkflowRunRepo) MarkAsFinished(ctx context.Context, id uuid.UUID, status biz.WorkflowRunStatus, reason string) error\n```\n\n```go\nfunc (r *WorkflowRunRepo) SaveAttestationBundle(ctx context.Context, id uuid.UUID, digest string, bundle []byte, blockReleasedVersions bool) error\n```\nSaveAttestationBundle persists the attestation digest on the workflow run and the bundle bytes in the linked attestation row within a single transaction.\n\n```go\nfunc (r *WorkflowRunRepo) SaveAttestationDigest(ctx context.Context, id uuid.UUID, digest string, blockReleasedVersions bool) error\n```\n\n```go\nfunc (r *WorkflowRunRepo) UpdatePolicyStatus(ctx context.Context, id uuid.UUID, summary *chainloop.PolicyStatusSummary) error\n```\nUpdatePolicyStatus persists the canonical policy status summary plus the legacy has\\_policy\\_violations bool (kept populated for back-compat with older clients still reading WorkflowRunItem.has\\_policy\\_violations).\n\n","path":"github.com/chainloop-dev/chainloop/app/controlplane/pkg/data","name":"data","synopsis":"","isRedistributable":true}
