Skip to content
/ cfsvcenv Public

A Go package for binding Cloud Foundry service credentials (including user-provided services) to environment variables.

License

Notifications You must be signed in to change notification settings

govau/cfsvcenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cfsvcenv · Travis-CI GoDoc Report card

cfsvcenv is a Go package for binding Cloud Foundry service credentials (including user-provided services) to environment variables.

Rationale

Your Go program uses Cloud Foundry services to provide configuration to it. Cloud Foundry does this by injecting the configuration into the VCAP_SERVICES environment variable.

However, you want to keep your program CF-agnostic, and you also want to keep development simple

cfsvcenv binds the CF service credentials into the OS's environment so that your Go program does not need any special treatment when used within CF.

Usage and examples

Caveats

You cannot define environment variables in the global scope because these have not yet been bound. This is because the init() function that does the binding has not yet run.

For example this won't work:

package main

import (
	"fmt"
	"os"
)

var serviceAPIKey = os.Getenv("SERVICE_API_KEY")

func main() {
	fmt.Println(serviceAPIKey) // Will be empty
}

Development

go test -race ./...

About

A Go package for binding Cloud Foundry service credentials (including user-provided services) to environment variables.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published