core

package
v0.0.0-...-9c90d3e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PayloadContainer = iota
	MetricsContainer
	CacheContainer
	LogsContainer
	CoverageContainer
)

List of container names

View Source
const (
	ContainerImage     string = "container_image"
	ImpactedTestExists string = "impacted_test_exists"
	TotalFlakyTasks    string = "total_flaky_tasks"
	FlakyTasksPassed   string = "flaky_tasks_passed"
	FlakyTasksFailed   string = "flaky_tasks_failed"
	FlakyTasksError    string = "flaky_tasks_error"
	FlakyTasksAborted  string = "flaky_tasks_aborted"
	TotalSubModule     string = "total_submodule"
	ProcessedSubModule string = "processed_submodule"
	TotalExecTasks     string = "total_exec_tasks"
	ExecTasksPassed    string = "exec_tasks_passed" //nolint:gosec
	ExecTasksFailed    string = "exec_tasks_failed"
	ExecTasksError     string = "exec_tasks_error"
	ExecTasksAborted   string = "exec_tasks_aborted"
	BuildFailedRemarks string = "build_failed_reamrks"
)

const related to build cache

View Source
const (
	BuildPendingDesc string = "pending."
	BuildRunningDesc string = "running."
	BuildFailedDesc  string = "Failed"
	BuildPassedDesc  string = "Passed"
	BuildErrorDesc   string = "errored out."
	BuildAbortedDesc string = "was aborted."
	BuildUnknownDesc string = "in unknown state."
)

Build Description values.

View Source
const (
	// JobCompletedMsg stores the msg for already stopped job
	JobCompletedMsg = "job already completed"
	// JobAbortedByUser stores the remark to use while updating task because of abort build API
	JobAbortedByUser = "aborted by user"
)
View Source
const (
	TestFailedWeight = iota + 1
	TestAbortedWeight
	TestPassedWeight
	TestSkippedWeight
	TestDefaultWeight
)

TestStatusWeight returns the weight of the test status

View Source
const (
	AbortedBuild string = "aborted"
)

Build abort tag for redis

View Source
const EventHeader = "event_type"

EventHeader is the kafka header for webhook event type.

View Source
const JwtIDPrefix = "jti:"

JwtIDPrefix is the jwt-id prefix while creating the key

Variables

View Source
var LicenseTierConfigMapping = map[Tier]TierConfig{
	"small":  {CPUs: "2", RAM: "4Gi", Storage: "4Gi", CreditsPM: 5},
	"medium": {CPUs: "4", RAM: "8Gi", Storage: "8Gi", CreditsPM: 10},
	"large":  {CPUs: "8", RAM: "16Gi", Storage: "16Gi", CreditsPM: 30},
	"xlarge": {CPUs: "16", RAM: "32Gi", Storage: "32Gi", CreditsPM: 100},
}

LicenseTierConfigMapping is used for License mapping

View Source
var TaskTierConfigMapping = map[Tier]TierConfig{
	"internal": {CPUs: "0.5", RAM: "256Mi", Storage: "256Mi", CreditsPM: 0},
	"xsmall":   {CPUs: "1", RAM: "2Gi", Storage: "2Gi", CreditsPM: 2},
	"small":    {CPUs: "2", RAM: "4Gi", Storage: "4Gi", CreditsPM: 5},
	"medium":   {CPUs: "4", RAM: "8Gi", Storage: "8Gi", CreditsPM: 10},
	"large":    {CPUs: "8", RAM: "16Gi", Storage: "16Gi", CreditsPM: 30},
	"xlarge":   {CPUs: "16", RAM: "32Gi", Storage: "32Gi", CreditsPM: 100},
}

TaskTierConfigMapping is used for License mapping

Functions

This section is empty.

Types

type AggregatedFlakyTestExecInfo

type AggregatedFlakyTestExecInfo struct {
	Results            []TestExecutionStatus `json:"results"`
	Threshold          int                   `json:"threshold"`
	NumberOfExecutions int                   `json:"number_of_executions"`
	TotalTransitions   int                   `json:"total_transitions"`
	FirstTransition    int                   `json:"first_transition"`
	LastValidStatus    TestExecutionStatus   `json:"-"`
}

AggregatedFlakyTestExecInfo stores aggerated info for flaky test results

type Author

type Author struct {
	Name  string    `db:"name"`
	Email string    `db:"email"`
	Date  time.Time `db:"date"`
}

Author identifies a git commit author.

type AuthorMeta

type AuthorMeta struct {
	TotalCommits      int    `db:"total_commits" json:"commits_count"`
	TotalBuilds       int    `db:"total_builds" json:"builds_count"`
	TotalRepositories int    `db:"total_repos" json:"repositories_count"`
	TotalTests        int    `db:"total_tests" json:"tests_count"`
	Name              string `db:"author" json:"author"`
}

AuthorMeta contains meta data for a git author

type AuthorStats

type AuthorStats struct {
	Name              string  `json:"name" db:"author_name"`
	LatestCommit      string  `json:"latest_commit_id" db:"latest_commit_id"`
	FlakyCount        int     `json:"flaky_count" db:"flaky_count"`
	CommitCount       int     `json:"commit_count" db:"commit_count"`
	AverageTransition float64 `json:"transition"`
	BlocklistedTests  int     `json:"test_blocklisted"`
}

AuthorStats contains stats of the author for the repo

type AzureBlob

type AzureBlob interface {
	// UploadBytes uploads a buffer in blocks to a block blob.
	UploadBytes(ctx context.Context, path string, rawBytes []byte, containerID int, mimeType string) (string, error)
	// UploadStream copies the file held in io.Reader to the Blob at blockBlobURL
	UploadStream(ctx context.Context, path string, reader io.Reader, containerID int, mimeType string) (string, error)
	// GenerateSasURL generates Azure SAS URL
	GenerateSasURL(ctx context.Context, blobPath string, containerID int) (string, error)
	// DownloadStream downloads the data from the blob return result in io.Reader
	DownloadStream(ctx context.Context, path string, containerID int) (io.ReadCloser, error)
	// ReplaceWithCDN replaces the azure URL with Azure CDN URL.
	ReplaceWithCDN(urlStr string) string
}

AzureBlob defines operation for working with azure store

type Badge

type Badge struct {
	BuildStatus      string  `json:"status"`
	Duration         string  `json:"duration"`
	TotalTests       int     `json:"total_tests"`
	Passed           int     `json:"passed"`
	Failed           int     `json:"failed"`
	Skipped          int     `json:"skipped"`
	DiscoveredTests  int     `json:"discovered_tests"`
	PercentTimeSaved float64 `json:"time_saved_percent"`
	BuildID          string  `json:"build_id"`
	ExecutionTime    int     `json:"-"`
	TimeSaved        string  `json:"time_saved"`
}

Badge represents struct for badge data

type BadgeFlaky

type BadgeFlaky struct {
	BuildStatus   string `json:"job_status"`
	BuildID       string `json:"job_id"`
	FlakyTests    int    `json:"flaky_tests"`
	NonFlakyTests int    `json:"non_flaky_tests"`
	Quarantined   int    `json:"quarantined_tests"`
}

BadgeFlaky represents struct for badge related to flaky data

type BlockTest

type BlockTest struct {
	ID        string              `db:"id"`
	TestID    string              `db:"test_id"`
	Status    TestExecutionStatus `db:"status" json:"status"`
	BlockedBy string              `db:"blocked_by"`
	RepoID    string              `db:"repo_id"`
	Branch    string              `db:"branch"`
	Created   time.Time           `db:"created_at"`
	Updated   time.Time           `db:"updated_at"`
	Locator   string              `json:"test_locator"`
	TestName  string              `json:"test_name"`
}

BlockTest represents the blocklisted test

type BlockTestStore

type BlockTestStore interface {
	// CreateInTx persists a new blocklist in the datastore within transaction
	CreateInTx(ctx context.Context, tx *sqlx.Tx, blockTests []*BlockTest) error
	// FindBlockTest returns block tests
	FindBlockTest(ctx context.Context, repoID, branch, typeFilter string) (blockTests []*BlockTest, err error)
}

BlockTestStore defines operations for working with blocktest store

type Branch

type Branch struct {
	ID      string    `json:"-" db:"id"`
	Name    string    `json:"-" db:"name"`
	RepoID  string    `json:"-" db:"repo_id"`
	Created time.Time `json:"-" db:"created_at"`
	Updated time.Time `json:"-" db:"updated_at"`
}

Branch represents a git branch.

type BranchCommit

type BranchCommit struct {
	ID         string    `json:"-" db:"id"`
	CommitID   string    `json:"-" db:"commit_id"`
	BranchName string    `json:"-" db:"branch_name"`
	RepoID     string    `json:"-" db:"repo_id"`
	Created    time.Time `json:"-" db:"created_at"`
	Updated    time.Time `json:"-" db:"updated_at"`
}

BranchCommit represents a git branch.

type BranchCommitStore

type BranchCommitStore interface {
	// CreateInTx persists a new entries to the branch_commit relationship table.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, branchCommits []*BranchCommit) error
}

BranchCommitStore defines datastore operation for working with branch_commit relationship table.

type BranchStore

type BranchStore interface {
	// CreateInTx persists a new branch in the datastore and executes the statements within the specified transaction
	CreateInTx(ctx context.Context, tx *sqlx.Tx, branch *Branch) error
	// FindByRepo fetch the list of all branches which are there for a particular user
	FindByRepo(ctx context.Context, repoID string) ([]string, error)
}

BranchStore defines datastore operation for working with branch.

type Build

type Build struct {
	BuildNum          int                     `json:"build_num" db:"build_num"`
	ID                string                  `json:"id" db:"id"`
	BaseCommit        string                  `json:"base_commit" db:"base_commit"`
	CommitID          string                  `json:"commit_id,omitempty" db:"commit_id"`
	CommitAuthor      string                  `json:"commit_author,omitempty"`
	CommitMessage     *zero.String            `json:"commit_message,omitempty"`
	RepoID            string                  `json:"repo_id,omitempty" db:"repo_id"`
	EventID           string                  `json:"event_id,omitempty" db:"event_id"`
	Actor             string                  `json:"-" db:"actor"`
	PayloadAddress    string                  `json:"-" db:"payload_address"`
	Created           time.Time               `json:"created_at" db:"created_at"`
	Updated           time.Time               `json:"-" db:"updated_at"`
	StartTime         zero.Time               `json:"start_time" db:"start_time"`
	EndTime           zero.Time               `json:"end_time" db:"end_time"`
	Status            BuildStatus             `json:"status,omitempty" db:"status"`
	TimeAllTests      int                     `json:"time_all_tests_ms,omitempty" db:"time_all_tests_ms,omitempty"`
	TimeImpactedTests int                     `json:"time_impacted_tests_ms,omitempty" db:"time_impacted_tests_ms,omitempty"`
	Meta              *ExecutionMeta          `json:"execution_meta,omitempty"`
	FlakyMeta         *FlakyExecutionMetadata `json:"flaky_execution_meta,omitempty"`
	ExecutionStatus   BuildExecutionStatus    `json:"build_execution_status,omitempty"`
	BuildsList        []*BuildsCreated        `json:"builds_list,omitempty"`
	Tag               BuildTag                `json:"build_tag,omitempty" db:"tag"`
	Branch            string                  `json:"branch" db:"branch_name"`
	Tier              Tier                    `json:"tier,omitempty" db:"tier"`
	Remark            zero.String             `json:"remark" db:"remark"`
	JobView           JobView                 `json:"job_view" db:"job_view"`
}

Build represents the user's builds.

type BuildAbortConsumer

type BuildAbortConsumer interface {
	// Run runs the queue consumer in background.
	Run(ctx context.Context)
	// Close closes the queue consumer
	Close() error
}

BuildAbortConsumer represents the build abort consumer.

type BuildAbortProducer

type BuildAbortProducer interface {
	// Enqueue inserts payload in queue.
	Enqueue(buildID, orgID string) error
	// Close closes the queue producer.
	Close() error
}

BuildAbortProducer represents the build abort producer.

type BuildAbortService

type BuildAbortService interface {
	// AbortBuild aborts the running and initiating tasks
	AbortBuild(ctx context.Context, buildID, repoID, orgID string) (string, error)
}

BuildAbortService implements the build abort service

type BuildCache

type BuildCache struct {
	TokenPath             string    `redis:"token_path"`
	InstallationTokenPath string    `redis:"installation_token_path"`
	SecretPath            string    `redis:"secret_path"`
	GitProvider           SCMDriver `redis:"git_provider"`
	RepoSlug              string    `redis:"repo_slug"`
	PullRequestNumber     int       `redis:"pull_request_number"`
	PayloadAddress        string    `redis:"payload_address"`
	BaseCommitID          string    `redis:"base_commit_id"`
	TargetCommitID        string    `redis:"target_commit_id"`
	RepoID                string    `redis:"repo_id"`
	CollectCoverage       bool      `redis:"collect_coverage"`
	Tier                  Tier      `redis:"tier"`
	BuildTag              BuildTag  `redis:"tag"`
	Branch                string    `redis:"branch"`
	TotalExecTasks        int       `redis:"total_exec_tasks"`
	ExecTasksPassed       int       `redis:"exec_tasks_passed"`
	ExecTasksFailed       int       `redis:"exec_tasks_failed"`
	ExecTasksError        int       `redis:"exec_tasks_error"`
	ExecTasksAborted      int       `redis:"exec_tasks_aborted"`
	FlakyConsecutiveRuns  int       `redis:"flaky_consecutive_runs"`
	ImpactedTestExists    bool      `redis:"impacted_test_exists"`
	ContainerImage        string    `redis:"container_image"`
	FailedTestCount       int       `redis:"failed_test_count"`
	FlakyTestCount        int       `redis:"flaky_test_count"`
	TotalFlakyTasks       int       `redis:"total_flaky_tasks"`
	FlakyTasksPassed      int       `redis:"flaky_tasks_passed"`
	FlakyTasksFailed      int       `redis:"flaky_tasks_failed"`
	FlakyTasksError       int       `redis:"flaky_tasks_error"`
	FlakyTasksAborted     int       `redis:"flaky_tasks_aborted"`
	TotalSubModule        int       `redis:"total_submodule"`
	ProcessedSubModule    int       `redis:"processed_submodule"`
	BuildFailedRemarks    string    `redis:"build_failed_reamrks"`
	Aborted               bool      `redis:"aborted"`
}

BuildCache details related to a particular build, is cached in redis.

type BuildCoverageStatus

type BuildCoverageStatus struct {
	BuildID             string    `db:"build_id"`
	BaseCommitID        string    `db:"base_commit_id"`
	CoverageAvailable   bool      `db:"coverage_available"`
	CoverageRecoverable bool      `db:"coverage_recoverable"`
	Created             time.Time `db:"created_at"`
	Updated             time.Time `db:"updated_at"`
}

BuildCoverageStatus represents the coverage for a build.

type BuildCoverageStatusStore

type BuildCoverageStatusStore interface {
	// Create persists the BuildCoverageStatus data into datastore.
	Create(ctx context.Context, ccStatus *BuildCoverageStatus) error
	// FindDependentCoverageJobs finds dependent coverage jobs for given commitIDs
	FindDependentCoverageJobsToRun(ctx context.Context, repoID string, commitIDs []string) ([]*CoverageInput, error)
	// FindPendingCoverageJobsToRun finds pending coverage jobs in the system to run (by orgID sorted)
	FindPendingCoverageJobsToRun(ctx context.Context) ([]*CoverageInput, error)
	// UpdateBulkCoverageAvailableTrueInTx sets coverage_available to true for all commitIDs for a given repoID
	UpdateBulkCoverageAvailableTrueInTx(ctx context.Context, tx *sqlx.Tx, repoID string, commitIDs []string) error
	// GetCoverageStatusCounts helps in assessing whether coverage data for a commit can be made available and hence do smart-selection
	GetCoverageStatusCounts(ctx context.Context, commitID, repoID string) (*int16, *int16, int, error)
}

