githubapi

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApprovePr

func ApprovePr(approverClient *github.Client, ghPrClientDetails GhPrClientDetails, prNumber *int) error

func BumpVersion added in v0.0.17

func BumpVersion(ghPrClientDetails GhPrClientDetails, defaultBranch string, filePath string, newFileContent string, triggeringRepo string, triggeringRepoSHA string, triggeringActor string, autoMerge bool) error

func CompareRepoDirectories

func CompareRepoDirectories(ghPrClientDetails GhPrClientDetails, sourcePath string, targetPath string, defaultBranch string) (bool, string, error)

func DetectDrift added in v0.0.8

func DetectDrift(ghPrClientDetails GhPrClientDetails) error

func DoesPrHasLabel

func DoesPrHasLabel(eventPayload github.PullRequestEvent, name string) bool

func GeneratePromotionPlan added in v0.0.8

func GeneratePromotionPlan(ghPrClientDetails GhPrClientDetails, config *cfg.Config, configBranch string) (map[string]PromotionInstance, error)

func GenerateSyncTreeEntriesForCommit added in v0.0.17

func GenerateSyncTreeEntriesForCommit(treeEntries *[]*github.TreeEntry, ghPrClientDetails GhPrClientDetails, sourcePath string, targetPath string, defaultBranch string) error

func GetBotGhIdentity added in v0.1.4

func GetBotGhIdentity(githubGraphQlClient *githubv4.Client, ctx context.Context) (string, error)

go-github is my peffered way to interact with GitHub because of the better developer expirience(pre made types, easy API mocking). But some functionality is not availalble in GH V3 rest API, like PR comment minimization, so here we are:

func GetFileContent

func GetFileContent(ghPrClientDetails GhPrClientDetails, branch string, filePath string) (string, error, int)

func GetInRepoConfig added in v0.0.8

func GetInRepoConfig(ghPrClientDetails GhPrClientDetails, defaultBranch string) (*cfg.Config, error)

func HandleEvent added in v0.0.8

func HandleEvent(r *http.Request, ctx context.Context, mainGhClientCache *lru.Cache[string, GhClientPair], prApproverGhClientCache *lru.Cache[string, GhClientPair], githubWebhookSecret []byte)

func HandlePREvent added in v0.1.4

func HandlePREvent(eventPayload *github.PullRequestEvent, ghPrClientDetails GhPrClientDetails, mainGithubClientPair GhClientPair, approverGithubClientPair GhClientPair, ctx context.Context)

func MergePr added in v0.1.7

func MergePr(details GhPrClientDetails, number *int) error

func MimizeStalePrComments

func MimizeStalePrComments(ghPrClientDetails GhPrClientDetails, githubGraphQlClient *githubv4.Client, botIdentity string) error

func SetCommitStatus

func SetCommitStatus(ghPrClientDetails GhPrClientDetails, state string)

Types

type GhClientPair added in v0.1.4

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

func (*GhClientPair) GetAndCache added in v0.1.7

func (gcp *GhClientPair) GetAndCache(ghClientCache *lru.Cache[string, GhClientPair], ghAppIdEnvVarName string, ghAppPKeyPathEnvVarName string, ghOauthTokenEnvVarName string, repoOwner string, ctx context.Context)

type GhPrClientDetails

type GhPrClientDetails struct {
	GhClientPair *GhClientPair
	// This whole struct describe the metadata of the PR, so it makes sense to share the context with everything to generate HTTP calls related to that PR, right?
	Ctx           context.Context //nolint:containedctx
	DefaultBranch string
	Owner         string
	Repo          string
	PrAuthor      string
	PrNumber      int
	PrSHA         string
	Ref           string
	PrLogger      *log.Entry
	Labels        []*github.Label
	PrMetadata    prMetadata
}

func (GhPrClientDetails) CommentOnPr

func (p GhPrClientDetails) CommentOnPr(commentBody string) error

func (*GhPrClientDetails) GetDefaultBranch

func (p *GhPrClientDetails) GetDefaultBranch() (string, error)

func (*GhPrClientDetails) GetRef

func (p *GhPrClientDetails) GetRef() (string, error)

func (*GhPrClientDetails) GetSHA

func (p *GhPrClientDetails) GetSHA() (string, error)

func (*GhPrClientDetails) ToggleCommitStatus

func (p *GhPrClientDetails) ToggleCommitStatus(context string, user string) error

type PromotionInstance added in v0.0.8

type PromotionInstance struct {
	Metadata          PromotionInstanceMetaData `deep:"-"` // Unit tests ignore Metadata currently
	ComputedSyncPaths map[string]string         // key is target, value is source
}

type PromotionInstanceMetaData added in v0.0.8

type PromotionInstanceMetaData struct {
	SourcePath                     string
	TargetPaths                    []string
	PerComponentSkippedTargetPaths map[string][]string // ComponentName is the key,
	ComponentNames                 []string
	AutoMerge                      bool
}

Jump to

Keyboard shortcuts

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