utils

package
v0.0.0-...-9963a76 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: Apache-2.0 Imports: 34 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(key []byte, encodedCiphertext string) (string, error)

Decrypt decrypts a base64 encoded ciphertext using AES-256-GCM

func AESEncrypt

func AESEncrypt(key []byte, plaintext string) (string, error)

Encrypt encrypts a plaintext string using AES-256-GCM

func CollapsedGraph

func CollapsedGraph(impactedParent *string, currentNode string, adjMap map[string]map[string]graph.Edge[string], g graph.Graph[string, configuration.Project], impactedProjects map[string]configuration.Project) error

func ConvertJobsToDiggerJobs

func ConvertJobsToDiggerJobs(jobType scheduler.DiggerCommand, vcsType models.DiggerVCSType, organisationId uint, jobsMap map[string]scheduler.Job, projectMap map[string]configuration.Project, projectsGraph graph.Graph[string, configuration.Project], githubInstallationId int64, branch string, prNumber int, repoOwner string, repoName string, repoFullName string, commitSha string, commentId int64, diggerConfigStr string, gitlabProjectId int, aiSummaryCommentId string, reportTerraformOutput bool, coverAllImpactedProjects bool, VCSConnectionId *uint) (*uuid.UUID, map[string]*models.DiggerJob, error)

ConvertJobsToDiggerJobs jobs is map with project name as a key and a Job as a value

func ExtractCleanRepoName

func ExtractCleanRepoName(gitlabURL string) (string, error)

func GenerateTerraformCode

func GenerateTerraformCode(appCode string, generationEndpoint string, apiToken string) (string, error)

func GetAiSummaryFromTerraformPlans

func GetAiSummaryFromTerraformPlans(plans string, summaryEndpoint string, apiToken string) (string, error)

func GetBitbucketService

func GetBitbucketService(bb BitbucketProvider, token string, repoOwner string, repoName string, prNumber int) (*orchestrator_bitbucket.BitbucketAPI, error)

func GetDiggerConfigForBitbucketBranch

func GetDiggerConfigForBitbucketBranch(bb BitbucketProvider, token string, repoFullName string, repoOwner string, repoName string, cloneUrl string, branch string, prNumber int) (string, *dg_configuration.DiggerConfig, graph.Graph[string, dg_configuration.Project], error)

func GetDiggerConfigForBranchGitlab

func GetDiggerConfigForBranchGitlab(gh GitlabProvider, projectId int, repoFullName string, repoOwner string, repoName string, cloneUrl string, branch string, prNumber int, discussionId string) (string, *dg_configuration.DiggerConfig, graph.Graph[string, dg_configuration.Project], error)

func GetGithubClient

func GetGithubClient(gh GithubClientProvider, installationId int64, repoFullName string) (*github.Client, *string, error)

func GetGithubClientFromAppId

func GetGithubClientFromAppId(gh GithubClientProvider, installationId int64, githubAppId int64, repoFullName string) (*github.Client, *string, error)

func GetGithubHostname

func GetGithubHostname() string

func GetGithubService

func GetGithubService(gh GithubClientProvider, installationId int64, repoFullName string, repoOwner string, repoName string) (*github2.GithubService, *string, error)

func GetGitlabService

func GetGitlabService(gh GitlabProvider, projectId int, repoName string, repoFullName string, prNumber int, discussionId string) (*orchestrator_gitlab.GitLabService, error)

func GetWorkflowIdAndUrlFromDiggerJobId

func GetWorkflowIdAndUrlFromDiggerJobId(client *github.Client, repoOwner string, repoName string, diggerJobID string) (int64, string, error)

func ImpactedProjectsOnlyGraph

func ImpactedProjectsOnlyGraph(projectsGraph graph.Graph[string, configuration.Project], impactedProjectMap map[string]configuration.Project) (graph.Graph[string, configuration.Project], error)

func IsInRepoAllowList

func IsInRepoAllowList(repoUrl string) bool

func PostCommentForBatch

func PostCommentForBatch(batch *models.DiggerBatch, comment string, githubClientProvider GithubClientProvider) error

func ReportInitialJobsStatus

func ReportInitialJobsStatus(cr *CommentReporter, jobs []scheduler.Job) error

func ReportLayersTableForJobs

func ReportLayersTableForJobs(cr *CommentReporter, jobs []scheduler.Job) error

func SetPRStatusForJobs

func SetPRStatusForJobs(prService ci.PullRequestService, prNumber int, jobs []scheduler.Job) error

func TraverseGraphVisitAllParentsFirst

func TraverseGraphVisitAllParentsFirst(g graph.Graph[string, configuration.Project], visit func(value string) bool) error

func UpdateCRComment

