Documentation ¶
Index ¶
- type BranchSCM
- type ChatUserStore
- type CommitSCM
- type ConfigInteractor
- type ConfigSCM
- type DeploymentInteractor
- func (i *DeploymentInteractor) CreateDeploymentStatus(ctx context.Context, ds *ent.DeploymentStatus) (*ent.DeploymentStatus, error)
- func (i *DeploymentInteractor) Deploy(ctx context.Context, u *ent.User, r *ent.Repo, t *ent.Deployment, ...) (*ent.Deployment, error)
- func (i *DeploymentInteractor) DeployToRemote(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, ...) (*ent.Deployment, error)
- type DeploymentSCM
- type DeploymentStatisticsInteractor
- type DeploymentStatisticsStore
- type DeploymentStatusSCM
- type DeploymentStatusStore
- type DeploymentStore
- type DeploymentValidator
- type DynamicPayloadValidator
- type EventInteractor
- type EventStore
- type FindRepoOfUserByNamespaceNameOptions
- type FrozenWindowValidator
- type Interactor
- type InteractorConfig
- type LicenseInteractor
- type ListDeploymentsOfRepoOptions
- type ListInactiveDeploymentsLessThanTimeOptions
- type ListOptions
- type ListPermsOfRepoOptions
- type ListReposOfUserOptions
- type LockInteractor
- type LockStore
- type LockValidator
- type PermInteractor
- type PermStore
- type RefValidator
- type RepoInteractor
- type RepoSCM
- type RepoStore
- type ReviewInteractor
- type ReviewStore
- type ReviewValidator
- type SCM
- type SearchDeploymentsOfUserOptions
- type SearchUsersOptions
- type SerializationValidator
- type StatusValidator
- type Store
- type TagSCM
- type UserInteractor
- func (i *UserInteractor) IsAdminUser(ctx context.Context, login string) bool
- func (i *UserInteractor) IsEntryMember(ctx context.Context, login string) bool
- func (i *UserInteractor) IsEntryOrg(ctx context.Context, namespace string) bool
- func (i *UserInteractor) IsOrgMember(ctx context.Context, orgs []string) bool
- func (i *UserInteractor) SyncRemoteRepo(ctx context.Context, u *ent.User, re *extent.RemoteRepo, t time.Time) error
- type UserSCM
- type UserStore
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BranchSCM ¶
type BranchSCM interface { ListBranches(ctx context.Context, u *ent.User, r *ent.Repo, opt *ListOptions) ([]*extent.Branch, error) GetBranch(ctx context.Context, u *ent.User, r *ent.Repo, branch string) (*extent.Branch, error) GetDefaultBranch(ctx context.Context, u *ent.User, r *ent.Repo) (*extent.Branch, error) }
type ChatUserStore ¶
type ChatUserStore interface { FindChatUserByID(ctx context.Context, id string) (*ent.ChatUser, error) CreateChatUser(ctx context.Context, cu *ent.ChatUser) (*ent.ChatUser, error) UpdateChatUser(ctx context.Context, cu *ent.ChatUser) (*ent.ChatUser, error) DeleteChatUser(ctx context.Context, cu *ent.ChatUser) error }
ChatUserStore defines operations for working with chat_users.
type CommitSCM ¶
type CommitSCM interface { ListCommits(ctx context.Context, u *ent.User, r *ent.Repo, branch string, opt *ListOptions) ([]*extent.Commit, error) CompareCommits(ctx context.Context, u *ent.User, r *ent.Repo, base, head string, opt *ListOptions) ([]*extent.Commit, []*extent.CommitFile, error) GetCommit(ctx context.Context, u *ent.User, r *ent.Repo, sha string) (*extent.Commit, error) ListCommitStatuses(ctx context.Context, u *ent.User, r *ent.Repo, sha string) ([]*extent.Status, error) }
CommitSCM defines operations for working with commit.
type ConfigInteractor ¶
type ConfigInteractor service
func (*ConfigInteractor) GetEvaluatedConfig ¶
func (i *ConfigInteractor) GetEvaluatedConfig(ctx context.Context, u *ent.User, r *ent.Repo, v *extent.EvalValues) (*extent.Config, error)
GetEvaluatedConfig returns the config after evaluating the variables.
type DeploymentInteractor ¶
type DeploymentInteractor service
DeploymentInteractor provides application logic for interacting with deployments.
func (*DeploymentInteractor) CreateDeploymentStatus ¶
func (i *DeploymentInteractor) CreateDeploymentStatus(ctx context.Context, ds *ent.DeploymentStatus) (*ent.DeploymentStatus, error)
CreateDeploymentStatus create a DeploymentStatus and dispatch the event.
func (*DeploymentInteractor) Deploy ¶
func (i *DeploymentInteractor) Deploy(ctx context.Context, u *ent.User, r *ent.Repo, t *ent.Deployment, env *extent.Env) (*ent.Deployment, error)
Deploy posts a new deployment to SCM with the payload. But if it requires a review, it saves the payload on the store and waits until reviewed. It returns an error for a undeployable payload.
func (*DeploymentInteractor) DeployToRemote ¶
func (i *DeploymentInteractor) DeployToRemote(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, env *extent.Env) (*ent.Deployment, error)
DeployToRemote posts a new deployment to SCM with the saved payload after review has finished. It returns an error for a undeployable payload.
type DeploymentSCM ¶
type DeploymentSCM interface { // SCM returns the deployment with UID and SHA. CreateRemoteDeployment(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, e *extent.Env) (*extent.RemoteDeployment, error) CancelDeployment(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, s *ent.DeploymentStatus) error }
DeploymentSCM defines operations for working with remote users.
type DeploymentStatisticsInteractor ¶
type DeploymentStatisticsInteractor service
DeploymentStatisticsInteractor provides application logic for interacting with deployment_statistics.
func (*DeploymentStatisticsInteractor) ProduceDeploymentStatisticsOfRepo ¶
func (i *DeploymentStatisticsInteractor) ProduceDeploymentStatisticsOfRepo(ctx context.Context, r *ent.Repo, d *ent.Deployment) (*ent.DeploymentStatistics, error)
type DeploymentStatisticsStore ¶
type DeploymentStatisticsStore interface { ListAllDeploymentStatistics(ctx context.Context) ([]*ent.DeploymentStatistics, error) ListDeploymentStatisticsGreaterThanTime(ctx context.Context, updated time.Time) ([]*ent.DeploymentStatistics, error) FindDeploymentStatisticsOfRepoByEnv(ctx context.Context, r *ent.Repo, env string) (*ent.DeploymentStatistics, error) CreateDeploymentStatistics(ctx context.Context, s *ent.DeploymentStatistics) (*ent.DeploymentStatistics, error) UpdateDeploymentStatistics(ctx context.Context, s *ent.DeploymentStatistics) (*ent.DeploymentStatistics, error) }
DeploymentStatisticsStore defines operations for working with deployment_statistics.
type DeploymentStatusSCM ¶
type DeploymentStatusSCM interface {
CreateRemoteDeploymentStatus(ctx context.Context, u *ent.User, r *ent.Repo, d *ent.Deployment, ds *extent.RemoteDeploymentStatus) (*extent.RemoteDeploymentStatus, error)
}
DeploymentStatusSCM defines operations for working with remote deployment status.
type DeploymentStatusStore ¶
type DeploymentStatusStore interface { ListDeploymentStatuses(ctx context.Context, d *ent.Deployment) ([]*ent.DeploymentStatus, error) FindDeploymentStatusByID(ctx context.Context, id int) (*ent.DeploymentStatus, error) // CreateEntDeploymentStatus create a DeploymentStatus entity to the store. // Ent is appended to distinguish it from the interactor. CreateEntDeploymentStatus(ctx context.Context, s *ent.DeploymentStatus) (*ent.DeploymentStatus, error) }
PermStore defines operations for working with deployment_statuses.
type DeploymentStore ¶
type DeploymentStore interface { CountDeployments(ctx context.Context) (int, error) SearchDeploymentsOfUser(ctx context.Context, u *ent.User, opt *SearchDeploymentsOfUserOptions) ([]*ent.Deployment, error) ListInactiveDeploymentsLessThanTime(ctx context.Context, opt *ListInactiveDeploymentsLessThanTimeOptions) ([]*ent.Deployment, error) ListDeploymentsOfRepo(ctx context.Context, r *ent.Repo, opt *ListDeploymentsOfRepoOptions) ([]*ent.Deployment, error) FindDeploymentByID(ctx context.Context, id int) (*ent.Deployment, error) FindDeploymentByUID(ctx context.Context, uid int64) (*ent.Deployment, error) FindDeploymentOfRepoByNumber(ctx context.Context, r *ent.Repo, number int) (*ent.Deployment, error) FindPrevRunningDeployment(ctx context.Context, d *ent.Deployment) (*ent.Deployment, error) FindPrevSuccessDeployment(ctx context.Context, d *ent.Deployment) (*ent.Deployment, error) GetNextDeploymentNumberOfRepo(ctx context.Context, r *ent.Repo) (int, error) CreateDeployment(ctx context.Context, d *ent.Deployment) (*ent.Deployment, error) UpdateDeployment(ctx context.Context, d *ent.Deployment) (*ent.Deployment, error) }
DeploymentStore defines operations for working with deployments.
type DeploymentValidator ¶
type DeploymentValidator struct {
// contains filtered or unexported fields
}
DeploymentValidator validate that it is deployable.
func NewDeploymentValidator ¶
func NewDeploymentValidator(validators []Validator) *DeploymentValidator
func (*DeploymentValidator) Validate ¶
func (v *DeploymentValidator) Validate(d *ent.Deployment) error
type DynamicPayloadValidator ¶
DynamicPayloadValidator validate the payload with the specifications defined in the configuration file.
func (*DynamicPayloadValidator) Validate ¶
func (v *DynamicPayloadValidator) Validate(d *ent.Deployment) error
type EventInteractor ¶
type EventInteractor struct {
// contains filtered or unexported fields
}
func (*EventInteractor) SubscribeEvent ¶
func (i *EventInteractor) SubscribeEvent(fn func(e *ent.Event)) error
func (*EventInteractor) UnsubscribeEvent ¶
func (i *EventInteractor) UnsubscribeEvent(fn func(e *ent.Event)) error
type EventStore ¶
type EventStore interface { ListEventsGreaterThanTime(ctx context.Context, t time.Time) ([]*ent.Event, error) CreateEvent(ctx context.Context, e *ent.Event) (*ent.Event, error) CheckNotificationRecordOfEvent(ctx context.Context, e *ent.Event) bool }
EventStore defines operations for working with events.
type FindRepoOfUserByNamespaceNameOptions ¶
type FindRepoOfUserByNamespaceNameOptions struct {
Namespace, Name string
}
FindRepoOfUserByNamespaceName specifies the parameters to get the repository.
type FrozenWindowValidator ¶
FrozenWindowValidator validate that the time is in the frozen window.
func (*FrozenWindowValidator) Validate ¶
func (v *FrozenWindowValidator) Validate(d *ent.Deployment) error
type Interactor ¶
type Interactor struct { Store SCM // services used for talking to different parts of the entities. *ConfigInteractor *DeploymentInteractor *DeploymentStatisticsInteractor *EventInteractor *LicenseInteractor *LockInteractor *RepoInteractor *ReviewInteractor *UserInteractor *PermInteractor // contains filtered or unexported fields }
func NewInteractor ¶
func NewInteractor(c *InteractorConfig) *Interactor
func (*Interactor) Init ¶
func (i *Interactor) Init()
type InteractorConfig ¶
type InteractorConfig struct { ServerHost string ServerProto string ServerProxyHost string ServerProxyProto string OrgEntries []string MemberEntries []string AdminUsers []string WebhookSecret string LicenseKey string Store SCM }
func (*InteractorConfig) BuildWebhookURL ¶
func (c *InteractorConfig) BuildWebhookURL() string
func (*InteractorConfig) CheckWebhookSSL ¶
func (c *InteractorConfig) CheckWebhookSSL() bool
type LicenseInteractor ¶
type LicenseInteractor struct { LicenseKey string // contains filtered or unexported fields }
func (*LicenseInteractor) GetLicense ¶
type ListDeploymentsOfRepoOptions ¶
type ListDeploymentsOfRepoOptions struct { ListOptions Env string Status string }
type ListInactiveDeploymentsLessThanTimeOptions ¶
type ListInactiveDeploymentsLessThanTimeOptions struct { ListOptions Less time.Time }
ListInactiveDeploymentsLessThanTimeOptions specifies the optional parameters that get inactive deployments.
type ListOptions ¶
ListOptions specifies the optional parameters that support cursor pagination.
type ListPermsOfRepoOptions ¶
type ListPermsOfRepoOptions struct { ListOptions // Query search the 'login' contains the query. Query string }
type ListReposOfUserOptions ¶
type ListReposOfUserOptions struct { ListOptions // Query search the repos contains the query in the namespace or name. Query string // Sorted instructs the system to sort by the 'deployed_at' field. Sorted bool }
ListReposOfUser specifies the optional parameters that search repos.
type LockInteractor ¶
type LockInteractor service
LockInteractor provides application logic for interacting with users.
type LockStore ¶
type LockStore interface { ListExpiredLocksLessThanTime(ctx context.Context, t time.Time) ([]*ent.Lock, error) ListLocksOfRepo(ctx context.Context, r *ent.Repo) ([]*ent.Lock, error) FindLockOfRepoByEnv(ctx context.Context, r *ent.Repo, env string) (*ent.Lock, error) HasLockOfRepoForEnv(ctx context.Context, r *ent.Repo, env string) (bool, error) FindLockByID(ctx context.Context, id int) (*ent.Lock, error) CreateLock(ctx context.Context, l *ent.Lock) (*ent.Lock, error) UpdateLock(ctx context.Context, l *ent.Lock) (*ent.Lock, error) DeleteLock(ctx context.Context, l *ent.Lock) error }
LockStore defines operations for working with locks.
type LockValidator ¶
LockValidator validate that the environment of the repository is locked.
func (*LockValidator) Validate ¶
func (v *LockValidator) Validate(d *ent.Deployment) error
type PermInteractor ¶
type PermInteractor struct {
// contains filtered or unexported fields
}
func (*PermInteractor) ResyncPerms ¶
func (i *PermInteractor) ResyncPerms(ctx context.Context) error
ResyncPerms delete all permissions not included in the organization entries.
type PermStore ¶
type PermStore interface { ListPerms(ctx context.Context, opt *ListOptions) ([]*ent.Perm, error) ListPermsOfRepo(ctx context.Context, r *ent.Repo, opt *ListPermsOfRepoOptions) ([]*ent.Perm, error) FindPermOfRepo(ctx context.Context, r *ent.Repo, u *ent.User) (*ent.Perm, error) CreatePerm(ctx context.Context, p *ent.Perm) (*ent.Perm, error) UpdatePerm(ctx context.Context, p *ent.Perm) (*ent.Perm, error) DeletePermsOfUserLessThanSyncedAt(ctx context.Context, u *ent.User, t time.Time) (int, error) DeletePerm(ctx context.Context, p *ent.Perm) error }
PermStore defines operations for working with perms.
type RefValidator ¶
RefValidator validate that the 'ref' is matched with the 'deployable_ref' pattern.
func (*RefValidator) Validate ¶
func (v *RefValidator) Validate(d *ent.Deployment) error
type RepoInteractor ¶
type RepoInteractor struct { WebhookURL string WebhookSSL bool WebhookSecret string // contains filtered or unexported fields }
RepoInteractor provides application logic for interacting with repos.
type RepoSCM ¶
type RepoSCM interface { ListRemoteRepos(ctx context.Context, u *ent.User) ([]*extent.RemoteRepo, error) CreateWebhook(ctx context.Context, u *ent.User, r *ent.Repo, c *extent.WebhookConfig) (int64, error) DeleteWebhook(ctx context.Context, u *ent.User, r *ent.Repo, id int64) error }
RepoSCM defines operations for working with remote repos.
type RepoStore ¶
type RepoStore interface { CountActiveRepos(ctx context.Context) (int, error) CountRepos(ctx context.Context) (int, error) ListReposOfUser(ctx context.Context, u *ent.User, opt *ListReposOfUserOptions) ([]*ent.Repo, error) FindRepoOfUserByID(ctx context.Context, u *ent.User, id int64) (*ent.Repo, error) FindRepoOfUserByNamespaceName(ctx context.Context, u *ent.User, opt *FindRepoOfUserByNamespaceNameOptions) (*ent.Repo, error) FindRepoByID(ctx context.Context, id int64) (*ent.Repo, error) SyncRepo(ctx context.Context, r *extent.RemoteRepo) (*ent.Repo, error) UpdateRepo(ctx context.Context, r *ent.Repo) (*ent.Repo, error) Activate(ctx context.Context, r *ent.Repo) (*ent.Repo, error) Deactivate(ctx context.Context, r *ent.Repo) (*ent.Repo, error) }
RepoStore defines operations for working with repos.
type ReviewInteractor ¶
type ReviewInteractor service
func (*ReviewInteractor) RespondReview ¶
RespondReview update the status of review.
type ReviewStore ¶
type ReviewStore interface { SearchReviews(ctx context.Context, u *ent.User) ([]*ent.Review, error) ListReviews(ctx context.Context, d *ent.Deployment) ([]*ent.Review, error) FindReviewOfUser(ctx context.Context, u *ent.User, d *ent.Deployment) (*ent.Review, error) FindReviewByID(ctx context.Context, id int) (*ent.Review, error) // CreateReview creates a review of which status is pending. CreateReview(ctx context.Context, rv *ent.Review) (*ent.Review, error) // UpdateReview update the status and comment of the review. UpdateReview(ctx context.Context, rv *ent.Review) (*ent.Review, error) }
ReviewStore defines operations for working with reviews.
type ReviewValidator ¶
type ReviewValidator struct {
Store ReviewStore
}
ReviewValidator verifies the request is approved or not. If one of the reviews has approve the status is approved.
func (*ReviewValidator) Validate ¶
func (v *ReviewValidator) Validate(d *ent.Deployment) error
type SearchDeploymentsOfUserOptions ¶
type SearchDeploymentsOfUserOptions struct { ListOptions Statuses []deployment.Status Owned bool ProductionOnly bool From time.Time To time.Time }
SearchDeploymentsOfUserOptions specifies the optional parameters that search deployments.
type SearchUsersOptions ¶
type SearchUsersOptions struct { ListOptions // Query search the 'login' contains the query. Query string }
SearchUsersOptions specifies the optional parameters that search users.
type SerializationValidator ¶
type SerializationValidator struct { Env *extent.Env Store DeploymentStore }
SerializationValidator verify if there is currently a running deployment for the environment.
func (*SerializationValidator) Validate ¶
func (v *SerializationValidator) Validate(d *ent.Deployment) error
type StatusValidator ¶
type StatusValidator struct {
Status deployment.Status
}
StatusValidator validate the deployment status is valid.
func (*StatusValidator) Validate ¶
func (v *StatusValidator) Validate(d *ent.Deployment) error
type Store ¶
type Store interface { UserStore ChatUserStore RepoStore PermStore DeploymentStore DeploymentStatusStore DeploymentStatisticsStore LockStore ReviewStore EventStore }
type UserInteractor ¶
type UserInteractor struct {
// contains filtered or unexported fields
}
UserInteractor provides application logic for interacting with users.
func (*UserInteractor) IsAdminUser ¶
func (i *UserInteractor) IsAdminUser(ctx context.Context, login string) bool
IsAdminUser verifies that the login is an admin or not.
func (*UserInteractor) IsEntryMember ¶
func (i *UserInteractor) IsEntryMember(ctx context.Context, login string) bool
IsEntryMember verifies that the login is a member or not.
func (*UserInteractor) IsEntryOrg ¶
func (i *UserInteractor) IsEntryOrg(ctx context.Context, namespace string) bool
IsEntryOrg verifies that the organization is in the organization entries or not.
func (*UserInteractor) IsOrgMember ¶
func (i *UserInteractor) IsOrgMember(ctx context.Context, orgs []string) bool
IsOrgMember verifies that the user's organizations is in the member entries or not.
func (*UserInteractor) SyncRemoteRepo ¶
func (i *UserInteractor) SyncRemoteRepo(ctx context.Context, u *ent.User, re *extent.RemoteRepo, t time.Time) error
SyncRemoteRepo synchronizes with the remote repository.
type UserSCM ¶
type UserSCM interface { GetRemoteUserByToken(ctx context.Context, token string) (*extent.RemoteUser, error) ListRemoteOrgsByToken(ctx context.Context, token string) ([]string, error) }
UserSCM defines operations for working with remote users.
type UserStore ¶
type UserStore interface { CountUsers(context.Context) (int, error) SearchUsers(ctx context.Context, opts *SearchUsersOptions) ([]*ent.User, error) FindUserByID(ctx context.Context, id int64) (*ent.User, error) FindUserByHash(ctx context.Context, hash string) (*ent.User, error) FindUserByLogin(ctx context.Context, login string) (*ent.User, error) CreateUser(ctx context.Context, u *ent.User) (*ent.User, error) UpdateUser(ctx context.Context, u *ent.User) (*ent.User, error) DeleteUser(ctx context.Context, u *ent.User) error }
UserStore defines operations for working with users.
type Validator ¶
type Validator interface {
Validate(d *ent.Deployment) error
}
Validator defines the method that validate a deployment.