BuildCoverageStatusStore defines datastore operation for working with commit_coverage_status table

type BuildData

type BuildData struct {
	Expiry  int64  `json:"exp"`
	JwtID   string `json:"jti"`
	BuildID string `json:"build_id"`
	OrgID   string `json:"org_id"`
	RepoID  string `json:"repo_id"`
}

BuildData represents the data which is stored in JWT for internal auth

type BuildExecutionStatus

type BuildExecutionStatus struct {
	Total      int `json:"total_builds_executed,omitempty"`
	Passed     int `json:"builds_passed"`
	Skipped    int `json:"builds_skipped"`
	Failed     int `json:"builds_failed"`
	Aborted    int `json:"builds_aborted"`
	Error      int `json:"builds_error"`
	Running    int `json:"builds_running"`
	Initiating int `json:"builds_initiating"`
}

BuildExecutionStatus specifies the counts of status

type BuildMeta

type BuildMeta struct {
	Total       int     `json:"total_builds_executed"`
	Error       int     `json:"builds_error"`
	Initiating  int     `json:"builds_initiating"`
	Passed      int     `json:"builds_passed"`
	Running     int     `json:"builds_running"`
	Failed      int     `json:"builds_failed"`
	Aborted     int     `json:"builds_aborted"`
	AvgDuration float64 `json:"avg_builds_duration"`
}

BuildMeta contains additional info of the builds executed

type BuildMonitor

type BuildMonitor interface {
	// FindAndUpdate find and update the build based on the task status.
	FindAndUpdate(ctx context.Context, orgID string, task *Task) error
	// FindTimeSavedData is a utility func which returns time-saved
	// data in a given build by not running unimpacted tests
	FindTimeSavedData(ctx context.Context, buildID, commitID, repoID string) (*TimeSavedData, error)
}

BuildMonitor represents the build monitoring service.

type BuildService

type BuildService interface {
	// ParseGitEvent parses the git scm webhook event.
	ParseGitEvent(ctx context.Context, gitEvent *GitEvent, repo *Repository, buildTag BuildTag) (*ParserResponse, error)
	// CreateBuild creates a new build.
	CreateBuild(ctx context.Context, payload *ParserResponse, driver SCMDriver, isNewGitEvent bool) (int, error)
}

BuildService performs common functionalities related to Build.

type BuildStatus

type BuildStatus string

BuildStatus specifies the status of a build

const (
	BuildRunning    BuildStatus = "running"
	BuildFailed     BuildStatus = "failed"
	BuildPassed     BuildStatus = "passed"
	BuildInitiating BuildStatus = "initiating"
	BuildAborted    BuildStatus = "aborted"
	BuildError      BuildStatus = "error"
)

Build Status values.

type BuildStore

type BuildStore interface {
	// CreateInTx persists a new build to the datastore and executes the statement within supplied transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, build *Build) error
	// FindByRepo returns the builds of a repo.
	FindByRepo(ctx context.Context, repoName, orgID, buildID, branchName, statusFilter,
		searchID string, authorsNames, tags []string, lastSeenTime time.Time, limit int) ([]*Build, error)
	// FindByBuildID returns the build from buildID.
	FindByBuildID(ctx context.Context, buildID string) (*Build, error)
	// FindByCommit returns the build by commitID.
	FindByCommit(ctx context.Context, commitID, repoName, orgID, branchName string, lastSeenTime time.Time, limit int) ([]*Build, error)
	// Update persists build changes to the datastore.
	Update(ctx context.Context, build *Build) error
	// MarkStarted  marks build as started in the datastore.
	MarkStarted(ctx context.Context, build *Build) error
	// MarkStopped   marks build as stopped in the datastore.
	MarkStopped(ctx context.Context, build *Build, orgID string) error
	// MarkStoppedInTx  marks build as stopped in the datastore and executes the query in given transaction.
	MarkStoppedInTx(ctx context.Context, tx *sqlx.Tx, build *Build, orgID string) error
	// FindBuildStatus return the builds information in a selected date range
	FindBuildStatus(ctx context.Context, repoName, orgID, branchName string, startDate, endDate time.Time) ([]*Build, error)
	// FindBuildStatusFailed return the builds information in a selected date range of failed builds.
	FindBuildStatusFailed(ctx context.Context, repoName, orgID, branchName string, startDate, endDate time.Time, limit int) ([]*Build, error)
	// CheckBuildCache check if build cache exits in redis.
	CheckBuildCache(ctx context.Context, buildID string) error
	// StoreBuildCache store build details in redis cache.
	StoreBuildCache(ctx context.Context, buildID string, buildCache *BuildCache) error
	// GetBuildCache get build details from redis cache.
	GetBuildCache(ctx context.Context, buildID string) (*BuildCache, error)
	// DeleteBuildCache deletes the build details from redis cache.
	DeleteBuildCache(ctx context.Context, buildID string) error
	// UpdateExecTaskCount updates the count of exec tasks in build cache.
	UpdateExecTaskCount(ctx context.Context, buildID string, count int) error
	// UpdateFlakyExecutionCount updates the flaky execution count  in build cache.
	UpdateFlakyExecutionCount(ctx context.Context, buildID string, executionCount int) error
	// StopStaleBuildsInTx marks the builds as error after timeout within specified transaction.
	StopStaleBuildsInTx(ctx context.Context, tx *sqlx.Tx, timeout time.Duration) (int64, error)
	// FindTests returns the tests in a build.
	FindTests(ctx context.Context, buildID, repoName, orgID string, offset, limit int) ([]*Test, error)
	// FindLastBuildCommitSha returns commitID for last passed build
	FindLastBuildCommitSha(ctx context.Context, repoID, branch string) (string, error)
	// FindBuildMeta returns the meta for the builds
	FindBuildMeta(ctx context.Context, repoName, orgID, branch string) ([]*BuildExecutionStatus, error)
	// FindBaseBuildCommitForRebuildPostMerge return basecommit id for latest build on given commitID
	FindBaseBuildCommitForRebuildPostMerge(ctx context.Context, repoID,
		branch, commitID string) (string, error)
	// UpdateTier updates yml tier for given build within specified transaction
	UpdateTier(ctx context.Context, build *Build) error
	// CheckIfCommitIDBuilt checks if given commitID was ever built on TAS for given repo. Useful in deciding first ever commit
	CheckIfCommitIDBuilt(ctx context.Context, commitID, repoID string) (bool, error)
	// CheckIfPassedBuildExistsInTx checks if given repoID has any successful build
	// and executes the query in specified transaction
	CheckIfPassedBuildExistsInTx(ctx context.Context, tx *sqlx.Tx, repoID string) (bool, error)
	// CountPassedFailedBuildsForRepo returns count of builds which have passed or failed for a given repoID
	CountPassedFailedBuildsForRepo(ctx context.Context, repoID string) (int, error)
	// FindCommitDiff finds the diff of commits for a particular job
	FindCommitDiff(ctx context.Context, orgName, repoName, gitProvider, buildID string) (string, error)
	// UpdateBuildCache updates the build cache based on provided map
	UpdateBuildCache(ctx context.Context, buildID string, updateMap map[string]interface{}, skipKeycheck bool) error
	// IncrementCacheCount updates count of a field in buildCache
	IncrementCacheCount(ctx context.Context, buildID, field string, count int) error
	// FindLastBuildTier finds the tier of the last build that had run for a given repoID
	FindLastBuildTierInTx(ctx context.Context, tx *sqlx.Tx, repoID string) (Tier, error)
	// FindMttfAndMttr finds the mean time to failure and mean time to repair for a repo and branch
	FindMttfAndMttr(ctx context.Context, repoID, branchName string, startDate, endDate time.Time) (*MttfAndMttr, error)
	// FindJobsWithTestsStatus finds the tests status with in the `limit` builds
	FindJobsWithTestsStatus(ctx context.Context, repoName, orgID, branchName string, limit int) ([]*Build, error)
	// UpdateTestsRuntimes updates all_tests_runtime and impacted_tests_runtime columns
	UpdateTestsRuntimes(ctx context.Context, build *Build) error
	// FindBuildWiseTimeSaved returns build-wise time saved data in a given duration
	FindBuildWiseTimeSaved(ctx context.Context, repoID, branchName string, minCreatedAt time.Time,
		maxCreatedAt time.Time, limit, offset int) ([]*BuildWiseTimeSaved, error)
}

BuildStore defines datastore operation for working with build

type BuildTag

type BuildTag string

BuildTag is used to tag build as Flaky, premerge, postmerge

const (
	PostMergeTag BuildTag = "postmerge"
	PreMergeTag  BuildTag = "premerge"
)

Build Tag values

type BuildWiseTimeSaved

type BuildWiseTimeSaved struct {
	BuildID           string  `json:"build_id" db:"build_id"`
	TimeAllTests      int     `json:"time_all_tests_ms" db:"time_all_tests_ms"`
	TimeImpactedTests int     `json:"time_impacted_tests_ms" db:"time_impacted_tests_ms"`
	TimeSaved         int     `json:"time_saved_ms" db:"time_saved_ms"`
	PercentTimeSaved  float64 `json:"percent_time_saved" db:"percent_time_saved"`
	NetTimeSaved      int     `json:"net_time_saved_ms" db:"net_time_saved_ms"`
}

BuildWiseTimeSaved represents information related to build wise time saved

type BuildsCreated

type BuildsCreated struct {
	Created  int    `json:"created_at"`
	BuildID  string `json:"build_id"`
	BuildTag string `json:"build_tag"`
}

BuildsCreated is wrapper for buildID and created_at date

type CommentService

type CommentService interface {
	// CreateIssueComment creates a comment on issue/PR.
	CreateIssueComment(ctx context.Context, gitProvider SCMDriver,
		issueNumber int, tokenPath, installationTokenPath, repoSlug, body string) error
	// CreateFlakyComment Creates a comment with ftm results on issue/PR
	CreateFlakyComment(ctx context.Context, buildCache *BuildCache,
		flakyMeta *FlakyExecutionMetadata, buildID string)
}

CommentService Create comments on issues/PRs

type CommitCntSinceLastPostMerge

type CommitCntSinceLastPostMerge struct {
	ID        string    `db:"id" json:"id"`
	RepoID    string    `db:"repo_id" json:"repo_id"`
	Branch    string    `db:"branch" json:"branch"`
	CommitCnt int       `db:"commit_cnt" json:"commit_cnt"`
	CreatedAt time.Time `db:"created_at" json:"-"`
	UpdatedAt time.Time `db:"updated_at" json:"-"`
}

CommitCntSinceLastPostMerge define commitcnt since last postmerge build

type CommitCntSinceLastPostMergeStore

type CommitCntSinceLastPostMergeStore interface {
	// CreateInTx  creates commitCntFromLastPostMerge in the datastore within specified transaction
	CreateInTx(ctx context.Context, tx *sqlx.Tx, commitCnt *CommitCntSinceLastPostMerge) error
	// FindInTx returns  commitCnt by repoid and branch name within specified transaction
	FindInTx(ctx context.Context, tx *sqlx.Tx, repoID string, branchName string) (*CommitCntSinceLastPostMerge, error)
}

CommitCntSinceLastPostMergeStore defines operations to store commitCnt by repoID and branch

type CommitDiff

type CommitDiff struct {
	Link string
}

CommitDiff contains link for comparison

type CommitDiscovery

type CommitDiscovery struct {
	ID        string          `db:"id"`
	RepoID    string          `db:"repo_id"`
	CommitID  string          `db:"commit_id"`
	TestIDs   json.RawMessage `db:"test_ids"`
	SuiteIDs  json.RawMessage `db:"suite_ids"`
	Created   time.Time       `db:"created_at"`
	Updated   time.Time       `db:"updated_at"`
	SubModule string          `db:"submodule"`
}

CommitDiscovery represents the tests and suites discovered in a commit.

type CommitDiscoveryStore

type CommitDiscoveryStore interface {
	// CreateInTx persists a the tests and suites discovered for a commit in the datastore and
	// executes the statements within the specified transaction
	CreateInTx(ctx context.Context, tx *sqlx.Tx, entity *CommitDiscovery) error
}

CommitDiscoveryStore defines datastore operation for working with commit_discovery store.

type CommitService

type CommitService interface {
	// Find returns the commit information by sha.
	Find(ctx context.Context, scmProvider SCMDriver, oauth *Token, repo, sha string) (*GitCommit, error)
}

CommitService provides access to the commit history from the external source code management service (e.g. GitHub).

type Committer

type Committer struct {
	Name  zero.String `db:"name"`
	Email zero.String `db:"email"`
	Date  zero.Time   `db:"date"`
}

Committer identifies a git commit commiter.

type CoverageInput

type CoverageInput struct {
	BuildID        string
	OrgID          string
	PayloadAddress string
}

CoverageInput represents the input for the repoqueue

type CoverageManager

type CoverageManager interface {
	// IsBaseCommitCoverageAvailable helps in determine whether coverageData is available or can be made available later
	IsBaseCommitCoverageAvailable(ctx context.Context, baseCommit string, repo *Repository) (bool, error)
	// CanRunCoverageImmediately checks if coverage job can be run immediately
	CanRunCoverageImmediately(ctx context.Context, baseCommit, repoID string) (bool, error)
	// RunCoverageJob runs the coverage job for a build
	RunCoverageJob(ctx context.Context, input *CoverageInput) error
	// InsertCoverageData performs post coverage-collection steps
	InsertCoverageData(ctx context.Context, data []*TestCoverage) error
	// RunPendingCoverageJobs finds and runs all the pending coverage jobs (recoverable jobs whose base commit's build coverage is recorded)
	RunPendingCoverageJobs(ctx context.Context) error
}

CoverageManager acts as a layer between the coverage APIs and coverage store that contains non-trivial business logic

type CreditsUsage

type CreditsUsage struct {
	ID            string    `db:"id" json:"-"`
	OrgID         string    `db:"org_id" json:"org_id"`
	User          string    `db:"user" json:"user"`
	TaskID        string    `db:"task_id" json:"task_id"`
	Created       time.Time `db:"created_at" json:"-"`
	Updated       time.Time `db:"updated_at" json:"-"`
	Consumed      int32     `json:"credits_consumed"`
	Tier          Tier      `json:"tier"`
	Duration      float64   `json:"duration"`
	MachineConfig string    `json:"machine_config"`
	CommitID      string    `json:"commit_id,omitempty"`
	BuildID       string    `json:"build_id,omitempty"`
	RepoName      string    `json:"repo_name,omitempty"`
	BuildTag      string    `json:"build_tag,omitempty"`
}

CreditsUsage represents information on how the credits were consumed by user of an organization

type CreditsUsageStore

type CreditsUsageStore interface {
	// CreateInTx persists the users credit usage in datastore and executes the statement in the specified transaction
	CreateInTx(ctx context.Context, tx *sqlx.Tx, usage *CreditsUsage) error
	// FindByOrgOrUser returns the credit usage from datastore by user or organization.
	FindByOrgOrUser(ctx context.Context, user, orgID string, startDate, endDate time.Time, offset, limit int) ([]*CreditsUsage, error)
	// FindTotalConsumedCredits returns the total consumed credit for an org with given timeline
	FindTotalConsumedCredits(ctx context.Context, orgID string, startDate, endDate time.Time) (int32, error)
}

CreditsUsageStore defines datastore operation for working with credits_usage

type DB

type DB interface {
	// Close closes the db connection.
	Close() error

	// ExecuteTransactionWithRetry wrapper for executing queries in a transaction and retries the transaction
	//  if transaction deadlock or transaction timeout.
	ExecuteTransactionWithRetry(
		ctx context.Context,
		maxRetries uint,
		delay,
		maxJitter time.Duration,
		errorMsg string,
		fn func(tx *sqlx.Tx) error) (err error)

	// Execute wrapper for executing the queries.
	Execute(fn func(conn *sqlx.DB) error) (err error)
}

