ketchup

module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: MIT

README

ketchup

Build Status codecov Go Report Card Dependabot Status Quality Gate Status

Thanks to OpenEmoji for favicon.

Thanks to FontAwesome for icons.

Check your Github dependencies every day at 8am and send a digest by email.

Features

  • Timezone aware cron
  • Simple and plain HTML interface, mobile ready
  • Swagger UI documentation available on /api endpoint
  • 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 provided SQL. Configuration is done by passing -dbHost, -dbName, -dbUser, -dbPass arg 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 (without secrets) in the infra/ folder. We don't manage authentification and rely on Traefik basic-auth.

Mailer

Usage

Usage of ketchup:
  -address string
        [http] Listen address {KETCHUP_ADDRESS}
  -cert string
        [http] 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'")
  -dbHost string
        [db] Host {KETCHUP_DB_HOST}
  -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 "15s")
  -hsts
        [owasp] Indicate Strict Transport Security {KETCHUP_HSTS} (default true)
  -ketchupsDefaultPage uint
        [ketchups] Default page {KETCHUP_KETCHUPS_DEFAULT_PAGE} (default 1)
  -ketchupsDefaultPageSize uint
        [ketchups] Default page size {KETCHUP_KETCHUPS_DEFAULT_PAGE_SIZE} (default 20)
  -ketchupsMaxPageSize uint
        [ketchups] Max page size {KETCHUP_KETCHUPS_MAX_PAGE_SIZE} (default 100)
  -ketchupsName string
        [ketchups] Resource's name {KETCHUP_KETCHUPS_NAME} (default "Ketchup")
  -ketchupsPath string
        [ketchups] HTTP Path {KETCHUP_KETCHUPS_PATH} (default "/api/ketchups")
  -key string
        [http] Key file {KETCHUP_KEY}
  -mailerPass string
        [mailer] Pass {KETCHUP_MAILER_PASS}
  -mailerURL string
        [mailer] URL (an instance of github.com/ViBiOh/mailer) {KETCHUP_MAILER_URL}
  -mailerUser string
        [mailer] User {KETCHUP_MAILER_USER}
  -okStatus int
        [http] Healthy HTTP Status code {KETCHUP_OK_STATUS} (default 204)
  -port uint
        [http] Listen port {KETCHUP_PORT} (default 1080)
  -prometheusPath string
        [prometheus] Path for exposing metrics {KETCHUP_PROMETHEUS_PATH} (default "/metrics")
  -schedulerHour string
        [scheduler] Hour of cron, 24-hour format {KETCHUP_SCHEDULER_HOUR} (default "08:00")
  -schedulerLoginID uint
        [scheduler] Scheduler user ID {KETCHUP_SCHEDULER_LOGIN_ID} (default 1)
  -schedulerTimezone string
        [scheduler] Timezone {KETCHUP_SCHEDULER_TIMEZONE} (default "Europe/Paris")
  -swaggerTitle string
        [swagger] API Title {KETCHUP_SWAGGER_TITLE} (default "API")
  -swaggerVersion string
        [swagger] API Version {KETCHUP_SWAGGER_VERSION} (default "1.0.0")
  -url string
        [alcotest] URL to check {KETCHUP_URL}
  -userAgent string
        [alcotest] User-Agent for check {KETCHUP_USER_AGENT} (default "Alcotest")
  -usersDefaultPage uint
        [users] Default page {KETCHUP_USERS_DEFAULT_PAGE} (default 1)
  -usersDefaultPageSize uint
        [users] Default page size {KETCHUP_USERS_DEFAULT_PAGE_SIZE} (default 20)
  -usersMaxPageSize uint
        [users] Max page size {KETCHUP_USERS_MAX_PAGE_SIZE} (default 100)
  -usersName string
        [users] Resource's name {KETCHUP_USERS_NAME} (default "Users")
  -usersPath string
        [users] HTTP Path {KETCHUP_USERS_PATH} (default "/api/users")

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