Skip to content

Commit

Permalink
mmmdeps
Browse files Browse the repository at this point in the history
  • Loading branch information
vito committed Jan 26, 2016
1 parent f5888b6 commit 158b26c
Show file tree
Hide file tree
Showing 526 changed files with 44,304 additions and 735 deletions.
24 changes: 19 additions & 5 deletions Godeps_darwin/Godeps.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ImportPath": "github.com/vito/houdini",
"GoVersion": "go1.5.1",
"GoVersion": "go1.5",
"Packages": [
"./..."
],
Expand All @@ -11,8 +11,8 @@
},
{
"ImportPath": "github.com/cloudfoundry-incubator/garden",
"Comment": "go-wshd-803-g82ff031",
"Rev": "82ff031e787b461f85791f654938e631970f87ad"
"Comment": "go-wshd-814-g491838e",
"Rev": "491838e5ca0410322926fb9385c666658b47d254"
},
{
"ImportPath": "github.com/kr/pty",
Expand All @@ -23,13 +23,27 @@
"ImportPath": "github.com/nu7hatch/gouuid",
"Rev": "179d4d0c4d8d407a32af483c2354df1d2c91e6c3"
},
{
"ImportPath": "github.com/onsi/ginkgo",
"Comment": "v1.2.0-36-g3341026",
"Rev": "33410268c3881642c746ada23c04eeb331212596"
},
{
"ImportPath": "github.com/onsi/gomega",
"Comment": "v1.0-77-g28f13bc",
"Rev": "28f13bc54cf0f72e3fa395ba9d3added0b3b849c"
},
{
"ImportPath": "github.com/pivotal-golang/archiver/compressor",
"Rev": "f598990ddfeda2767a09346acf844a7d216c1256"
},
{
"ImportPath": "github.com/pivotal-golang/lager",
"Rev": "d954ca8f99bb6748798a9c3e09d5475eef71b21c"
"Rev": "95b2ada4cdf781bdcf07e5207879e034ac8c5314"
},
{
"ImportPath": "github.com/pkg/term/termios",
"Rev": "d7ef5fb23c9838dfaf4731b1dd94aacaedd89181"
"Rev": "5a50d6bc3358220989f87053a9505dc9e0359a90"
},
{
"ImportPath": "github.com/tedsuo/rata",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,85 +16,84 @@
\__._| |_.__/
```

Warden in Go, because why not.
A rich golang client and server for container creation and management with pluggable backends for [linux](https://github.com/cloudfoundry-incubator/garden-linux/), [windows](https://github.com/cloudfoundry-incubator/garden-windows) and [The Open Container Initiative Spec](https://github.com/cloudfoundry-incubator/guardian/).

* [![Build Status](https://travis-ci.org/cloudfoundry-incubator/garden.png?branch=master)](https://travis-ci.org/cloudfoundry-incubator/garden)
* [![Coverage Status](https://coveralls.io/repos/cloudfoundry-incubator/garden/badge.png?branch=HEAD)](https://coveralls.io/r/cloudfoundry-incubator/garden?branch=HEAD)
* [Tracker](https://www.pivotaltracker.com/s/projects/962374)
* [Warden](https://github.com/cloudfoundry/warden)
[![Build Status](https://travis-ci.org/cloudfoundry-incubator/garden.png?branch=master)](https://travis-ci.org/cloudfoundry-incubator/garden)
[![Coverage Status](https://coveralls.io/repos/cloudfoundry-incubator/garden/badge.png?branch=HEAD)](https://coveralls.io/r/cloudfoundry-incubator/garden?branch=HEAD)

# Backends
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.

Garden provides a platform-neutral API for containerization. Backends implement support for various specific platforms. So far, the list of backends is as follows:
If you're just getting started, you probably want to begin by setting up one of the [backends](#backends) listed below.
If you want to use the Garden client to manage containers, see the [Client API](#client-api) section.

- [Garden Linux](https://github.com/cloudfoundry-incubator/garden-linux/) - Linux Backend
# Backends

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

The canonical API for Garden is defined as a collection of Go interfaces. See the [godoc documentation](http://godoc.org/github.com/cloudfoundry-incubator/garden) for details.
- [Garden Linux](https://github.com/cloudfoundry-incubator/garden-linux/) - Linux backend
- [Guardian](https://github.com/cloudfoundry-incubator/guardian/) - Linux backend using [runc](https://github.com/opencontainers/runc)
- [Greenhouse](https://github.com/cloudfoundry-incubator/garden-windows) - Windows backend

For convenience during Garden development, Garden also supports a REST API which may be used to "kick the tyres". The REST API is not supported.
# Client API

For example, if [Garden Linux](https://github.com/cloudfoundry-incubator/garden-linux) is deployed to `localhost` and configured to listen on port `7777`, the following commands may be used to kick its tyres:
```sh
# list containers (should be empty)
curl http://127.0.0.1:7777/containers
The canonical API for Garden is defined as a collection of Go interfaces.
See the [godoc documentation](http://godoc.org/github.com/cloudfoundry-incubator/garden) for details.

# create a container
curl -H "Content-Type: application/json" \
-XPOST http://127.0.0.1:7777/containers \
-d '{"rootfs":"docker:///busybox"}'
## Example use

# list containers (should list the handle returned above)
curl http://127.0.0.1:7777/containers
_Error checking ignored for brevity._

# spawn a process
#
# curl will choke here as the protocol is hijacked, but...it probably worked.
curl -H "Content-Type: application/json" \
-XPOST http://127.0.0.1:7777/containers/${handle}/processes \
-d '{"path":"sleep","args":["10"],"user":"vcap"}'
Import these packages:
```

See [REST API examples](doc/garden-api.md) for more.

# Testing

## Pre-requisites

* [git](http://git-scm.com/) (for garden and its dependencies on github)
* [mercurial](http://mercurial.selenic.com/) (for some dependencies not on github)

Make a directory to contain go code:
```
$ mkdir ~/go
"github.com/cloudfoundry-incubator/garden"
"github.com/cloudfoundry-incubator/garden/client"
"github.com/cloudfoundry-incubator/garden/client/connection"
```

Install Go. For example, install [gvm](https://github.com/moovweb/gvm) and issue:
Create a client:
```
$ gvm install go1.4.1
$ gvm use go1.4.1
gardenClient := client.New(connection.New("tcp", "127.0.0.1:7777"))
```

Make sure that your `$GOPATH` and `$PATH` are set. For example:
Create a container:
```
$ export GOPATH=~/go:$GOPATH
$ export PATH=$PATH:~/go/bin
container, _ := gardenClient.Create(garden.ContainerSpec{})
```

Get garden and its dependencies:
Run a process:
```
$ go get -t -u github.com/cloudfoundry-incubator/garden
$ cd $GOPATH/src/github.com/cloudfoundry-incubator/garden
$ go get -t -u ./...
buffer := &bytes.Buffer{}
process, _ := container.Run(garden.ProcessSpec{
User: "alice",
Path: "echo",
Args: []string{"hello from the container"},
}, garden.ProcessIO{
Stdout: buffer,
Stderr: buffer,
})
exitCode := process.Wait()
fmt.Println(buffer.String())
```

Install ginkgo (used to test garden):
```
$ go install github.com/onsi/ginkgo/ginkgo
```
# Development

## Prerequisites

* [go](https://golang.org)
* [git](http://git-scm.com/) (for garden and its dependencies)
* [mercurial](http://mercurial.selenic.com/) (for some other dependencies not using git)

## Running the tests

Run the tests:
Assuming go is installed and `$GOPATH` is set:
```
$ ginkgo -r
mkdir -p $GOPATH/src/github.com/cloudfoundry-incubator
cd $GOPATH/src/github.com/cloudfoundry-incubator
git clone git@github.com:cloudfoundry-incubator/garden
cd garden
go get -t -u ./...
go install github.com/onsi/ginkgo/ginkgo
ginkgo -r
```
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ type Connection interface {

LimitBandwidth(handle string, limits garden.BandwidthLimits) (garden.BandwidthLimits, error)
LimitCPU(handle string, limits garden.CPULimits) (garden.CPULimits, error)
LimitDisk(handle string, limits garden.DiskLimits) (garden.DiskLimits, error)
LimitMemory(handle string, limit garden.MemoryLimits) (garden.MemoryLimits, error)

CurrentBandwidthLimits(handle string) (garden.BandwidthLimits, error)
Expand Down Expand Up @@ -448,22 +447,6 @@ func (c *connection) CurrentCPULimits(handle string) (garden.CPULimits, error) {
return res, err
}

func (c *connection) LimitDisk(handle string, limits garden.DiskLimits) (garden.DiskLimits, error) {
res := garden.DiskLimits{}

err := c.do(
routes.LimitDisk,
limits,
&res,
rata.Params{
"handle": handle,
},
nil,
)

return res, err
}

func (c *connection) CurrentDiskLimits(handle string) (garden.DiskLimits, error) {
res := garden.DiskLimits{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,6 @@ type FakeConnection struct {
result1 garden.CPULimits
result2 error
}
LimitDiskStub func(handle string, limits garden.DiskLimits) (garden.DiskLimits, error)
limitDiskMutex sync.RWMutex
limitDiskArgsForCall []struct {
handle string
limits garden.DiskLimits
}
limitDiskReturns struct {
result1 garden.DiskLimits
result2 error
}
LimitMemoryStub func(handle string, limit garden.MemoryLimits) (garden.MemoryLimits, error)
limitMemoryMutex sync.RWMutex
limitMemoryArgsForCall []struct {
Expand Down Expand Up @@ -696,40 +686,6 @@ func (fake *FakeConnection) LimitCPUReturns(result1 garden.CPULimits, result2 er
}{result1, result2}
}

func (fake *FakeConnection) LimitDisk(handle string, limits garden.DiskLimits) (garden.DiskLimits, error) {
fake.limitDiskMutex.Lock()
fake.limitDiskArgsForCall = append(fake.limitDiskArgsForCall, struct {
handle string
limits garden.DiskLimits
}{handle, limits})
fake.limitDiskMutex.Unlock()
if fake.LimitDiskStub != nil {
return fake.LimitDiskStub(handle, limits)
} else {
return fake.limitDiskReturns.result1, fake.limitDiskReturns.result2
}
}

func (fake *FakeConnection) LimitDiskCallCount() int {
fake.limitDiskMutex.RLock()
defer fake.limitDiskMutex.RUnlock()
return len(fake.limitDiskArgsForCall)
}

func (fake *FakeConnection) LimitDiskArgsForCall(i int) (string, garden.DiskLimits) {
fake.limitDiskMutex.RLock()
defer fake.limitDiskMutex.RUnlock()
return fake.limitDiskArgsForCall[i].handle, fake.limitDiskArgsForCall[i].limits
}

func (fake *FakeConnection) LimitDiskReturns(result1 garden.DiskLimits, result2 error) {
fake.LimitDiskStub = nil
fake.limitDiskReturns = struct {
result1 garden.DiskLimits
result2 error
}{result1, result2}
}

func (fake *FakeConnection) LimitMemory(handle string, limit garden.MemoryLimits) (garden.MemoryLimits, error) {
fake.limitMemoryMutex.Lock()
fake.limitMemoryArgsForCall = append(fake.limitMemoryArgsForCall, struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ func (container *container) CurrentCPULimits() (garden.CPULimits, error) {
return container.connection.CurrentCPULimits(container.handle)
}

func (container *container) LimitDisk(limits garden.DiskLimits) error {
_, err := container.connection.LimitDisk(container.handle, limits)
if err != nil {
return err
}

return nil
}

func (container *container) CurrentDiskLimits() (garden.DiskLimits, error) {
return container.connection.CurrentDiskLimits(container.handle)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,10 @@ type Container interface {
// Limits the CPU shares for a container.
LimitCPU(limits CPULimits) error

// Returns the currently set CPU limts for a container.
CurrentCPULimits() (CPULimits, error)

// Limits the disk usage for a container.
//
// The disk limits that are set by this command only have effect for the container's unprivileged user.
// Files/directories created by its privileged user are not subject to these limits.
//
// TODO: explain how disk management works.
LimitDisk(limits DiskLimits) error

// Returns the currently set Disk limts for a container.
CurrentDiskLimits() (DiskLimits, error)

// Limits the memory usage for a container.
Expand All @@ -82,7 +76,7 @@ type Container interface {
// If a container port is not given, the port will be the same as the
// container port.
//
// The two resulting ports are returned in the response.
// The resulting host and container ports are returned in that order.
//
// Errors:
// * When no port can be acquired from the server's port pool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ type FakeContainer struct {
result1 garden.CPULimits
result2 error
}
LimitDiskStub func(limits garden.DiskLimits) error
limitDiskMutex sync.RWMutex
limitDiskArgsForCall []struct {
limits garden.DiskLimits
}
limitDiskReturns struct {
result1 error
}
CurrentDiskLimitsStub func() (garden.DiskLimits, error)
currentDiskLimitsMutex sync.RWMutex
currentDiskLimitsArgsForCall []struct{}
Expand Down Expand Up @@ -457,38 +449,6 @@ func (fake *FakeContainer) CurrentCPULimitsReturns(result1 garden.CPULimits, res
}{result1, result2}
}

func (fake *FakeContainer) LimitDisk(limits garden.DiskLimits) error {
fake.limitDiskMutex.Lock()
fake.limitDiskArgsForCall = append(fake.limitDiskArgsForCall, struct {
limits garden.DiskLimits
}{limits})
fake.limitDiskMutex.Unlock()
if fake.LimitDiskStub != nil {
return fake.LimitDiskStub(limits)
} else {
return fake.limitDiskReturns.result1
}
}

func (fake *FakeContainer) LimitDiskCallCount() int {
fake.limitDiskMutex.RLock()
defer fake.limitDiskMutex.RUnlock()
return len(fake.limitDiskArgsForCall)
}

func (fake *FakeContainer) LimitDiskArgsForCall(i int) garden.DiskLimits {
fake.limitDiskMutex.RLock()
defer fake.limitDiskMutex.RUnlock()
return fake.limitDiskArgsForCall[i].limits
}

func (fake *FakeContainer) LimitDiskReturns(result1 error) {
fake.LimitDiskStub = nil
fake.limitDiskReturns = struct {
result1 error
}{result1}
}

func (fake *FakeContainer) CurrentDiskLimits() (garden.DiskLimits, error) {
fake.currentDiskLimitsMutex.Lock()
fake.currentDiskLimitsArgsForCall = append(fake.currentDiskLimitsArgsForCall, struct{}{})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package garden
import "net"

type NetOutRule struct {
// the protocol to be whitelisted; default TCP
// the protocol to be whitelisted
Protocol Protocol `json:"protocol,omitempty"`

// a list of ranges of IP addresses to whitelist; Start to End inclusive; default all
Expand Down
Loading

0 comments on commit 158b26c

Please sign in to comment.