Documentation ¶
Index ¶
- Constants
- Variables
- func IsErrInvalidUUID(err error) bool
- func IsErrValidation(err error) bool
- func IsNotFound(err error) bool
- type AttachOpts
- type Attestation
- type AttestationRef
- type AttestationUseCase
- type CASCredentialsUseCase
- type ContractCreateOpts
- type ContractUpdateOpts
- type CreateOpts
- type ErrInvalidUUID
- type ErrNotFound
- type Integration
- type IntegrationAndAttachment
- type IntegrationAttachment
- type IntegrationAttachmentRepo
- type IntegrationRepo
- type IntegrationUseCase
- func (uc *IntegrationUseCase) AddDependencyTrack(ctx context.Context, orgID, host, apiKey string, enableProjectCreation bool) (*Integration, error)
- func (uc *IntegrationUseCase) AttachToWorkflow(ctx context.Context, opts *AttachOpts) (*IntegrationAttachment, error)
- func (uc *IntegrationUseCase) Delete(ctx context.Context, orgID, integrationID string) error
- func (uc *IntegrationUseCase) Detach(ctx context.Context, orgID, attachmentID string) error
- func (uc *IntegrationUseCase) FindByIDInOrg(ctx context.Context, orgID, id string) (*Integration, error)
- func (uc *IntegrationUseCase) List(ctx context.Context, orgID string) ([]*Integration, error)
- func (uc *IntegrationUseCase) ListAttachments(ctx context.Context, orgID, workflowID string) ([]*IntegrationAttachment, error)
- type Membership
- type MembershipRepo
- type MembershipUseCase
- func (uc *MembershipUseCase) ByOrg(ctx context.Context, orgID string) ([]*Membership, error)
- func (uc *MembershipUseCase) ByUser(ctx context.Context, userID string) ([]*Membership, error)
- func (uc *MembershipUseCase) Create(ctx context.Context, orgID, userID string, current bool) (*Membership, error)
- func (uc *MembershipUseCase) Delete(ctx context.Context, id string) error
- func (uc *MembershipUseCase) SetCurrent(ctx context.Context, userID, membershipID string) (*Membership, error)
- type NewIntegrationUsecaseOpts
- type NewUserUseCaseParams
- type OCIRepoCreateOpts
- type OCIRepoOpts
- type OCIRepoUpdateOpts
- type OCIRepoValidationStatus
- type OCIRepository
- type OCIRepositoryReader
- type OCIRepositoryRepo
- type OCIRepositoryUseCase
- func (uc *OCIRepositoryUseCase) CreateOrUpdate(ctx context.Context, orgID, repoURL, username, password string) (*OCIRepository, error)
- func (uc *OCIRepositoryUseCase) Delete(ctx context.Context, id string) error
- func (uc *OCIRepositoryUseCase) FindByID(ctx context.Context, id string) (*OCIRepository, error)
- func (uc *OCIRepositoryUseCase) FindMainRepo(ctx context.Context, orgID string) (*OCIRepository, error)
- func (uc *OCIRepositoryUseCase) PerformValidation(ctx context.Context, id string) (err error)
- type OrgMetricsRepo
- type OrgMetricsUseCase
- func (uc *OrgMetricsUseCase) RunsTotal(ctx context.Context, orgID string, timeWindow time.Duration) (int32, error)
- func (uc *OrgMetricsUseCase) RunsTotalByRunnerType(ctx context.Context, orgID string, timeWindow time.Duration) (map[string]int32, error)
- func (uc *OrgMetricsUseCase) RunsTotalByStatus(ctx context.Context, orgID string, timeWindow time.Duration) (map[string]int32, error)
- func (uc *OrgMetricsUseCase) TopWorkflowsByRunsCount(ctx context.Context, orgID string, numWorkflows int, timeWindow time.Duration) ([]*TopWorkflowsByRunsCountItem, error)
- type Organization
- type OrganizationRepo
- type OrganizationUseCase
- type RobotAccount
- type RobotAccountRepo
- type RobotAccountUseCase
- func (uc *RobotAccountUseCase) Create(ctx context.Context, name string, orgID, workflowID string) (*RobotAccount, error)
- func (uc *RobotAccountUseCase) FindByID(ctx context.Context, id string) (*RobotAccount, error)
- func (uc *RobotAccountUseCase) List(ctx context.Context, orgID, workflowID string, includeRevoked bool) ([]*RobotAccount, error)
- func (uc *RobotAccountUseCase) Revoke(ctx context.Context, orgID, id string) error
- type TopWorkflowsByRunsCountItem
- type User
- type UserOrgFinder
- type UserRepo
- type UserUseCase
- func (uc *UserUseCase) CurrentOrg(ctx context.Context, userID string) (*Organization, error)
- func (uc *UserUseCase) DeleteUser(ctx context.Context, userID string) error
- func (uc *UserUseCase) FindByID(ctx context.Context, userID string) (*User, error)
- func (uc *UserUseCase) FindOrCreateByEmail(ctx context.Context, email string) (*User, error)
- type Workflow
- type WorkflowContract
- type WorkflowContractRepo
- type WorkflowContractUseCase
- func (uc *WorkflowContractUseCase) Create(ctx context.Context, orgID, name string, schema *schemav1.CraftingSchema) (*WorkflowContract, error)
- func (uc *WorkflowContractUseCase) Delete(ctx context.Context, orgID, contractID string) error
- func (uc *WorkflowContractUseCase) Describe(ctx context.Context, orgID, contractID string, revision int) (*WorkflowContractWithVersion, error)
- func (uc *WorkflowContractUseCase) FindByIDInOrg(ctx context.Context, orgID, contractID string) (*WorkflowContract, error)
- func (uc *WorkflowContractUseCase) FindVersionByID(ctx context.Context, versionID string) (*WorkflowContractVersion, error)
- func (uc *WorkflowContractUseCase) List(ctx context.Context, orgID string) ([]*WorkflowContract, error)
- func (uc *WorkflowContractUseCase) Update(ctx context.Context, orgID, contractID, name string, ...) (*WorkflowContractWithVersion, error)
- type WorkflowContractVersion
- type WorkflowContractWithVersion
- type WorkflowRepo
- type WorkflowRun
- type WorkflowRunCreateOpts
- type WorkflowRunExpirerOpts
- type WorkflowRunExpirerUseCase
- type WorkflowRunRepo
- type WorkflowRunStatus
- type WorkflowRunUseCase
- func (uc *WorkflowRunUseCase) AssociateAttestation(ctx context.Context, id string, ref *AttestationRef) error
- func (uc *WorkflowRunUseCase) Create(ctx context.Context, opts *WorkflowRunCreateOpts) (*WorkflowRun, error)
- func (uc *WorkflowRunUseCase) ExistsInWorkflow(ctx context.Context, workflowID, id string) (bool, error)
- func (uc *WorkflowRunUseCase) List(ctx context.Context, orgID, workflowID string, p *pagination.Options) ([]*WorkflowRun, string, error)
- func (uc *WorkflowRunUseCase) MarkAsFinished(ctx context.Context, id string, status WorkflowRunStatus, reason string) error
- func (uc *WorkflowRunUseCase) View(ctx context.Context, orgID, runID string) (*WorkflowRun, error)
- type WorkflowRunWithContract
- type WorkflowUseCase
- func (uc *WorkflowUseCase) Create(ctx context.Context, opts *CreateOpts) (*Workflow, error)
- func (uc *WorkflowUseCase) Delete(ctx context.Context, orgID, workflowID string) error
- func (uc *WorkflowUseCase) FindByID(ctx context.Context, workflowID string) (*Workflow, error)
- func (uc *WorkflowUseCase) FindByIDInOrg(ctx context.Context, orgID, workflowID string) (*Workflow, error)
- func (uc *WorkflowUseCase) IncRunsCounter(ctx context.Context, workflowID string) error
- func (uc *WorkflowUseCase) List(ctx context.Context, orgID string) ([]*Workflow, error)
Constants ¶
const DependencyTrackKind = "Dependency-Track"
Variables ¶
var ErrAlreadyRepoInOrg = errors.New("there is already an OCI repository associated with this organization")
var ProviderSet = wire.NewSet( NewWorkflowUsecase, NewUserUseCase, NewRootAccountUseCase, NewWorkflowRunUsecase, NewOrganizationUsecase, NewAttestationUseCase, NewWorkflowContractUsecase, NewCASCredentialsUseCase, NewOCIRepositoryUsecase, NewOrgMetricsUseCase, NewIntegrationUsecase, NewMembershipUsecase, NewWorkflowRunExpirerUseCase, wire.Struct(new(NewIntegrationUsecaseOpts), "*"), wire.Struct(new(NewUserUseCaseParams), "*"), )
ProviderSet is biz providers.
Functions ¶
func IsErrInvalidUUID ¶
func IsErrValidation ¶
func IsNotFound ¶
Types ¶
type AttachOpts ¶
type AttachOpts struct {
IntegrationID, WorkflowID, OrgID string
Config *v1.IntegrationAttachmentConfig
}
type Attestation ¶
type AttestationRef ¶
type AttestationUseCase ¶
type AttestationUseCase struct {
// contains filtered or unexported fields
}
func NewAttestationUseCase ¶
func NewAttestationUseCase(logger log.Logger) *AttestationUseCase
func (*AttestationUseCase) FetchFromStore ¶
func (uc *AttestationUseCase) FetchFromStore(ctx context.Context, downloader backend.Downloader, digest string) (*Attestation, error)
func (*AttestationUseCase) UploadAttestationToOCI ¶
func (uc *AttestationUseCase) UploadAttestationToOCI(ctx context.Context, envelope *dsse.Envelope, uploader backend.Uploader, workflowRunID string) (string, error)
UploadAttestationToOCI uploads the attestation to the OCI CAS returning the reference to the attestation
type CASCredentialsUseCase ¶
type CASCredentialsUseCase struct {
// contains filtered or unexported fields
}
func (*CASCredentialsUseCase) GenerateTemporaryCredentials ¶
func (uc *CASCredentialsUseCase) GenerateTemporaryCredentials(ctx context.Context, orgID, secretID string, role robotaccount.Role) (string, error)
type ContractCreateOpts ¶
type ContractUpdateOpts ¶
type CreateOpts ¶
type CreateOpts struct {
Name, OrgID, Project, Team, ContractID string
}
type ErrInvalidUUID ¶
type ErrInvalidUUID struct {
// contains filtered or unexported fields
}
func NewErrInvalidUUID ¶
func NewErrInvalidUUID(err error) ErrInvalidUUID
func (ErrInvalidUUID) Error ¶
func (e ErrInvalidUUID) Error() string
type ErrNotFound ¶
type ErrNotFound struct {
// contains filtered or unexported fields
}
func NewErrNotFound ¶
func NewErrNotFound(entity string) ErrNotFound
func (ErrNotFound) Error ¶
func (e ErrNotFound) Error() string
type Integration ¶
type IntegrationAndAttachment ¶
type IntegrationAndAttachment struct { *Integration *IntegrationAttachment }
type IntegrationAttachment ¶
type IntegrationAttachmentRepo ¶
type IntegrationAttachmentRepo interface { Create(ctx context.Context, integrationID, workflowID uuid.UUID, config *v1.IntegrationAttachmentConfig) (*IntegrationAttachment, error) List(ctx context.Context, orgID, workflowID uuid.UUID) ([]*IntegrationAttachment, error) FindByIDInOrg(ctx context.Context, orgID, ID uuid.UUID) (*IntegrationAttachment, error) SoftDelete(ctx context.Context, ID uuid.UUID) error }
type IntegrationRepo ¶
type IntegrationRepo interface { Create(ctx context.Context, orgID uuid.UUID, kind string, secretID string, config *v1.IntegrationConfig) (*Integration, error) List(ctx context.Context, orgID uuid.UUID) ([]*Integration, error) FindByIDInOrg(ctx context.Context, orgID, ID uuid.UUID) (*Integration, error) SoftDelete(ctx context.Context, ID uuid.UUID) error }
type IntegrationUseCase ¶
type IntegrationUseCase struct {
// contains filtered or unexported fields
}
func NewIntegrationUsecase ¶
func NewIntegrationUsecase(opts *NewIntegrationUsecaseOpts) *IntegrationUseCase
func (*IntegrationUseCase) AddDependencyTrack ¶
func (uc *IntegrationUseCase) AddDependencyTrack(ctx context.Context, orgID, host, apiKey string, enableProjectCreation bool) (*Integration, error)
func (*IntegrationUseCase) AttachToWorkflow ¶
func (uc *IntegrationUseCase) AttachToWorkflow(ctx context.Context, opts *AttachOpts) (*IntegrationAttachment, error)
- Integration and workflows exists in current organization - Integration is compatible with the provided installation config, i.e can autocreate
func (*IntegrationUseCase) Delete ¶
func (uc *IntegrationUseCase) Delete(ctx context.Context, orgID, integrationID string) error
func (*IntegrationUseCase) Detach ¶
func (uc *IntegrationUseCase) Detach(ctx context.Context, orgID, attachmentID string) error
Detach integration from workflow
func (*IntegrationUseCase) FindByIDInOrg ¶
func (uc *IntegrationUseCase) FindByIDInOrg(ctx context.Context, orgID, id string) (*Integration, error)
func (*IntegrationUseCase) List ¶
func (uc *IntegrationUseCase) List(ctx context.Context, orgID string) ([]*Integration, error)
func (*IntegrationUseCase) ListAttachments ¶
func (uc *IntegrationUseCase) ListAttachments(ctx context.Context, orgID, workflowID string) ([]*IntegrationAttachment, error)
type Membership ¶
type MembershipRepo ¶
type MembershipRepo interface { FindByUser(ctx context.Context, userID uuid.UUID) ([]*Membership, error) FindByOrg(ctx context.Context, orgID uuid.UUID) ([]*Membership, error) FindByIDInUser(ctx context.Context, userID, ID uuid.UUID) (*Membership, error) SetCurrent(ctx context.Context, ID uuid.UUID) (*Membership, error) Create(ctx context.Context, orgID, userID uuid.UUID, current bool) (*Membership, error) Delete(ctx context.Context, ID uuid.UUID) error }
type MembershipUseCase ¶
type MembershipUseCase struct {
// contains filtered or unexported fields
}
func NewMembershipUsecase ¶
func NewMembershipUsecase(repo MembershipRepo, logger log.Logger) *MembershipUseCase
func (*MembershipUseCase) ByOrg ¶
func (uc *MembershipUseCase) ByOrg(ctx context.Context, orgID string) ([]*Membership, error)
func (*MembershipUseCase) ByUser ¶
func (uc *MembershipUseCase) ByUser(ctx context.Context, userID string) ([]*Membership, error)
func (*MembershipUseCase) Create ¶
func (uc *MembershipUseCase) Create(ctx context.Context, orgID, userID string, current bool) (*Membership, error)
func (*MembershipUseCase) Delete ¶
func (uc *MembershipUseCase) Delete(ctx context.Context, id string) error
func (*MembershipUseCase) SetCurrent ¶
func (uc *MembershipUseCase) SetCurrent(ctx context.Context, userID, membershipID string) (*Membership, error)
type NewIntegrationUsecaseOpts ¶
type NewIntegrationUsecaseOpts struct { IRepo IntegrationRepo IaRepo IntegrationAttachmentRepo WfRepo WorkflowRepo CredsRW credentials.ReaderWriter Logger log.Logger }
type NewUserUseCaseParams ¶
type NewUserUseCaseParams struct { UserRepo UserRepo MembershipUseCase *MembershipUseCase OrganizationUseCase *OrganizationUseCase Logger log.Logger }
type OCIRepoCreateOpts ¶
type OCIRepoCreateOpts struct { *OCIRepoOpts OrgID uuid.UUID }
type OCIRepoOpts ¶
type OCIRepoOpts struct {
Repository, Username, Password, SecretName string
}
type OCIRepoUpdateOpts ¶
type OCIRepoUpdateOpts struct { *OCIRepoOpts ID uuid.UUID }
type OCIRepoValidationStatus ¶
type OCIRepoValidationStatus string
var OCIRepoValidationFailed OCIRepoValidationStatus = "Invalid"
var OCIRepoValidationOK OCIRepoValidationStatus = "OK"
func (OCIRepoValidationStatus) Values ¶
func (OCIRepoValidationStatus) Values() (kinds []string)
Implements https://pkg.go.dev/entgo.io/ent/schema/field#EnumValues
type OCIRepository ¶
type OCIRepository struct {
ID, Repo, SecretName string
CreatedAt, ValidatedAt *time.Time
OrganizationID string
ValidationStatus OCIRepoValidationStatus
}
type OCIRepositoryReader ¶
type OCIRepositoryRepo ¶
type OCIRepositoryRepo interface { FindMainRepo(ctx context.Context, orgID uuid.UUID) (*OCIRepository, error) FindByID(ctx context.Context, ID uuid.UUID) (*OCIRepository, error) UpdateValidationStatus(ctx context.Context, ID uuid.UUID, status OCIRepoValidationStatus) error Create(context.Context, *OCIRepoCreateOpts) (*OCIRepository, error) Update(context.Context, *OCIRepoUpdateOpts) (*OCIRepository, error) Delete(ctx context.Context, ID uuid.UUID) error }
type OCIRepositoryUseCase ¶
type OCIRepositoryUseCase struct {
// contains filtered or unexported fields
}
func NewOCIRepositoryUsecase ¶
func NewOCIRepositoryUsecase(repo OCIRepositoryRepo, credsRW credentials.ReaderWriter, p backend.Provider, l log.Logger) *OCIRepositoryUseCase
func (*OCIRepositoryUseCase) CreateOrUpdate ¶
func (uc *OCIRepositoryUseCase) CreateOrUpdate(ctx context.Context, orgID, repoURL, username, password string) (*OCIRepository, error)
func (*OCIRepositoryUseCase) Delete ¶
func (uc *OCIRepositoryUseCase) Delete(ctx context.Context, id string) error
Delete will delete the secret in the external secrets manager and the repository in the database
func (*OCIRepositoryUseCase) FindByID ¶
func (uc *OCIRepositoryUseCase) FindByID(ctx context.Context, id string) (*OCIRepository, error)
func (*OCIRepositoryUseCase) FindMainRepo ¶
func (uc *OCIRepositoryUseCase) FindMainRepo(ctx context.Context, orgID string) (*OCIRepository, error)
func (*OCIRepositoryUseCase) PerformValidation ¶
func (uc *OCIRepositoryUseCase) PerformValidation(ctx context.Context, id string) (err error)
Validate that the repository is valid and reachable TODO: run this process periodically in the background
type OrgMetricsRepo ¶
type OrgMetricsRepo interface { // Total number of runs within the provided time window (from now) RunsTotal(ctx context.Context, orgID uuid.UUID, timeWindow time.Duration) (int32, error) // Total number by run status RunsByStatusTotal(ctx context.Context, orgID uuid.UUID, timeWindow time.Duration) (map[string]int32, error) RunsByRunnerTypeTotal(ctx context.Context, orgID uuid.UUID, timeWindow time.Duration) (map[string]int32, error) TopWorkflowsByRunsCount(ctx context.Context, orgID uuid.UUID, numWorkflows int, timeWindow time.Duration) ([]*TopWorkflowsByRunsCountItem, error) }
type OrgMetricsUseCase ¶
type OrgMetricsUseCase struct {
// contains filtered or unexported fields
}
func NewOrgMetricsUseCase ¶
func NewOrgMetricsUseCase(r OrgMetricsRepo, l log.Logger) (*OrgMetricsUseCase, error)
func (*OrgMetricsUseCase) RunsTotalByRunnerType ¶
func (*OrgMetricsUseCase) RunsTotalByStatus ¶
func (*OrgMetricsUseCase) TopWorkflowsByRunsCount ¶
func (uc *OrgMetricsUseCase) TopWorkflowsByRunsCount(ctx context.Context, orgID string, numWorkflows int, timeWindow time.Duration) ([]*TopWorkflowsByRunsCountItem, error)
type Organization ¶
type OrganizationRepo ¶
type OrganizationUseCase ¶
type OrganizationUseCase struct {
// contains filtered or unexported fields
}
func NewOrganizationUsecase ¶
func NewOrganizationUsecase(repo OrganizationRepo, repoUC *OCIRepositoryUseCase, iUC *IntegrationUseCase, logger log.Logger) *OrganizationUseCase
func (*OrganizationUseCase) Create ¶
func (uc *OrganizationUseCase) Create(ctx context.Context, name string) (*Organization, error)
func (*OrganizationUseCase) Delete ¶
func (uc *OrganizationUseCase) Delete(ctx context.Context, id string) error
Delete deletes an organization and all relevant data This includes: - The organization - The associated repositories - The associated integrations The reason for just deleting these two associated components only is because they have external secrets that need to be deleted as well, and for that we leverage their own delete methods The rest of the data gets removed by the database cascade delete
func (*OrganizationUseCase) FindByID ¶
func (uc *OrganizationUseCase) FindByID(ctx context.Context, id string) (*Organization, error)
type RobotAccount ¶
type RobotAccountRepo ¶
type RobotAccountRepo interface { Create(ctx context.Context, name string, workflowID uuid.UUID) (*RobotAccount, error) List(ctx context.Context, workflowID uuid.UUID, includeRevoked bool) ([]*RobotAccount, error) FindByID(ctx context.Context, ID uuid.UUID) (*RobotAccount, error) Revoke(ctx context.Context, orgID, ID uuid.UUID) error }
type RobotAccountUseCase ¶
type RobotAccountUseCase struct {
// contains filtered or unexported fields
}
func NewRootAccountUseCase ¶
func NewRootAccountUseCase(robotAccountRepo RobotAccountRepo, workflowRepo WorkflowRepo, conf *conf.Auth, logger log.Logger) *RobotAccountUseCase
func (*RobotAccountUseCase) Create ¶
func (uc *RobotAccountUseCase) Create(ctx context.Context, name string, orgID, workflowID string) (*RobotAccount, error)
func (*RobotAccountUseCase) FindByID ¶
func (uc *RobotAccountUseCase) FindByID(ctx context.Context, id string) (*RobotAccount, error)
func (*RobotAccountUseCase) List ¶
func (uc *RobotAccountUseCase) List(ctx context.Context, orgID, workflowID string, includeRevoked bool) ([]*RobotAccount, error)
type UserOrgFinder ¶
type UserUseCase ¶
type UserUseCase struct {
// contains filtered or unexported fields
}
func NewUserUseCase ¶
func NewUserUseCase(opts *NewUserUseCaseParams) *UserUseCase
func (*UserUseCase) CurrentOrg ¶
func (uc *UserUseCase) CurrentOrg(ctx context.Context, userID string) (*Organization, error)
Find the organization associated with the user that's marked as current
func (*UserUseCase) DeleteUser ¶
func (uc *UserUseCase) DeleteUser(ctx context.Context, userID string) error
DeleteUser deletes the user, related memberships and organization if needed
func (*UserUseCase) FindOrCreateByEmail ¶
type WorkflowContract ¶
type WorkflowContractRepo ¶
type WorkflowContractRepo interface { Create(ctx context.Context, opts *ContractCreateOpts) (*WorkflowContract, error) List(ctx context.Context, orgID uuid.UUID) ([]*WorkflowContract, error) FindByIDInOrg(ctx context.Context, orgID, ID uuid.UUID) (*WorkflowContract, error) Describe(ctx context.Context, orgID, contractID uuid.UUID, revision int) (*WorkflowContractWithVersion, error) FindVersionByID(ctx context.Context, versionID uuid.UUID) (*WorkflowContractVersion, error) Update(ctx context.Context, opts *ContractUpdateOpts) (*WorkflowContractWithVersion, error) SoftDelete(ctx context.Context, contractID uuid.UUID) error }
type WorkflowContractUseCase ¶
type WorkflowContractUseCase struct {
// contains filtered or unexported fields
}
func NewWorkflowContractUsecase ¶
func NewWorkflowContractUsecase(repo WorkflowContractRepo, logger log.Logger) *WorkflowContractUseCase
func (*WorkflowContractUseCase) Create ¶
func (uc *WorkflowContractUseCase) Create(ctx context.Context, orgID, name string, schema *schemav1.CraftingSchema) (*WorkflowContract, error)
we currently only support schema v1
func (*WorkflowContractUseCase) Delete ¶
func (uc *WorkflowContractUseCase) Delete(ctx context.Context, orgID, contractID string) error
Delete soft-deletes the entry
func (*WorkflowContractUseCase) Describe ¶
func (uc *WorkflowContractUseCase) Describe(ctx context.Context, orgID, contractID string, revision int) (*WorkflowContractWithVersion, error)
func (*WorkflowContractUseCase) FindByIDInOrg ¶
func (uc *WorkflowContractUseCase) FindByIDInOrg(ctx context.Context, orgID, contractID string) (*WorkflowContract, error)
func (*WorkflowContractUseCase) FindVersionByID ¶
func (uc *WorkflowContractUseCase) FindVersionByID(ctx context.Context, versionID string) (*WorkflowContractVersion, error)
func (*WorkflowContractUseCase) List ¶
func (uc *WorkflowContractUseCase) List(ctx context.Context, orgID string) ([]*WorkflowContract, error)
func (*WorkflowContractUseCase) Update ¶
func (uc *WorkflowContractUseCase) Update(ctx context.Context, orgID, contractID, name string, schema *schemav1.CraftingSchema) (*WorkflowContractWithVersion, error)
type WorkflowContractVersion ¶
type WorkflowContractWithVersion ¶
type WorkflowContractWithVersion struct { Contract *WorkflowContract Version *WorkflowContractVersion }
type WorkflowRepo ¶
type WorkflowRepo interface { Create(context.Context, *CreateOpts) (*Workflow, error) List(ctx context.Context, orgID uuid.UUID) ([]*Workflow, error) GetOrgScoped(ctx context.Context, orgID, workflowID uuid.UUID) (*Workflow, error) IncRunsCounter(ctx context.Context, workflowID uuid.UUID) error FindByID(ctx context.Context, workflowID uuid.UUID) (*Workflow, error) SoftDelete(ctx context.Context, workflowID uuid.UUID) error }
type WorkflowRun ¶
type WorkflowRunCreateOpts ¶
type WorkflowRunExpirerOpts ¶
type WorkflowRunExpirerUseCase ¶
type WorkflowRunExpirerUseCase struct {
// contains filtered or unexported fields
}
func NewWorkflowRunExpirerUseCase ¶
func NewWorkflowRunExpirerUseCase(wfrRepo WorkflowRunRepo, logger log.Logger) *WorkflowRunExpirerUseCase
func (*WorkflowRunExpirerUseCase) ExpirationSweep ¶
func (uc *WorkflowRunExpirerUseCase) ExpirationSweep(ctx context.Context, olderThan time.Time) error
ExpirationSweep looks for runs older than the provider time and marks them as expired
func (*WorkflowRunExpirerUseCase) Run ¶
func (uc *WorkflowRunExpirerUseCase) Run(ctx context.Context, opts *WorkflowRunExpirerOpts)
type WorkflowRunRepo ¶
type WorkflowRunRepo interface { Create(ctx context.Context, workflowID, robotaccountID, contractVersion uuid.UUID, runURL, runnerType string) (*WorkflowRun, error) FindByID(ctx context.Context, ID uuid.UUID) (*WorkflowRun, error) FindByIDInOrg(ctx context.Context, orgID, ID uuid.UUID) (*WorkflowRun, error) MarkAsFinished(ctx context.Context, ID uuid.UUID, status WorkflowRunStatus, reason string) error SaveAttestationRef(ctx context.Context, ID uuid.UUID, ref *AttestationRef) error List(ctx context.Context, orgID, workflowID uuid.UUID, p *pagination.Options) ([]*WorkflowRun, string, error) // List the runs that have not finished and are older than a given time ListNotFinishedOlderThan(ctx context.Context, olderThan time.Time) ([]*WorkflowRun, error) // Set run as expired Expire(ctx context.Context, id uuid.UUID) error }
type WorkflowRunStatus ¶
type WorkflowRunStatus string
const ( WorkflowRunInitialized WorkflowRunStatus = "initialized" WorkflowRunSuccess WorkflowRunStatus = "success" WorkflowRunError WorkflowRunStatus = "error" WorkflowRunExpired WorkflowRunStatus = "expired" WorkflowRunCancelled WorkflowRunStatus = "canceled" )
func (WorkflowRunStatus) Values ¶
func (WorkflowRunStatus) Values() (kinds []string)
Implements https://pkg.go.dev/entgo.io/ent/schema/field#EnumValues
type WorkflowRunUseCase ¶
type WorkflowRunUseCase struct {
// contains filtered or unexported fields
}
func NewWorkflowRunUsecase ¶
func NewWorkflowRunUsecase(wfrRepo WorkflowRunRepo, wfRepo WorkflowRepo, logger log.Logger) (*WorkflowRunUseCase, error)
func (*WorkflowRunUseCase) AssociateAttestation ¶
func (uc *WorkflowRunUseCase) AssociateAttestation(ctx context.Context, id string, ref *AttestationRef) error
Store the attestation digest for the workflowrun
func (*WorkflowRunUseCase) Create ¶
func (uc *WorkflowRunUseCase) Create(ctx context.Context, opts *WorkflowRunCreateOpts) (*WorkflowRun, error)
Create will add a new WorkflowRun, associate it to a schemaVersion and increment the counter in the associated workflow
func (*WorkflowRunUseCase) ExistsInWorkflow ¶
func (uc *WorkflowRunUseCase) ExistsInWorkflow(ctx context.Context, workflowID, id string) (bool, error)
The workflowRun belongs to the provided workflowRun
func (*WorkflowRunUseCase) List ¶
func (uc *WorkflowRunUseCase) List(ctx context.Context, orgID, workflowID string, p *pagination.Options) ([]*WorkflowRun, string, error)
List the workflowruns associated with an org and optionally filtered by a workflow
func (*WorkflowRunUseCase) MarkAsFinished ¶
func (uc *WorkflowRunUseCase) MarkAsFinished(ctx context.Context, id string, status WorkflowRunStatus, reason string) error
func (*WorkflowRunUseCase) View ¶
func (uc *WorkflowRunUseCase) View(ctx context.Context, orgID, runID string) (*WorkflowRun, error)
type WorkflowRunWithContract ¶
type WorkflowRunWithContract struct { *WorkflowRun *WorkflowContractVersion }
type WorkflowUseCase ¶
type WorkflowUseCase struct {
// contains filtered or unexported fields
}
func NewWorkflowUsecase ¶
func NewWorkflowUsecase(wfr WorkflowRepo, schemaUC *WorkflowContractUseCase, logger log.Logger) *WorkflowUseCase
func (*WorkflowUseCase) Create ¶
func (uc *WorkflowUseCase) Create(ctx context.Context, opts *CreateOpts) (*Workflow, error)
func (*WorkflowUseCase) Delete ¶
func (uc *WorkflowUseCase) Delete(ctx context.Context, orgID, workflowID string) error
Delete soft-deletes the entry
func (*WorkflowUseCase) FindByIDInOrg ¶
func (*WorkflowUseCase) IncRunsCounter ¶
func (uc *WorkflowUseCase) IncRunsCounter(ctx context.Context, workflowID string) error