config

package
v0.0.0-...-5fb48e9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config provides the configuration helpers for gopher, for pulling configuration from the environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLogger

func DefaultLogger(cfg C) zerolog.Logger

DefaultLogger returns a zerolog.Logger using settings from our config struct.

func DefaultRedis

func DefaultRedis(cfg C) *redis.Options

DefaultRedis returns a default Redis config from our own config struct.

Types

type C

type C struct {
	// LogLevel is the logging level
	// Env: LOG_LEVEL
	LogLevel zerolog.Level

	// Env is the current environment.
	// Env: ENV
	Env Environment

	// Port is the TCP port for web workers to listen on, loaded from PORT
	// Env: PORT
	Port uint16

	// Heroku are the Labs Dyno Metadata environment variables
	Heroku H

	// Redis is the Redis configuration, loaded from REDIS_URL
	Redis R

	// Slack is the Slack configuration, loaded from a few SLACK_* environment
	// variables
	Slack S
}

C is the configuration struct.

func LoadEnv

func LoadEnv() (C, error)

LoadEnv loads the configuration from the appropriate environment variables.

type Environment

type Environment string

Environment is the current runtime environment.

const (
	// Development is for when it's the development environment
	Development Environment = "development"

	// Testing is WISOTT
	Testing Environment = "testing"

	// Staging is WISOTT
	Staging Environment = "staging"

	// Production is WISOTT
	Production Environment = "production"
)

type H

type H struct {
	// AppID is the HEROKU_APP_ID
	AppID string

	// AppName is the HEROKU_APP_NAME
	AppName string

	// DynoID is the HEROKU_DYNO_ID
	DynoID string

	// Commit is the HEROKU_SLUG_COMMIT
	Commit string
}

H is the Heroku environment configuration

type R

type R struct {
	// Addr is the Redis host and port to connect to
	Addr string

	// User is the Redis user
	User string

	// Password is the Redis password
	Password string

	// Insecure is whether we should connect to Redis over plain text
	Insecure bool

	// SkipVerify is whether we skip x.509 certification validation
	SkipVerify bool
}

R are the Redis-specific options.

type S

type S struct {
	// AppID is the Slack App ID
	// Env: SLACK_APP_ID
	AppID string

	// TeamID is the workspace the app is deployed to
	// ENV: SLACK_TEAM_ID
	TeamID string

	// BotAccessToken is the bot access token for API calls
	// ENV: SLACK_BOT_ACCESS_TOKEN
	BotAccessToken string

	// ClientID is the Client ID
	// Env: SLACK_CLIENT_ID
	ClientID string

	// ClientSecret is the Client secret
	// Env: SLACK_CLIENT_SECRET
	ClientSecret string

	// RequestSecret is the HMAC signing secret used for Slack request signing
	// Env: SLACK_REQUEST_SECRET
	RequestSecret string

	// RequestToken is the Slack verification token
	// Env: SLACK_REQUEST_TOKEN
	RequestToken string
}

S is the Slack environment configuration

Jump to

Keyboard shortcuts

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