env

package module
Version: v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: AGPL-3.0 Imports: 14 Imported by: 8

README

Overview:

This repo facilitates the management of environment variables for a given Unee-T installation.

This is one of the dependency which is called when you deploy several of the Unee-T modules we need for a complete Unee-T installation.

This will create the following functions:

  • GetSecret: Get the value of an AWS Parameter from the paramater store based on the AWS variable name.
  • New:
  • Bucket: Create the S3 Bucket we need for a given Unee-T service.
  • SNS: Create the arn endpoint we need when we deploy Unee-T dependencies
  • Udomain: Create the urls for each service we need for a given Unee-T environment based on the DOMAIN and STAGE (DEV, DEMO or PROD).
  • BugzillaDSN: get the string needed to access the bugzilla database. This is based on the AWS variables
    • MYSQL_HOST
    • MYSQL_PORT
    • BUGZILLA_DB_NAME
    • BUGZILLA_DB_USER
    • BUGZILLA_DB_PASSWORD
  • Protect: Make sure all calls are protected with the API key for this installation using: curl -H 'Authorization: Bearer secret' style
  • Towr: A workaround for gorilla/pat: https://stackoverflow.com/questions/50753049/

Pre-requisite:

In each of the environments that will need this code, the following AWS secrets MUST have been declared:

  • DOMAIN
  • INSTALLATION_ID
  • STAGE
  • DEFAULT_REGION
  • MYSQL_HOST
  • MYSQL_PORT
  • BUGZILLA_DB_NAME
  • BUGZILLA_DB_USER
  • BUGZILLA_DB_PASSWORD

Unee-T modules which uses a go.mod files:

For the following repositories, the dependancy is declared in the file go.mod:

Deployment:
  • Tag release this repo with a version number [version]
  • In each of the repositories that uses this codebase (see above),
    • Update the go dependancy go get -u See Using Go Modules for more information
    • Deploy the updated code (this is usually done via a tag release of the code in the repo for that code).

Other Unee-T modules that uses this codebase:

For the following modules the dependency is declared directly in the file main.go:

Deployment:
  • Tag release this repo with a version number [version]
  • In each of the repositories that uses this codebase (see above),
    • update the relevant line in file main.mod to the new [version] number : Example:
      require (
      	...
          github.com/unee-t-ins/env [version]
          ...
      )
      
    • Deploy the updated code (this is usually done via a tag release of the code in the repo for that code).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Protect

func Protect(currentBzConnexion http.Handler, APIAccessToken string) http.Handler

Protect using: curl -H 'Authorization: Bearer secret' style Modelled after https://github.com/apex/up-examples/blob/master/oss/golang-basic-auth/main.go#L16

func Towr

func Towr(currentBzConnexion http.Handler) func(http.ResponseWriter, *http.Request)

Towr is a workaround for gorilla/pat: https://stackoverflow.com/questions/50753049/ Wish I could make this simpler

Types

type Environment added in v1.0.2

type Environment struct {
	Cfg       aws.Config
	AccountID string
	Stage     string
	// contains filtered or unexported fields
}

Environment is a type of variable to help us manage our differing {dev,demo,prod} AWS accounts

func NewConfig added in v0.4.0

func NewConfig(cfg aws.Config) (thisEnvironment Environment, err error)

NewConfig setups the configuration assuming various parameters have been setup in the AWS account - DEFAULT_REGION - STAGE

func (Environment) Bucket added in v1.0.2

func (thisEnvironment Environment) Bucket(svc string) string

func (Environment) BugzillaDSN added in v1.0.2

func (thisEnvironment Environment) BugzillaDSN() string

func (Environment) GetSecret added in v1.0.2

func (thisEnvironment Environment) GetSecret(key string) string

func (Environment) SNS added in v1.0.2

func (thisEnvironment Environment) SNS(name, region string) string

func (Environment) Udomain added in v1.0.2

func (thisEnvironment Environment) Udomain(service string) string

type EnvironmentId added in v1.0.3

type EnvironmentId int

We need this so it can be exported

const (
	EnvUnknown EnvironmentId = iota // Oops
	EnvDev                          // Development aka Staging
	EnvProd                         // Production
	EnvDemo                         // Demo, which is like Production, for prospective customers to try
)

https://github.com/unee-t/processInvitations/blob/master/sql/1_process_one_invitation_all_scenario_v3.0.sql#L12-L16

type HandlerSqlConnexion added in v1.0.2

type HandlerSqlConnexion struct {
	DSN            string // aurora database connection string
	APIAccessToken string
	// contains filtered or unexported fields
}

HandlerSqlConnexion is a type of variable to help us manage our connexion to the SQL databases

func NewDbConnexion added in v1.0.1

func NewDbConnexion() (bzDbConnexion HandlerSqlConnexion, err error)

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL