app

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package app defines the actual HTTP application that handles webhooks for the GitHub App.

Index

Constants

View Source
const (
	// HydrosConfigPath default path to look for the hydros repository configuration file.
	// TODO(jeremy): We should expose this as a configuration option for hydros.
	HydrosConfigPath = "hydros.yaml"
	// SharedRepository is the name of the repository containing the shared hydros configurationf or all repositories
	SharedRepository = ".github"
)
View Source
const (
	UserAgent = "hydros/0.0.1"
)

Variables

This section is empty.

Functions

func BuildConfig

func BuildConfig(appId int64, webhookSecret string, privateKeySecret string) (*githubapp.Config, error)

BuildConfig is a helper function to build the GitHubApp configuration. Palantir libraries use *githubapp.Config for basic configuration. We don't necessarily want to directly use that configuration because not all of those options make sense. For example, we allow URIs to be used for the secrets. So this is a helper function to convert our values into githubapp.Config which can be passed to those libraries.

func LogErrorCallback

func LogErrorCallback(w http.ResponseWriter, r *http.Request, err error)

LogErrorCallback handles errors by logging them

Types

type App

type App struct {
	IntegrationID int64  `yaml:"integration_id" json:"integrationId"`
	WebhookSecret string `yaml:"webhook_secret" json:"webhookSecret"`
	PrivateKey    string `yaml:"private_key" json:"privateKey"`
}

type Config

type Config struct {
	Server HTTPConfig `yaml:"server"`

	AppConfig HydrosConfig `yaml:"app_configuration"`
}

Config is the configuration for the Hydros application For an example see here: https://github.com/palantir/go-githubapp/blob/6c13ccc79f901e0c04c7530df9c775a30347f3cd/example/config.yml

type ConfigFetcher

type ConfigFetcher struct {
	Loader *appconfig.Loader
}

func (*ConfigFetcher) ConfigForRepositoryBranch

func (cf *ConfigFetcher) ConfigForRepositoryBranch(ctx context.Context, client *github.Client, owner, repository, branch string) FetchedConfig

type FetchedConfig

type FetchedConfig struct {
	Config     *v1alpha1.HydrosConfig
	LoadError  error
	ParseError error

	Source string
	Path   string
}

FetchedConfig represents the hydros configuration fetched from GitHub and used to configure hydros

type HTTPConfig

type HTTPConfig struct {
	Address string `yaml:"address"`
	Port    int    `yaml:"port"`
}

type HydrosConfig

type HydrosConfig struct {
	// WebhookSecretURI allows the webhook secret to be provided as a URI
	// e.g. gcpSecretManager:///projects/${PROJECT}/secrets/${SECRET}/versions/latest
	WebhookSecretURI string `yaml:"webhook_secret_uri"`
}

HydrosConfig is configuration specific to hydros

type HydrosHandler

type HydrosHandler struct {
	githubapp.ClientCreator
	Manager *gitops.Manager
	// contains filtered or unexported fields
}

HydrosHandler is a handler for certain GitHub events. It currently handles PushEvents by sending them to Renderer which knows how to do in place modification using KRMs. TODO(jeremy): Also handle syncer.

func NewHandler

func NewHandler(cc githubapp.ClientCreator, transports *hGithub.TransportManager, workDir string, numWorkers int) (*HydrosHandler, error)

NewHandler starts a new HydrosHandler for GitHub. cc: ClientCreator for creating GitHub clients. transports: Manage GitHub transports workDir: The directory to use for storing temporary files and checking out repositories numWorkers: The number of workers to use for processing events

func (*HydrosHandler) Handle

func (h *HydrosHandler) Handle(ctx context.Context, eventType, deliveryID string, payload []byte) error

func (*HydrosHandler) Handles

func (h *HydrosHandler) Handles() []string

type Server

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

Server is the server that wraps hydros in order to handle webhooks

TODO(jeremy): We might want to add a queue similar to what we did in flock to handle multiple syncs

func NewServer

func NewServer(baseHREF string, port int, config githubapp.Config, handler *HydrosHandler) (*Server, error)

NewServer creates a new server that relies on IAP as an authentication proxy.

func (*Server) StartAndBlock

func (s *Server) StartAndBlock()

StartAndBlock starts the server and blocks.

Jump to

Keyboard shortcuts

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