func UpdateCRComment(cr *CommentReporter, comment string) error

Types

type BitbucketClientProvider

type BitbucketClientProvider struct{}

func (BitbucketClientProvider) NewClient

func (b BitbucketClientProvider) NewClient(token string) (*bitbucket.Client, error)

type BitbucketProvider

type BitbucketProvider interface {
	NewClient(token string) (*bitbucket.Client, error)
}

type CommentReporter

type CommentReporter struct {
	PrNumber  int
	PrService ci.PullRequestService
	CommentId string
}

func InitCommentReporter

func InitCommentReporter(prService ci.PullRequestService, prNumber int, commentMessage string) (*CommentReporter, error)

type CommentReporterManager

type CommentReporterManager struct {
	CommentReporter *CommentReporter
	// contains filtered or unexported fields
}

CommentReporterManager thin wrapper around CommentReporter that makes it "Lazy" so we dont comment anything when it is initialized and we can update comment at any time (initial update creates a new comment, future updates will update that comment)

func InitCommentReporterManager

func InitCommentReporterManager(prService ci.PullRequestService, prNumber int) CommentReporterManager

func (*CommentReporterManager) GetCommentReporter

func (cm *CommentReporterManager) GetCommentReporter() (*CommentReporter, error)

func (*CommentReporterManager) UpdateComment

func (cm *CommentReporterManager) UpdateComment(commentMessage string) (*CommentReporter, error)

type DecryptedVCSConnection

type DecryptedVCSConnection struct {
	GithubId               int64
	ClientID               string
	ClientSecret           string
	WebhookSecret          string
	PrivateKey             string
	PrivateKeyBase64       string
	Org                    string
	Name                   string
	GithubAppUrl           string
	OrganisationID         uint
	BitbucketAccessToken   string
	BitbucketWebhookSecret string
}

represents a decrypted record

func DecryptConnection

func DecryptConnection(g *models.VCSConnection, key []byte) (*DecryptedVCSConnection, error)

type DiggerGithubClientMockProvider

type DiggerGithubClientMockProvider struct {
	MockedHTTPClient *net.Client
}

func (DiggerGithubClientMockProvider) FetchCredentials

func (gh DiggerGithubClientMockProvider) FetchCredentials(githubAppId string) (string, string, string, string, error)

func (DiggerGithubClientMockProvider) Get

func (gh DiggerGithubClientMockProvider) Get(githubAppId int64, installationId int64) (*github.Client, *string, error)

func (DiggerGithubClientMockProvider) NewClient

func (gh DiggerGithubClientMockProvider) NewClient(netClient *net.Client) (*github.Client, error)

type DiggerGithubRealClientProvider

type DiggerGithubRealClientProvider struct {
}

just a wrapper around github client to be able to use mocks

func (DiggerGithubRealClientProvider) FetchCredentials

func (gh DiggerGithubRealClientProvider) FetchCredentials(githubAppId string) (string, string, string, string, error)

func (DiggerGithubRealClientProvider) Get

func (gh DiggerGithubRealClientProvider) Get(githubAppId int64, installationId int64) (*github.Client, *string, error)

func (DiggerGithubRealClientProvider) NewClient

func (gh DiggerGithubRealClientProvider) NewClient(netClient *net.Client) (*github.Client, error)

type GithubClientProvider

type GithubClientProvider interface {
	NewClient(netClient *net.Client) (*github.Client, error)
	Get(githubAppId int64, installationId int64) (*github.Client, *string, error)
	FetchCredentials(githubAppId string) (string, string, string, string, error)
}

type GitlabClientProvider

type GitlabClientProvider struct{}

func (GitlabClientProvider) NewClient

func (g GitlabClientProvider) NewClient(token string) (*gitlab.Client, error)

type GitlabProvider

type GitlabProvider interface {
	NewClient(token string) (*gitlab.Client, error)
}

type LoggingRoundTripper

type LoggingRoundTripper struct {
	Rt net.RoundTripper
}

func (*LoggingRoundTripper) RoundTrip

func (lrt *LoggingRoundTripper) RoundTrip(req *net.Request) (*net.Response, error)

type SentrySlogWriter

type SentrySlogWriter struct {
	// contains filtered or unexported fields
}

SentrySlogWriter adapts Sentry's log output to a structured logger.

func NewSentrySlogWriter

func NewSentrySlogWriter(logger *slog.Logger) *SentrySlogWriter

NewSentrySlogWriter creates a new adapter to redirect Sentry logs to slog.

func (*SentrySlogWriter) Write

func (s *SentrySlogWriter) Write(p []byte) (n int, err error)

Write implements io.Writer to process Sentry's logs and send them to slog.

Jump to

Keyboard shortcuts

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