Skip to content
Go Warden
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
ci Use garden-ci-xenial 1.0.1 - golang 1.11.2 Nov 8, 2018
client Generate fakes with latest version of counterfeiter Jun 8, 2018
doc Rationalise documentation Jan 15, 2015
gardenfakes Generate fakes with latest version of counterfeiter Jun 8, 2018
routes
scripts
server Close stdin pipe when run fails Oct 19, 2018
transport Reference new code.cloudfoundry.org import paths Jul 14, 2016
.drone.yml bin => scripts Apr 24, 2014
.gitignore Ignore IntelliJ files. Apr 29, 2015
.gitmodules Remove last vestiges of protobufs Feb 2, 2015
.travis.yml bump to go 1.4.1 [#86810456] Feb 3, 2015
LICENSE
NOTICE
README.md
backend.go
client.go
container.go
errors.go
garden_suite_test.go
net_in.go Add NetIn to ContainerSpec Feb 16, 2017
net_out_rule.go Remove erroneous claim from NetOutRule documentation Jan 21, 2016
net_out_rule_test.go

README.md

                                                 ,-.
                                                  ) \
                                              .--'   |
                                             /       /
                                             |_______|
                                            (  O   O  )
                                             {'-(_)-'}
                                           .-{   ^   }-.
                                          /   '.___.'   \
                                         /  |    o    |  \
                                         |__|    o    |__|
                                         (((\_________/)))
                                             \___|___/
                                        jgs.--' | | '--.
                                           \__._| |_.__/

Note: This repository should be imported as code.cloudfoundry.org/garden.

A rich golang client and server for container creation and management with pluggable backends for The Open Container Initiative Spec and windows.

Garden is a platform-agnostic Go API for container creation and management, with pluggable backends for different platforms and runtimes. This package contains the canonical client, as well as a server package containing an interface to be implemented by backends.

If you're just getting started, you probably want to begin by setting up one of the backends listed below. If you want to use the Garden client to manage containers, see the Client API section.

Backends

Backends implement support for various specific platforms. So far, the list of backends is as follows:

Client API

The canonical API for Garden is defined as a collection of Go interfaces. See the godoc documentation for details.

Example use

Install needed packages:

go get code.cloudfoundry.org/garden
go get code.cloudfoundry.org/lager

Import these packages:

"bytes"
"fmt"
"os"

"code.cloudfoundry.org/garden"
"code.cloudfoundry.org/garden/client"
"code.cloudfoundry.org/garden/client/connection"

Create a client:

gardenClient := client.New(connection.New("tcp", "127.0.0.1:7777"))

Create a container:

container, err := gardenClient.Create(garden.ContainerSpec{})
if err != nil {
  os.Exit(1)
}

Run a process:

buffer := &bytes.Buffer{}
process, err := container.Run(garden.ProcessSpec{
  Path: "echo",
  Args: []string{"hello from the container"},
}, garden.ProcessIO{
  Stdout: buffer,
  Stderr: buffer,
})
if err != nil {
  os.Exit(1)
}

exitCode, err := process.Wait()
if err != nil {
  os.Exit(1)
}

fmt.Printf("Exit code: %d, Process output %s", exitCode, buffer.String())

Development

Prerequisites

  • go
  • git (for garden and its dependencies)
  • mercurial (for some other dependencies not using git)

Running the tests

Assuming go is installed and $GOPATH is set:

mkdir -p $GOPATH/src/code.cloudfoundry.org
cd $GOPATH/src/code.cloudfoundry.org
git clone git@github.com:cloudfoundry/garden
cd garden
go get -t -u ./...
go install github.com/onsi/ginkgo/ginkgo
ginkgo -r
You can’t perform that action at this time.