prbot

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

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

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

pr-bot

PR-Bot is an event driven service that listens to GitHub webhooks and performs actions based on the events received.

Development

Local Setup

In order to run the PR-Bot locally, you will need to setup a webhook proxy to receive the GitHub webhooks and forward them to your local service. You can use smee.io for this purpose.

  1. https://smee.io/ to setup the webhook proxy.
  2. Setup the webhook in the github repository with the smee.io url with the pull request scopes. NOTE: Make sure that the content-type is set to application/json in the webhook settings.
  3. Get your AWS credentials.
  4. Run the pr-bot service locally with make run.
  5. In a separate terminal run smee -u SMEE_CHANNEL_URL --target http://localhost:9090/v1/webhook.

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"`
		DisableTLS bool   `yaml:"DisableTLS" env:"DISABLE_TLS" env-default:"false" env-description:"Disable TLS"`
		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_"`
	Datastore struct {
		Table string        `yaml:"Table" env:"TABLE"`
		TTL   time.Duration `yaml:"TTL" env:"TTL"`
	} `yaml:"Datastore" env-prefix:"DATASTORE_"`
	Identity struct {
		AllowedCallerArns     []string `yaml:"AllowedCallerArns" env:"ALLOWED_CALLER_ARNS"`
		AllowedCallerAccounts []string `yaml:"AllowedCallerAccounts" env:"ALLOWED_CALLER_ACCOUNTS"`
	} `yaml:"Identity" env-prefix:"IDENTITY_"`
}

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
pr-bot command
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
⌂ 换网址