DB represents the MySQL client

type DBStores

type DBStores struct {
	TestStore                        TestStore
	TestSuiteStore                   TestSuiteStore
	TestExecutionStore               TestExecutionStore
	TestSuiteExecutionStore          TestSuiteExecutionStore
	TestBranchStore                  TestBranchStore
	TestSuiteBranchStore             TestSuiteBranchStore
	DiscoveryStore                   DiscoveryStore
	ExecutionStore                   ExecutionStore
	OrgStore                         OrganizationStore
	RepoStore                        RepoStore
	UserStore                        GitUserStore
	EventStore                       GitEventStore
	CommitDiscoveryStore             CommitDiscoveryStore
	CommitStore                      GitCommitStore
	BranchStore                      BranchStore
	BranchCommitStore                BranchCommitStore
	BuildStore                       BuildStore
	TaskStore                        TaskStore
	CoverageStore                    TestCoverageStore
	LicenseStore                     LicenseStore
	CreditsUsageStore                CreditsUsageStore
	UserOrgStore                     UserOrgStore
	TaskQueueStore                   TaskQueueStore
	HookStore                        HookStore
	LoginStore                       LoginStore
	BuildCoverageStatusStore         BuildCoverageStatusStore
	PostMergeConfigStore             PostMergeConfigStore
	PostMergeStoreManager            PostMergeStoreManager
	CommitCntSinceLastPostMergeStore CommitCntSinceLastPostMergeStore
	EventQueueStore                  EventQueueStore
	SynapseStore                     SynapseStore
	FlakyConfigStore                 FlakyConfigStore
	FlakyTestStore                   FlakyTestStore
	BlockTestStore                   BlockTestStore
	FlakyExecutionStore              FlakyExecutionStore
	UserInfoStore                    UserInfoStore
	UserDemoStore                    UserDemoStore
}

DBStores contains collection of neuron dbstores

type DiscoveryStore

type DiscoveryStore interface {
	// Create persists the data in the datastore.
	Create(ctx context.Context,
		tests []*Test,
		testBranches []*TestBranch,
		suites []*TestSuite,
		suiteBranches []*TestSuiteBranch,
		commitDiscovery *CommitDiscovery) error
}

DiscoveryStore is wrapper for executing all the queries related to test discovery in a transaction.

type EmailNotificationManager

type EmailNotificationManager interface {
	// SendMailOnNewUserSignUp make api request to send email to new joinee, team notification, admin notification
	SendMailOnNewUserSignUp(ctx context.Context, user *GitUser, frontendURL string, orgs []*Organization) error
	// SendRepoNotification make api post request to send email to repo_admin on successful import of new repo
	SendRepoNotification(ctx context.Context, repo *Repository) error
	// UserDemoNotification make api post request to send email to TAS team when user take demo
	UserDemoNotification(ctx context.Context, user *UserInfoDemoDetails) error
	// SendBuildStatus sends email notification to repo admin on first successful (passed or failed) build
	SendBuildStatus(ctx context.Context, orgName, buildID,
		gitProvider, repoName, totalTests string, passedJob bool) error
	// OpenSourceUserNotification sends mail to TAS team in case open source user add details
	OpenSourceUserNotification(ctx context.Context, user *OpenSourceUserInfo) error
}

EmailNotificationManager has contracts for sendmail

type EventBlob

type EventBlob struct {
	EventID                    string       `json:"event_id"`
	BuildID                    string       `json:"build_id"`
	RepoID                     string       `json:"repo_id"`
	OrgID                      string       `json:"org_id"`
	RepoSlug                   string       `json:"repo_slug"`
	ForkSlug                   string       `json:"fork_slug,omitempty"`
	RepoLink                   string       `json:"repo_link"`
	BaseCommit                 string       `json:"build_base_commit"`
	TargetCommit               string       `json:"build_target_commit"`
	GitProvider                SCMDriver    `json:"git_provider"`
	PrivateRepo                bool         `json:"private_repo"`
	EventType                  EventType    `json:"event_type"`
	DiffURL                    string       `json:"diff_url,omitempty"`
	PullRequestNumber          int          `json:"pull_request_number,omitempty"`
	Commits                    []scm.Commit `json:"commits,omitempty"`
	TasFileName                string       `json:"tas_file_name"`
	ParentCommitCoverageExists bool         `json:"parent_commit_coverage_exists"`
	EventBody                  []byte       `json:"-"`
	RawToken                   []byte       `json:"-"`
	BranchName                 string       `json:"branch_name"`
	LicenseTier                Tier         `json:"license_tier"`
	CollectCoverage            bool         `json:"collect_coverage"`
}

EventBlob represents the azure blob storage object

type EventQueueStore

type EventQueueStore interface {
	// CreateInTx creates events in event_queue store.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, events ...*QueueableEvent) error
	// UpdateBulkInTx updates the given events in event_queue store
	UpdateBulkInTx(ctx context.Context, tx *sqlx.Tx, events ...*QueueableEvent) error
	// UpdateInTx updates the event in event_queue store and executes the query within the specified transaction.
	UpdateInTx(ctx context.Context, tx *sqlx.Tx, event *QueueableEvent) error
	// FindAndUpdateInTx find and update the  event in event_queue store and executes the query within the specified transaction.
	FindAndUpdateInTx(ctx context.Context, tx *sqlx.Tx, buildID string, eventType QueueableEventType,
		refEntityType RefEntityType, queueStatus QueueStatus) (bool, error)
	// UpdateBulkByIDInTx updates the status of events in event_queue store by ID and returns the number of rows affected
	UpdateBulkByIDInTx(ctx context.Context, tx *sqlx.Tx, status QueueStatus, eventIDs ...string) (int64, error)
	// FindByRefEntityIDInTx finds event uniquely identified by refEntityID, refEntityType and eventType
	FindByRefEntityIDInTx(ctx context.Context, tx *sqlx.Tx,
		eventType QueueableEventType, refEntityID string, refEntityType RefEntityType, readLock bool) (*QueueableEvent, error)
	// FindByOrgIDAndStatusInTx finds events for a given orgID with given status with or without read lock on relevant rows
	FindByOrgIDAndStatusInTx(ctx context.Context, tx *sqlx.Tx,
		orgID string, status QueueStatus, eventType QueueableEventType, readLock bool, limit int) ([]*QueueableEvent, error)
	// FetchStatusCountInTx fetches the ready and processing counts for given orgID
	FetchStatusCountInTx(ctx context.Context, tx *sqlx.Tx,
		orgID string, eventType QueueableEventType, readLock bool) (readyCount, processingCount int64, err error)
	// FetchStaleEventCountInTx returns org wise ready and processing tasks for
	// task events after timeout within specified transaction
	FetchStaleEventCountInTx(ctx context.Context, tx *sqlx.Tx,
		timeout time.Duration) ([]*StaleEvents, error)
	// FindOrgs fetches all organizations that have events in event_queue table for a given status and particular event_type
	FindOrgs(ctx context.Context, status QueueStatus, eventType QueueableEventType) ([]string, error)
	// StopStaleEventsInTx marks the events as failed after timeout within specified transaction.
	StopStaleEventsInTx(ctx context.Context, tx *sqlx.Tx, timeout time.Duration) (int64, error)
}

EventQueueStore defines datastore operation for working with event_queue data-store.

type EventType

type EventType string

EventType represents the webhook event

const (
	// EventPush represents the push event.
	EventPush EventType = "push"
	// EventPullRequest represents the pull request event.
	EventPullRequest EventType = "pull-request"
	// EventPing represents the ping event.
	EventPing EventType = "ping"
)

type ExecutionMeta

type ExecutionMeta struct {
	Total             int     `json:"total_tests_executed"`
	Passed            int     `json:"tests_passed"`
	Blocklisted       int     `json:"tests_blocklisted"`
	Quarantined       int     `json:"tests_quarantined"`
	Skipped           int     `json:"tests_skipped"`
	Failed            int     `json:"tests_failed"`
	Aborted           int     `json:"tests_aborted"`
	TotalTestDuration int     `json:"total_test_duration"`
	AvgTestDuration   float64 `json:"avg_test_duration"`
	TotalTests        int     `json:"total_tests"`
	Unimpacted        int     `json:"tests_unimpacted"`
	Completed         int     `json:"tests_completed"`
	Flaky             int     `json:"flaky_tests"`
	NonFlaky          int     `json:"non_flaky_tests"`
}

ExecutionMeta contains additional info of the tests executed

type ExecutionResult

type ExecutionResult struct {
	TestPayload      []TestPayload      `json:"testResults"`
	TestSuitePayload []TestSuitePayload `json:"testSuiteResults"`
}

ExecutionResult contains test results

type ExecutionStore

type ExecutionStore interface {
	// Create persists the data in the datastore.
	Create(ctx context.Context,
		testExecutions []*TestExecution,
		testSuiteExecutions []*TestSuiteExecution,
		buildID string) error
}

ExecutionStore is wrapper for executing all the queries related to execution in a transaction.

type FlakyAlgo

type FlakyAlgo string

FlakyAlgo is a type of Algo

const (
	// RunningXTimes is a flaky algo
	RunningXTimes FlakyAlgo = "running_x_times"
)

type FlakyConfig

type FlakyConfig struct {
	Org             string          `json:"org,omitempty"`
	Repo            string          `json:"repo,omitempty"`
	ID              string          `db:"id" json:"id"`
	RepoID          string          `db:"repo_id" json:"repo_id"`
	Branch          string          `db:"branch" json:"branch"`
	IsActive        bool            `db:"is_active" json:"is_active"`
	AutoQuarantine  bool            `db:"auto_quarantine" json:"auto_quarantine"`
	ConfigType      FlakyConfigType `db:"config_type" json:"config_type"`
	AlgoName        FlakyAlgo       `db:"algo_name" json:"algo_name"`
	ConsecutiveRuns int             `db:"consecutive_runs" json:"consecutive_runs"`
	Threshold       int             `db:"threshold" json:"threshold"`
	CreatedAt       time.Time       `db:"created_at" json:"-"`
	UpdatedAt       time.Time       `db:"updated_at" json:"-"`
}

FlakyConfig defines flaky config

type FlakyConfigStore

type FlakyConfigStore interface {
	// Create persists a new postmergeconfig in the datastore
	Create(ctx context.Context, flakyConfig *FlakyConfig) error
	// Update updates existing flakyconfig in the datastore
	Update(ctx context.Context, flakyConfig *FlakyConfig) error
	// FindIfActiveConfigExists checks if there is an active config for given branch, repo and config type
	FindIfActiveConfigExists(ctx context.Context,
		repoID, branchName string, configType FlakyConfigType) (err error)
	// FindActiveFlakyConfig returns active flakyconfig by repoid and branch name
	FindActiveFlakyConfig(ctx context.Context, repoID string,
		branchName string, configType FlakyConfigType) (flakyConfig *FlakyConfig, err error)
	// FindAllFlakyConfig returns all flakyconfig by repoID
	FindAllFlakyConfig(ctx context.Context, repoID string) (flakyConfigList []*FlakyConfig, sqlErr error)
}

FlakyConfigStore has datastore operations contracts for flakyconfig table

type FlakyConfigType

type FlakyConfigType string

FlakyConfigType defines type of flaky config

const (
	FlakyConfigPostMerge FlakyConfigType = "postmerge"
	FlakyConfigPreMerge  FlakyConfigType = "premerge"
)

const defines all flaky config

type FlakyExecutionMetadata

type FlakyExecutionMetadata struct {
	ImpactedTests      int       `json:"impacted_tests"`
	FlakyTests         int       `json:"flaky_tests"`
	OverAllFlakiness   float32   `json:"overall_flakiness"`
	Blocklisted        int       `json:"tests_blocklisted"`
	Skipped            int       `json:"tests_skipped"`
	Failed             int       `json:"tests_failed"`
	Aborted            int       `json:"tests_aborted"`
	Quarantined        int       `json:"tests_quarantined"`
	NonFlakyTests      int       `json:"tests_nonflaky"`
	JobsCount          int       `json:"jobs_count"`
	FirstFlakeID       string    `json:"first_flake_id"`
	FirstFlakeTime     time.Time `json:"first_flake_time"`
	LastFlakeID        string    `json:"last_flake_id"`
	LastFlakeTime      time.Time `json:"last_flake_time"`
	LastFlakeStatus    string    `json:"last_flake_status"`
	FirstFlakeCommitID string    `json:"first_flake_commit_id"`
	LastFlakeCommitID  string    `json:"last_flake_commit_id"`
}

FlakyExecutionMetadata stores execution metadata for flaky_build

type FlakyExecutionStore

type FlakyExecutionStore interface {
	// Create persists the data in the datastore.
	Create(ctx context.Context,
		FlakyTestExecution []*FlakyTestExecution,
		blockTests []*BlockTest,
		buildID string) error
}

FlakyExecutionStore is wrapper for executing all the queries related to flakyexecution in a transaction.

type FlakyTaskBuilder

type FlakyTaskBuilder interface {
	// CreateFlakyTask creates flaky task and insert them in queue
	CreateFlakyTask(ctx context.Context, build *BuildCache, lastExecTask *Task, flakyConfig *FlakyConfig, orgID string) error
}

FlakyTaskBuilder defines all the operation performed to create and enqueue the flaky task

type FlakyTestExecution

type FlakyTestExecution struct {
	ID              string                       `db:"id" json:"-"`
	TestID          string                       `db:"test_id" json:"test_id,omitempty"`
	AlgoName        FlakyAlgo                    `db:"algo_name" json:"algo_name,omitempty"`
	ExecInfo        string                       `db:"exec_info" json:"-"`
	Status          TestExecutionStatus          `db:"status" json:"status,omitempty"`
	BuildID         string                       `db:"build_id" json:"build_id,omitempty"`
	TaskID          string                       `db:"task_id" json:"-"`
	CreatedAt       time.Time                    `db:"created_at" json:"-"`
	UpdatedAt       time.Time                    `db:"updated_at" json:"-"`
	TestName        string                       `json:"test_name,omitempty"`
	TestResults     []TestExecutionStatus        `json:"test_results,omitempty"`
	FlakyRate       float32                      `json:"flaky_rate"`
	ExecutionInfo   *AggregatedFlakyTestExecInfo `json:"-"`
	TestMeta        *FlakyExecutionMetadata      `json:"execution_meta,omitempty"`
	TestSuiteName   zero.String                  `json:"test_suite_name,omitempty"`
	TestSuiteID     zero.String                  `json:"test_suite_id,omitempty"`
	ExecutionStatus TestExecutionStatus          `json:"execution_status,omitempty"`
	FileName        string                       `json:"file_name,omitempty"`
}

FlakyTestExecution represents flaky test execution results

type FlakyTestStore

type FlakyTestStore interface {
	// FindTests gives test details for all tests
	FindTests(ctx context.Context, buildID, taskID string,
		statusFilter, executionStatusFilter, searchText string, offset, limit int) ([]*FlakyTestExecution, error)
	// CreateInTx persists a new flaky test in the datastore.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, FlakyTestExecutionResults []*FlakyTestExecution) error
	// MarkTestsToStableInTx marks quarantined tests to non flaky
	MarkTestsToStableInTx(ctx context.Context, tx *sqlx.Tx, buildID string) (int64, error)
	// FindTestsInJob gives the total flaky tests in a particular job.
	FindTestsInJob(ctx context.Context, repoName, orgID, branchName string,
		startDate, endDate time.Time) ([]*FlakyTestExecution, error)
	// ListFlakyTests return the total flaky tests in a particular job.
	ListFlakyTests(ctx context.Context, repoName, orgID, branchName string,
		startDate, endDate time.Time, offset, limit int) ([]*FlakyTestExecution, error)
}

