ketchup

module
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: MIT

README

ketchup

Build codecov Go Report Card Quality Gate Status

Thanks to OpenEmoji for favicon.

Thanks to FontAwesome for icons.

Check your GitHub or Helm dependencies every day at 8am and send a digest by email.

Features

  • Timezone aware cron
  • Simple and plain HTML interface, mobile ready
  • Healthcheck available on /health endpoint
  • Version available on /version endpoint
  • Prometheus metrics for Golang and HTTP available on /metrics endpoint
  • Graceful shutdown of HTTP listener
  • Docker/Kubernetes ready container
  • 12factor app compliant

Getting started

Prerequisites

You need a GitHub OAuth Token, with no particular permission, for having a decent rate-limiting when querying GitHub. Configuration is done by passing -githubToken arg or setting equivalent environment variable (cf. Usage section)

You need a Postgres database for storing your datas. I personnaly use free tier of ElephantSQL. Once setup, you have to to create schema with Auth DDL and Ketchup DDL. Configuration is done by passing -dbHost, -dbName, -dbUser, -dbPass args or setting equivalent environment variables (cf. Usage section).

You need a Redis instance for storing captcha token and distributed locks accross multiples instances. Configuration is done by passing -redisAddress, -redisPassword, -redisDatabase args or setting equivalent environment variables (cf. Usage section).

In order to send email, you must configure a mailer. Configuration is done by passing -mailerURL arg or setting equivalent environment variable (cf. Usage section).

Installation

Golang binary is built with static link. You can download it directly from the GitHub Release page or build it by yourself by cloning this repo and running make.

A Docker image is available for amd64, arm and arm64 platforms on Docker Hub: vibioh/ketchup.

You can configure app by passing CLI args or environment variables (cf. Usage section). CLI override environment variables.

You'll find a Kubernetes exemple in the infra/ folder, using my app chart

Endpoints

  • GET /health: healthcheck of server, respond okStatus (default 204) or 503 during graceDuration when SIGTERM is received
  • GET /ready: same response than /health but it also checks external dependencies availability
  • GET /version: value of VERSION environment variable
  • GET /metrics: Prometheus metrics values

Usage

