prbot

package module
v0.0.0-...-b5dc63d Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

README

pr-bot

Service backing PR bot github app

Documentation

Index

Constants

View Source
const APIVersion string = "/v1"
View Source
const UI string = "/ui"

Variables

This section is empty.

Functions

func ProcessCLIArgs

func ProcessCLIArgs(cfg *Config) string

ProcessArgs processes and handles CLI arguments

Types

type Config

type Config struct {
	Build struct {
		Commit  string `yaml:"Commit" env:"COMMIT" env-description:"Commit hash of the build passed"`
		Repo    string `yaml:"Repo" env:"REPO" env-description:"Github repo containing the source of the build"`
		Version string `yaml:"Version" env:"VERSION" env-description:"Version number 1-0.14.qwehsadhascxzva"`
	} `yaml:"Build" env-prefix:"BUILD_"`
	ServiceName string `yaml:"ServiceName" env:"SERVICE_NAME" env-default:"pr-bot" env-description:"Name of the service"`
	Env         string `yaml:"Env" env:"ENV" env-default:"local" env-description:"stage name; one of local|dev|staging|prod"`
	Server      struct {
		Host string `yaml:"Host" env:"HOST" env-description:"Server host"`
		Port int    `yaml:"Port" env:"PORT" env-description:"Server port"`
		TLS  struct {
			CertFile string `yaml:"CertFile" env:"CERT_FILE" env-description:"Server certificate file path"`
			KeyFile  string `yaml:"KeyFile" env:"KEY_FILE" env-description:"File path of server cert's private key"`
		} `yaml:"TLS" env-prefix:"TLS_"`
	} `yaml:"Server" env-prefix:"SERVER_"`
	AWS struct {
		Region  string `yaml:"REGION" env:"REGION" env-default:"us-east-1"`
		Secrets struct {
			Webhook string `yaml:"Webhook" env:"WEBHOOK" env-default:"/ci/pr-bot/webhook"`
			Token   string `yaml:"Token" env:"TOKEN" env-default:"/ci/pr-bot/token"`
		} `yaml:"Secrets" env-prefix:"SECRETS_"`
	} `yaml:"AWS" env-prefix:"AWS_"`
	OPA struct {
		Bundles struct {
			Root     string `yaml:"Root" env:"ROOT"`
			Filename string `yaml:"Filename" env:"FILENAME"`
			ECR      struct {
				Registry string `yaml:"Registry" env:"REGISTRY"`
				Repo     string `yaml:"Repo" env:"REPO"`
				Tag      string `yaml:"Tag" env:"TAG"`
			} `yaml:"ECR" env-prefix:"ECR_"`
		} `yaml:"Bundles" env-prefix:"BUNDLES_"`
		EvaluationReport struct {
			TTL       time.Duration `yaml:"TTL" env:"TTL"`
			TableName string        `yaml:"TableName" env:"TABLE_NAME"`
		} `yaml:"EvaluationReport" env-prefix:"EVALUATION_REPORT_"`
	} `yaml:"OPA" env-prefix:"OPA_"`
	Reviewer struct {
		Locker struct {
			TableName string `yaml:"TableName" env:"TABLE_NAME"`
		} `yaml:"Locker" env-prefix:"LOCKER_"`
	} `yaml:"Reviewer" env-prefix:"REVIEWER_"`
	GHE struct {
		ServiceAccount string `yaml:"ServiceAccount" env:"SERVICE_ACCOUNT"`
		Hostname       string `yaml:"Hostname" env:"HOSTNAME" env-default:"github.com"`
	} `yaml:"GHE" env-prefix:"GHE_"`
	ConfigStore struct {
		Table   string        `yaml:"Table" env:"TABLE"`
		Refresh time.Duration `yaml:"Refresh" env:"REFRESH"`
	} `yaml:"ConfigStore" env-prefix:"CONFIG_STORE_"`
	Throttler struct {
		Table        string `yaml:"Table" env:"TABLE"`
		PartitionKey string `yaml:"PartitionKey" env:"PARTITION_KEY"`
		SortKey      string `yaml:"SortKey" env:"SORT_KEY"`
		TTLFieldName string `yaml:"TTLFieldName" env:"TTL_FIELD_NAME"`
	} `yaml:"Throttler" env-prefix:"THROTTLER_"`
}

func ParseConfigFiles

func ParseConfigFiles() (*Config, error)

type Endpoint

type Endpoint interface {
	Routes() chi.Router
	Path() string
}

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg *Config, routes http.Handler) *Server

NewServer creates and configures a server

func (*Server) Start

func (srv *Server) Start()

func (*Server) WaitForGracefulShutdown

func (srv *Server) WaitForGracefulShutdown()

type Service

type Service struct {
	Router            *chi.Mux
	Config            *Config
	Logger            zerolog.Logger
	Secrets           secrets.Manager
	DDB               *dynamodb.Client
	ECR               *ecr.Client
	Metrics           metrics.Emitter
	EvaluationManager evaluation.Manager
}

func NewService

func NewService(cfg *Config) (*Service, error)

func (*Service) Close

func (s *Service) Close()

func (*Service) MountRoutes

func (s *Service) MountRoutes(healthcheck Endpoint, endpoints []Endpoint)

Directories

Path Synopsis
cmd
opa
ui
templates
templ: version: v0.2.543
templ: version: v0.2.543
templates/components
templ: version: v0.2.543
templ: version: v0.2.543
templates/pages
templ: version: v0.2.543
templ: version: v0.2.543

Jump to

Keyboard shortcuts

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