FlakyTestStore defines datastore operation for working with Flakytest execution

type GitCommit

type GitCommit struct {
	ID             string                  `json:"id,omitempty" db:"id"`
	CommitID       string                  `json:"commit_id" db:"commit_id"`
	ParentCommitID string                  `json:"-" db:"parent_commit_id"`
	Message        string                  `json:"message" db:"message"`
	RepoID         string                  `json:"-" db:"repo_id"`
	Created        time.Time               `json:"created_at" db:"created_at"`
	Updated        time.Time               `json:"-" db:"updated_at"`
	Link           string                  `json:"link" db:"link"`
	Author         Author                  `json:"author" db:"author"`
	Committer      Committer               `json:"committer" db:"committer"`
	TestsAdded     int                     `json:"tests_added"`
	LatestBuild    *Build                  `json:"latest_build,omitempty"`
	Status         string                  `json:"status,omitempty"`
	Coverage       *TestCoverage           `json:"coverage,omitempty"`
	TestMeta       *ExecutionMeta          `json:"execution_meta,omitempty"`
	FlakyMeta      *FlakyExecutionMetadata `json:"flaky_execution_meta,omitempty"`
	Meta           *TaskMeta               `json:"task_meta,omitempty"`
	BuildID        string                  `json:"build_id,omitempty"`
	BuildNum       int                     `json:"build_num,omitempty"`
	BuildTag       string                  `json:"build_tag,omitempty"`
	Graph          []int                   `json:"contributor_graph,omitempty"`
	Branch         string                  `json:"branch,omitempty"`
	CommitDiffURL  string                  `json:"commit_diff_url,omitempty"`
}

GitCommit represents a git commit.

type GitCommitStore

type GitCommitStore interface {
	// CreateInTx persists a new commit to the datastore and executes the statement within supplied transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, commits []*GitCommit) error
	// FindByCommitID checks if commit exists in the datastore.
	FindByCommitID(ctx context.Context, commitID, repoID string) (string, error)
	// FindByCommitIDTx checks if commit exists in the datastore in transaction.
	FindByCommitIDTx(ctx context.Context, tx *sqlx.Tx, commitID, repoID string) (string, error)
	// FindByRepo returns all the commits for a repo.
	FindByRepo(ctx context.Context, repoName, orgID, commitID, buildID,
		branchName, orgName, gitProvider, statusFilter, searchText string, authorsNames []string,
		offset, limit int) ([]*GitCommit, error)
	// FindImpactedTests returns all the  tests impacted by the commit.
	FindImpactedTests(ctx context.Context, commitID, buildID, taskID, repoName, orgID, statusFilter, searchText, branchName string,
		offset, limit int) ([]*TestExecution, error)
	// FindAuthors returns the author of each commit of the repository.
	FindAuthors(ctx context.Context, repoName, orgID, branchName, author, nextAuthor string, limit int) ([]*GitCommit, error)
	// FindAuthorCommitActivity returns the commit author activity of the repository.
	FindAuthorCommitActivity(ctx context.Context, repoName, orgID, nextAuthor string, limit int) (map[string]map[int]int, string, error)
	// FindByBuild returns all the commits that are there for a particular build ID.
	FindByBuild(ctx context.Context, repoName, orgID, buildID string, offset, limit int) ([]*GitCommit, error)
	// FindCommitStatus returns the status of latest `limit` commits.
	FindCommitStatus(ctx context.Context, repoName, orgID, branchName string, limit int) ([]*GitCommit, error)
	// FindCommitMeta returns the commit meta of all the commits
	FindCommitMeta(ctx context.Context, repoName, orgID, branchName string) ([]*TaskMeta, error)
	// FindContributoGraph returns the commit meta of all the commits
	FindContributorGraph(ctx context.Context, repoName, orgID, branchName string) ([]*GitCommit, error)
	// FindAuthorStats returns the stats of the author in the contributors section
	FindAuthorStats(ctx context.Context, repoName, orgID, branchName, author string, startDate, endDate time.Time) (*AuthorStats, error)
	// FindTransitions finds the number of transitions of the tests in a particular duration
	FindTransitions(ctx context.Context, repoName, orgID, branchName, author string, startDate, endDate time.Time) (int, error)
}

GitCommitStore defines datastore operation for working with git_commits.

type GitEvent

type GitEvent struct {
	ID                string          `db:"id"`
	RepoID            string          `db:"repo_id"`
	EventName         EventType       `db:"event_name"`
	ChangeList        null.String     `db:"change_list"`
	CommitID          string          `db:"commit_id"`
	GitProviderHandle SCMDriver       `db:"git_provider_handle"`
	EventPayload      json.RawMessage `db:"event_payload"`
	Response          null.String     `db:"response"`
	StatusCode        null.Int        `db:"status_code"`
	Created           time.Time       `db:"created_at"`
	Updated           time.Time       `db:"updated_at"`
}

GitEvent represents the git webhook event.

type GitEventStore

type GitEventStore interface {
	// Create persists a new git event to the datastore and executes the statement within supplied transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, event *GitEvent) error
	// FindByBuildID returns git event for a build.
	FindByBuildID(ctx context.Context, buildID string) (*GitEvent, error)
}

GitEventStore defines datastore operation for working with git_events

type GitLoginProvider

type GitLoginProvider interface {
	// Get returns the login middleware based on the type of scm provider (eg. github)
	Get(clientID SCMDriver) (login.Middleware, error)
}

GitLoginProvider returns a git authenticator middleware

type GitStatus

type GitStatus struct {
	Status   BuildStatus
	CommitID string
}

GitStatus is the git scm status which will be updated using APIs.

type GitStatusService

type GitStatusService interface {
	// UpdateGitStatus updates status on Git SCM provider.
	UpdateGitStatus(ctx context.Context, gitProvider SCMDriver, repoSlug, buildID, commitID, tokenPath, installationTokenPath string,
		status BuildStatus, buildTag BuildTag) error
}

GitStatusService sends the commit status to an external git SCM provider.

type GitTokenHandler

type GitTokenHandler interface {
	// GetToken returns a valid token for given args
	GetToken(ctx context.Context, getInstallation bool,
		gitProvider SCMDriver, k8namespace, orgName, mask, id string) (token *Token, tokenRefreshed bool, err error)
	// GetTokenFromPath returns a valid token for given token path
	GetTokenFromPath(ctx context.Context, gitProvider SCMDriver,
		tokenPath, installationTokenPath string) (token *Token, tokenRefreshed bool, err error)
	// UpdateInstallationToken updates installation token in vault
	UpdateInstallationToken(gitProvider SCMDriver, k8namespace, orgName string, token *Token) error
	// UpdateTokenInVault updates oauth token in vault
	UpdateTokenInVault(tokenPath string, token *Token) error
}

GitTokenHandler handles git token related things

type GitUser

type GitUser struct {
	ID          string    `db:"id"`
	GitProvider SCMDriver `db:"git_provider"`
	Username    string    `db:"username"`
	Avatar      string    `db:"avatar"`
	Email       string    `db:"email"`
	Created     time.Time `db:"created_at"`
	Updated     time.Time `db:"updated_at"`
	Mask        string    `db:"mask"`
	Oauth       Token
}

GitUser represents the git scm user

type GitUserService

type GitUserService interface {
	// Find returns the authenticated user.
	Find(ctx context.Context, driver SCMDriver, loginToken *login.Token) (*GitUser, error)
}

GitUserService provides access to user account resources in the remote system (e.g. GitHub,GitLab).

type GitUserStore

type GitUserStore interface {
	// Create persists a new user to the datastore.
	Create(ctx context.Context, user *GitUser) error
	// CreateInTx persists a new user to the datastore and executes the statement within the transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, user *GitUser) error
	// Find returns a user from the datastore.
	Find(ctx context.Context, username string, gitProvider SCMDriver) (*GitUser, error)
	// FindByID returns a user from the datastore by userID.
	FindByID(ctx context.Context, userID string) (*GitUser, error)
	// FindByOrg returns a user from the datastore by organization.
	FindByOrg(ctx context.Context, userID string, orgName string) (*GitUser, string, error)
	// FindUserTasUsageInfo finds the total usage of tas for a user
	FindUserTasUsageInfo(ctx context.Context, orgID, userID string) ([]*AuthorMeta, error)
	// FindAdminByOrgNameAndGitProvider finds the admin user of org using orgName and GitProvider
	FindAdminByOrgNameAndGitProvider(ctx context.Context, orgName, gitProvider string) (*GitUser, error)
	// FindAdminByBuildID finds admin's name & email from git_users table of the repo by using buildID
	FindAdminByBuildID(ctx context.Context, buildID string) (*GitUser, error)
}

GitUserStore defines datastore operation for working with gitusers

type GithubApp

type GithubApp interface {
	// GetInstallation returns installation data (organization name and installation token)
	GetInstallation(installationID string) (string, *Token, error)
	// GetInstallationToken returns installation token for particular installation ID(Org)
	GetInstallationToken(installationID string) (string, *Token, error)
}

GithubApp hanldes operation related to github apps

type HookParser

type HookParser interface {
	// CreateAndScheduleBuild parses the webhook and creates a build and queues the build/
	CreateAndScheduleBuild(eventType EventType, driver SCMDriver, repoID string, msg []byte) error
}

HookParser parses the webhook from the source code management system.

type HookService

type HookService interface {
	// Create a new git scm webhook
	Create(ctx context.Context, token *Token, gitProvider SCMDriver, repo *Repository) error
	// Delete a git scm webhook
	Delete(ctx context.Context, user *GitUser, repo *Repository, token *Token) error
}

HookService manages post-commit hooks in the external source code management service (e.g. GitHub).

type HookStore

type HookStore interface {
	// CreateEntities persists the webhook related data in the datastore and
	// check if build can be created
	CreateEntities(ctx context.Context, payload *ParserResponse) (createBuild bool, err error)
	// CreateBuild creates a new build  and tasks in the datastore.
	CreateBuild(ctx context.Context, payloadAddress string, payload *ParserResponse) (*Job, error)
}

HookStore is wrapper for executing all the queries related to a webhook event in a transaction.

type InputLocatorConfig

type InputLocatorConfig struct {
	Locators []LocatorConfig `json:"locators"`
}

type IrregularTests

type IrregularTests struct {
	TestID            string    `json:"test_id" db:"test_id"`
	TestName          string    `json:"test_name" db:"name"`
	SlowBuildID       string    `json:"slow_build_id" db:"slow_build_id"`
	FastBuildID       string    `json:"fast_build_id" db:"fast_build_id"`
	SlowCommitID      string    `json:"slow_commit_id" db:"slow_commit_id"`
	FastCommitID      string    `json:"fast_commit_id" db:"fast_commit_id"`
	SlowExecutionTime time.Time `json:"slow_execution_time" db:"slow_execution_time"`
	FastExecutionTime time.Time `json:"fast_execution_time" db:"fast_execution_time"`
	SlowDuration      uint64    `json:"slow_duration" db:"slow_duration"`
	FastDuration      uint64    `json:"fast_duration" db:"fast_duration"`
}

IrregularTests represents the tests whose execution time differs by more than 1.5 times

type Job

type Job struct {
	ID      string      `json:"id"`
	Status  QueueStatus `json:"status"`
	OrgID   string      `json:"org_id"`
	TaskID  string      `json:"task_id"`
	Created time.Time   `json:"created_at"`
	Updated time.Time   `json:"updated_at"`
}

Job represents the item queued in task queue.

func FromQueueableEventToJob

func FromQueueableEventToJob(event *QueueableEvent) *Job

FromQueueableEventToJob is utility function to convert a QueueableEvent to Job

func (*Job) ToQueueableEvent

func (j *Job) ToQueueableEvent() *QueueableEvent

ToQueueableEvent is utility function to convert a Job to QueueableEvent

type JobInfo

type JobInfo struct {
	Status  StatusType `json:"status"`
	JobID   string     `json:"job_id"`
	ID      string     `json:"id"`
	Mode    string     `json:"mode"`
	BuildID string     `json:"build_id"`
	Message string     `json:"message"`
}

JobInfo stuct for job updates info

type JobView

type JobView string
const (
	DefaultView JobView = "default"
	FtmOnlyView JobView = "ftm_only"
)

type K8sRunner

type K8sRunner interface {

	// Init the resources required for the execution engine.
	Init(ctx context.Context, r *RunnerOptions, payload *ParserResponse) error

	// Run runs the execution engine.
	Run(ctx context.Context, r *RunnerOptions) error

	// Destroy the execution engine.
	Destroy(ctx context.Context, r *RunnerOptions) error

	// Cleanup the resources required for the execution engine.
	Cleanup(ctx context.Context, r *RunnerOptions) error

	// CreateNamespace create a new k8 namespace
	CreateNamespace(ctx context.Context, l *License) error

	// CreateSecret creates a new k8s secret.
	CreateSecret(ctx context.Context, namespace, secretName string, secretType UserSecretType, data []byte) error

	// DeleteSecret deletes a k8s secret.
	DeleteSecret(ctx context.Context, namespace, secretName string) error

	// UpdateSecret updates a k8s secret.
	UpdateSecret(ctx context.Context, namespace, secretName string, secretKey UserSecretType, data []byte) error

	// CreatePersistentVolumeClaim create the persistent volume claim.
	CreatePersistentVolumeClaim(ctx context.Context, r *RunnerOptions, license *License) error

	// DeletePersistentVolumeClaim delete the persistent volume claim.
	DeletePersistentVolumeClaim(ctx context.Context, r *RunnerOptions) error

	// Spawn creates and runs the pod in k8s.
	Spawn(ctx context.Context, runnerOptions *RunnerOptions, buildID, taskID string) <-chan error

	// WaitForPodTermination waits for pods to get terminated before spawning next one.
	WaitForPodTermination(ctx context.Context, podName, podNamespace string) error
}

K8sRunner is the interface that must be implemented by an execution engine.

type License

type License struct {
	ID             string      `db:"id"`
	Type           LicenseType `db:"type" json:"license_type"`
	OrgID          string      `db:"org_id" json:"org_id" binding:"required"`
	CreditsBought  int64       `db:"credits_bought" json:"credits_bought"`
	CreditsBalance int64       `db:"credits_balance"`
	CreditsExpiry  time.Time   `db:"credits_expiry" json:"credits_expiry"`
	Concurrency    int64       `db:"concurrency" json:"concurrency"`
	Tier           Tier        `db:"tier" json:"tier"`
	Created        time.Time   `db:"created_at"`
	Updated        time.Time   `db:"updated_at"`
}

License represents information pertaining to license given to an org

type LicenseStore

type LicenseStore interface {
	// Create persists a new license in the datastore.
	Create(ctx context.Context, l *License) error
	// Find returns a license from the datastore.
	Find(ctx context.Context, orgID string) (*License, error)
	// FindInTx returns a license from the datastore and executes the statement in the given transaction.
	FindInTx(ctx context.Context, tx *sqlx.Tx, orgID string) (license *License, err error)
	// Update the license info in the datastore.
	Update(ctx context.Context, l *License) error
	// CreateInTx creates the new license in datastore.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, orgz []*Organization) error
}

LicenseStore defines datastore operation for working with license

type LicenseType

type LicenseType string

LicenseType specifies the type of the License

const (
	Basic      LicenseType = "Basic"
	Teams      LicenseType = "Teams"
	Enterprise LicenseType = "Enterprise"
)

LicenseType values.

type LocatorConfig

type LocatorConfig struct {
	Locator string `json:"locator"`
}

type LoginDetails

type LoginDetails struct {
	Name           string  `json:"name"`
	SynapseID      string  `json:"synapse_id"`
	SecretKey      string  `json:"secret_key"`
	CPU            float32 `json:"cpu"`
	RAM            int64   `json:"ram"`
	SynapseVersion string  `json:"synapse_version"`
}

