Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

135 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Go CF Environment Package

CI CodeQL OpenSSF Scorecard Go Version Latest Release License: Apache 2.0

Overview

cfenv is a package to assist you in writing Go apps that run on Cloud Foundry. It provides convenience functions and structures that map to Cloud Foundry environment variable primitives (http://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html).

Requirements

Go 1.25 or later.

Usage

go get github.com/cloudfoundry-community/go-cfenv

package main

import (
	"fmt"

	"github.com/cloudfoundry-community/go-cfenv"
)

func main() {
	appEnv, _ := cfenv.Current()

	fmt.Println("ID:", appEnv.ID)
	fmt.Println("Index:", appEnv.Index)
	fmt.Println("Name:", appEnv.Name)
	fmt.Println("Host:", appEnv.Host)
	fmt.Println("Port:", appEnv.Port)
	fmt.Println("Version:", appEnv.Version)
	fmt.Println("Home:", appEnv.Home)
	fmt.Println("MemoryLimit:", appEnv.MemoryLimit)
	fmt.Println("WorkingDir:", appEnv.WorkingDir)
	fmt.Println("TempDir:", appEnv.TempDir)
	fmt.Println("User:", appEnv.User)
	fmt.Println("Services:", appEnv.Services)
}

File-based service bindings

Apps with the file-based-vcap-services feature enabled receive their bindings in the file named by VCAP_SERVICES_FILE_PATH rather than in VCAP_SERVICES, which Cloud Foundry then does not set at all. cfenv.Current reads whichever of the two the platform provides, so switching the feature on needs no application change beyond a version of this package that supports it.

The SERVICE_BINDING_ROOT form of RFC-0030 is not supported: those bindings follow the Kubernetes servicebinding.io layout, which has no faithful translation into the VCAP_SERVICES shape this package exposes.

Contributing

Pull requests welcomed. Please run make check and make audit before submitting.

About

Go Cloud Foundry Environment Parsing Package

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages