Documentation ¶
Overview ¶
Package ghapp defines the actual HTTP application that handles webhooks for the GitHub App.
Index ¶
- Constants
- func BuildConfig(appId int64, webhookSecret string, privateKeySecret string) (*githubapp.Config, error)
- func LogErrorCallback(w http.ResponseWriter, r *http.Request, err error)
- type App
- type Config
- type ConfigFetcher
- type FetchedConfig
- type HTTPConfig
- type HydrosConfig
- type HydrosHandler
- type Server
Constants ¶
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 = ".github" )
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 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 ¶
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 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) 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.