Usage of ketchup:
  -address string
        [server] Listen address {KETCHUP_ADDRESS}
  -cert string
        [server] Certificate file {KETCHUP_CERT}
  -corsCredentials
        [cors] Access-Control-Allow-Credentials {KETCHUP_CORS_CREDENTIALS}
  -corsExpose string
        [cors] Access-Control-Expose-Headers {KETCHUP_CORS_EXPOSE}
  -corsHeaders string
        [cors] Access-Control-Allow-Headers {KETCHUP_CORS_HEADERS} (default "Content-Type")
  -corsMethods string
        [cors] Access-Control-Allow-Methods {KETCHUP_CORS_METHODS} (default "GET")
  -corsOrigin string
        [cors] Access-Control-Allow-Origin {KETCHUP_CORS_ORIGIN} (default "*")
  -csp string
        [owasp] Content-Security-Policy {KETCHUP_CSP} (default "default-src 'self'; base-uri 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'")
  -dbHost string
        [db] Host {KETCHUP_DB_HOST}
  -dbMaxConn uint
        [db] Max Open Connections {KETCHUP_DB_MAX_CONN} (default 5)
  -dbName string
        [db] Name {KETCHUP_DB_NAME}
  -dbPass string
        [db] Pass {KETCHUP_DB_PASS}
  -dbPort uint
        [db] Port {KETCHUP_DB_PORT} (default 5432)
  -dbSslmode string
        [db] SSL Mode {KETCHUP_DB_SSLMODE} (default "disable")
  -dbUser string
        [db] User {KETCHUP_DB_USER}
  -frameOptions string
        [owasp] X-Frame-Options {KETCHUP_FRAME_OPTIONS} (default "deny")
  -githubToken string
        [github] OAuth Token {KETCHUP_GITHUB_TOKEN}
  -graceDuration string
        [http] Grace duration when SIGTERM received {KETCHUP_GRACE_DURATION} (default "30s")
  -hsts
        [owasp] Indicate Strict Transport Security {KETCHUP_HSTS} (default true)
  -idleTimeout string
        [server] Idle Timeout {KETCHUP_IDLE_TIMEOUT} (default "2m")
  -key string
        [server] Key file {KETCHUP_KEY}
  -loggerJson
        [logger] Log format as JSON {KETCHUP_LOGGER_JSON}
  -loggerLevel string
        [logger] Logger level {KETCHUP_LOGGER_LEVEL} (default "INFO")
  -loggerLevelKey string
        [logger] Key for level in JSON {KETCHUP_LOGGER_LEVEL_KEY} (default "level")
  -loggerMessageKey string
        [logger] Key for message in JSON {KETCHUP_LOGGER_MESSAGE_KEY} (default "message")
  -loggerTimeKey string
        [logger] Key for timestamp in JSON {KETCHUP_LOGGER_TIME_KEY} (default "time")
  -mailerName string
        [mailer] HTTP Username or AMQP Exchange name {KETCHUP_MAILER_NAME} (default "mailer")
  -mailerPassword string
        [mailer] HTTP Pass {KETCHUP_MAILER_PASSWORD}
  -mailerURL string
        [mailer] URL (https?:// or amqps?://) {KETCHUP_MAILER_URL}
  -notifierLoginID uint
        [notifier] Scheduler user ID {KETCHUP_NOTIFIER_LOGIN_ID} (default 1)
  -notifierPushUrl string
        [notifier] Pushgateway URL {KETCHUP_NOTIFIER_PUSH_URL}
  -okStatus int
        [http] Healthy HTTP Status code {KETCHUP_OK_STATUS} (default 204)
  -port uint
        [server] Listen port {KETCHUP_PORT} (default 1080)
  -prometheusAddress string
        [prometheus] Listen address {KETCHUP_PROMETHEUS_ADDRESS}
  -prometheusCert string
        [prometheus] Certificate file {KETCHUP_PROMETHEUS_CERT}
  -prometheusIdleTimeout string
        [prometheus] Idle Timeout {KETCHUP_PROMETHEUS_IDLE_TIMEOUT} (default "10s")
  -prometheusIgnore string
        [prometheus] Ignored path prefixes for metrics, comma separated {KETCHUP_PROMETHEUS_IGNORE}
  -prometheusKey string
        [prometheus] Key file {KETCHUP_PROMETHEUS_KEY}
  -prometheusPort uint
        [prometheus] Listen port {KETCHUP_PROMETHEUS_PORT} (default 9090)
  -prometheusReadTimeout string
        [prometheus] Read Timeout {KETCHUP_PROMETHEUS_READ_TIMEOUT} (default "5s")
  -prometheusShutdownTimeout string
        [prometheus] Shutdown Timeout {KETCHUP_PROMETHEUS_SHUTDOWN_TIMEOUT} (default "5s")
  -prometheusWriteTimeout string
        [prometheus] Write Timeout {KETCHUP_PROMETHEUS_WRITE_TIMEOUT} (default "10s")
  -publicURL string
        Public URL {KETCHUP_PUBLIC_URL} (default "https://ketchup.vibioh.fr")
  -readTimeout string
        [server] Read Timeout {KETCHUP_READ_TIMEOUT} (default "5s")
  -redisAddress string
        [redis] Redis Address {KETCHUP_REDIS_ADDRESS} (default "localhost:6379")
  -redisDatabase int
        [redis] Redis Database {KETCHUP_REDIS_DATABASE}
  -redisPassword string
        [redis] Redis Password, if any {KETCHUP_REDIS_PASSWORD}
  -schedulerEnabled
        [scheduler] Enable cron job {KETCHUP_SCHEDULER_ENABLED} (default true)
  -schedulerHour string
        [scheduler] Hour of cron, 24-hour format {KETCHUP_SCHEDULER_HOUR} (default "08:00")
  -schedulerTimezone string
        [scheduler] Timezone {KETCHUP_SCHEDULER_TIMEZONE} (default "Europe/Paris")
  -shutdownTimeout string
        [server] Shutdown Timeout {KETCHUP_SHUTDOWN_TIMEOUT} (default "10s")
  -title string
        Application title {KETCHUP_TITLE} (default "Ketchup")
  -url string
        [alcotest] URL to check {KETCHUP_URL}
  -userAgent string
        [alcotest] User-Agent for check {KETCHUP_USER_AGENT} (default "Alcotest")
  -writeTimeout string
        [server] Write Timeout {KETCHUP_WRITE_TIMEOUT} (default "10s")

Contributing

Thanks for your interest in contributing! There are many ways to contribute to this project. Get started here.

CI

Following variables are required for CI:

Name Purpose
DOCKER_USER for publishing Docker image
DOCKER_PASS for publishing Docker image
SCRIPTS_NO_INTERACTIVE for disabling prompt in CI

Jump to

Keyboard shortcuts

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