environments

package
v0.0.0-...-c34d2c7 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package environments determines code behavior across services such as debug mode.

usage: config := environments.GetConfig(os.Getenv(environments.EnvVar))

Package environments determines code behavior across services such as debug mode.

usage: config := environments.GetConfig(os.Getenv(environments.EnvVar))

Index

Constants

View Source
const (
	// DefaultEnv is the fallback environment
	DefaultEnv = "development"
	// EnvVar is the typical environment variable used to determine
	// the current environment, e.g. with      os.Getenv(EnvVar)
	EnvVar = "ENV"
	// SentryEnvVar is the environment variable name for fetching this secret from k8s
	SentryEnvVar = "SENTRY_DSN"
	// DeployEnvVar is set by Kubernetes during a new deployment so we can identify the code version
	DeployEnvVar = "DEPLOY"
	// GoogleCloudSecretPath is the file location for the mounted GCloud auth token
	GoogleCloudSecretPath = "/etc/secrets/gcloud.json"
)
View Source
const (
	// GcloudEnvVar is the environment variable for accessing the GCloud secret key
	GcloudEnvVar = "GCLOUD"
	// GcloudProjectEnvVar is the environment variable for accessign the Gcloud project name
	GcloudProjectEnvVar = "GCLOUD_PROJECT"
)

Variables

This section is empty.

Functions

func GetGoogleCloudProject

func GetGoogleCloudProject() string

GetGoogleCloudProject returns the identifier of the google cloud project8

func GetPublicSentryDSN

func GetPublicSentryDSN(secret string) (string, error)

GetPublicSentryDSN returns a Sentry Id that can be returned in JS

Types

type Config

type Config struct {
	Name         string       // Name of the environment, which shows up in logs
	Debug        bool         // Controls security and log verbosity
	ExternalApex string       // Apex domain off of which services operate externally
	InternalApex string       // Apex domain off of which services operate internally
	LogLevel     logrus.Level // Verbosity of logging
	Scheme       string       // default URL scheme - http or https
}

Config controls behavior for the environment across services

func GetConfig

func GetConfig(envName string) (conf Config, err error)

GetConfig returns the environment config Typically you should use os.Getenv("ENV") and pass that in here,

func (*Config) GetDeployVersion

func (c *Config) GetDeployVersion() string

GetDeployVersion returns the current code version from Jenkins in non-dev environments

func (*Config) GetIntercomClient

func (c *Config) GetIntercomClient() *intercom.Client

GetIntercomClient reutrns an intercom.io client

func (*Config) GetLogger

func (c *Config) GetLogger(serviceName string) *logrus.Entry

GetLogger returns a structured logger

func (*Config) GetSentryDSN

func (c *Config) GetSentryDSN() string

GetSentryDSN returns the secret API key for Sentry.io

type SentryClient

type SentryClient interface {
	CapturePanicAndWait(func(), map[string]string, ...sentry.Interface) (interface{}, string)
	CaptureError(error, map[string]string, ...sentry.Interface) string
	SetHttpContext(*sentry.Http)
	SetUserContext(*sentry.User)
	ClearContext()
}

SentryClient is a type for handling errors (without importing sentry directly)

func ErrorClient

func ErrorClient(c SentryConfig) SentryClient

ErrorClient returns a an error handler for sending to GetSentry.com

type SentryConfig

type SentryConfig interface {
	GetSentryDSN() string
	GetDeployVersion() string

	GetLogger(string) *logrus.Entry
	// contains filtered or unexported methods
}

SentryConfig is an interface for being able to retrieve error handler funcs

Jump to

Keyboard shortcuts

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