controllers

package
v0.0.0-...-8da0845 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommitStatusSuccess CommitStatus = "success"
	CommitStatusFailure              = "failure"
	CommitStatusError                = "error"
	CommitStatusPending              = "pending"
)

Variables

This section is empty.

Functions

func GitHubEmptyCommitOnBranchWithDefaultClient

func GitHubEmptyCommitOnBranchWithDefaultClient(ctx context.Context, req githubv4.CreateCommitOnBranchInput, opts ...GHOption) (string, error)

GitHubEmptyCommitOnBranchWithDefaultClient creates an empty commit on a branch using the default client

Types

type AWS

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

func NewAWSController

func NewAWSController(opts ...Option) (*AWS, error)

func (*AWS) GetSecret

func (a *AWS) GetSecret(key string, encrypted bool) (*string, error)

func (*AWS) PutS3Object

func (a *AWS) PutS3Object(eventType, bucket string, body []byte) error

type Client

type Client struct {
	V3 *github.Client
	V4 *githubv4.Client
	// contains filtered or unexported fields
}

Client - cache struct holding an entry for each installation ID

type CommitOnBranchRequest

type CommitOnBranchRequest struct {
	Owner, Repository, Branch, Message string
}

type CommitStatus

type CommitStatus = string

type Credentials

type Credentials struct {
	AppId         int64                     `json:"app_id,omitempty"`
	PrivateKey    string                    `json:"private_key,omitempty"`
	WebhookSecret *validation.WebhookSecret `json:"webhook_secret"`
	Token         string                    `json:"token,omitempty"`
}

Credentials is a helper struct to hold the GitHub credentials

type EventInstallationId

type EventInstallationId struct {
	Installation struct {
		ID *int64 `json:"id"`
	} `json:"installation"`
}

type GHOption

type GHOption func(*GitHub)

func WithAWSController

func WithAWSController(aws *AWS) GHOption

func WithAuthMode

func WithAuthMode(mode string) GHOption

func WithLogger

func WithLogger(logger *slog.Logger) GHOption

func WithSSMKey

func WithSSMKey(key string) GHOption

func WithToken

func WithToken(token string) GHOption

func WithWebhookSecret

func WithWebhookSecret(secret *validation.WebhookSecret) GHOption

type GitHub

type GitHub struct {
	Credentials
	// contains filtered or unexported fields
}

func NewGitHubController

func NewGitHubController(opts ...GHOption) (*GitHub, error)

func (*GitHub) CreatePromotionTargetRef

func (g *GitHub) CreatePromotionTargetRef(pCtx *promotion.Context) (*github.Reference, error)

CreatePromotionTargetRef creates a new ref in the repository

func (*GitHub) CreatePullRequest

func (g *GitHub) CreatePullRequest(pCtx *promotion.Context) (*github.PullRequest, error)

CreatePullRequest creates a new pull request in the repository

func (*GitHub) EmptyCommitOnBranch

func (g *GitHub) EmptyCommitOnBranch(clients *Client, ctx context.Context, createCommitOnBranchInput githubv4.CreateCommitOnBranchInput) (string, error)

EmptyCommitOnBranch creates an empty commit on a branch

func (*GitHub) FastForwardRefToSha

func (g *GitHub) FastForwardRefToSha(pCtx *promotion.Context) error

FastForwardRefToSha pushes a commit to a ref, used to merge an open pull request via fast-forward

func (*GitHub) FindPullRequest

func (g *GitHub) FindPullRequest(pCtx *promotion.Context) (*github.PullRequest, error)

FindPullRequest searches for an open pull request that matches the promotion request

func (*GitHub) GetGitHubClients

func (g *GitHub) GetGitHubClients(body []byte) (*Client, error)

GetGitHubClients returns a GitHub client for the given installation ID or token

func (*GitHub) GetPromotionSourceRootRef

func (g *GitHub) GetPromotionSourceRootRef(pCtx *promotion.Context) (*string, error)

GetPromotionSourceRootRef fetches the root commit present on the head ref

func (*GitHub) PromotionTargetRefExists

func (g *GitHub) PromotionTargetRefExists(ctx *promotion.Context) bool

PromotionTargetRefExists checks if a ref exists in the repository

func (*GitHub) RateLimits

func (g *GitHub) RateLimits(clt *github.Client) (*github.RateLimits, error)

RateLimits fetches the rate limits for the currently authenticated identity

func (*GitHub) RequestTitle

func (g *GitHub) RequestTitle(pCtx promotion.Context) *string

RequestTitle generates a title for a promotion request

func (*GitHub) RetrieveCredentials

func (g *GitHub) RetrieveCredentials() error

RetrieveCredentials fetches the GitHub credentials from the environment or SSM

func (*GitHub) SendPromotionFeedbackCommitStatus

func (g *GitHub) SendPromotionFeedbackCommitStatus(context string, promotionResult *promotion.Result, promotionError error, commitStatus CommitStatus) error

SendPromotionFeedbackCommitStatus sends a commit status to the head commit of the promotion request

func (*GitHub) ValidateWebhookSecret

func (g *GitHub) ValidateWebhookSecret(secret []byte, headers map[string]string) error

type Option

type Option func(*AWS)

func WithAWSContext

func WithAWSContext(ctx context.Context) Option

func WithAWSLogger

func WithAWSLogger(logger *slog.Logger) Option

Jump to

Keyboard shortcuts

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