LoginDetails struct

type LoginStore

type LoginStore interface {
	// Create persists the data in the datastore.
	Create(ctx context.Context, user *GitUser, userExists bool, orgs ...*Organization) error
	// UpdateOrgList  updates the org list in db
	UpdateOrgList(ctx context.Context, user *GitUser, orgs []*Organization) ([]*Organization, error)
}

LoginStore is wrapper for executing all the queries related to a webhook event in a transaction.

type Message

type Message struct {
	Type    MessageType `json:"type"`
	Content []byte      `json:"content"`
	Success bool        `json:"success"`
}

Message struct

type MessageType

type MessageType string

MessageType defines type of message

const (
	MsgLogin         MessageType = "login"
	MsgLogout        MessageType = "logout"
	MsgTask          MessageType = "task"
	MsgInfo          MessageType = "info"
	MsgError         MessageType = "error"
	MsgResourceStats MessageType = "resourcestats"
	MsgJobInfo       MessageType = "jobinfo"
)

types of messages

type MonthWiseNetTests

type MonthWiseNetTests struct {
	MonthNo    int    `json:"month" db:"month"`
	MonthName  string `json:"month_name" db:"month_name"`
	Year       int    `json:"year" db:"year"`
	TotalTests uint64 `json:"total_tests" db:"total_tests"`
}

MonthWiseNetTests represents tests found for a repo in a month

type MttfAndMttr

type MttfAndMttr struct {
	MTTF      int64       `json:"mttf_in_sec" db:"-"`
	MTTR      int64       `json:"mttr_in_sec" db:"-"`
	Status    BuildStatus `json:"-" db:"status"`
	TimeStamp time.Time   `json:"-" db:"created_at"`
}

MttfAndMttr defines data related to mean time to failure and mean time to recovery of jobs

type OpenSourceUserInfo

type OpenSourceUserInfo struct {
	FirstName   string `json:"first_name" binding:"required"`
	LastName    string `json:"last_name"`
	EmailID     string `json:"email_id" binding:"required"`
	Link        string `json:"repository_link" binding:"required"`
	Description string `json:"description"`
}

OpenSourceUserInfo is a request body of a open source user

type OrgDetailsCache

type OrgDetailsCache struct {
	QueuedTasks      int    `redis:"queued_tasks"`
	RunningTasks     int    `redis:"running_tasks"`
	TotalConcurrency int    `redis:"total_concurrency"`
	RunnerType       string `redis:"runner_type"`
}

OrgDetailsCache details related to a particular org, is cached in redis

type Organization

type Organization struct {
	ID          string      `json:"id" db:"id"`
	Name        string      `json:"name" db:"name"`
	Avatar      string      `json:"avatar" db:"avatar"`
	GitProvider SCMDriver   `json:"git_provider" db:"git_provider"`
	Created     time.Time   `json:"-" db:"created_at"`
	Updated     time.Time   `json:"-"  db:"updated_at"`
	SecretKey   zero.String `json:"synapse_key" db:"secret_key"`
	RunnerType  Runner      `json:"runner_type" db:"runner_type"`
}

Organization represents a git organization

type OrganizationService

type OrganizationService interface {
	// List returns a list of organization to which the
	// user is a member.
	List(context.Context, SCMDriver, *GitUser, *Token) ([]*Organization, error)
	// GetOrganization returns org details for an org name
	GetOrganization(ctx context.Context, driver SCMDriver, user *GitUser, t *Token, orgName string) (*Organization, error)
}

OrganizationService provides access to organization and team access in the external source code management system (e.g. GitHub).

type OrganizationStore

type OrganizationStore interface {
	// Create persists a new organization in datastore.
	Create(ctx context.Context, orgs []*Organization) error
	// CreateInTx persists a new organization in datastore and executes the statement within the transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, orgs []*Organization) error
	// FindOrCreate finds if organization exists otherwise creates a new organization.
	FindOrCreate(ctx context.Context, orgs *Organization) (string, error)
	// Find returns the organization in the datastore.
	Find(ctx context.Context, org *Organization) (string, error)
	// FindRunnerType returns the runner type of the organization in the datastore.
	FindRunnerType(ctx context.Context, orgID string) (Runner, error)
	// FindOrgsByNameTx finds the organizations in the datastore by name and executes the statement within the transaction.
	FindOrgsByNameTx(ctx context.Context, tx *sqlx.Tx, gitProvider SCMDriver, orgs []*Organization) ([]*Organization, error)
	// FindUserOrgs returns the user's organizations.
	FindUserOrgs(ctx context.Context, userID string) ([]*Organization, error)
	// FindUserOrgsTx returns the user's organizations and executes the statement within the transaction.
	FindUserOrgsTx(ctx context.Context, tx *sqlx.Tx, userID string) ([]*Organization, error)
	// FindByID returns the organization by the ID.
	FindByID(ctx context.Context, orgID string) (*Organization, error)
	// GetOrgCache returns the org concurrency details in cache.
	GetOrgCache(ctx context.Context, orgID string) (*OrgDetailsCache, error)
	// UpdateKeysInCache updates the org concurrency details in cache.
	UpdateKeysInCache(ctx context.Context, orgID string, concurrencyKeys map[string]int64) error
	// UpdateConfigInfo updates the org config info
	UpdateConfigInfo(ctx context.Context, orgID, secretKey, runnerType string) error
	// UpdateSynapseInfo updates the org synapse info
	UpdateSynapseToken(ctx context.Context, orgID, secretKey, token string) error
	// FindBySecretKey returns the organization by the secretKey.
	FindBySecretKey(ctx context.Context, secretKey string) (*Organization, error)
}

OrganizationStore defines operations for working with organizations.

type ParserResponse

type ParserResponse struct {
	Repository            *Repository
	EventBlob             *EventBlob
	GitCommits            []*GitCommit
	License               *License
	RunnerType            Runner
	SecretPath            string
	TokenPath             string
	InstallationTokenPath string
	Rebuild               bool
	BuildTag              BuildTag
}

ParserResponse response after extracting details from webhook

type Payloadresponse

type Payloadresponse struct {
	PullRequests *CommitDiff `json:"PullRequest"`
	Commit       *CommitDiff `json:"Commit"`
}

Payloadreponse contains information related to diff

type Perm

type Perm struct {
	Read  bool `db:"perm_read"     json:"read"`
	Write bool `db:"perm_write"    json:"write"`
	Admin bool `db:"perm_admin"    json:"admin"`
}

Perm represents the user' s repository permissions

type PodType

type PodType string

PodType specifies the type of pod

const (
	NucleusPod  PodType = "nucleus"
	CoveragePod PodType = "coverage"
)

Values that PodType can take

type PostMergeConfig

type PostMergeConfig struct {
	ID           string                `db:"id" json:"id"`
	Repo         string                `json:"repo"`
	Org          string                `json:"org"`
	RepoID       string                `db:"repo_id" json:"-"`
	Branch       string                `db:"branch" json:"branch"`
	IsActive     bool                  `db:"is_active" json:"is_active"`
	StrategyName PostMergeStrategyName `db:"strategy_name" json:"strategy_name"`
	Threshold    string                `db:"threshold" json:"threshold"`
	CreatedAt    time.Time             `db:"created_at" json:"-"`
	UpdatedAt    time.Time             `db:"updated_at" json:"-"`
}

PostMergeConfig defines postmerge config

type PostMergeConfigStore

type PostMergeConfigStore interface {
	// Create persists a new postmergeconfig in the datastore
	Create(ctx context.Context, postMergeConfig *PostMergeConfig) error
	// Update updates existing postmergeconfig in the datastore
	Update(ctx context.Context, postMergeConfig *PostMergeConfig) error
	// FindActivePostMergeConfigInTx returns active postmergeconfig by repoid and branch name within specified transaction
	FindActivePostMergeConfigInTx(ctx context.Context, tx *sqlx.Tx, repoID string,
		branchName string) (postMergeConfig *PostMergeConfig, err error)
	// FindAllPostMergeConfig returns all postmergeconfig by repoID
	FindAllPostMergeConfig(ctx context.Context, repoID string) (postMergeConfigList []*PostMergeConfig, sqlErr error)
}

PostMergeConfigStore has datastore operations contracts for postmergeconfig table

type PostMergeStoreManager

type PostMergeStoreManager interface {
	// FindAndUpdateInTx finds postmerge config in db and  checks strategy threshold
	// and update commit cnt in commitcnt store and runs the queries in same transaction
	FindAndUpdateInTx(ctx context.Context, tx *sqlx.Tx, repoID, branch string,
		commitCnt int) (postMergeConfig *PostMergeConfig, thresholdMet bool, err error)
}

PostMergeStoreManager defines operations on postmergeconfig and commitCnt

type PostMergeStrategyName

type PostMergeStrategyName string

PostMergeStrategyName is a strategy name

const (
	// AfterNCommitStrategy is commit strategy name
	AfterNCommitStrategy PostMergeStrategyName = "after_n_commits"
)

type PostProcessingQueuePayload

type PostProcessingQueuePayload struct {
	OrgID          string `json:"org_id"`
	BuildID        string `json:"build_id"`
	BaseCommitID   string `json:"base_commit_id"`
	RepoID         string `json:"repo_id"`
	PayloadAddress string `json:"payload_address"`
}

PostProcessingQueuePayload represents the payload for item in post processing queue.

type PullRequestService

type PullRequestService interface {
	// Find returns pullrequest object by prNumber.
	Find(ctx context.Context, scmProvider SCMDriver, oauth *Token, reposlug string, prNumber int) (*scm.PullRequest, error)
}

PullRequestService provides pullrequest object

type QueueConsumer

type QueueConsumer interface {
	// Run runs the queue consumer in background.
	Run(ctx context.Context)
	// Close closes the queue consumer
	Close() error
}

QueueConsumer represents the queue consumer.

type QueueProducer

type QueueProducer interface {
	// Enqueue inserts payload in queue.
	Enqueue(payload interface{}) error
	// Close closes the queue producer.
	Close() error
}

QueueProducer represents the queue producer.

type QueueStatus

type QueueStatus string

QueueStatus represents the status of tasks in queue.

const (
	Ready      QueueStatus = "ready"
	Processing QueueStatus = "processing"
	Completed  QueueStatus = "completed"
	Failed     QueueStatus = "failed"
	Aborted    QueueStatus = "aborted"
)

List of task queue statuses

type QueueableEvent

type QueueableEvent struct {
	ID            string             `db:"id"`
	Status        QueueStatus        `db:"status"`
	OrgID         string             `db:"org_id"`
	Type          QueueableEventType `db:"event_type" validate:"omitempty,oneof=task"`
	RefEntityID   string             `db:"ref_entity_id"`
	RefEntityType RefEntityType      `db:"ref_entity_type" validate:"omitempty,oneof=task"`
	Created       time.Time          `db:"created_at"`
	Updated       time.Time          `db:"updated_at"`
}

QueueableEvent represents a singular event that can be DB backed queued

type QueueableEventType

type QueueableEventType string

QueueableEventType represents the type of queueable event

const (
	TaskEvent QueueableEventType = "task"
)

QueableEventType values exhaustive set

type RedisDB

type RedisDB interface {
	// Client is the redis client
	Client() redis.UniversalClient
}

RedisDB wrapper around the redis db client.

type RefEntityType

type RefEntityType string

RefEntityType represents the type of entity being queued as a queueable event

const (
	RefEntityTaskType RefEntityType = "task"
)

RefEntityType values exhaustive set

type RepoMeta

type RepoMeta struct {
	TotalTests int `json:"total_tests"`
	*BuildMeta
}

RepoMeta contains additional info of the builds

type RepoSecretItem

type RepoSecretItem struct {
	Value   string    `json:"value"`
	Updated time.Time `json:"updated_at"`
}

type RepoSettingsInfo

type RepoSettingsInfo struct {
	OrgName        string  `json:"org,omitempty"`
	RepoName       string  `json:"repo,omitempty"`
	Strict         bool    `json:"strict"`
	ConfigFileName string  `json:"config_file_name"`
	JobView        JobView `json:"job_view"`
}

RepoSettingsInfo is the request body for the repo settings

type RepoStore

type RepoStore interface {
	// Create persists a new repository in the data store.
	Create(ctx context.Context, repo *Repository) error
	// Find returns the repository in the data store.
	Find(ctx context.Context, orgID string, name string) (*Repository, error)
	// Find returns the repository in the data store by repoID.
	FindByID(ctx context.Context, repoID string) (*Repository, error)
	// FindByCommitID returns the repository in the data store by commitID.
	FindByCommitID(ctx context.Context, commitID string) (repoName string, authorName string, err error)
	// FindActiveByName returns the active repositories in the data store by commitID.
	FindActiveByName(ctx context.Context, repoName, orgName string, gitProvider SCMDriver) (repo *Repository, err error)
	// FindIfActive returns the repository if active.
	FindIfActive(ctx context.Context, orgID string, name string) (*Repository, error)
	// FindAllActiveMap returns all the active repositories for an org in a map.
	FindAllActiveMap(ctx context.Context, orgID string) (map[string]struct{}, error)
	// FindAllActive returns all the active repositories for a user in a slice.
	FindAllActive(ctx context.Context, orgID, searchText string, offset, limit int) ([]*Repository, error)
	// UpdateStatus updates the status of info in repo table related to config files.
	UpdateStatus(ctx context.Context, repoConfig RepoSettingsInfo, orgID, userID string) error
	// FindByBuildID returns repo by buildID
	FindByBuildID(ctx context.Context, buildID string) (*Repository, error)
	// FindBadgeData returns the data of badge
	FindBadgeData(ctx context.Context, repoName, orgName, branchName, buildID, gitProvider string) (*Badge, error)
	// RemoveRepo deactivate the repo from repo import page
	RemoveRepo(ctx context.Context, repoName, orgID, userID string) error
	// FindTokenPathInfo return the info required to create token path to vault
	FindTokenPathInfo(ctx context.Context, repoID string) (*TokenPathInfo, error)
	// FindBadgeDataFlaky returns the data of badge related to flaky jobs
	FindBadgeDataFlaky(ctx context.Context, repoName, orgName, branchName, gitProvider string) (*BadgeFlaky, error)
}

RepoStore defines operations for working with repositories.

type Repository

type Repository struct {
	ID                string    `json:"id,omitempty" db:"id"`
	OrgID             string    `json:"-" db:"org_id"`
	Strict            bool      `json:"-" db:"strict"`
	Name              string    `json:"name,omitempty" db:"name"`
	Admin             string    `json:"-" db:"admin_id"`
	Namespace         string    `json:"namespace,omitempty"`
	Private           bool      `json:"private" db:"private"`
	Secret            string    `json:"-" db:"webhook_secret"`
	Link              string    `json:"link" db:"link"`
	HTTPURL           string    `json:"http_url,omitempty" db:"git_http_url"`
	SSHURL            string    `json:"ssh_url,omitempty" db:"git_ssh_url"`
	Active            bool      `json:"active" db:"active"`
	TasFileName       string    `json:"-"  db:"tas_file_name"`
	PostMergeStrategy int       `json:"-"  db:"post_merge_strategy"`
	Created           time.Time `json:"created_at"  db:"created_at"`
	Updated           time.Time `json:"updated_at"  db:"updated_at"`
	Perm              *Perm     `json:"permissions,omitempty"`
	Mask              string    `json:"-" db:"mask"`
	CollectCoverage   bool      `json:"-" db:"collect_coverage"`
	Meta              *RepoMeta `json:"metadata,omitempty"`
	LatestBuild       *Build    `json:"latest_build,omitempty"`
	RepoGraph         []int     `json:"repo_graph,omitempty"`
	JobView           JobView   `json:"job_view" db:"job_view"`
}

