config

package
v0.0.0-...-8990c7c Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFile = "deployer.conf"

ConfigFile name

Variables

This section is empty.

Functions

func GenKeyHex

func GenKeyHex(byteLen int) string

GenKeyHex generates a crypto-random key with byte length byteLen and hex-encodes it to a string.

func Init

func Init() (string, error)

Init generates an initial config string.

Types

type Config

type Config struct {
	Address string `hcl:"address" envconfig:"DEPLOYER_ADDRESS"`
	BaseURL string `hcl:"base_url" envconfig:"DEPLOYER_BASE_URL"`
	Title   string `hcl:"title" envconfig:"DEPLOYER_TITLE"`

	JWT struct {
		Secret string `hcl:"secret" envconfig:"DEPLOYER_JWT_SECRET"`
	} `hcl:"jwt"`

	FileStorage struct {
		Type string `hcl:"type" envconfig:"DEPLOYER_FILE_STORAGE_TYPE"`

		Local struct {
			Dir string `hcl:"dir" envconfig:"DEPLOYER_FILE_STORAGE_LOCAL_DIR"`
		} `hcl:"local"`

		GoogleCloudStorage struct {
			ServiceAccountFile string `hcl:"service_account_file" envconfig:"DEPLOYER_FILE_STORAGE_GCS_SERVICE_ACCOUNT_FILE"`
			Bucket             string `hcl:"bucket" envconfig:"DEPLOYER_FILE_STORAGE_GCS_BUCKET"`
		} `hcl:"google_cloud_storage"`

		AmazonS3 struct {
			AccessKey string `hcl:"access_key" envconfig:"DEPLOYER_FILE_STORAGE_S3_ACCESS_KEY"`
			SecretKey string `hcl:"secret_key" envconfig:"DEPLOYER_FILE_STORAGE_S3_SECRET_KEY"`
			Region    string `hcl:"region" envconfig:"DEPLOYER_FILE_STORAGE_S3_REGION"`
			Bucket    string `hcl:"bucket" envconfig:"DEPLOYER_FILE_STORAGE_S3_BUCKET"`
		} `hcl:"amazon_s3"`
	} `hcl:"file_storage"`

	Store struct {
		Type string `hcl:"type" envconfig:"DEPLOYER_STORE_TYPE"`

		PostgreSQL struct {
			Address     string `hcl:"address" envconfig:"DEPLOYER_STORE_POSTGRESQL_ADDRESS"`
			Username    string `hcl:"username" envconfig:"DEPLOYER_STORE_POSTGRESQL_USERNAME"`
			Password    string `hcl:"password" envconfig:"DEPLOYER_STORE_POSTGRESQL_PASSWORD"`
			Database    string `hcl:"database" envconfig:"DEPLOYER_STORE_POSTGRESQL_DATABASE"`
			SSLMode     string `hcl:"sslmode" envconfig:"DEPLOYER_STORE_POSTGRESQL_SSLMODE"`
			SSLRootCert string `hcl:"sslrootcert" envconfig:"DEPLOYER_STORE_POSTGRESQL_SSLROOTCERT"`
		} `hcl:"postgresql"`

		MySQL struct {
			Address  string `hcl:"address" envconfig:"DEPLOYER_STORE_MYSQL_ADDRESS"`
			Username string `hcl:"username" envconfig:"DEPLOYER_STORE_MYSQL_USERNAME"`
			Password string `hcl:"password" envconfig:"DEPLOYER_STORE_MYSQL_PASSWORD"`
			Database string `hcl:"database" envconfig:"DEPLOYER_STORE_MYSQL_DATABASE"`
		} `hcl:"mysql"`
	} `hcl:"store"`

	OAuth struct {
		Google struct {
			ClientID string `hcl:"client_id" envconfig:"DEPLOYER_OAUTH_GOOGLE_CLIENT_ID"`
			Secret   string `hcl:"secret" envconfig:"DEPLOYER_OAUTH_GOOGLE_SECRET"`
		} `hcl:"google"`

		Facebook struct {
			ClientID string `hcl:"client_id" envconfig:"DEPLOYER_OAUTH_FACEBOOK_CLIENT_ID"`
			Secret   string `hcl:"secret" envconfig:"DEPLOYER_OAUTH_FACEBOOK_SECRET"`
		} `hcl:"facebook"`

		Github struct {
			ClientID string `hcl:"client_id" envconfig:"DEPLOYER_OAUTH_GITHUB_CLIENT_ID"`
			Secret   string `hcl:"secret" envconfig:"DEPLOYER_OAUTH_GITHUB_SECRET"`
		} `hcl:"github"`
	} `hcl:"oauth"`
}

Config is a deployer configuration struct.

func GetConfig

func GetConfig(useEnv bool) (cfg *Config, err error)

GetConfig loads configuration from environment variables or from file.

func ReadEnv

func ReadEnv() (*Config, error)

ReadEnv reads a deployer config from environment variables.

func ReadFile

func ReadFile(filename string) (*Config, error)

ReadFile reads a deployer config from file.

Jump to

Keyboard shortcuts

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