cfenvnested

package module
v0.0.0-...-2ac32ef Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

README

Go Cloud Foundry Environment Package (cfenvnested)

NOTE: this is a fork of https://github.com/cloudfoundry-community/go-cfenv that allows service credentials with nested structures. One day we will figure out how to blend the two together.

Overview

GoDoc

cfenvnested 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.com/docs/using/deploying-apps/environment-variable.html).

Build Status
  • Build Status - Master Master
  • Build Status - Develop Develop
Usage

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

package main

import (
	"github.com/cloudfoundry-community/go-cfenvnested"
)

func main() {
	appEnv := cfenvnested.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)
}
Contributing

Pull requests welcomed. Please ensure you make your changes in a branch off of the develop branch, not the master branch.

Remember that you probably need to patch https://github.com/cloudfoundry-community/go-cfenv project as well.

Documentation

Overview

Package cfenvnested provides information about the current app deployed on Cloud Foundry, including any bound service(s).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentEnv

func CurrentEnv() map[string]string

CurrentEnv translates the current environment to a map[string]string.

func Env

func Env(env []string) map[string]string

Env translates the provided environment to a map[string]string.

Types

type App

type App struct {
	ApplicationID   string   `json:"application_id"`   // guid of the app
	ID              string   `json:"instance_id"`      // id of the app
	Index           int      `json:"instance_index"`   // index of the app
	Name            string   `json:"name"`             // name of the app
	Host            string   `json:"host"`             // host of the app
	Port            int      `json:"port"`             // port of the app
	Version         string   `json:"version"`          // version of the app
	ApplicationURIs []string `json:"application_uris"` // application uri of the app
	Home            string   // root folder for the deployed app
	MemoryLimit     string   // maximum amount of memory that each instance of the application can consume
	WorkingDir      string   // present working directory, where the buildpack that processed the application ran
	TempDir         string   // directory location where temporary and staging files are stored
	User            string   // user account under which the DEA runs
	Services        Services // services bound to the app
}

An App holds information about the current app running on Cloud Foundry

func Current

func Current() (*App, error)

Current creates a new App with the current environment.

func New

func New(env map[string]string) (*App, error)

New creates a new App with the provided environment.

type Service

type Service struct {
	Name           string                 // name of the service
	Label          string                 // label of the service
	Tags           []string               // tags for the service
	Plan           string                 // plan of the service
	Credentials    map[string]interface{} // credentials for the service
	SyslogDrainURL string                 `json:"syslog_drain_url,omitempty"`
}

Service describes a bound service. For bindable services Cloud Foundry will add connection details to the VCAP_SERVICES environment variable when you restart your application, after binding a service instance to your application.

The results are returned as a JSON document that contains an object for each service for which one or more instances are bound to the application. The service object contains a child object for each service instance of that service that is bound to the application.

type Services

type Services map[string][]Service

Services is an association of service labels to a slice of services with that label.

func (*Services) WithLabel

func (s *Services) WithLabel(label string) ([]Service, error)

WithLabel finds the service with the specified label.

func (*Services) WithName

func (s *Services) WithName(name string) (*Service, error)

WithName finds the service with the specified name.

func (*Services) WithTag

func (s *Services) WithTag(tag string) ([]Service, error)

WithTag finds services with the specified tag.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/mitchellh/mapstructure
The mapstructure package exposes functionality to convert an abitrary map[string]interface{} into a native Go structure.
The mapstructure package exposes functionality to convert an abitrary map[string]interface{} into a native Go structure.
_workspace/src/github.com/onsi/ginkgo
Ginkgo is a BDD-style testing framework for Golang The godoc documentation describes Ginkgo's API.
Ginkgo is a BDD-style testing framework for Golang The godoc documentation describes Ginkgo's API.
_workspace/src/github.com/onsi/ginkgo/config
Ginkgo accepts a number of configuration options.
Ginkgo accepts a number of configuration options.
_workspace/src/github.com/onsi/ginkgo/ginkgo
The Ginkgo CLI The Ginkgo CLI is fully documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli) To install: go install github.com/onsi/ginkgo/ginkgo To run tests: ginkgo To run tests in all subdirectories: ginkgo -r To run tests in particular packages: ginkgo <flags> /path/to/package /path/to/another/package To run tests in parallel ginkgo -nodes=N where N is the number of nodes.
The Ginkgo CLI The Ginkgo CLI is fully documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli) To install: go install github.com/onsi/ginkgo/ginkgo To run tests: ginkgo To run tests in all subdirectories: ginkgo -r To run tests in particular packages: ginkgo <flags> /path/to/package /path/to/another/package To run tests in parallel ginkgo -nodes=N where N is the number of nodes.
_workspace/src/github.com/onsi/ginkgo/ginkgo/aggregator
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output as one coherent stream.
Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output as one coherent stream.
_workspace/src/github.com/onsi/ginkgo/ginkgo/support/fsnotify
Package fsnotify implements filesystem notification.
Package fsnotify implements filesystem notification.
_workspace/src/github.com/onsi/ginkgo/reporters
Ginkgo's Default Reporter A number of command line flags are available to tweak Ginkgo's default output.
Ginkgo's Default Reporter A number of command line flags are available to tweak Ginkgo's default output.
_workspace/src/github.com/onsi/ginkgo/thirdparty/gomocktestreporter
The gomocktestreporter package provides a Ginkgo friendly implementation of [Gomock's](https://code.google.com/p/gomock/) `TestReporter` interface.
The gomocktestreporter package provides a Ginkgo friendly implementation of [Gomock's](https://code.google.com/p/gomock/) `TestReporter` interface.
_workspace/src/github.com/onsi/gomega
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
_workspace/src/github.com/onsi/gomega/matchers
Gomega matchers This package implements the Gomega matchers and does not typically need to be imported.
Gomega matchers This package implements the Gomega matchers and does not typically need to be imported.

Jump to

Keyboard shortcuts

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