type RepositoryService

type RepositoryService interface {
	// Find returns a repository by name.
	Find(ctx context.Context, repoSlug string, token *Token, gitProvider SCMDriver) (*Repository, error)
	// List returns a list of repositories.
	List(ctx context.Context, page int, size int, userID, orgID, orgName string, user *GitUser) ([]*Repository, int, error)
	// ListBranches returns a list of branches of a repo.
	ListBranches(ctx context.Context, page, size int, repoName string, user *GitUser) (branches []string, next int, err error)
}

RepositoryService provides access to repository information in the remote source code management system (e.g. GitHub).

type Requests

type Requests interface {
	// MakeAPIRequest is an utility function for making API requests
	MakeAPIRequest(ctx context.Context, httpMethod, endpoint string, body []byte, token string) ([]byte, error)
}

Requests is a util interface for making API Requests

type ResourceStats

type ResourceStats struct {
	Status StatType `json:"status"`
	CPU    float32  `json:"cpu"`
	RAM    int64    `json:"ram"`
}

ResourceStats struct for CPU, RAM details

type ResponseMetadata

type ResponseMetadata struct {
	NextCursor string `json:"next_cursor"`
}

ResponseMetadata for setting metadata in response

type Runner

type Runner string

Runner defines type of runner

const (
	SelfHosted  Runner = "self-hosted"
	CloudRunner Runner = "cloud-runner"
)

Possible Runner types

type RunnerOptions

type RunnerOptions struct {
	DockerImage               string            `json:"docker_image"`
	ContainerPort             int               `json:"container_port"`
	SecretName                string            `json:"-"`
	HostPort                  int               `json:"host_port"`
	Label                     map[string]string `json:"label"`
	NameSpace                 string            `json:"name_space"`
	PodName                   string            `json:"pod_name"`
	ContainerName             string            `json:"container_name"`
	ContainerArgs             []string          `json:"container_args"`
	ContainerCommands         []string          `json:"container_commands"`
	PersistentVolumeClaimName string            `json:"-"`
	Env                       []string          `json:"env"`
	OrgID                     string            `json:"org_id"`
	Vault                     *VaultOpts        `json:"-"`
	LogfilePath               string            `json:"logfile_path"`
	PodType                   PodType           `json:"pod_type"`
	Tier                      Tier              `json:"tier"`
}

RunnerOptions provides the the required instructions for execution engine.

type SCM

type SCM struct {
	Client     *scm.Client
	SelfHosted bool
	Name       string
}

SCM is wrapper around scm.Client

type SCMDriver

type SCMDriver string

SCMDriver identifies source code management driver.

const (
	DriverGithub    SCMDriver = "github"
	DriverGitlab    SCMDriver = "gitlab"
	DriverBitbucket SCMDriver = "bitbucket"
)

SCMDriver values.

func (SCMDriver) MarshalBinary

func (d SCMDriver) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (SCMDriver) String

func (d SCMDriver) String() string

VerifyDriver verifies if the SCMDriver is valid.

func (*SCMDriver) UnmarshalBinary

