Documentation
¶
Index ¶
- Constants
- Variables
- func BuildUrl(repo, pullToken string) (string, error)
- func Nonce(size int) string
- type BuildJobTemplateData
- type CheckNameAvailabilityOutput
- type Domain
- type ErrEventNotSupported
- type GitWebhookPayload
- type Github
- type Gitlab
- type Impl
- func (d *Impl) AddBuild(ctx RegistryContext, build entities.Build) (*entities.Build, error)
- func (d *Impl) CheckUserNameAvailability(ctx RegistryContext, username string) (*CheckNameAvailabilityOutput, error)
- func (d *Impl) CreateAdminCredential(ctx RegistryContext, credential entities.Credential) (*entities.Credential, error)
- func (d *Impl) CreateBuildRun(ctx RegistryContext, build *entities.Build, hook *GitWebhookPayload, ...) error
- func (d *Impl) CreateCredential(ctx RegistryContext, credential entities.Credential) (*entities.Credential, error)
- func (d *Impl) CreateRepository(ctx RegistryContext, repoName string) (*entities.Repository, error)
- func (d *Impl) DeleteBuild(ctx RegistryContext, buildId repos.ID) error
- func (d *Impl) DeleteCredential(ctx RegistryContext, userName string) error
- func (d *Impl) DeleteRepository(ctx RegistryContext, repoName string) error
- func (d *Impl) DeleteRepositoryDigest(ctx RegistryContext, repoName string, digest string) error
- func (d *Impl) GetBuild(ctx RegistryContext, buildId repos.ID) (*entities.Build, error)
- func (d *Impl) GetBuildRun(ctx RegistryContext, buildId repos.ID, runName string) (*entities.BuildRun, error)
- func (*Impl) GetBuildTemplate(obj BuildJobTemplateData) ([]byte, error)
- func (d *Impl) GetLatestBuildRun(ctx RegistryContext, buildId repos.ID) (*entities.BuildRun, error)
- func (d *Impl) GetToken(ctx RegistryContext, username string) (string, error)
- func (d *Impl) GetTokenKey(ctx context.Context, username string, accountname string) (string, error)
- func (d *Impl) GithubAddWebhook(ctx context.Context, userId repos.ID, repoUrl string) (repos.ID, error)
- func (d *Impl) GithubInstallationToken(ctx context.Context, repoUrl string) (string, error)
- func (d *Impl) GithubListBranches(ctx context.Context, userId repos.ID, repoUrl string, ...) ([]*entities.GitBranch, error)
- func (d *Impl) GithubListInstallations(ctx context.Context, userId repos.ID, pagination *types.Pagination) ([]*entities.GithubInstallation, error)
- func (d *Impl) GithubListRepos(ctx context.Context, userId repos.ID, installationId int64, ...) (*entities.GithubListRepository, error)
- func (d *Impl) GithubSearchRepos(ctx context.Context, userId repos.ID, q, org string, ...) (*entities.GithubSearchRepository, error)
- func (d *Impl) GitlabAddWebhook(ctx context.Context, userId repos.ID, repoId string) (*int, error)
- func (d *Impl) GitlabListBranches(ctx context.Context, userId repos.ID, repoId string, query *string, ...) ([]*entities.GitBranch, error)
- func (d *Impl) GitlabListGroups(ctx context.Context, userId repos.ID, query *string, ...) ([]*entities.GitlabGroup, error)
- func (d *Impl) GitlabListRepos(ctx context.Context, userId repos.ID, gid string, query *string, ...) ([]*entities.GitlabProject, error)
- func (d *Impl) GitlabPullToken(ctx context.Context, userId repos.ID) (string, error)
- func (d *Impl) ListBuildRuns(ctx RegistryContext, search map[string]repos.MatchFilter, ...) (*repos.PaginatedRecord[*entities.BuildRun], error)
- func (d *Impl) ListBuilds(ctx RegistryContext, repoName string, search map[string]repos.MatchFilter, ...) (*repos.PaginatedRecord[*entities.Build], error)
- func (d *Impl) ListBuildsByGit(ctx context.Context, repoUrl, branch, provider string) ([]*entities.Build, error)
- func (d *Impl) ListCredentials(ctx RegistryContext, search map[string]repos.MatchFilter, ...) (*repos.PaginatedRecord[*entities.Credential], error)
- func (d *Impl) ListRepositories(ctx RegistryContext, search map[string]repos.MatchFilter, ...) (*repos.PaginatedRecord[*entities.Repository], error)
- func (d *Impl) ListRepositoryDigests(ctx RegistryContext, repoName string, search map[string]repos.MatchFilter, ...) (*repos.PaginatedRecord[*entities.Digest], error)
- func (d *Impl) MatchRecordVersion(annotations map[string]string, rv int) (int, error)
- func (d *Impl) OnBuildRunApplyErrorMessage(ctx RegistryContext, clusterName string, name string, errorMsg string) error
- func (d *Impl) OnBuildRunDeleteMessage(ctx RegistryContext, buildRun entities.BuildRun) error
- func (d *Impl) OnBuildRunUpdateMessage(ctx RegistryContext, buildRun entities.BuildRun, status t2.ResourceStatus, ...) error
- func (d *Impl) ParseGithubHook(eventType string, hookBody []byte) (*GitWebhookPayload, error)
- func (d *Impl) ParseGitlabHook(eventType string, hookBody []byte) (*GitWebhookPayload, error)
- func (d *Impl) ProcessRegistryEvents(ctx context.Context, events []entities.Event, logger logging.Logger) error
- func (d *Impl) TriggerBuild(ctx RegistryContext, buildId repos.ID) error
- func (d *Impl) UpdateBuild(ctx RegistryContext, id repos.ID, build entities.Build) (*entities.Build, error)
- func (d *Impl) UpdateBuildInternal(ctx context.Context, build *entities.Build) (*entities.Build, error)
- type PublishMsg
- type RegistryContext
- type ResourceDispatcher
- type ResourceEventPublisher
- type UpdateAndDeleteOpts
Constants ¶
View Source
const (
KL_ADMIN = "kloudlite"
)
Variables ¶
View Source
var Module = fx.Module( "domain", fx.Provide( func(e *env.Env, logger logging.Logger, repositoryRepo repos.DbRepo[*entities.Repository], credentialRepo repos.DbRepo[*entities.Credential], buildRepo repos.DbRepo[*entities.Build], buildCacheRepo repos.DbRepo[*entities.BuildCacheKey], tagRepo repos.DbRepo[*entities.Digest], buildRunRepo repos.DbRepo[*entities.BuildRun], iamClient iam.IAMClient, cacheClient kv.BinaryDataRepo, authClient auth.AuthClient, github Github, gitlab Gitlab, resourceEventPublisher ResourceEventPublisher, dispatcher ResourceDispatcher, ) (Domain, error) { return &Impl{ repositoryRepo: repositoryRepo, credentialRepo: credentialRepo, iamClient: iamClient, envs: e, digestRepo: tagRepo, logger: logger, cacheClient: cacheClient, buildRepo: buildRepo, buildCacheRepo: buildCacheRepo, buildRunRepo: buildRunRepo, authClient: authClient, github: github, gitlab: gitlab, resourceEventPublisher: resourceEventPublisher, dispatcher: dispatcher, }, nil }), )
Functions ¶
Types ¶
type BuildJobTemplateData ¶
type Domain ¶
type Domain interface {
ProcessRegistryEvents(ctx context.Context, events []entities.Event, logger logging.Logger) error
CheckUserNameAvailability(ctx RegistryContext, username string) (*CheckNameAvailabilityOutput, error)
// registry
ListRepositories(ctx RegistryContext, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.Repository], error)
CreateRepository(ctx RegistryContext, repoName string) (*entities.Repository, error)
DeleteRepository(ctx RegistryContext, repoName string) error
// tags
ListRepositoryDigests(ctx RegistryContext, repoName string, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.Digest], error)
DeleteRepositoryDigest(ctx RegistryContext, repoName string, digest string) error
// credential
ListCredentials(ctx RegistryContext, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.Credential], error)
CreateCredential(ctx RegistryContext, credential entities.Credential) (*entities.Credential, error)
DeleteCredential(ctx RegistryContext, userName string) error
CreateAdminCredential(ctx RegistryContext, credential entities.Credential) (*entities.Credential, error)
GetToken(ctx RegistryContext, username string) (string, error)
GetTokenKey(ctx context.Context, username string, accountname string) (string, error)
AddBuild(ctx RegistryContext, build entities.Build) (*entities.Build, error)
UpdateBuild(ctx RegistryContext, id repos.ID, build entities.Build) (*entities.Build, error)
UpdateBuildInternal(ctx context.Context, build *entities.Build) (*entities.Build, error)
ListBuilds(ctx RegistryContext, repoName string, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.Build], error)
GetBuild(ctx RegistryContext, buildId repos.ID) (*entities.Build, error)
DeleteBuild(ctx RegistryContext, buildId repos.ID) error
TriggerBuild(ctx RegistryContext, buildId repos.ID) error
// webhook
ParseGithubHook(eventType string, hookBody []byte) (*GitWebhookPayload, error)
ParseGitlabHook(eventType string, hookBody []byte) (*GitWebhookPayload, error)
GithubInstallationToken(ctx context.Context, repoUrl string) (string, error)
GithubListInstallations(ctx context.Context, userId repos.ID, pagination *types.Pagination) ([]*entities.GithubInstallation, error)
GithubListRepos(ctx context.Context, userId repos.ID, installationId int64, pagination *types.Pagination) (*entities.GithubListRepository, error)
GithubSearchRepos(ctx context.Context, userId repos.ID, q, org string, pagination *types.Pagination) (*entities.GithubSearchRepository, error)
GithubListBranches(ctx context.Context, userId repos.ID, repoUrl string, pagination *types.Pagination) ([]*entities.GitBranch, error)
GithubAddWebhook(ctx context.Context, userId repos.ID, repoUrl string) (repos.ID, error)
GitlabListGroups(ctx context.Context, userId repos.ID, query *string, pagination *types.Pagination) ([]*entities.GitlabGroup, error)
GitlabListRepos(ctx context.Context, userId repos.ID, gid string, query *string, pagination *types.Pagination) ([]*entities.GitlabProject, error)
GitlabListBranches(ctx context.Context, userId repos.ID, repoId string, query *string, pagination *types.Pagination) ([]*entities.GitBranch, error)
GitlabAddWebhook(ctx context.Context, userId repos.ID, repoId string) (*int, error)
GitlabPullToken(ctx context.Context, userId repos.ID) (string, error)
GetBuildTemplate(obj BuildJobTemplateData) ([]byte, error)
ListBuildsByGit(ctx context.Context, repoUrl, branch, provider string) ([]*entities.Build, error)
// AddBuildCache(ctx RegistryContext, buildCache entities.BuildCacheKey) (*entities.BuildCacheKey, error)
// UpdateBuildCache(ctx RegistryContext, id repos.ID, buildCache entities.BuildCacheKey) (*entities.BuildCacheKey, error)
// DeleteBuildCache(ctx RegistryContext, id repos.ID) error
// ListBuildCaches(ctx RegistryContext, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.BuildCacheKey], error)
ListBuildRuns(ctx RegistryContext, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.BuildRun], error)
GetLatestBuildRun(ctx RegistryContext, buildId repos.ID) (*entities.BuildRun, error)
GetBuildRun(ctx RegistryContext, buildId repos.ID, runName string) (*entities.BuildRun, error)
OnBuildRunUpdateMessage(ctx RegistryContext, buildRun entities.BuildRun, status t.ResourceStatus, opts UpdateAndDeleteOpts) error
OnBuildRunDeleteMessage(ctx RegistryContext, buildRun entities.BuildRun) error
OnBuildRunApplyErrorMessage(ctx RegistryContext, clusterName string, name string, errorMsg string) error
// ListBuildsByCache(ctx RegistryContext, cacheId repos.ID, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.Build], error)
CreateBuildRun(ctx RegistryContext, build *entities.Build, hook *GitWebhookPayload, pullToken string, seed string) error
}
type ErrEventNotSupported ¶
type ErrEventNotSupported struct {
// contains filtered or unexported fields
}
func (*ErrEventNotSupported) Error ¶
func (e *ErrEventNotSupported) Error() string
type GitWebhookPayload ¶
type Github ¶
type Github interface {
Callback(ctx context.Context, code, state string) (*github.User, *oauth2.Token, error)
GetToken(ctx context.Context, token *oauth2.Token) (*oauth2.Token, error)
GetInstallationToken(ctx context.Context, repoUrl string) (string, error)
ListInstallations(ctx context.Context, accToken *entities.AccessToken, pagination *types.Pagination) ([]*github.Installation, error)
ListRepos(ctx context.Context, accToken *entities.AccessToken, instId int64, pagination *types.Pagination) (*github.ListRepositories, error)
SearchRepos(ctx context.Context, accToken *entities.AccessToken, q, org string, pagination *types.Pagination) (*github.RepositoriesSearchResult, error)
ListBranches(ctx context.Context, accToken *entities.AccessToken, repoUrl string, pagination *types.Pagination) ([]*github.Branch, error)
CheckWebhookExists(ctx context.Context, token *entities.AccessToken, repoUrl string, webhookId *entities.GithubWebhookId) (bool, error)
AddWebhook(ctx context.Context, accToken *entities.AccessToken, repoUrl string, webhookUrl string) (*entities.GithubWebhookId, error)
DeleteWebhook(ctx context.Context, accToken *entities.AccessToken, repoUrl string, hookId entities.GithubWebhookId) error
GetLatestCommit(ctx context.Context, accToken *entities.AccessToken, repoUrl string, branchName string) (string, error)
}
type Gitlab ¶
type Gitlab interface {
Callback(ctx context.Context, code, state string) (*gitlab.User, *oauth2.Token, error)
ListGroups(ctx context.Context, token *entities.AccessToken, query *string, pagination *types.Pagination) ([]*entities.GitlabGroup, error)
ListRepos(ctx context.Context, token *entities.AccessToken, gid string, query *string, pagination *types.Pagination) ([]*gitlab.Project, error)
ListBranches(ctx context.Context, token *entities.AccessToken, repoId string, query *string, pagination *types.Pagination) ([]*gitlab.Branch, error)
CheckWebhookExists(ctx context.Context, token *entities.AccessToken, repoId string, webhookId *entities.GitlabWebhookId) (bool, error)
AddWebhook(ctx context.Context, token *entities.AccessToken, repoId string) (*int, error)
DeleteWebhook(ctx context.Context, token *entities.AccessToken, repoUrl string, hookId entities.GitlabWebhookId) error
RepoToken(ctx context.Context, token *entities.AccessToken) (*oauth2.Token, error)
GetRepoId(repoUrl string) string
GetLatestCommit(ctx context.Context, token *entities.AccessToken, repoUrl string, branchName string) (string, error)
GetTriggerWebhookUrl() string
}
type Impl ¶
type Impl struct {
// contains filtered or unexported fields
}
func (*Impl) CheckUserNameAvailability ¶
func (d *Impl) CheckUserNameAvailability(ctx RegistryContext, username string) (*CheckNameAvailabilityOutput, error)
func (*Impl) CreateAdminCredential ¶
func (d *Impl) CreateAdminCredential(ctx RegistryContext, credential entities.Credential) (*entities.Credential, error)
func (*Impl) CreateBuildRun ¶
func (d *Impl) CreateBuildRun(ctx RegistryContext, build *entities.Build, hook *GitWebhookPayload, pullToken string, seed string) error
func (*Impl) CreateCredential ¶
func (d *Impl) CreateCredential(ctx RegistryContext, credential entities.Credential) (*entities.Credential, error)
CreateCredential implements Domain.
func (*Impl) CreateRepository ¶
func (d *Impl) CreateRepository(ctx RegistryContext, repoName string) (*entities.Repository, error)
CreateRepository implements Domain.
func (*Impl) DeleteBuild ¶
func (d *Impl) DeleteBuild(ctx RegistryContext, buildId repos.ID) error
func (*Impl) DeleteCredential ¶
func (d *Impl) DeleteCredential(ctx RegistryContext, userName string) error
DeleteCredential implements Domain.
func (*Impl) DeleteRepository ¶
func (d *Impl) DeleteRepository(ctx RegistryContext, repoName string) error
DeleteRepository implements Domain.
func (*Impl) DeleteRepositoryDigest ¶
func (d *Impl) DeleteRepositoryDigest(ctx RegistryContext, repoName string, digest string) error
func (*Impl) GetBuildRun ¶
func (*Impl) GetBuildTemplate ¶
func (*Impl) GetBuildTemplate(obj BuildJobTemplateData) ([]byte, error)
func (*Impl) GetLatestBuildRun ¶
func (*Impl) GetToken ¶
func (d *Impl) GetToken(ctx RegistryContext, username string) (string, error)
func (*Impl) GetTokenKey ¶
func (*Impl) GithubAddWebhook ¶
func (*Impl) GithubInstallationToken ¶
func (*Impl) GithubListBranches ¶
func (*Impl) GithubListInstallations ¶
func (d *Impl) GithubListInstallations(ctx context.Context, userId repos.ID, pagination *types.Pagination) ([]*entities.GithubInstallation, error)
func (*Impl) GithubListRepos ¶
func (*Impl) GithubSearchRepos ¶
func (*Impl) GitlabAddWebhook ¶
func (*Impl) GitlabListBranches ¶
func (*Impl) GitlabListGroups ¶
func (*Impl) GitlabListRepos ¶
func (*Impl) GitlabPullToken ¶
func (*Impl) ListBuildRuns ¶
func (d *Impl) ListBuildRuns(ctx RegistryContext, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.BuildRun], error)
func (*Impl) ListBuilds ¶
func (d *Impl) ListBuilds(ctx RegistryContext, repoName string, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.Build], error)
func (*Impl) ListBuildsByGit ¶
func (*Impl) ListCredentials ¶
func (d *Impl) ListCredentials(ctx RegistryContext, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.Credential], error)
ListCredentials implements Domain.
func (*Impl) ListRepositories ¶
func (d *Impl) ListRepositories(ctx RegistryContext, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.Repository], error)
ListRepositories implements Domain.
func (*Impl) ListRepositoryDigests ¶
func (d *Impl) ListRepositoryDigests(ctx RegistryContext, repoName string, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.Digest], error)
func (*Impl) MatchRecordVersion ¶
func (*Impl) OnBuildRunApplyErrorMessage ¶
func (*Impl) OnBuildRunDeleteMessage ¶
func (d *Impl) OnBuildRunDeleteMessage(ctx RegistryContext, buildRun entities.BuildRun) error
func (*Impl) OnBuildRunUpdateMessage ¶
func (d *Impl) OnBuildRunUpdateMessage(ctx RegistryContext, buildRun entities.BuildRun, status t2.ResourceStatus, opts UpdateAndDeleteOpts) error
func (*Impl) ParseGithubHook ¶
func (d *Impl) ParseGithubHook(eventType string, hookBody []byte) (*GitWebhookPayload, error)
func (*Impl) ParseGitlabHook ¶
func (d *Impl) ParseGitlabHook(eventType string, hookBody []byte) (*GitWebhookPayload, error)
func (*Impl) ProcessRegistryEvents ¶
func (*Impl) TriggerBuild ¶
func (d *Impl) TriggerBuild(ctx RegistryContext, buildId repos.ID) error
func (*Impl) UpdateBuild ¶
type PublishMsg ¶
type PublishMsg string
const ( PublishAdd PublishMsg = "added" PublishDelete PublishMsg = "deleted" PublishUpdate PublishMsg = "updated" )
type RegistryContext ¶
type RegistryContext struct {
context.Context
UserId repos.ID
UserName string
AccountName string
UserEmail string
}
func NewRegistryContext ¶
func (RegistryContext) GetAccountName ¶
func (c RegistryContext) GetAccountName() string
func (RegistryContext) GetUserEmail ¶
func (c RegistryContext) GetUserEmail() string
func (RegistryContext) GetUserId ¶
func (c RegistryContext) GetUserId() repos.ID
func (RegistryContext) GetUserName ¶
func (c RegistryContext) GetUserName() string
type ResourceDispatcher ¶
type ResourceEventPublisher ¶
type ResourceEventPublisher interface {
PublishBuildRunEvent(cluster *entities.BuildRun, msg PublishMsg)
PublishBuildCacheEvent(buildcache *entities.BuildCacheKey, msg PublishMsg)
}
type UpdateAndDeleteOpts ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.