gh_webhook

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	GitHubWebhookKeyMountPath string `env:"WEBHOOK_KEY_MOUNT_PATH,required"`
	GitHubWebhookKeyName      string `env:"WEBHOOK_KEY_NAME,required"`
	Port                      string `env:"PORT,default=8080"`
	PubSubTopic               string `env:"PUBSUB_TOPIC,required"`
	PubSubProjectID           string `env:"PUBSUB_PROJECT_ID,required"`
}

Config defines the set of environment variables required for running the webhook service.

func NewConfig

func NewConfig(ctx context.Context) (*Config, error)

NewConfig creates a new Config from environment variables.

func (*Config) ToFlags

func (cfg *Config) ToFlags(set *cli.FlagSet) *cli.FlagSet

ToFlags binds the config to the cli.FlagSet and returns it.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate validates the webhook config after load.

type FileReader

type FileReader interface {
	ReadFile(filename string) ([]byte, error)
}

FileReader can read a file and return the content.

func NewOSFileReader

func NewOSFileReader() FileReader

Provdes an instance of a FileReader.

type MockFileReader

type MockFileReader struct {
	ReadFileMock *ReadFileResErr
	ReadFileFunc func(filename string) ([]byte, error)
}

func (*MockFileReader) ReadFile

func (m *MockFileReader) ReadFile(filename string) ([]byte, error)

type OSFileReader

type OSFileReader struct{}

OSFileReader implements FileReader using the os package.

func (OSFileReader) ReadFile

func (o OSFileReader) ReadFile(filename string) ([]byte, error)

ReadFile reads a file and returns its content.

type ReadFileResErr

type ReadFileResErr struct {
	Res []byte
	Err error
}

type Server

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

Server provides the server implementation for receiving webhooks.

func NewServer

func NewServer(ctx context.Context, h *renderer.Renderer, cfg *Config, wco *WebhookClientOptions) (*Server, error)

NewServer creates a new HTTP server implementation that will handle receiving webhook payloads.

func (*Server) Close

func (s *Server) Close() error

Close handles the graceful shutdown of the webhook server.

func (*Server) Routes

func (s *Server) Routes(ctx context.Context) http.Handler

Routes creates a ServeMux for all the routes that this Router supports.

type WebhookClientOptions

type WebhookClientOptions struct {
	PubSubClientOverride *pubsub.Client
	OSFileReaderOverride FileReader
}

WebhookClientOptions encapsulate client config options as well as dependency implementation overrides.

Jump to

Keyboard shortcuts

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