func (d *SCMDriver) UnmarshalBinary(b []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (SCMDriver) VerifyDriver

func (d SCMDriver) VerifyDriver() error

VerifyDriver verifies if the SCMDriver is valid.

type SCMProvider

type SCMProvider interface {
	GetClient(scmClientID SCMDriver) (*SCM, error)
}

SCMProvider represents new git scm provider

type Scheduler

type Scheduler interface {
	//  Run starts the scheduler on startup.
	Run(ctx context.Context)
}

Scheduler will runs the tasks in regular intervals.

type SchedulerManager

type SchedulerManager interface {
	//  StopStaleBuilds marks stale builds as error
	StopStaleBuilds(ctx context.Context) error
}

SchedulerManager manages operations for stale builds

type Services

type Services struct {
	BuildService         BuildService
	UserService          GitUserService
	OrgService           OrganizationService
	RepoService          RepositoryService
	HookService          HookService
	CommitService        CommitService
	GitStatusService     GitStatusService
	CommentService       CommentService
	TestExecutionService TestExecutionService
	PullRequestService   PullRequestService
	BuildAbortService    BuildAbortService
}

Services contains collection of neuron services

type Session

type Session interface {
	// CreateToken creates the JWT token
	CreateToken(data *UserData) (*http.Cookie, error)
	// Authorize parses and validates the JWT Token
	Authorize(c *gin.Context) (*UserData, error)
	// CreateInternalToken creates internal JWT token
	CreateTokenInternal(data *BuildData) (string, error)
	// AuthorizeInternal parses and validates the internal JWT Token
	AuthorizeInternal(c *gin.Context) (*BuildData, error)
	// Invalidate deletes the cookie from server side.
	DeleteCookie() *http.Cookie
}

Session provides session management for authenticated users.

type SplitMode

type SplitMode string

SplitMode is the mode for splitting tests

const (
	FileSplit SplitMode = "file"
	TestSplit SplitMode = "test"
)

list of support test splitting modes

type StaleEvents

type StaleEvents struct {
	OrgID           string `json:"org_id" db:"org_id"`
	ReadyTasks      int64  `json:"ready_tasks" db:"ready_tasks"`
	ProcessingTasks int64  `json:"processing_tasks" db:"processing_tasks"`
}

StaleEvents stores org wise stale event counts

type StatType

type StatType string

StatType defines type of resource status

const (
	ResourceRelease StatType = "release"
	ResourceCapture StatType = "capture"
)

ResourceStats types

type Status

type Status string

Status specifies the status of a Task

const (
	TaskRunning    Status = "running"
	TaskFailed     Status = "failed"
	TaskPassed     Status = "passed"
	TaskInitiating Status = "initiating"
	TaskAborted    Status = "aborted"
	TaskError      Status = "error"
	TaskSkipped    Status = "skipped"
)

Task Status values.

type StatusType

type StatusType string

StatusType defines type job status

const (
	JobCompleted StatusType = "complete"
	JobStarted   StatusType = "started"
	JobFailed    StatusType = "failed"
	JobInitiated StatusType = "initiated"
)

JobInfo types

type SuiteExecutionMeta

type SuiteExecutionMeta struct {
	Total                int        `json:"total_executions"`
	AvgTestSuiteDuration zero.Float `json:"avg_test_suite_duration"`
	Passed               int        `json:"tests_suite_passed"`
	Blocklisted          int        `json:"tests_suite_blocklisted"`
	Skipped              int        `json:"tests_suite_skipped"`
	Failed               int        `json:"tests_suite_failed"`
	Aborted              int        `json:"tests_suite_aborted"`
}

SuiteExecutionMeta contains additional info of the test suites executed

type Synapse

type Synapse struct {
	ID             string        `db:"id" json:"id"`
	OrgID          string        `db:"org_id" json:"-,omitempty"`
	Name           string        `db:"name" json:"name"`
	TotalCPU       float32       `db:"total_cpu_core" json:"total_cpu_core"`
	TotalRAM       int64         `db:"total_ram_mib" json:"total_ram_mib"`
	Status         SynapseStatus `db:"status" json:"status,omitempty"`
	CreatedAt      time.Time     `db:"created_at" json:"first_connected,omitempty"`
	UpdatedAt      time.Time     `db:"updated_at" json:"last_connected,omitempty"`
	AvailableCPU   float32       `json:"available_cpu_core"`
	AvailableRAM   int64         `json:"available_ram_mib"`
	IsActive       bool          `db:"is_active" json:"is_active,omitempty"`
	SynapseVersion string        `db:"synapse_version" json:"synapse_version"`
}

Synapse represents db entry of synapse table

type SynapseClientManager

type SynapseClientManager interface {
	// NewClient creates a new client
	NewClient(ws *websocket.Conn, loginDetails LoginDetails) *SynapseMeta
	// AuthenticateClient authenticates the client
	AuthenticateClient(synapseMeta *SynapseMeta) bool
	// UpdateJobStatus updates job status - attach/dettach jobs to synapse
	UpdateJobStatus(synapseMeta *SynapseMeta, jobInfo *JobInfo) error
	// CaptureResources captures resources
	CaptureResources(synapseMeta *SynapseMeta, cpu float32, ram int64) error
	// ReleaseResources releases resources
	ReleaseResources(synapseMeta *SynapseMeta, cpu float32, ram int64) error
	// SendMessage sends message
	SendMessage(synapseMeta *SynapseMeta, message *Message) error
	// MarkJobFailed marks the job failed
	MarkJobFailed(jobInfo *JobInfo, remarks string)
}

SynapseClientManager defines operations for managing synapse

type SynapseJobInfo

type SynapseJobInfo struct {
	BuildID string
	Mode    string
	ID      string
	Status  StatusType
}

SynapseJobInfo describes the job description for synapse

type SynapseMeta

type SynapseMeta struct {
	ID              string `redis:"id"`
	Name            string
	SecretKey       string
	OrgID           string
	IsAuthenticated bool
	CPU             float32          `redis:"cpu"`
	RAM             int64            `redis:"ram"`
	Jobs            []SynapseJobInfo `redis:"jobs"`
	IsAlive         string           `redis:"isalive"`
	TotalRAM        int64            `redis:"total_ram"`
	TotalCPU        float32          `redis:"total_cpu"`
	Connection      *websocket.Conn
	AbortConnection chan bool
	Lock            sync.Mutex
	NeuronID        string `redis:"neuron_id"`
	LastAliveTime   int64  `redis:"last_alive_time"`
	SynapseVersion  string `redis:"synapse_version"`
}

SynapseMeta stores metadata for synapse TODO: convert job array to set.

type SynapsePoolManager

type SynapsePoolManager interface {
	// RegisterSynapse registers new clients in pool
	RegisterSynapse(s *SynapseMeta) error
	// DeRegisterSynapse deregister client from pool
	DeRegisterSynapse(s *SynapseMeta)
	// GetSynapseFromWS retrieve synapse from websocket information
	GetSynapseFromWS(ws *websocket.Conn) *SynapseMeta
	// FindExecutor schedules job on synapse
	FindExecutor(r *RunnerOptions) (*SynapseMeta, error)
	// GetSynapseFromID get synapse from id
	GetSynapseFromID(synapseID string) (*SynapseMeta, bool)
	// MonitorConnection monitors the synapse for disconnections
	MonitorConnection(ctx context.Context, synapse *SynapseMeta)
	// SetAllSynapseToNotAlive sets IsAlive to NotAlive for all registered synapse when graceful timeout is called
	SetAllSynapseToNotAlive(ctx context.Context)
}

SynapsePoolManager defines operations for managing synapsepool

type SynapseQueueManager

type SynapseQueueManager interface {
	// Run consumes synapse messages
	Run(ctx context.Context)
	// ScheduleTask publishes task for synapse
	ScheduleTask(r *RunnerOptions, synapseID string) error
}

SynapseQueueManager defines operations for pub/sub for synapse

type SynapseStatus

type SynapseStatus string

SynapseStatus represent synapse status in db

const (
	Connected    SynapseStatus = "connected"
	Disconnected SynapseStatus = "disconnected"
)

const related to SynapseStatus

type SynapseStatusCount

type SynapseStatusCount struct {
	Connected     int `db:"connected" json:"connected"`
	Disconnected  int `db:"disconnected" json:"disconnected"`
	TotalRegister int `db:"total_register" json:"total_register"`
}

SynapseStatusCount defines synapse status count output

type SynapseStore

type SynapseStore interface {
	// StoreSynapseMeta stores synapse metadata in to redis
	StoreSynapseMeta(ctx context.Context, synapseMeta *SynapseMeta) error
	// UpdateSynapseResources updates cpu, memory for a synapse in redis
	UpdateSynapseResources(ctx context.Context, synapseMeta *SynapseMeta, cpu float64, ram int64) error
	// UpdateSynapseJobs updates job status in redis
	UpdateSynapseJobs(ctx context.Context, synapseMeta *SynapseMeta) error
	// GetSynapseMeta get synapse metadata from the redis
	GetSynapseMeta(ctx context.Context, synapseID string) (*SynapseMeta, error)
	// ListSynapseMeta retrives the available synapses for an organization
	ListSynapseMeta(ctx context.Context, orgID string) ([]string, error)
	// DeleteSynapseMeta delete synapse metadata from redis
	DeleteSynapseMeta(ctx context.Context, synapseMeta *SynapseMeta) error
	// GetSynapseList lists the synapse info of orgs
	GetSynapseList(ctx context.Context, orgID string) ([]*Synapse, error)
	// TestSynapseConnection checks if synapse is connected or not
	TestSynapseConnection(ctx context.Context, orgID string) (isExist bool, err error)
	// UpdateIsActiveSynapse updates is_active for given synapse in DB
	UpdateIsActiveSynapse(ctx context.Context, isActive bool, synapseID, orgID string) error
	// CountSynapse returns list of status and their count of synapse
	CountSynapse(ctx context.Context, orgID string) (*SynapseStatusCount, error)
}

SynapseStore defines operations for managing database for synapse

type SynapseTask

type SynapseTask struct {
	SynapseID string
	Task      *RunnerOptions
}

SynapseTask holds info for publishing task in redis

type SynapseTaskQueue

type SynapseTaskQueue interface {
	// Enqueue enqueues task message
	Enqueue(r *RunnerOptions, createdAt time.Time) <-chan error
	// InitConsumer intiate the consumer
	InitConsumer(ctx context.Context)
}

SynapseTaskQueue defines operation synapse task queue

type SyncMap

type SyncMap interface {
	// Add store the key-value pair in threadsafe env
	Set(key string, value chan struct{}) (chan struct{}, bool)
	// Get gives the value corresponding to the key in threadsafe env
	Get(key string) (chan struct{}, bool)
	// CleanUp deletes the key from map
	CleanUp(key string)
}

SyncMap provides the wrapper functions available in sync.Map with defined key-value pair type

type Task

type Task struct {
	ID             string                  `db:"id" json:"task_id"`
	RepoID         string                  `db:"repo_id" json:"-"`
	BuildID        string                  `db:"build_id" json:"-"`
	Created        time.Time               `db:"created_at" json:"created_at,omitempty"`
	Updated        time.Time               `db:"updated_at" json:"-"`
	Status         Status                  `db:"status" json:"status,omitempty"`
	StartTime      zero.Time               `db:"start_time" json:"start_time,omitempty"`
	EndTime        zero.Time               `db:"end_time" json:"end_time,omitempty"`
	Tier           Tier                    `db:"tier" json:"tier,omitempty"`
	Type           TaskType                `db:"type" json:"type"`
	TestLocators   zero.String             `db:"test_locators" json:"-"`
	Remark         zero.String             `json:"remark" db:"remark"`
	ContainerImage string                  `db:"container_image" json:"container_image,omitempty"`
	SubModule      string                  `db:"submodule" json:"submodule,omitempty"`
	Label          string                  `json:"label"`
	TestsMeta      *ExecutionMeta          `json:"execution_meta,omitempty"`
	FlakyMeta      *FlakyExecutionMetadata `json:"flaky_execution_meta,omitempty"`
}

Task represents the containers spawned for each build .

type TaskBuilder

type TaskBuilder interface {
	// CreateTask creates and returns the task for execution and flaky
	// TODO : add support for discovery task
	CreateTask(ctx context.Context, taskID, buildID, orgID, repoID, subModule string, taskType TaskType, locatorConfig *InputLocatorConfig,
		tier Tier) (*Task, error)

	// CreateJob creates and return job object
	CreateJob(taskID, orgID string, status QueueStatus) *Job

	// EnqueueTaskAndJob creates task entry in db and enqueue respective jobs to queue
	EnqueueTaskAndJob(ctx context.Context, buildID, orgID string, tasks []*Task, jobs []*Job, taskType TaskType) error
}

TaskBuilder is helper interface for common function related to task creation

type TaskHeapItem

type TaskHeapItem struct {
	TaskID             string
	TestsAllocated     string
	TotalTestsDuration int
}

TaskHeapItem is an item in the task heap.

type TaskMeta

type TaskMeta struct {
	TotalBuilds     int     `json:"total_builds_executed"`
	Initiating      int     `json:"tasks_initiating"`
	Running         int     `json:"tasks_running"`
	Failed          int     `json:"tasks_failed"`
	Aborted         int     `json:"tasks_aborted"`
	AvgTaskDuration float64 `json:"avg_task_duration"`
	Passed          int     `json:"passed"`
	Error           int     `json:"error"`
	Total           int     `json:"total"`
	Skipped         int     `json:"skipped"`
}

TaskMeta contains additional info of the tasks executed

type TaskQueueManager

type TaskQueueManager interface {
	// EnqueueTasks inserts tasks in queue.
	EnqueueTasks(orgID, buildID string, jobs ...*Job) error
	// DequeueTasks Dequeue tasks for the orgID.
	DequeueTasks(orgID string) error
	// Close closes the queue.
	Close() error
}

TaskQueueManager manages the task queue.

type TaskQueueScheduler

type TaskQueueScheduler interface {
	//  Run starts the scheduler on startup.
	Run(ctx context.Context)
}

TaskQueueScheduler will schedule tasks which are in ready state after startup.

type TaskQueueStore

type TaskQueueStore interface {
	// Create create tasks in tasksqueue store.
	Create(ctx context.Context, orgID, buildID string, tasks ...*Job) error
	// FindAndUpdateTasks finds and updates the status of tasks in the task queue store and returns the messages.
	FindAndUpdateTasks(ctx context.Context, orgID string, limit int) ([]*Job, error)
	// UpdateTask updates the task in queue, updates credit usage, updates task table and decrements the count in redis.
	UpdateTask(ctx context.Context, task *Task, orgID string) error
	// MarkError marks all tasks and build as error and tasks failed in task queue.
	MarkError(ctx context.Context, buildID, orgID, remark string, jobs []*Job) error
}

TaskQueueStore represents the task_queue store operations.

type TaskQueueUtils

type TaskQueueUtils interface {
	// MarkTaskToStatus marks the tasks as error.
	MarkTaskToStatus(task *Task, orgID string, status Status)
}

TaskQueueUtils has the common utilities for task queue.

type TaskRunner

type TaskRunner interface {
	// ScheduleTask schedules task on synapse or k8s depending on the runner type
	ScheduleTask(ctx context.Context, r *RunnerOptions, buildID, jobID, taskID, customDockerImage string) <-chan error
}

TaskRunner is the interface which defines the implementation intiating task based on runner type

type TaskStore

type TaskStore interface {
	// Create persists a new task in the datastore.
	Create(ctx context.Context, task ...*Task) error
	// CreateInTx persists a new task in the datastore and executes the statements within the specified transaction
	CreateInTx(ctx context.Context, tx *sqlx.Tx, task ...*Task) error
	// Find the task in datastore by id.
	Find(ctx context.Context, taskID string) (*Task, error)
	// UpdateInTx  persists changes to the task in the datastore and executes the statements within the specified transaction.
	UpdateInTx(ctx context.Context, tx *sqlx.Tx, task *Task) error
	// UpdateByBuildID update the status of all tasks for a build.
	UpdateByBuildID(ctx context.Context, status Status, taskType TaskType, remark, buildID string) error
	// UpdateByBuildIDInTx update the status of all tasks for a build and executes the statements within the specified transaction
	UpdateByBuildIDInTx(ctx context.Context, tx *sqlx.Tx, status Status, remark, buildID string) error
	// StopStaleTasksInTx marks the tasks as error after timeout within specified transaction.
	StopStaleTasksInTx(ctx context.Context, tx *sqlx.Tx, timeout time.Duration) (int64, error)
	// FetchTask fetches all the task which are there for a particular buildID
	FetchTask(ctx context.Context, buildID string, offset, limit int) ([]*Task, error)
	// FetchTaskHavingStatus fetches all the tasks which are in given state for a particular buildID
	FetchTaskHavingStatus(ctx context.Context, buildID string, status Status) ([]*Task, error)
}

TaskStore defines datastore operation for working with Task

type TaskType

type TaskType string

TaskType specifies the type of a Task

const (
	DiscoveryTask TaskType = "discover"
	ExecutionTask TaskType = "execute"
	FlakyTask     TaskType = "flaky"
)

Task Type values.

type TaskUpdateManager

type TaskUpdateManager interface {
	// TaskUpdate updates the task and build as per provided status
	TaskUpdate(ctx context.Context, task *Task, orgID string) error
	// UpdateAllTasksForBuild fetches and update all task for a build
	UpdateAllTasksForBuild(ctx context.Context, remark, buildID, orgID string) error
}

TaskUpdateManager defines utility functions for updating task(s)

type Test

type Test struct {
	ID            string                  `db:"id" json:"id"`
	Name          string                  `db:"name" json:"name"`
	TestSuiteID   zero.String             `db:"test_suite_id" json:"test_suite_id,omitempty"`
	DebutCommit   string                  `db:"debut_commit" json:"debut_commit,omitempty"`
	RepoID        string                  `db:"repo_id" json:"repo_id,omitempty"`
	TestLocator   string                  `db:"test_locator" json:"test_locator,omitempty"`
	Status        zero.String             `db:"status" json:"-"`
	Execution     *TestExecution          `json:"execution_details,omitempty"`
	Meta          *ExecutionMeta          `json:"execution_meta,omitempty"`
	FlakyMeta     *FlakyExecutionMetadata `json:"flaky_execution_meta,omitempty"`
	LatestBuild   *Build                  `json:"latest_build,omitempty"`
	Suite         *TestSuite              `json:"suite,omitempty"`
	Created       time.Time               `db:"created_at" json:"created_at"`
	Updated       time.Time               `db:"updated_at" json:"-"`
	TestSuiteName zero.String             `json:"test_suite_name,omitempty"`
	TestStatus    []*TestStatus           `json:"test_status,omitempty"`
	Transition    *Transition             `json:"transition,omitempty"`
	Introduced    *time.Time              `json:"introduced_at,omitempty"`
	SubModule     string                  `db:"submodule" json:"submodule"`
}

Test represents the user's tests.

type TestBranch

type TestBranch struct {
	ID         string    `json:"id,omitempty" db:"id"`
	TestID     string    `json:"test_id" db:"test_id"`
	RepoID     string    `json:"repo_id" db:"repo_id"`
	BranchName string    `json:"branch_name" db:"branch_name"`
	Updated    time.Time `json:"-" db:"updated_at"`
	Created    time.Time `json:"-" db:"created_at"`
}

TestBranch represents the test and branch relation

type TestBranchStore

type TestBranchStore interface {
	// CreateInTx persisits a new test and branch relation in the datastore and executes the statements within the specified transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, testBranch []*TestBranch) error
}

TestBranchStore defines datastore operation for working with test_branch store

type TestCoverage

type TestCoverage struct {
	ID            string          `db:"id"`
	CommitID      string          `db:"commit_id"`
	RepoID        string          `db:"repo_id"`
	Blob          string          `db:"blob_link"`
	TotalCoverage json.RawMessage `db:"total_coverage"`
	Created       time.Time       `db:"created_at"`
	Updated       time.Time       `db:"updated_at"`
}

TestCoverage represents the code coverage for each testfile.

type TestCoverageStore

type TestCoverageStore interface {
	// CreateInTx persists the coverage data into datastore.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, coverage []*TestCoverage) error
	// FindCommitCoverage finds the coverage data into datastore by commitID.
	FindCommitCoverage(ctx context.Context, repoID, commitID string) (*TestCoverage, error)
}

TestCoverageStore defines datastore operation for working with test coverage

type TestExecution

type TestExecution struct {
	ID              string              `json:"id,omitempty" db:"id"`
	TestID          string              `json:"test_id,omitempty" db:"test_id"`
	CommitID        string              `json:"commit_id,omitempty" db:"commit_id"`
	CommitAuthor    string              `json:"commit_author,omitempty"`
	CommitMessage   *zero.String        `json:"commit_message,omitempty"`
	Status          TestExecutionStatus `json:"status,omitempty" db:"status"`
	Created         time.Time           `json:"created_at" db:"created_at"`
	Updated         time.Time           `json:"-" db:"updated_at"`
	StartTime       zero.Time           `json:"start_time" db:"start_time"`
	EndTime         zero.Time           `json:"end_time" db:"end_time"`
	Duration        int                 `json:"duration" db:"duration"`
	Stdout          string              `json:"-" db:"stdout"`
	Stderr          string              `json:"-" db:"stderr"`
	BlocklistSource zero.String         `json:"-" db:"blocklist_source"`
	TaskID          string              `json:"task_id,omitempty" db:"task_id"`
	BuildID         string              `json:"build_id,omitempty" db:"build_id"`
	BuildNum        int                 `json:"build_num,omitempty"`
	TestName        string              `json:"test_name,omitempty"`
	TestSuiteName   zero.String         `json:"test_suite_name,omitempty"`
	SuiteID         zero.String         `json:"test_suite_id,omitempty"`
	BuildTag        string              `json:"build_tag,omitempty"`
	Transition      *Transition         `json:"transition,omitempty"`
	Branch          string              `json:"branch,omitempty"`
}

TestExecution represents the executed test.

type TestExecutionService

type TestExecutionService interface {
	// StoreTestMetrics stores test metrics on azure blob in csv format.
	StoreTestMetrics(ctx context.Context, path string, metrics [][]string) error
	// FetchMetrics fetches the metrics from azure blob in array format.
	FetchMetrics(ctx context.Context, path, executionID string) (metrics []*TestMetrics, err error)
	// StoreTestFailures stores test failures on azure blob in json format.
	StoreTestFailures(ctx context.Context, path string, failureDetails map[string]string) error
	// FetchTestFailures fetches the test failures from azure blob in array format.
	FetchTestFailures(ctx context.Context, path, executionID string) (failureMsg string, err error)
}

TestExecutionService defines operations for working with test execution data

type TestExecutionStatus

type TestExecutionStatus string

TestExecutionStatus specifies the status of a test which was executed

const (
	TestFailed      TestExecutionStatus = "failed"
	TestPassed      TestExecutionStatus = "passed"
	TestAborted     TestExecutionStatus = "aborted"
	TestSkipped     TestExecutionStatus = "skipped"
	TestPending     TestExecutionStatus = "pending"
	TestBlocklisted TestExecutionStatus = "blocklisted"
	TestQuarantined TestExecutionStatus = "quarantined"
	TestFlaky       TestExecutionStatus = "flaky"
	TestNonFlaky    TestExecutionStatus = "nonflaky"
	TestNotRun      TestExecutionStatus = "notrun"
)

TestExecution Status values.

func (TestExecutionStatus) Weight

func (t TestExecutionStatus) Weight() int

Weight returns the weight of the test status

type TestExecutionStore

type TestExecutionStore interface {
	// CreateInTx persists a new test in the datastore and executes the statement in the specified transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, testExecution []*TestExecution) error
	// FindByTestID finds the executions of a test.
	FindByTestID(ctx context.Context, testID, repoName, orgID, branchName, statusFilter, searchID string,
		startDate, endDate time.Time, offset, limit int) ([]*TestExecution, error)
	// FindStatus finds the status of the test.
	FindStatus(ctx context.Context, testID, interval, repoName, orgID, branchName string,
		startDate, endDate time.Time) ([]*TestExecution, error)
	// FindExecutionTimeImpactedTests finds the total time taken by all the impacted tests in there execution
	FindExecutionTimeImpactedTests(ctx context.Context, commitID, buildID, repoID string) (totalImpactedTests, totalTime int, err error)
	// FindTimeByRunningAllTests finds the total time taken by all the tests discovered in the buildID, commitID
	FindTimeByRunningAllTests(ctx context.Context, buildID, commitID, repoID string) (totalTests, totalTime int, err error)
	// FindRepoTestStatusesFailed returns the test execution statuses for a repository.
	FindRepoTestStatusesFailed(ctx context.Context, repoName, orgID, branchName string,
		startDate, endDate time.Time, limit int) ([]*Test, error)
	// FindLatestExecution finds the latest execution for given testIDs and repo.
	FindLatestExecution(ctx context.Context, repoID string, testIDs []string) ([]*Test, error)

	// FindImpactedTestsByBuild returns list of all impacted test for given build
	FindImpactedTestsByBuild(ctx context.Context, buildID string) (map[string][]*Test, error)
}

TestExecutionStore defines datastore operation for working with test execution store

type TestMetrics

type TestMetrics struct {
	ID              string    `json:"-"`
	TestExecutionID string    `json:"-"`
	Memory          uint64    `json:"memory"`
	CPU             float64   `json:"cpu"`
	Storage         uint64    `json:"storage"`
	RecordTime      time.Time `json:"record_time"`
}

TestMetrics represents the metrics for each test.

type TestPayload

type TestPayload struct {
	TestID          string              `json:"testID"`
	Detail          string              `json:"_detail"`
	SuiteID         string              `json:"suiteID"`
	Suites          []string            `json:"_suites"`
	Title           string              `json:"title"`
	FullTitle       string              `json:"fullTitle"`
	Name            string              `json:"name"`
	Duration        int                 `json:"duration"`
	FilePath        string              `json:"file"`
	Line            string              `json:"line"`
	Col             string              `json:"col"`
	CurrentRetry    int                 `json:"currentRetry"`
	Status          TestExecutionStatus `json:"status"`
	DAG             []string            `json:"dependsOn"`
	Filelocator     string              `json:"locator"`
	BlocklistSource string              `json:"blocklistSource"`
	Blocklisted     bool                `json:"blocklist"`
	StartTime       time.Time           `json:"start_time"`
	EndTime         time.Time           `json:"end_time"`
	Stats           []TestProcessStats  `json:"stats"`
	FailureMessage  string              `json:"failureMessage"`
}

TestPayload represents the request body for test execution

type TestProcessStats

type TestProcessStats struct {
	Memory     uint64    `json:"memory_consumed,omitempty"`
	CPU        float64   `json:"cpu_percentage,omitempty"`
	Storage    uint64    `json:"storage,omitempty"`
	RecordTime time.Time `json:"record_time"`
}

TestProcessStats process stats associated with each test

type TestReportRequestPayload

type TestReportRequestPayload struct {
	TaskID   string            `json:"taskID" binding:"required"`
	BuildID  string            `json:"buildID" binding:"required"`
	RepoID   string            `json:"repoID" binding:"required"`
	OrgID    string            `json:"orgID" binding:"required"`
	CommitID string            `json:"commitID" binding:"required"`
	TaskType TaskType          `json:"taskType" binding:"required,oneof=discover execute flaky"`
	Results  []ExecutionResult `json:"results"`
}

TestReportRequestPayload represents the request body for test and test suite report api.

type TestReportResponsePayload

type TestReportResponsePayload struct {
	TaskID     string `json:"taskID"`
	TaskStatus Status `json:"taskStatus"`
	Remark     string `json:"remark,omitempty"`
}

TestReportResponsePayload represents the response body for test and test suite report api.

type TestSplitter

type TestSplitter interface {
	// Split will split the impacted tests into multiple tasks.
	Split(ctx context.Context, orgID, buildID, discoveryTaskID string,
		testIDs []string, executeAll bool, parallelCount int,
		branch string, splitMode SplitMode, subModule string) error
}

TestSplitter splits the impacted tests into multiple tasks.

type TestStatus

type TestStatus struct {
	CommitID   string      `json:"commit_id"`
	AuthorName string      `json:"author_name"`
	Status     zero.String `json:"status"`
	Created    int         `json:"created_at"`
	StartTime  zero.Int    `json:"start_time"`
	EndTime    zero.Int    `json:"end_time"`
	BuildID    string      `json:"build_id"`
	Branch     string      `json:"branch"`
}

TestStatus represents the status of a test

type TestStore

type TestStore interface {
	// CreateInTx persists a new test in the datastore and executes the statement in the specified transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, testData []*Test) error
	// FindByRepo returns the tests for a repository.
	FindByRepo(ctx context.Context, repoName, orgID, testID, branchName, statusFilter, searchText string, authorsNames []string,
		offset, limit int) ([]*Test, error)
	// FindRepoTestStatuses returns the test execution statuses for a repository.
	FindRepoTestStatuses(ctx context.Context, repoName, orgID, branchName, status, tag, searchText, lastSeenID string,
		startDate, endDate time.Time, limit int, isJobs bool) ([]*Test, error)
	// FindUninpactedTests returns the test which are not impacted by the given build and commit.
	FindUnimpactedTests(ctx context.Context, commitID, buildID, repoName, orgID string, offset, limit int) ([]*Test, error)
	// FindIntroducedDate returns the first date when this test was introduced
	FindIntroducedDate(ctx context.Context, repoName, orgID, branchName, lastSeenID string, limit int) (map[string]time.Time, error)
	// FindRepoTestStatusesSlowest returns the test execution statuses for a repository.
	FindRepoTestStatusesSlowest(ctx context.Context, repoName, orgID, branchName string,
		startDate, endDate time.Time, limit int) ([]*Test, error)
	// FindTestData return the tests information in a selected date range with respect to commit id.
	FindTestData(ctx context.Context, repoName, orgID, branchName string, startDate, endDate time.Time) ([]*GitCommit, error)
	// FindTestMeta returns the tests meta for all the tests in a selected repo
	FindTestMeta(ctx context.Context, repoName, orgID, buildID string,
		commitID, branchName string) ([]*ExecutionMeta, error)
	// FindBlocklistedTests returns the number of blocklisted tests by an author
	FindBlocklistedTests(ctx context.Context, repoName, orgID, branchName, authorName string, startDate, endDate time.Time) (int, error)
	// FindIrregularTests returns the tests which shows irregularity in execution time
	FindIrregularTests(ctx context.Context, repoID, branch string, startDate, endDate time.Time, limit int) ([]*IrregularTests, error)
	// FindMonthWiseNetTests returns monthwise total tests present in the repo between start-date and end-date
	FindMonthWiseNetTests(ctx context.Context, RepoID, branchName string, startDate, endDate time.Time) ([]*MonthWiseNetTests, error)
	// FindAddedTests returns the total tests added in a repo in a given duration
	FindAddedTests(ctx context.Context, repoID, branchName string, startDate,
		endDate time.Time) (int64, error)
}

TestStore defines datastore operation for working with test

type TestSuite

type TestSuite struct {
	ID            string              `db:"id" json:"id"`
	ParentSuiteID zero.String         `db:"parent_suite_id" json:"parent_suite_id"`
	Name          string              `db:"name" json:"name"`
	FilePath      zero.String         `db:"file_path" json:"-"`
	DebutCommit   string              `db:"debut_commit" json:"debut_commit"`
	RepoID        string              `db:"repo_id" json:"-"`
	Created       time.Time           `db:"created_at" json:"-"`
	Updated       time.Time           `db:"updated_at" json:"-"`
	Meta          *SuiteExecutionMeta `json:"execution_meta,omitempty"`
	LatestBuild   *Build              `json:"latest_build,omitempty"`
	TotalTests    int                 `db:"total_tests" json:"total_tests"`
	Execution     *TestSuiteExecution `json:"execution_details,omitempty"`
	SubModule     string              `db:"submodule" json:"submodule"`
	Branch        string              `json:"branch,omitempty"`
}

TestSuite represents the user's test_suites.

type TestSuiteBranch

type TestSuiteBranch struct {
	ID          string    `json:"id,omitempty" db:"id"`
	TestSuiteID string    `json:"test_suite_id" db:"test_suite_id"`
	RepoID      string    `json:"repo_id" db:"repo_id"`
	BranchName  string    `json:"branch_name" db:"branch_name"`
	Updated     time.Time `json:"-" db:"updated_at"`
	Created     time.Time `json:"-" db:"created_at"`
}

TestSuiteBranch represents the test_suite and branch relation.

type TestSuiteBranchStore

type TestSuiteBranchStore interface {
	// CreateInTx persisits a new test_suite and branch relation in the datastore and executes the statements within the specified transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, tb []*TestSuiteBranch) error
}

TestSuiteBranchStore defines datastore operation for working with test_suite_branch store.

type TestSuiteExecution

type TestSuiteExecution struct {
	ID              string                   `json:"id,omitempty" db:"id"`
	SuiteID         string                   `json:"suite_id,omitempty" db:"suite_id"`
	CommitID        string                   `json:"commit_id,omitempty" db:"commit_id"`
	Status          TestSuiteExecutionStatus `json:"status,omitempty" db:"status"`
	Created         time.Time                `json:"created_at" db:"created_at"`
	Updated         time.Time                `json:"-" db:"updated_at"`
	StartTime       zero.Time                `json:"start_time" db:"start_time"`
	EndTime         zero.Time                `json:"end_time" db:"end_time"`
	Duration        int                      `json:"duration" db:"duration"`
	Stdout          string                   `json:"-" db:"stdout"`
	Stderr          string                   `json:"-" db:"stderr"`
	BlocklistSource zero.String              `json:"-" db:"blocklist_source"`
	TaskID          string                   `json:"task_id,omitempty" db:"task_id"`
	BuildID         string                   `json:"build_id,omitempty" db:"build_id"`
	BuildNum        int                      `json:"build_num,omitempty"`
	BuildTag        string                   `json:"build_tag,omitempty"`
	Branch          string                   `json:"branch_name,omitempty"`
}

TestSuiteExecution represents the executed test suite

type TestSuiteExecutionStatus

type TestSuiteExecutionStatus string

TestSuiteExecutionStatus specifies the status of a test suite which was executed

const (
	TestSuiteStopped     TestSuiteExecutionStatus = "stopped"
	TestSuiteFailed      TestSuiteExecutionStatus = "failed"
	TestSuitePassed      TestSuiteExecutionStatus = "passed"
	TestSuiteAborted     TestSuiteExecutionStatus = "aborted"
	TestSuiteSkipped     TestSuiteExecutionStatus = "skipped"
	TestSuitePending     TestSuiteExecutionStatus = "pending"
	TestSuiteBlocklisted TestSuiteExecutionStatus = "blocklisted"
)

TestSuiteExecution Status values

type TestSuiteExecutionStore

type TestSuiteExecutionStore interface {
	// CreateInTx persists a new test in the datastore and executes the statement in the specified transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, testSuiteExecution []*TestSuiteExecution) error
}

TestSuiteExecutionStore defines datastore operation for working with test suite execution store

type TestSuitePayload

type TestSuitePayload struct {
	SuiteID         string                   `json:"suiteID"`
	SuiteName       string                   `json:"suiteName"`
	ParentSuiteID   string                   `json:"parentSuiteID"`
	BlocklistSource string                   `json:"blocklistSource"`
	Blocklisted     bool                     `json:"blocklist"`
	StartTime       time.Time                `json:"start_time"`
	EndTime         time.Time                `json:"end_time"`
	Duration        int                      `json:"duration"`
	Status          TestSuiteExecutionStatus `json:"status"`
	Stats           []TestProcessStats       `json:"stats"`
}

TestSuitePayload represents the request body for test suite execution

type TestSuiteStore

type TestSuiteStore interface {
	// CreateInTx persists a new test suite in the datastore and executes the statement in the specified transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, testData []*TestSuite) error
	// FindByRepo returns the test suites for a repository.
	FindByRepo(ctx context.Context, repoName, orgID, suiteID, branchName, statusFilter,
		searchText string, authorsNames []string, offset, limit int) ([]*TestSuite, error)
	// FindExecution returns the execution data for the test suites.
	FindExecution(ctx context.Context, testSuiteID, repoName, orgID, branchName, statusFilter, searchText string,
		startDate, endDate time.Time, offset, limit int) ([]*TestSuiteExecution, error)
	// FindStatus returns test execution status of the test suites.
	FindStatus(ctx context.Context, testSuiteID, repoName, orgID, branchName string,
		startDate, endDate time.Time) ([]*TestSuiteExecution, error)
	// FindMeta returns suite meta of all the test suites.
	FindMeta(ctx context.Context, repoName, orgID, buildID, commitID,
		branchName string) ([]*SuiteExecutionMeta, error)
}

TestSuiteStore defines datastore operation for working with test suites

type Tier

type Tier string

Tier specifies the license type.

const (
	Internal Tier = "internal"
	XSmall   Tier = "xsmall"
	Small    Tier = "small"
	Medium   Tier = "medium"
	Large    Tier = "large"
	XLarge   Tier = "xlarge"
)

LicenseTier values.

func (Tier) IsSmallerThan

func (t1 Tier) IsSmallerThan(t2 Tier) bool

type TierConfig

type TierConfig struct {
	CPUs      string
	RAM       string
	Storage   string
	CreditsPM int32
}

TierConfig the license tier config values.

func (TierConfig) String

func (tc TierConfig) String() string

type TimeSavedData

type TimeSavedData struct {
	PercentTimeSaved         float64 `json:"time_saved_percent"`
	TimeTakenByAllTests      int     `json:"time_taken_all_tests_ms"`
	TimeTakenByImpactedTests int     `json:"time_taken_impacted_tests_ms"`
	TotalTests               int     `json:"total_tests"`
	TotalImpactedTests       int     `json:"total_impacted_tests"`
}

TimeSavedData defines information related to time saved by not running unimpacted tests

type Token

type Token struct {
	AccessToken        string    `json:"access_token"`
	RefreshToken       string    `json:"refresh_token,omitempty"`
	Expiry             time.Time `json:"expiry"`
	InstallationToken  string    `json:"installation_token,omitempty"`
	InstallationExpiry time.Time `json:"installation_expiry,omitempty"`
	InstallationID     string    `json:"installation_id,omitempty"`
}

Token represents the git oauth token for private repositories

func (*Token) SetInstallationRequestContext

func (t *Token) SetInstallationRequestContext(ctx context.Context) context.Context

SetInstallationRequestContext sets the installation token values in the request context

func (*Token) SetRequestContext

func (t *Token) SetRequestContext(ctx context.Context) context.Context

SetRequestContext sets the token values in the request context

type TokenPathInfo

type TokenPathInfo struct {
	OrgID       string    `db:"org_id"`
	OrgName     string    `db:"org_name"`
	UserID      string    `db:"admin_id"`
	UserMask    string    `db:"user_mask"`
	GitProvider SCMDriver `db:"git_provider"`
}

TokenPathInfo represents Info required to create git token path

type Transition

type Transition struct {
	PreviousStatus string `json:"test_previous_status"`
	CurrentStatus  string `json:"test_current_status"`
}

Transition represents a test's transition from Passed to Failed, Failed to Blocklisted etc

type UserData

type UserData struct {
	Expiry      int64     `json:"exp"`
	JwtID       string    `json:"jti"`
	UserID      string    `json:"user_id"`
	GitProvider SCMDriver `json:"git_provider"`
	UserName    string    `json:"username"`
}

UserData represents the data stored in the cookies

type UserDemoStore

type UserDemoStore interface {
	// Create creates the user info in the db
	Create(ctx context.Context, info *UserInfoDemoDetails) error
}

UserDemoStore defines datastore operation for working with userdemo related data.

type UserInfo

type UserInfo struct {
	ID              string    `db:"id"`
	UserID          string    `db:"user_id"`
	UserDescription string    `db:"user_description"`
	Experience      string    `db:"experience"`
	TeamSize        string    `db:"team_size"`
	OrgID           string    `db:"org_id"`
	Created         time.Time `db:"created_at"`
	Updated         time.Time `db:"updated_at"`
	IsActive        bool      `db:"is_active"`
}

UserInfo represents the information entity of user

type UserInfoDemoDetails

type UserInfoDemoDetails struct {
	ID        string `db:"id"`
	Name      string `db:"name"`
	FirstName string `json:"first_name" binding:"required"`
	LastName  string `json:"last_name"`
	EmailID   string `db:"email_id" json:"email_id" binding:"required,email"`
	Company   string `db:"company_name" json:"company"`
	Created   string `db:"created_at" json:"-"`
	Updated   string `db:"updated_at" json:"-"`
}

UserInfoDemoDetails is a request body of user information

type UserInfoStore

type UserInfoStore interface {
	// Create adds the information of user in database
	Create(ctx context.Context, userInfo *UserInfo) error
	// Find finds the info of a user from a database
	Find(ctx context.Context, userID, orgID string) (*UserInfo, error)
	// UpdateActiveUser adds the information of user in database
	UpdateActiveUser(ctx context.Context, userInfo *UserInfo) error
}

UserInfoStore defines datastore operation for working with userInfo related data.

type UserOrg

type UserOrg struct {
	ID      string    `db:"id"`
	UserID  string    `db:"user_id"`
	OrgID   string    `db:"org_id"`
	Created time.Time `db:"created_at"`
	Updated time.Time `db:"updated_at"`
}

UserOrg represents a git user's organizations

type UserOrgStore

type UserOrgStore interface {
	// Create persists a new userorg in the datastore and executes the statement within the transaction.
	CreateInTx(ctx context.Context, tx *sqlx.Tx, userOrgs []*UserOrg) error
	// FindIfExists finds if the user org relation exists.
	FindIfExists(ctx context.Context, userID, orgID string) error
}

UserOrgStore defines operations for working with user_organization store.

type UserSecretType

type UserSecretType string

UserSecretType represents the type of opaque k8s secret

const (
	Oauth      UserSecretType = "oauth"
	RepoSecret UserSecretType = "reposecrets"
)

supported secret types

type Vault

type Vault interface {
	// CreateSecret create the Vault secret.
	CreateSecret(path string, values map[string]interface{}) error
	// CreateNamespace create the Vault namespace.
	CreateNamespace(namespacePath string) error
	// ListNamespace list the Vault namespace details.
	ListNamespace(namespacePath string) error
	// ListAllNamespaces list all namespaces in Vault.
	ListAllNamespaces(namespacePath string) ([]interface{}, error)
	// GetTokenPath returns the OAuth token path.
	GetTokenPath(gitProvider SCMDriver, mask, id string) string
	// GetInstallationTokenPath returns the Installation token path.
	GetInstallationTokenPath(gitProvider SCMDriver, k8namespace, orgName string) string
	// GetSecretPath returns the repo secret path.
	GetSecretPath(gitProvider SCMDriver, k8namespace, orgName, mask, id string) string
	// GetSecretMetadataPath returns the repo secrets metadata path.
	GetSecretMetadataPath(gitProvider SCMDriver, k8namespace, orgName, mask, id string) string
	// ReadSecret returns the secret in given path.
	ReadSecret(path string) (map[string]interface{}, error)
	// CreateRole create the k8s auth rile in Vault.
	CreateRole(roleName, k8namespace, serviceAccountName string) error
	// DeleteRole delete the k8s role in Vault.
	DeleteRole(roleName string) error
	// DestroySecret destroy the secret and metadata in given path.
	DestroySecret(path string) error
	// HasSecret returns true if repo secret exists.
	HasSecret(path string) (bool, error)
}

Vault defines operation for working with vault store

type VaultOpts

type VaultOpts struct {
	// SecretPath path of the repo secrets.
	SecretPath string
	// TokenPath path of the user token.
	TokenPath string
	// RoleName vault role name
	RoleName string
	// Namespace is the default vault namespace
	Namespace string
	// RepoSecretName the name of the k8s resource for the user's repository secrets
	RepoSecretName string
	// TokenSecretName the name of the k8s resource for the user's token
	TokenSecretName string
}

VaultOpts provides the vault path options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL