diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index e1d67106649..bf281153ded 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -21,7 +21,7 @@ }, { "ImportPath": "code.google.com/p/google-api-go-client/compute/v1", - "Comment": "release-96", + "Comment": "release-105", "Rev": "98c78185197025f935947caac56a7b6d022f89d2" }, { @@ -31,7 +31,7 @@ }, { "ImportPath": "code.google.com/p/google-api-go-client/googleapi", - "Comment": "release-96", + "Comment": "release-105", "Rev": "98c78185197025f935947caac56a7b6d022f89d2" }, { @@ -195,7 +195,7 @@ }, { "ImportPath": "github.com/docker/spdystream", - "Rev": "83ae67e694a4ab5cbaee4d3126f25118712b26e6" + "Rev": "b2c3287865f3ad6aa22821ddb7b4692b896ac207" }, { "ImportPath": "github.com/elazarl/go-bindata-assetfs", @@ -212,7 +212,6 @@ }, { "ImportPath": "github.com/fsouza/go-dockerclient", - "Comment": "0.2.1-532-g2f1ad24", "Rev": "2f1ad24900b2777139b5becee93eb63a75b00617" }, { @@ -395,31 +394,31 @@ }, { "ImportPath": "github.com/mesos/mesos-go/detector", - "Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" + "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" }, { "ImportPath": "github.com/mesos/mesos-go/executor", - "Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" + "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" }, { "ImportPath": "github.com/mesos/mesos-go/mesosproto", - "Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" + "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" }, { "ImportPath": "github.com/mesos/mesos-go/mesosutil", - "Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" + "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" }, { "ImportPath": "github.com/mesos/mesos-go/messenger", - "Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" + "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" }, { "ImportPath": "github.com/mesos/mesos-go/scheduler", - "Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" + "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" }, { "ImportPath": "github.com/mesos/mesos-go/upid", - "Rev": "4b1767c0dfc51020e01f35da5b38472f40ce572a" + "Rev": "6440c09c9d8a1b365f3c3e9b2297dd856abd017c" }, { "ImportPath": "github.com/miekg/dns", @@ -440,7 +439,7 @@ }, { "ImportPath": "github.com/onsi/gomega", - "Comment": "v1.0-28-g8adf9e1730c5", + "Comment": "v1.0-28-g8adf9e1", "Rev": "8adf9e1730c55cdc590de7d49766cb2acc88d8f2" }, { @@ -501,6 +500,7 @@ }, { "ImportPath": "github.com/spf13/pflag", + "Comment": "v0.0.1-44-gb91b2a9", "Rev": "b91b2a94780f4e6b4d3b0c12fd9b5f4b05b1aa45" }, { @@ -509,19 +509,22 @@ }, { "ImportPath": "github.com/stretchr/testify/assert", + "Comment": "v1.0-17-g089c718", "Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff" }, { "ImportPath": "github.com/stretchr/testify/mock", + "Comment": "v1.0-17-g089c718", "Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff" }, { "ImportPath": "github.com/stretchr/testify/require", + "Comment": "v1.0-17-g089c718", "Rev": "089c7181b8c728499929ff09b62d3fdd8df8adff" }, { "ImportPath": "github.com/syndtr/gocapability/capability", - "Rev": "3c85049eaeb429febe7788d9c7aac42322a377fe" + "Rev": "2c00daeb6c3b45114c80ac44119e7b8801fdd852" }, { "ImportPath": "github.com/ugorji/go/codec", @@ -552,11 +555,6 @@ "ImportPath": "golang.org/x/net/html", "Rev": "cbcac7bb8415db9b6cb4d1ebab1dc9afbd688b97" }, - { - "ImportPath": "golang.org/x/net/spdy", - "Comment": "deleted-upstream", - "Rev": "d175081df37eff8cda13f478bc11a0a65b39958b" - }, { "ImportPath": "golang.org/x/net/websocket", "Rev": "cbcac7bb8415db9b6cb4d1ebab1dc9afbd688b97" @@ -575,6 +573,7 @@ }, { "ImportPath": "gopkg.in/natefinch/lumberjack.v2", + "Comment": "v1.0-16-g20b71e5", "Rev": "20b71e5b60d756d3d2f80def009790325acc2b23" }, { diff --git a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/AUTHORS b/Godeps/_workspace/src/code.google.com/p/google-api-go-client/AUTHORS deleted file mode 100644 index f73b7257457..00000000000 --- a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/AUTHORS +++ /dev/null @@ -1,10 +0,0 @@ -# This is the official list of authors for copyright purposes. -# This file is distinct from the CONTRIBUTORS files. -# See the latter for an explanation. - -# Names should be added to this file as -# Name or Organization -# The email address is not required for organizations. - -# Please keep the list sorted. -Google Inc. diff --git a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/CONTRIBUTORS b/Godeps/_workspace/src/code.google.com/p/google-api-go-client/CONTRIBUTORS deleted file mode 100644 index 4af9298dd94..00000000000 --- a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/CONTRIBUTORS +++ /dev/null @@ -1,46 +0,0 @@ -# This is the official list of people who can contribute -# (and typically have contributed) code to the repository. -# The AUTHORS file lists the copyright holders; this file -# lists people. For example, Google employees are listed here -# but not in AUTHORS, because Google holds the copyright. -# -# The submission process automatically checks to make sure -# that people submitting code are listed in this file (by email address). -# -# Names should be added to this file only after verifying that -# the individual or the individual's organization has agreed to -# the appropriate Contributor License Agreement, found here: -# -# http://code.google.com/legal/individual-cla-v1.0.html -# http://code.google.com/legal/corporate-cla-v1.0.html -# -# The agreement for individuals can be filled out on the web. -# -# When adding J Random Contributor's name to this file, -# either J's name or J's organization's name should be -# added to the AUTHORS file, depending on whether the -# individual or corporate CLA was used. - -# Names should be added to this file like so: -# Name -# -# An entry with two email addresses specifies that the -# first address should be used in the submit logs and -# that the second address should be recognized as the -# same person when interacting with Rietveld. - -# Please keep the list sorted. - -Alain Vongsouvanhalainv -Andrew Gerrand -Brad Fitzpatrick -Francesc Campoy -Garrick Evans -Glenn Lewis -Ivan Krasin -Jason Hall -Johan Euphrosine -Kostik Shtoyk -Nick Craig-Wood -Scott Van Woudenberg -Takashi Matsuo diff --git a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/LICENSE b/Godeps/_workspace/src/code.google.com/p/google-api-go-client/LICENSE deleted file mode 100644 index 263aa7a0c12..00000000000 --- a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2011 Google Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/Makefile b/Godeps/_workspace/src/code.google.com/p/google-api-go-client/Makefile deleted file mode 100644 index 20ce8a5f702..00000000000 --- a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -all: - go install code.google.com/p/google-api-go-client/googleapi - go install code.google.com/p/google-api-go-client/google-api-go-generator - $(GOPATH)/bin/google-api-go-generator -cache=false -install -api=* - -cached: - go install code.google.com/p/google-api-go-client/googleapi - go install code.google.com/p/google-api-go-client/google-api-go-generator - $(GOPATH)/bin/google-api-go-generator -cache=true -install -api=* diff --git a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/NOTES b/Godeps/_workspace/src/code.google.com/p/google-api-go-client/NOTES deleted file mode 100644 index 3b10889900a..00000000000 --- a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/NOTES +++ /dev/null @@ -1,13 +0,0 @@ -Discovery Service: -http://code.google.com/apis/discovery/ -http://code.google.com/apis/discovery/v1/reference.html - -The "type" key: -http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.1 - -The "format" key: -http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.23 -http://code.google.com/apis/discovery/v1/reference.html#parameter-format-summary - -Google JSON format docs: -http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml diff --git a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/README b/Godeps/_workspace/src/code.google.com/p/google-api-go-client/README deleted file mode 100644 index 9aca57bf6f3..00000000000 --- a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/README +++ /dev/null @@ -1,10 +0,0 @@ -Most of this project is auto-generated. - -The notable directories which are not auto-generated: - - google-api-go-generator/ -- the generator itself - google-api/ -- shared common code, used by auto-generated code - examples/ -- sample code - -When changing the generator, re-compile all APIs and submit the -modified APIs in the same CL as the generator changes itself. diff --git a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/TODO b/Godeps/_workspace/src/code.google.com/p/google-api-go-client/TODO deleted file mode 100644 index af55f146c77..00000000000 --- a/Godeps/_workspace/src/code.google.com/p/google-api-go-client/TODO +++ /dev/null @@ -1,2 +0,0 @@ -Moved to: -http://code.google.com/p/google-api-go-client/issues/ diff --git a/Godeps/_workspace/src/github.com/codegangsta/negroni/negroni_test.go b/Godeps/_workspace/src/github.com/codegangsta/negroni/negroni_test.go index 0f6607a3b0b..9fac0085617 100644 --- a/Godeps/_workspace/src/github.com/codegangsta/negroni/negroni_test.go +++ b/Godeps/_workspace/src/github.com/codegangsta/negroni/negroni_test.go @@ -72,4 +72,4 @@ func TestHandlers(t *testing.T) { // exactly the same as the one that was registered earlier handlers[0].ServeHTTP(response, (*http.Request)(nil), nil) expect(t, response.Code, http.StatusOK) -} \ No newline at end of file +} diff --git a/Godeps/_workspace/src/github.com/docker/libcontainer/capabilities_linux.go b/Godeps/_workspace/src/github.com/docker/libcontainer/capabilities_linux.go index b1c5c17604d..6b8b465c56b 100644 --- a/Godeps/_workspace/src/github.com/docker/libcontainer/capabilities_linux.go +++ b/Godeps/_workspace/src/github.com/docker/libcontainer/capabilities_linux.go @@ -49,6 +49,7 @@ var capabilityList = map[string]capability.Cap{ "SETFCAP": capability.CAP_SETFCAP, "WAKE_ALARM": capability.CAP_WAKE_ALARM, "BLOCK_SUSPEND": capability.CAP_BLOCK_SUSPEND, + "AUDIT_READ": capability.CAP_AUDIT_READ, } func newCapWhitelist(caps []string) (*whitelist, error) { diff --git a/Godeps/_workspace/src/github.com/docker/spdystream/connection.go b/Godeps/_workspace/src/github.com/docker/spdystream/connection.go index 9853cfc8433..bbc450edc0e 100644 --- a/Godeps/_workspace/src/github.com/docker/spdystream/connection.go +++ b/Godeps/_workspace/src/github.com/docker/spdystream/connection.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "golang.org/x/net/spdy" + "github.com/docker/spdystream/spdy" ) var ( @@ -593,6 +593,11 @@ func (s *Connection) remoteStreamFinish(stream *Stream) { // the stream Wait or WaitTimeout function on the stream returned // by this function. func (s *Connection) CreateStream(headers http.Header, parent *Stream, fin bool) (*Stream, error) { + // MUST synchronize stream creation (all the way to writing the frame) + // as stream IDs **MUST** increase monotonically. + s.nextIdLock.Lock() + defer s.nextIdLock.Unlock() + streamId := s.getNextStreamId() if streamId == 0 { return nil, fmt.Errorf("Unable to get new stream id") @@ -833,8 +838,6 @@ func (s *Connection) sendStream(stream *Stream, fin bool) error { // getNextStreamId returns the next sequential id // every call should produce a unique value or an error func (s *Connection) getNextStreamId() spdy.StreamId { - s.nextIdLock.Lock() - defer s.nextIdLock.Unlock() sid := s.nextStreamId if sid > 0x7fffffff { return 0 diff --git a/Godeps/_workspace/src/github.com/docker/spdystream/priority.go b/Godeps/_workspace/src/github.com/docker/spdystream/priority.go index 27a22594564..fc8582b5c6f 100644 --- a/Godeps/_workspace/src/github.com/docker/spdystream/priority.go +++ b/Godeps/_workspace/src/github.com/docker/spdystream/priority.go @@ -4,7 +4,7 @@ import ( "container/heap" "sync" - "golang.org/x/net/spdy" + "github.com/docker/spdystream/spdy" ) type prioritizedFrame struct { diff --git a/Godeps/_workspace/src/github.com/docker/spdystream/priority_test.go b/Godeps/_workspace/src/github.com/docker/spdystream/priority_test.go index 0e89665c2d6..0746be2a80a 100644 --- a/Godeps/_workspace/src/github.com/docker/spdystream/priority_test.go +++ b/Godeps/_workspace/src/github.com/docker/spdystream/priority_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "golang.org/x/net/spdy" + "github.com/docker/spdystream/spdy" ) func TestPriorityQueueOrdering(t *testing.T) { diff --git a/Godeps/_workspace/src/golang.org/x/net/spdy/dictionary.go b/Godeps/_workspace/src/github.com/docker/spdystream/spdy/dictionary.go similarity index 100% rename from Godeps/_workspace/src/golang.org/x/net/spdy/dictionary.go rename to Godeps/_workspace/src/github.com/docker/spdystream/spdy/dictionary.go diff --git a/Godeps/_workspace/src/golang.org/x/net/spdy/read.go b/Godeps/_workspace/src/github.com/docker/spdystream/spdy/read.go similarity index 100% rename from Godeps/_workspace/src/golang.org/x/net/spdy/read.go rename to Godeps/_workspace/src/github.com/docker/spdystream/spdy/read.go diff --git a/Godeps/_workspace/src/golang.org/x/net/spdy/spdy_test.go b/Godeps/_workspace/src/github.com/docker/spdystream/spdy/spdy_test.go similarity index 100% rename from Godeps/_workspace/src/golang.org/x/net/spdy/spdy_test.go rename to Godeps/_workspace/src/github.com/docker/spdystream/spdy/spdy_test.go diff --git a/Godeps/_workspace/src/golang.org/x/net/spdy/types.go b/Godeps/_workspace/src/github.com/docker/spdystream/spdy/types.go similarity index 99% rename from Godeps/_workspace/src/golang.org/x/net/spdy/types.go rename to Godeps/_workspace/src/github.com/docker/spdystream/spdy/types.go index f0b6d2b4752..7b6ee9c6f2b 100644 --- a/Godeps/_workspace/src/golang.org/x/net/spdy/types.go +++ b/Godeps/_workspace/src/github.com/docker/spdystream/spdy/types.go @@ -4,7 +4,7 @@ // Package spdy implements the SPDY protocol (currently SPDY/3), described in // http://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3. -package spdy // import "golang.org/x/net/spdy" +package spdy import ( "bytes" diff --git a/Godeps/_workspace/src/golang.org/x/net/spdy/write.go b/Godeps/_workspace/src/github.com/docker/spdystream/spdy/write.go similarity index 100% rename from Godeps/_workspace/src/golang.org/x/net/spdy/write.go rename to Godeps/_workspace/src/github.com/docker/spdystream/spdy/write.go diff --git a/Godeps/_workspace/src/github.com/docker/spdystream/stream.go b/Godeps/_workspace/src/github.com/docker/spdystream/stream.go index 5c7467f129a..66b342d668c 100644 --- a/Godeps/_workspace/src/github.com/docker/spdystream/stream.go +++ b/Godeps/_workspace/src/github.com/docker/spdystream/stream.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "golang.org/x/net/spdy" + "github.com/docker/spdystream/spdy" ) var ( diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go index 7ad1ade5710..ce78eff6fdd 100644 --- a/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go +++ b/Godeps/_workspace/src/github.com/garyburd/redigo/internal/commandinfo.go @@ -12,7 +12,7 @@ // License for the specific language governing permissions and limitations // under the License. -package internal // import "github.com/garyburd/redigo/internal" +package internal import ( "strings" diff --git a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go index a5cd454af56..1ae6f0cc2a4 100644 --- a/Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go +++ b/Godeps/_workspace/src/github.com/garyburd/redigo/redis/doc.go @@ -166,4 +166,4 @@ // if _, err := redis.Scan(reply, &value1, &value2); err != nil { // // handle error // } -package redis // import "github.com/garyburd/redigo/redis" +package redis diff --git a/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example-executor b/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example-executor deleted file mode 100755 index 540c230027f..00000000000 Binary files a/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example-executor and /dev/null differ diff --git a/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example-scheduler b/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example-scheduler deleted file mode 100755 index 932556ff1e6..00000000000 Binary files a/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example-scheduler and /dev/null differ diff --git a/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example_executor.go b/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example_executor.go deleted file mode 100644 index 91c9d624193..00000000000 --- a/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example_executor.go +++ /dev/null @@ -1,121 +0,0 @@ -// +build example-exec - -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package main - -import ( - "flag" - "fmt" - exec "github.com/mesos/mesos-go/executor" - mesos "github.com/mesos/mesos-go/mesosproto" -) - -type exampleExecutor struct { - tasksLaunched int -} - -func newExampleExecutor() *exampleExecutor { - return &exampleExecutor{tasksLaunched: 0} -} - -func (exec *exampleExecutor) Registered(driver exec.ExecutorDriver, execInfo *mesos.ExecutorInfo, fwinfo *mesos.FrameworkInfo, slaveInfo *mesos.SlaveInfo) { - fmt.Println("Registered Executor on slave ", slaveInfo.GetHostname()) -} - -func (exec *exampleExecutor) Reregistered(driver exec.ExecutorDriver, slaveInfo *mesos.SlaveInfo) { - fmt.Println("Re-registered Executor on slave ", slaveInfo.GetHostname()) -} - -func (exec *exampleExecutor) Disconnected(exec.ExecutorDriver) { - fmt.Println("Executor disconnected.") -} - -func (exec *exampleExecutor) LaunchTask(driver exec.ExecutorDriver, taskInfo *mesos.TaskInfo) { - fmt.Println("Launching task", taskInfo.GetName(), "with command", taskInfo.Command.GetValue()) - - runStatus := &mesos.TaskStatus{ - TaskId: taskInfo.GetTaskId(), - State: mesos.TaskState_TASK_RUNNING.Enum(), - } - _, err := driver.SendStatusUpdate(runStatus) - if err != nil { - fmt.Println("Got error", err) - } - - exec.tasksLaunched++ - fmt.Println("Total tasks launched ", exec.tasksLaunched) - // - // this is where one would perform the requested task - // - - // finish task - fmt.Println("Finishing task", taskInfo.GetName()) - finStatus := &mesos.TaskStatus{ - TaskId: taskInfo.GetTaskId(), - State: mesos.TaskState_TASK_FINISHED.Enum(), - } - _, err = driver.SendStatusUpdate(finStatus) - if err != nil { - fmt.Println("Got error", err) - } - fmt.Println("Task finished", taskInfo.GetName()) -} - -func (exec *exampleExecutor) KillTask(exec.ExecutorDriver, *mesos.TaskID) { - fmt.Println("Kill task") -} - -func (exec *exampleExecutor) FrameworkMessage(driver exec.ExecutorDriver, msg string) { - fmt.Println("Got framework message: ", msg) -} - -func (exec *exampleExecutor) Shutdown(exec.ExecutorDriver) { - fmt.Println("Shutting down the executor") -} - -func (exec *exampleExecutor) Error(driver exec.ExecutorDriver, err string) { - fmt.Println("Got error message:", err) -} - -// -------------------------- func inits () ----------------- // -func init() { - flag.Parse() -} - -func main() { - fmt.Println("Starting Example Executor (Go)") - - dconfig := exec.DriverConfig{ - Executor: newExampleExecutor(), - } - driver, err := exec.NewMesosExecutorDriver(dconfig) - - if err != nil { - fmt.Println("Unable to create a ExecutorDriver ", err.Error()) - } - - _, err = driver.Start() - if err != nil { - fmt.Println("Got error:", err) - return - } - fmt.Println("Executor process has started and running.") - driver.Join() -} diff --git a/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example_scheduler.go b/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example_scheduler.go deleted file mode 100644 index 5db1dcd3d9d..00000000000 --- a/Godeps/_workspace/src/github.com/mesos/mesos-go/examples/example_scheduler.go +++ /dev/null @@ -1,294 +0,0 @@ -// +build example-sched - -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package main - -import ( - "flag" - "fmt" - "io/ioutil" - "net" - "net/http" - "strconv" - "strings" - - "github.com/gogo/protobuf/proto" - log "github.com/golang/glog" - "github.com/mesos/mesos-go/auth" - "github.com/mesos/mesos-go/auth/sasl" - "github.com/mesos/mesos-go/auth/sasl/mech" - mesos "github.com/mesos/mesos-go/mesosproto" - util "github.com/mesos/mesos-go/mesosutil" - sched "github.com/mesos/mesos-go/scheduler" - "golang.org/x/net/context" -) - -const ( - CPUS_PER_TASK = 1 - MEM_PER_TASK = 128 - defaultArtifactPort = 12345 -) - -var ( - address = flag.String("address", "127.0.0.1", "Binding address for artifact server") - artifactPort = flag.Int("artifactPort", defaultArtifactPort, "Binding port for artifact server") - authProvider = flag.String("mesos_authentication_provider", sasl.ProviderName, - fmt.Sprintf("Authentication provider to use, default is SASL that supports mechanisms: %+v", mech.ListSupported())) - master = flag.String("master", "127.0.0.1:5050", "Master address ") - executorPath = flag.String("executor", "./example_executor", "Path to test executor") - taskCount = flag.String("task-count", "5", "Total task count to run.") - mesosAuthPrincipal = flag.String("mesos_authentication_principal", "", "Mesos authentication principal.") - mesosAuthSecretFile = flag.String("mesos_authentication_secret_file", "", "Mesos authentication secret file.") -) - -type ExampleScheduler struct { - executor *mesos.ExecutorInfo - tasksLaunched int - tasksFinished int - totalTasks int -} - -func newExampleScheduler(exec *mesos.ExecutorInfo) *ExampleScheduler { - total, err := strconv.Atoi(*taskCount) - if err != nil { - total = 5 - } - return &ExampleScheduler{ - executor: exec, - tasksLaunched: 0, - tasksFinished: 0, - totalTasks: total, - } -} - -func (sched *ExampleScheduler) Registered(driver sched.SchedulerDriver, frameworkId *mesos.FrameworkID, masterInfo *mesos.MasterInfo) { - log.Infoln("Framework Registered with Master ", masterInfo) -} - -func (sched *ExampleScheduler) Reregistered(driver sched.SchedulerDriver, masterInfo *mesos.MasterInfo) { - log.Infoln("Framework Re-Registered with Master ", masterInfo) -} - -func (sched *ExampleScheduler) Disconnected(sched.SchedulerDriver) {} - -func (sched *ExampleScheduler) ResourceOffers(driver sched.SchedulerDriver, offers []*mesos.Offer) { - - for _, offer := range offers { - cpuResources := util.FilterResources(offer.Resources, func(res *mesos.Resource) bool { - return res.GetName() == "cpus" - }) - cpus := 0.0 - for _, res := range cpuResources { - cpus += res.GetScalar().GetValue() - } - - memResources := util.FilterResources(offer.Resources, func(res *mesos.Resource) bool { - return res.GetName() == "mem" - }) - mems := 0.0 - for _, res := range memResources { - mems += res.GetScalar().GetValue() - } - - log.Infoln("Received Offer <", offer.Id.GetValue(), "> with cpus=", cpus, " mem=", mems) - - remainingCpus := cpus - remainingMems := mems - - var tasks []*mesos.TaskInfo - for sched.tasksLaunched < sched.totalTasks && - CPUS_PER_TASK <= remainingCpus && - MEM_PER_TASK <= remainingMems { - - sched.tasksLaunched++ - - taskId := &mesos.TaskID{ - Value: proto.String(strconv.Itoa(sched.tasksLaunched)), - } - - task := &mesos.TaskInfo{ - Name: proto.String("go-task-" + taskId.GetValue()), - TaskId: taskId, - SlaveId: offer.SlaveId, - Executor: sched.executor, - Resources: []*mesos.Resource{ - util.NewScalarResource("cpus", CPUS_PER_TASK), - util.NewScalarResource("mem", MEM_PER_TASK), - }, - } - log.Infof("Prepared task: %s with offer %s for launch\n", task.GetName(), offer.Id.GetValue()) - - tasks = append(tasks, task) - remainingCpus -= CPUS_PER_TASK - remainingMems -= MEM_PER_TASK - } - log.Infoln("Launching ", len(tasks), "tasks for offer", offer.Id.GetValue()) - driver.LaunchTasks([]*mesos.OfferID{offer.Id}, tasks, &mesos.Filters{RefuseSeconds: proto.Float64(1)}) - } -} - -func (sched *ExampleScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos.TaskStatus) { - log.Infoln("Status update: task", status.TaskId.GetValue(), " is in state ", status.State.Enum().String()) - if status.GetState() == mesos.TaskState_TASK_FINISHED { - sched.tasksFinished++ - } - - if sched.tasksFinished >= sched.totalTasks { - log.Infoln("Total tasks completed, stopping framework.") - driver.Stop(false) - } - - if status.GetState() == mesos.TaskState_TASK_LOST || - status.GetState() == mesos.TaskState_TASK_KILLED || - status.GetState() == mesos.TaskState_TASK_FAILED { - log.Infoln( - "Aborting because task", status.TaskId.GetValue(), - "is in unexpected state", status.State.String(), - "with message", status.GetMessage(), - ) - driver.Abort() - } -} - -func (sched *ExampleScheduler) OfferRescinded(sched.SchedulerDriver, *mesos.OfferID) {} - -func (sched *ExampleScheduler) FrameworkMessage(sched.SchedulerDriver, *mesos.ExecutorID, *mesos.SlaveID, string) { -} -func (sched *ExampleScheduler) SlaveLost(sched.SchedulerDriver, *mesos.SlaveID) {} -func (sched *ExampleScheduler) ExecutorLost(sched.SchedulerDriver, *mesos.ExecutorID, *mesos.SlaveID, int) { -} - -func (sched *ExampleScheduler) Error(driver sched.SchedulerDriver, err string) { - log.Infoln("Scheduler received error:", err) -} - -// ----------------------- func init() ------------------------- // - -func init() { - flag.Parse() - log.Infoln("Initializing the Example Scheduler...") -} - -// returns (downloadURI, basename(path)) -func serveExecutorArtifact(path string) (*string, string) { - serveFile := func(pattern string, filename string) { - http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, filename) - }) - } - - // Create base path (http://foobar:5000/) - pathSplit := strings.Split(path, "/") - var base string - if len(pathSplit) > 0 { - base = pathSplit[len(pathSplit)-1] - } else { - base = path - } - serveFile("/"+base, path) - - hostURI := fmt.Sprintf("http://%s:%d/%s", *address, *artifactPort, base) - log.V(2).Infof("Hosting artifact '%s' at '%s'", path, hostURI) - - return &hostURI, base -} - -func prepareExecutorInfo() *mesos.ExecutorInfo { - executorUris := []*mesos.CommandInfo_URI{} - uri, executorCmd := serveExecutorArtifact(*executorPath) - executorUris = append(executorUris, &mesos.CommandInfo_URI{Value: uri, Executable: proto.Bool(true)}) - - executorCommand := fmt.Sprintf("./%s", executorCmd) - - go http.ListenAndServe(fmt.Sprintf("%s:%d", *address, *artifactPort), nil) - log.V(2).Info("Serving executor artifacts...") - - // Create mesos scheduler driver. - return &mesos.ExecutorInfo{ - ExecutorId: util.NewExecutorID("default"), - Name: proto.String("Test Executor (Go)"), - Source: proto.String("go_test"), - Command: &mesos.CommandInfo{ - Value: proto.String(executorCommand), - Uris: executorUris, - }, - } -} - -func parseIP(address string) net.IP { - addr, err := net.LookupIP(address) - if err != nil { - log.Fatal(err) - } - if len(addr) < 1 { - log.Fatalf("failed to parse IP from address '%v'", address) - } - return addr[0] -} - -// ----------------------- func main() ------------------------- // - -func main() { - - // build command executor - exec := prepareExecutorInfo() - - // the framework - fwinfo := &mesos.FrameworkInfo{ - User: proto.String(""), // Mesos-go will fill in user. - Name: proto.String("Test Framework (Go)"), - } - - cred := (*mesos.Credential)(nil) - if *mesosAuthPrincipal != "" { - fwinfo.Principal = proto.String(*mesosAuthPrincipal) - secret, err := ioutil.ReadFile(*mesosAuthSecretFile) - if err != nil { - log.Fatal(err) - } - cred = &mesos.Credential{ - Principal: proto.String(*mesosAuthPrincipal), - Secret: secret, - } - } - bindingAddress := parseIP(*address) - config := sched.DriverConfig{ - Scheduler: newExampleScheduler(exec), - Framework: fwinfo, - Master: *master, - Credential: cred, - BindingAddress: bindingAddress, - WithAuthContext: func(ctx context.Context) context.Context { - ctx = auth.WithLoginProvider(ctx, *authProvider) - ctx = sasl.WithBindingAddress(ctx, bindingAddress) - return ctx - }, - } - driver, err := sched.NewMesosSchedulerDriver(config) - - if err != nil { - log.Errorln("Unable to create a SchedulerDriver ", err.Error()) - } - - if stat, err := driver.Run(); err != nil { - log.Infof("Framework stopped with status %s and error: %s\n", stat.String(), err.Error()) - } - -} diff --git a/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/health_checker.go b/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/health_checker.go deleted file mode 100644 index a87ce133d59..00000000000 --- a/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/health_checker.go +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package healthchecker - -import ( - "time" - - "github.com/mesos/mesos-go/upid" -) - -// HealthChecker defines the interface of a health checker. -type HealthChecker interface { - // Start will start the health checker, and returns a notification channel. - // if the checker thinks the slave is unhealthy, it will send the timestamp - // via the channel. - Start() <-chan time.Time - // Pause will pause the slave health checker. - Pause() - // Continue will continue the slave health checker with a new slave upid. - Continue(slaveUPID *upid.UPID) - // Stop will stop the health checker. it should be called only once during - // the life span of the checker. - Stop() -} diff --git a/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/mocked_slave_health_checker.go b/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/mocked_slave_health_checker.go deleted file mode 100644 index 0bee139a530..00000000000 --- a/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/mocked_slave_health_checker.go +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package healthchecker - -import ( - "time" - - "github.com/mesos/mesos-go/upid" - "github.com/stretchr/testify/mock" -) - -type MockedHealthChecker struct { - mock.Mock - ch chan time.Time -} - -// NewMockedHealthChecker returns a new mocked health checker. -func NewMockedHealthChecker() *MockedHealthChecker { - return &MockedHealthChecker{ch: make(chan time.Time, 1)} -} - -// Start will start the checker and returns the notification channel. -func (m *MockedHealthChecker) Start() <-chan time.Time { - m.Called() - return m.ch -} - -// Pause will pause the slave health checker. -func (m *MockedHealthChecker) Pause() { - m.Called() -} - -// Continue will continue the slave health checker with a new slave upid. -func (m *MockedHealthChecker) Continue(slaveUPID *upid.UPID) { - m.Called() -} - -// Stop will stop the checker. -func (m *MockedHealthChecker) Stop() { - m.Called() -} - -func (m *MockedHealthChecker) TriggerUnhealthyEvent() { - m.ch <- time.Now() -} diff --git a/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/slave_health_checker.go b/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/slave_health_checker.go deleted file mode 100644 index 3627b59ddec..00000000000 --- a/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/slave_health_checker.go +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package healthchecker - -import ( - "fmt" - "net/http" - "sync" - "time" - - log "github.com/golang/glog" - "github.com/mesos/mesos-go/upid" -) - -const ( - defaultTimeout = time.Second - defaultCheckDuration = time.Second - defaultThreshold = 5 -) - -// SlaveHealthChecker is for checking the slave's health. -type SlaveHealthChecker struct { - sync.RWMutex - slaveUPID *upid.UPID - client *http.Client - threshold int - checkDuration time.Duration - continuousUnhealthyCount int - stop chan struct{} - ch chan time.Time - paused bool -} - -// NewSlaveHealthChecker creates a slave health checker and return a notification channel. -// Each time the checker thinks the slave is unhealthy, it will send a notification through the channel. -func NewSlaveHealthChecker(slaveUPID *upid.UPID, threshold int, checkDuration time.Duration, timeout time.Duration) *SlaveHealthChecker { - checker := &SlaveHealthChecker{ - slaveUPID: slaveUPID, - client: &http.Client{Timeout: timeout}, - threshold: threshold, - checkDuration: checkDuration, - stop: make(chan struct{}), - ch: make(chan time.Time, 1), - } - if timeout == 0 { - checker.client.Timeout = defaultTimeout - } - if checkDuration == 0 { - checker.checkDuration = defaultCheckDuration - } - if threshold <= 0 { - checker.threshold = defaultThreshold - } - return checker -} - -// Start will start the health checker and returns the notification channel. -func (s *SlaveHealthChecker) Start() <-chan time.Time { - go func() { - ticker := time.Tick(s.checkDuration) - for { - select { - case <-ticker: - s.RLock() - if !s.paused { - s.doCheck() - } - s.RUnlock() - case <-s.stop: - return - } - } - }() - return s.ch -} - -// Pause will pause the slave health checker. -func (s *SlaveHealthChecker) Pause() { - s.Lock() - defer s.Unlock() - s.paused = true -} - -// Continue will continue the slave health checker with a new slave upid. -func (s *SlaveHealthChecker) Continue(slaveUPID *upid.UPID) { - s.Lock() - defer s.Unlock() - s.paused = false - s.slaveUPID = slaveUPID -} - -// Stop will stop the slave health checker. -// It should be called only once during the life span of the checker. -func (s *SlaveHealthChecker) Stop() { - close(s.stop) -} - -func (s *SlaveHealthChecker) doCheck() { - path := fmt.Sprintf("http://%s:%s/%s/health", s.slaveUPID.Host, s.slaveUPID.Port, s.slaveUPID.ID) - resp, err := s.client.Head(path) - unhealthy := false - if err != nil { - log.Errorf("Failed to request the health path: %v\n", err) - unhealthy = true - } else if resp.StatusCode != http.StatusOK { - log.Errorf("Failed to request the health path: status: %v\n", resp.StatusCode) - unhealthy = true - } - if unhealthy { - s.continuousUnhealthyCount++ - if s.continuousUnhealthyCount >= s.threshold { - select { - case s.ch <- time.Now(): // If no one is receiving the channel, then just skip it. - default: - } - s.continuousUnhealthyCount = 0 - } - return - } - s.continuousUnhealthyCount = 0 - resp.Body.Close() -} diff --git a/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/slave_health_checker_test.go b/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/slave_health_checker_test.go deleted file mode 100644 index 07cdb7cecbd..00000000000 --- a/Godeps/_workspace/src/github.com/mesos/mesos-go/healthchecker/slave_health_checker_test.go +++ /dev/null @@ -1,262 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package healthchecker - -import ( - "fmt" - "net/http" - "net/http/httptest" - "sync" - "sync/atomic" - "testing" - "time" - - "github.com/mesos/mesos-go/upid" - "github.com/stretchr/testify/assert" -) - -type thresholdMonitor struct { - cnt int32 - threshold int32 -} - -func newThresholdMonitor(threshold int) *thresholdMonitor { - return &thresholdMonitor{threshold: int32(threshold)} -} - -// incAndTest returns true if the threshold is reached. -func (t *thresholdMonitor) incAndTest() bool { - if atomic.AddInt32(&t.cnt, 1) >= t.threshold { - return false - } - return true -} - -// blockedServer replies only threshold times, after that -// it will block. -type blockedServer struct { - th *thresholdMonitor - ch chan struct{} -} - -func newBlockedServer(threshold int) *blockedServer { - return &blockedServer{ - th: newThresholdMonitor(threshold), - ch: make(chan struct{}), - } -} - -func (s *blockedServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if s.th.incAndTest() { - return - } - <-s.ch -} - -func (s *blockedServer) stop() { - close(s.ch) -} - -// eofServer will close the connection after it replies for threshold times. -// Thus the health checker will get an EOF error. -type eofServer struct { - th *thresholdMonitor -} - -func newEOFServer(threshold int) *eofServer { - return &eofServer{newThresholdMonitor(threshold)} -} - -func (s *eofServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if s.th.incAndTest() { - return - } - hj := w.(http.Hijacker) - conn, _, err := hj.Hijack() - if err != nil { - panic("Cannot hijack") - } - conn.Close() -} - -// errorStatusCodeServer will reply error status code (e.g. 503) after the -// it replies for threhold time. -type errorStatusCodeServer struct { - th *thresholdMonitor -} - -func newErrorStatusServer(threshold int) *errorStatusCodeServer { - return &errorStatusCodeServer{newThresholdMonitor(threshold)} -} - -func (s *errorStatusCodeServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if s.th.incAndTest() { - return - } - w.WriteHeader(http.StatusServiceUnavailable) -} - -// goodServer always returns status ok. -type goodServer bool - -func (s *goodServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {} - -// partitionedServer returns status ok at some first requests. -// Then it will block for a while, and then reply again. -type partitionedServer struct { - healthyCnt int32 - partitionCnt int32 - cnt int32 - mutex *sync.Mutex - cond *sync.Cond -} - -func newPartitionedServer(healthyCnt, partitionCnt int) *partitionedServer { - mutex := new(sync.Mutex) - cond := sync.NewCond(mutex) - return &partitionedServer{ - healthyCnt: int32(healthyCnt), - partitionCnt: int32(partitionCnt), - mutex: mutex, - cond: cond, - } -} - -func (s *partitionedServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { - cnt := atomic.AddInt32(&s.cnt, 1) - if cnt < s.healthyCnt { - return - } - if cnt < s.healthyCnt+s.partitionCnt { - s.mutex.Lock() - defer s.mutex.Unlock() - s.cond.Wait() - return - } - s.mutex.Lock() - defer s.mutex.Unlock() - s.cond.Broadcast() -} - -func TestSlaveHealthCheckerFailedOnBlockedSlave(t *testing.T) { - s := newBlockedServer(5) - ts := httptest.NewUnstartedServer(s) - ts.Start() - defer ts.Close() - - upid, err := upid.Parse(fmt.Sprintf("slave@%s", ts.Listener.Addr().String())) - assert.NoError(t, err) - - checker := NewSlaveHealthChecker(upid, 10, time.Millisecond*10, time.Millisecond*10) - ch := checker.Start() - defer checker.Stop() - - select { - case <-time.After(time.Second): - s.stop() - t.Fatal("timeout") - case <-ch: - s.stop() - assert.True(t, atomic.LoadInt32(&s.th.cnt) > 10) - } -} - -func TestSlaveHealthCheckerFailedOnEOFSlave(t *testing.T) { - s := newEOFServer(5) - ts := httptest.NewUnstartedServer(s) - ts.Start() - defer ts.Close() - - upid, err := upid.Parse(fmt.Sprintf("slave@%s", ts.Listener.Addr().String())) - assert.NoError(t, err) - - checker := NewSlaveHealthChecker(upid, 10, time.Millisecond*10, time.Millisecond*10) - ch := checker.Start() - defer checker.Stop() - - select { - case <-time.After(time.Second): - t.Fatal("timeout") - case <-ch: - assert.True(t, atomic.LoadInt32(&s.th.cnt) > 10) - } -} - -func TestSlaveHealthCheckerFailedOnErrorStatusSlave(t *testing.T) { - s := newErrorStatusServer(5) - ts := httptest.NewUnstartedServer(s) - ts.Start() - defer ts.Close() - - upid, err := upid.Parse(fmt.Sprintf("slave@%s", ts.Listener.Addr().String())) - assert.NoError(t, err) - - checker := NewSlaveHealthChecker(upid, 10, time.Millisecond*10, time.Millisecond*10) - ch := checker.Start() - defer checker.Stop() - - select { - case <-time.After(time.Second): - t.Fatal("timeout") - case <-ch: - assert.True(t, atomic.LoadInt32(&s.th.cnt) > 10) - } -} - -func TestSlaveHealthCheckerSucceed(t *testing.T) { - s := new(goodServer) - ts := httptest.NewUnstartedServer(s) - ts.Start() - defer ts.Close() - - upid, err := upid.Parse(fmt.Sprintf("slave@%s", ts.Listener.Addr().String())) - assert.NoError(t, err) - - checker := NewSlaveHealthChecker(upid, 10, time.Millisecond*10, time.Millisecond*10) - ch := checker.Start() - defer checker.Stop() - - select { - case <-time.After(time.Second): - assert.Equal(t, 0, checker.continuousUnhealthyCount) - case <-ch: - t.Fatal("Shouldn't get unhealthy notification") - } -} - -func TestSlaveHealthCheckerPartitonedSlave(t *testing.T) { - s := newPartitionedServer(5, 9) - ts := httptest.NewUnstartedServer(s) - ts.Start() - defer ts.Close() - - upid, err := upid.Parse(fmt.Sprintf("slave@%s", ts.Listener.Addr().String())) - assert.NoError(t, err) - - checker := NewSlaveHealthChecker(upid, 10, time.Millisecond*10, time.Millisecond*10) - ch := checker.Start() - defer checker.Stop() - - select { - case <-time.After(time.Second): - assert.Equal(t, 0, checker.continuousUnhealthyCount) - case <-ch: - t.Fatal("Shouldn't get unhealthy notification") - } -} diff --git a/Godeps/_workspace/src/github.com/mesos/mesos-go/mesos/doc.go b/Godeps/_workspace/src/github.com/mesos/mesos-go/mesos/doc.go deleted file mode 100644 index 6c0973f34c2..00000000000 --- a/Godeps/_workspace/src/github.com/mesos/mesos-go/mesos/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// This package was previously the home of the native bindings. Please use the -// native branch if you need to build against the native bindings. -package mesos diff --git a/Godeps/_workspace/src/github.com/mesos/mesos-go/testutil/testingutil.go b/Godeps/_workspace/src/github.com/mesos/mesos-go/testutil/testingutil.go deleted file mode 100644 index 5ec1d58ca12..00000000000 --- a/Godeps/_workspace/src/github.com/mesos/mesos-go/testutil/testingutil.go +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//Collection of resources for teting mesos artifacts. -package testutil - -import ( - "bytes" - "fmt" - "github.com/gogo/protobuf/proto" - log "github.com/golang/glog" - "github.com/mesos/mesos-go/upid" - "github.com/stretchr/testify/assert" - "io" - "net" - "net/http" - "net/http/httptest" - "os" - "reflect" - "testing" -) - -//MockMesosHttpProcess represents a remote http process: master or slave. -type MockMesosHttpServer struct { - PID *upid.UPID - Addr string - server *httptest.Server - t *testing.T - when map[string]http.HandlerFunc -} - -type When interface { - Do(http.HandlerFunc) -} - -type WhenFunc func(http.HandlerFunc) - -func (w WhenFunc) Do(f http.HandlerFunc) { - w(f) -} - -func (m *MockMesosHttpServer) On(uri string) When { - log.V(2).Infof("when %v do something special", uri) - return WhenFunc(func(f http.HandlerFunc) { - log.V(2).Infof("registered callback for %v", uri) - m.when[uri] = f - }) -} - -func NewMockMasterHttpServer(t *testing.T, handler func(rsp http.ResponseWriter, req *http.Request)) *MockMesosHttpServer { - var server *httptest.Server - when := make(map[string]http.HandlerFunc) - stateHandler := func(rsp http.ResponseWriter, req *http.Request) { - if "/state.json" == req.RequestURI { - state := fmt.Sprintf(`{ "leader": "master@%v" }`, server.Listener.Addr()) - log.V(1).Infof("returning JSON %v", state) - io.WriteString(rsp, state) - } else if f, found := when[req.RequestURI]; found { - f(rsp, req) - } else { - handler(rsp, req) - } - } - server = httptest.NewServer(http.HandlerFunc(stateHandler)) - assert.NotNil(t, server) - addr := server.Listener.Addr().String() - pid, err := upid.Parse("master@" + addr) - assert.NoError(t, err) - assert.NotNil(t, pid) - log.Infoln("Created test Master http server with PID", pid.String()) - return &MockMesosHttpServer{PID: pid, Addr: addr, server: server, t: t, when: when} -} - -func NewMockSlaveHttpServer(t *testing.T, handler func(rsp http.ResponseWriter, req *http.Request)) *MockMesosHttpServer { - server := httptest.NewServer(http.HandlerFunc(handler)) - assert.NotNil(t, server) - addr := server.Listener.Addr().String() - pid, err := upid.Parse("slave(1)@" + addr) - assert.NoError(t, err) - assert.NotNil(t, pid) - assert.NoError(t, os.Setenv("MESOS_SLAVE_PID", pid.String())) - assert.NoError(t, os.Setenv("MESOS_SLAVE_ID", "test-slave-001")) - log.Infoln("Created test Slave http server with PID", pid.String()) - return &MockMesosHttpServer{PID: pid, Addr: addr, server: server, t: t} -} - -func (s *MockMesosHttpServer) Close() { - s.server.Close() -} - -//MockMesosClient Http client to communicate with mesos processes (master,sched,exec) -type MockMesosClient struct { - pid *upid.UPID - t *testing.T -} - -func NewMockMesosClient(t *testing.T, pid *upid.UPID) *MockMesosClient { - return &MockMesosClient{t: t, pid: pid} -} - -// sendMessage Mocks sending event messages to a processes such as master, sched or exec. -func (c *MockMesosClient) SendMessage(targetPid *upid.UPID, message proto.Message) { - if c.t == nil { - panic("MockMesosClient needs a testing context.") - } - - messageName := reflect.TypeOf(message).Elem().Name() - data, err := proto.Marshal(message) - assert.NoError(c.t, err) - hostport := net.JoinHostPort(targetPid.Host, targetPid.Port) - targetURL := fmt.Sprintf("http://%s/%s/mesos.internal.%s", hostport, targetPid.ID, messageName) - log.Infoln("MockMesosClient Sending message to", targetURL) - req, err := http.NewRequest("POST", targetURL, bytes.NewReader(data)) - assert.NoError(c.t, err) - req.Header.Add("Libprocess-From", c.pid.String()) - req.Header.Add("Content-Type", "application/x-protobuf") - resp, err := http.DefaultClient.Do(req) - assert.NoError(c.t, err) - assert.Equal(c.t, http.StatusAccepted, resp.StatusCode) -} diff --git a/Godeps/_workspace/src/github.com/shurcooL/sanitized_anchor_name/main.go b/Godeps/_workspace/src/github.com/shurcooL/sanitized_anchor_name/main.go index 72a87535093..6baae23b50e 100644 --- a/Godeps/_workspace/src/github.com/shurcooL/sanitized_anchor_name/main.go +++ b/Godeps/_workspace/src/github.com/shurcooL/sanitized_anchor_name/main.go @@ -5,7 +5,7 @@ // // At this time, it does not try to ensure that generated anchor names // are unique, that responsibility falls on the caller. -package sanitized_anchor_name // import "github.com/shurcooL/sanitized_anchor_name" +package sanitized_anchor_name import "unicode" diff --git a/Godeps/_workspace/src/github.com/skratchdot/LICENSE-MIT b/Godeps/_workspace/src/github.com/skratchdot/LICENSE-MIT deleted file mode 100644 index afd04c82161..00000000000 --- a/Godeps/_workspace/src/github.com/skratchdot/LICENSE-MIT +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2013 skratchdot - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability.go b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability.go index 9df3b4151b6..c13f4e52a9c 100644 --- a/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability.go +++ b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability.go @@ -60,7 +60,8 @@ type Capabilities interface { Apply(kind CapType) error } -// NewPid create new initialized Capabilities object for given pid. +// NewPid create new initialized Capabilities object for given pid when it +// is nonzero, or for the current pid if pid is 0 func NewPid(pid int) (Capabilities, error) { return newPid(pid) } diff --git a/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability_linux.go b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability_linux.go index c5f335f7fb2..3dfcd398dcd 100644 --- a/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability_linux.go +++ b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/capability_linux.go @@ -24,12 +24,46 @@ const ( linuxCapVer3 = 0x20080522 ) -var capVers uint32 +var ( + capVers uint32 + capLastCap Cap +) func init() { var hdr capHeader capget(&hdr, nil) capVers = hdr.version + + if initLastCap() == nil { + CAP_LAST_CAP = capLastCap + if capLastCap > 31 { + capUpperMask = (uint32(1) << (uint(capLastCap) - 31)) - 1 + } else { + capUpperMask = 0 + } + } +} + +func initLastCap() error { + if capLastCap != 0 { + return nil + } + + f, err := os.Open("/proc/sys/kernel/cap_last_cap") + if err != nil { + return err + } + defer f.Close() + + var b []byte = make([]byte, 11) + _, err = f.Read(b) + if err != nil { + return err + } + + fmt.Sscanf(string(b), "%d", &capLastCap) + + return nil } func mkStringCap(c Capabilities, which CapType) (ret string) { @@ -351,7 +385,15 @@ func (c *capsV3) Load() (err error) { return } - f, err := os.Open(fmt.Sprintf("/proc/%d/status", c.hdr.pid)) + var status_path string + + if c.hdr.pid == 0 { + status_path = fmt.Sprintf("/proc/self/status") + } else { + status_path = fmt.Sprintf("/proc/%d/status", c.hdr.pid) + } + + f, err := os.Open(status_path) if err != nil { return } diff --git a/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enum.go b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enum.go index e2900a4e933..fd0ce7fe8ee 100644 --- a/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enum.go +++ b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enum.go @@ -34,110 +34,30 @@ const ( BOUNDS = BOUNDING ) +//go:generate go run enumgen/gen.go type Cap int -func (c Cap) String() string { - switch c { - case CAP_CHOWN: - return "chown" - case CAP_DAC_OVERRIDE: - return "dac_override" - case CAP_DAC_READ_SEARCH: - return "dac_read_search" - case CAP_FOWNER: - return "fowner" - case CAP_FSETID: - return "fsetid" - case CAP_KILL: - return "kill" - case CAP_SETGID: - return "setgid" - case CAP_SETUID: - return "setuid" - case CAP_SETPCAP: - return "setpcap" - case CAP_LINUX_IMMUTABLE: - return "linux_immutable" - case CAP_NET_BIND_SERVICE: - return "net_bind_service" - case CAP_NET_BROADCAST: - return "net_broadcast" - case CAP_NET_ADMIN: - return "net_admin" - case CAP_NET_RAW: - return "net_raw" - case CAP_IPC_LOCK: - return "ipc_lock" - case CAP_IPC_OWNER: - return "ipc_owner" - case CAP_SYS_MODULE: - return "sys_module" - case CAP_SYS_RAWIO: - return "sys_rawio" - case CAP_SYS_CHROOT: - return "sys_chroot" - case CAP_SYS_PTRACE: - return "sys_ptrace" - case CAP_SYS_PACCT: - return "sys_psacct" - case CAP_SYS_ADMIN: - return "sys_admin" - case CAP_SYS_BOOT: - return "sys_boot" - case CAP_SYS_NICE: - return "sys_nice" - case CAP_SYS_RESOURCE: - return "sys_resource" - case CAP_SYS_TIME: - return "sys_time" - case CAP_SYS_TTY_CONFIG: - return "sys_tty_config" - case CAP_MKNOD: - return "mknod" - case CAP_LEASE: - return "lease" - case CAP_AUDIT_WRITE: - return "audit_write" - case CAP_AUDIT_CONTROL: - return "audit_control" - case CAP_SETFCAP: - return "setfcap" - case CAP_MAC_OVERRIDE: - return "mac_override" - case CAP_MAC_ADMIN: - return "mac_admin" - case CAP_SYSLOG: - return "syslog" - case CAP_WAKE_ALARM: - return "wake_alarm" - case CAP_BLOCK_SUSPEND: - return "block_suspend" - } - return "unknown" -} - +// POSIX-draft defined capabilities. const ( - // POSIX-draft defined capabilities. - // In a system with the [_POSIX_CHOWN_RESTRICTED] option defined, this // overrides the restriction of changing file ownership and group // ownership. - CAP_CHOWN Cap = 0 + CAP_CHOWN = Cap(0) // Override all DAC access, including ACL execute access if // [_POSIX_ACL] is defined. Excluding DAC access covered by // CAP_LINUX_IMMUTABLE. - CAP_DAC_OVERRIDE Cap = 1 + CAP_DAC_OVERRIDE = Cap(1) // Overrides all DAC restrictions regarding read and search on files // and directories, including ACL restrictions if [_POSIX_ACL] is // defined. Excluding DAC access covered by CAP_LINUX_IMMUTABLE. - CAP_DAC_READ_SEARCH Cap = 2 + CAP_DAC_READ_SEARCH = Cap(2) // Overrides all restrictions about allowed operations on files, where // file owner ID must be equal to the user ID, except where CAP_FSETID // is applicable. It doesn't override MAC and DAC restrictions. - CAP_FOWNER Cap = 3 + CAP_FOWNER = Cap(3) // Overrides the following restrictions that the effective user ID // shall match the file owner ID when setting the S_ISUID and S_ISGID @@ -145,21 +65,21 @@ const ( // supplementary group IDs) shall match the file owner ID when setting // the S_ISGID bit on that file; that the S_ISUID and S_ISGID bits are // cleared on successful return from chown(2) (not implemented). - CAP_FSETID Cap = 4 + CAP_FSETID = Cap(4) // Overrides the restriction that the real or effective user ID of a // process sending a signal must match the real or effective user ID // of the process receiving the signal. - CAP_KILL Cap = 5 + CAP_KILL = Cap(5) // Allows setgid(2) manipulation // Allows setgroups(2) // Allows forged gids on socket credentials passing. - CAP_SETGID Cap = 6 + CAP_SETGID = Cap(6) // Allows set*uid(2) manipulation (including fsuid). // Allows forged pids on socket credentials passing. - CAP_SETUID Cap = 7 + CAP_SETUID = Cap(7) // Linux-specific capabilities @@ -171,17 +91,17 @@ const ( // to the current process' inheritable set // Allow taking bits out of capability bounding set // Allow modification of the securebits for a process - CAP_SETPCAP Cap = 8 + CAP_SETPCAP = Cap(8) // Allow modification of S_IMMUTABLE and S_APPEND file attributes - CAP_LINUX_IMMUTABLE Cap = 9 + CAP_LINUX_IMMUTABLE = Cap(9) // Allows binding to TCP/UDP sockets below 1024 // Allows binding to ATM VCIs below 32 - CAP_NET_BIND_SERVICE Cap = 10 + CAP_NET_BIND_SERVICE = Cap(10) // Allow broadcasting, listen to multicast - CAP_NET_BROADCAST Cap = 11 + CAP_NET_BROADCAST = Cap(11) // Allow interface configuration // Allow administration of IP firewall, masquerading and accounting @@ -196,36 +116,36 @@ const ( // Allow multicasting // Allow read/write of device-specific registers // Allow activation of ATM control sockets - CAP_NET_ADMIN Cap = 12 + CAP_NET_ADMIN = Cap(12) // Allow use of RAW sockets // Allow use of PACKET sockets // Allow binding to any address for transparent proxying (also via NET_ADMIN) - CAP_NET_RAW Cap = 13 + CAP_NET_RAW = Cap(13) // Allow locking of shared memory segments // Allow mlock and mlockall (which doesn't really have anything to do // with IPC) - CAP_IPC_LOCK Cap = 14 + CAP_IPC_LOCK = Cap(14) // Override IPC ownership checks - CAP_IPC_OWNER Cap = 15 + CAP_IPC_OWNER = Cap(15) // Insert and remove kernel modules - modify kernel without limit - CAP_SYS_MODULE Cap = 16 + CAP_SYS_MODULE = Cap(16) // Allow ioperm/iopl access // Allow sending USB messages to any device via /proc/bus/usb - CAP_SYS_RAWIO Cap = 17 + CAP_SYS_RAWIO = Cap(17) // Allow use of chroot() - CAP_SYS_CHROOT Cap = 18 + CAP_SYS_CHROOT = Cap(18) // Allow ptrace() of any process - CAP_SYS_PTRACE Cap = 19 + CAP_SYS_PTRACE = Cap(19) // Allow configuration of process accounting - CAP_SYS_PACCT Cap = 20 + CAP_SYS_PACCT = Cap(20) // Allow configuration of the secure attention key // Allow administration of the random device @@ -263,10 +183,10 @@ const ( // arbitrary SCSI commands // Allow setting encryption key on loopback filesystem // Allow setting zone reclaim policy - CAP_SYS_ADMIN Cap = 21 + CAP_SYS_ADMIN = Cap(21) // Allow use of reboot() - CAP_SYS_BOOT Cap = 22 + CAP_SYS_BOOT = Cap(22) // Allow raising priority and setting priority on other (different // UID) processes @@ -274,7 +194,7 @@ const ( // processes and setting the scheduling algorithm used by another // process. // Allow setting cpu affinity on other processes - CAP_SYS_NICE Cap = 23 + CAP_SYS_NICE = Cap(23) // Override resource limits. Set resource limits. // Override quota limits. @@ -287,33 +207,33 @@ const ( // Allow more than 64hz interrupts from the real-time clock // Override max number of consoles on console allocation // Override max number of keymaps - CAP_SYS_RESOURCE Cap = 24 + CAP_SYS_RESOURCE = Cap(24) // Allow manipulation of system clock // Allow irix_stime on mips // Allow setting the real-time clock - CAP_SYS_TIME Cap = 25 + CAP_SYS_TIME = Cap(25) // Allow configuration of tty devices // Allow vhangup() of tty - CAP_SYS_TTY_CONFIG Cap = 26 + CAP_SYS_TTY_CONFIG = Cap(26) // Allow the privileged aspects of mknod() - CAP_MKNOD Cap = 27 + CAP_MKNOD = Cap(27) // Allow taking of leases on files - CAP_LEASE Cap = 28 + CAP_LEASE = Cap(28) - CAP_AUDIT_WRITE Cap = 29 - CAP_AUDIT_CONTROL Cap = 30 - CAP_SETFCAP Cap = 31 + CAP_AUDIT_WRITE = Cap(29) + CAP_AUDIT_CONTROL = Cap(30) + CAP_SETFCAP = Cap(31) // Override MAC access. // The base kernel enforces no MAC policy. // An LSM may enforce a MAC policy, and if it does and it chooses // to implement capability based overrides of that policy, this is // the capability it should use to do so. - CAP_MAC_OVERRIDE Cap = 32 + CAP_MAC_OVERRIDE = Cap(32) // Allow MAC configuration or state changes. // The base kernel requires no MAC configuration. @@ -321,18 +241,24 @@ const ( // to implement capability based checks on modifications to that // policy or the data required to maintain it, this is the // capability it should use to do so. - CAP_MAC_ADMIN Cap = 33 + CAP_MAC_ADMIN = Cap(33) // Allow configuring the kernel's syslog (printk behaviour) - CAP_SYSLOG Cap = 34 + CAP_SYSLOG = Cap(34) // Allow triggering something that will wake the system - CAP_WAKE_ALARM Cap = 35 + CAP_WAKE_ALARM = Cap(35) // Allow preventing system suspends - CAP_BLOCK_SUSPEND Cap = 36 + CAP_BLOCK_SUSPEND = Cap(36) - CAP_LAST_CAP = CAP_BLOCK_SUSPEND + // Allow reading audit messages from the kernel + CAP_AUDIT_READ = Cap(37) ) -const capUpperMask = (uint32(1) << (uint(CAP_LAST_CAP) - 31)) - 1 +var ( + // Highest valid capability of the running kernel. + CAP_LAST_CAP = Cap(63) + + capUpperMask = ^uint32(0) +) diff --git a/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enum_gen.go b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enum_gen.go new file mode 100644 index 00000000000..b9e6d2d5e1e --- /dev/null +++ b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enum_gen.go @@ -0,0 +1,129 @@ +// generated file; DO NOT EDIT - use go generate in directory with source + +package capability + +func (c Cap) String() string { + switch c { + case CAP_CHOWN: + return "chown" + case CAP_DAC_OVERRIDE: + return "dac_override" + case CAP_DAC_READ_SEARCH: + return "dac_read_search" + case CAP_FOWNER: + return "fowner" + case CAP_FSETID: + return "fsetid" + case CAP_KILL: + return "kill" + case CAP_SETGID: + return "setgid" + case CAP_SETUID: + return "setuid" + case CAP_SETPCAP: + return "setpcap" + case CAP_LINUX_IMMUTABLE: + return "linux_immutable" + case CAP_NET_BIND_SERVICE: + return "net_bind_service" + case CAP_NET_BROADCAST: + return "net_broadcast" + case CAP_NET_ADMIN: + return "net_admin" + case CAP_NET_RAW: + return "net_raw" + case CAP_IPC_LOCK: + return "ipc_lock" + case CAP_IPC_OWNER: + return "ipc_owner" + case CAP_SYS_MODULE: + return "sys_module" + case CAP_SYS_RAWIO: + return "sys_rawio" + case CAP_SYS_CHROOT: + return "sys_chroot" + case CAP_SYS_PTRACE: + return "sys_ptrace" + case CAP_SYS_PACCT: + return "sys_pacct" + case CAP_SYS_ADMIN: + return "sys_admin" + case CAP_SYS_BOOT: + return "sys_boot" + case CAP_SYS_NICE: + return "sys_nice" + case CAP_SYS_RESOURCE: + return "sys_resource" + case CAP_SYS_TIME: + return "sys_time" + case CAP_SYS_TTY_CONFIG: + return "sys_tty_config" + case CAP_MKNOD: + return "mknod" + case CAP_LEASE: + return "lease" + case CAP_AUDIT_WRITE: + return "audit_write" + case CAP_AUDIT_CONTROL: + return "audit_control" + case CAP_SETFCAP: + return "setfcap" + case CAP_MAC_OVERRIDE: + return "mac_override" + case CAP_MAC_ADMIN: + return "mac_admin" + case CAP_SYSLOG: + return "syslog" + case CAP_WAKE_ALARM: + return "wake_alarm" + case CAP_BLOCK_SUSPEND: + return "block_suspend" + case CAP_AUDIT_READ: + return "audit_read" + } + return "unknown" +} + +// List returns list of all supported capabilities +func List() []Cap { + return []Cap{ + CAP_CHOWN, + CAP_DAC_OVERRIDE, + CAP_DAC_READ_SEARCH, + CAP_FOWNER, + CAP_FSETID, + CAP_KILL, + CAP_SETGID, + CAP_SETUID, + CAP_SETPCAP, + CAP_LINUX_IMMUTABLE, + CAP_NET_BIND_SERVICE, + CAP_NET_BROADCAST, + CAP_NET_ADMIN, + CAP_NET_RAW, + CAP_IPC_LOCK, + CAP_IPC_OWNER, + CAP_SYS_MODULE, + CAP_SYS_RAWIO, + CAP_SYS_CHROOT, + CAP_SYS_PTRACE, + CAP_SYS_PACCT, + CAP_SYS_ADMIN, + CAP_SYS_BOOT, + CAP_SYS_NICE, + CAP_SYS_RESOURCE, + CAP_SYS_TIME, + CAP_SYS_TTY_CONFIG, + CAP_MKNOD, + CAP_LEASE, + CAP_AUDIT_WRITE, + CAP_AUDIT_CONTROL, + CAP_SETFCAP, + CAP_MAC_OVERRIDE, + CAP_MAC_ADMIN, + CAP_SYSLOG, + CAP_WAKE_ALARM, + CAP_BLOCK_SUSPEND, + CAP_AUDIT_READ, + } +} diff --git a/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enumgen/gen.go b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enumgen/gen.go new file mode 100644 index 00000000000..4c733809b1b --- /dev/null +++ b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/enumgen/gen.go @@ -0,0 +1,92 @@ +package main + +import ( + "bytes" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/token" + "io/ioutil" + "log" + "os" + "strings" +) + +const fileName = "enum.go" +const genName = "enum_gen.go" + +type generator struct { + buf bytes.Buffer + caps []string +} + +func (g *generator) writeHeader() { + g.buf.WriteString("// generated file; DO NOT EDIT - use go generate in directory with source\n") + g.buf.WriteString("\n") + g.buf.WriteString("package capability") +} + +func (g *generator) writeStringFunc() { + g.buf.WriteString("\n") + g.buf.WriteString("func (c Cap) String() string {\n") + g.buf.WriteString("switch c {\n") + for _, cap := range g.caps { + fmt.Fprintf(&g.buf, "case %s:\n", cap) + fmt.Fprintf(&g.buf, "return \"%s\"\n", strings.ToLower(cap[4:])) + } + g.buf.WriteString("}\n") + g.buf.WriteString("return \"unknown\"\n") + g.buf.WriteString("}\n") +} + +func (g *generator) writeListFunc() { + g.buf.WriteString("\n") + g.buf.WriteString("// List returns list of all supported capabilities\n") + g.buf.WriteString("func List() []Cap {\n") + g.buf.WriteString("return []Cap{\n") + for _, cap := range g.caps { + fmt.Fprintf(&g.buf, "%s,\n", cap) + } + g.buf.WriteString("}\n") + g.buf.WriteString("}\n") +} + +func main() { + fs := token.NewFileSet() + parsedFile, err := parser.ParseFile(fs, fileName, nil, 0) + if err != nil { + log.Fatal(err) + } + var caps []string + for _, decl := range parsedFile.Decls { + decl, ok := decl.(*ast.GenDecl) + if !ok || decl.Tok != token.CONST { + continue + } + for _, spec := range decl.Specs { + vspec := spec.(*ast.ValueSpec) + name := vspec.Names[0].Name + if strings.HasPrefix(name, "CAP_") { + caps = append(caps, name) + } + } + } + g := &generator{caps: caps} + g.writeHeader() + g.writeStringFunc() + g.writeListFunc() + src, err := format.Source(g.buf.Bytes()) + if err != nil { + fmt.Println("generated invalid Go code") + fmt.Println(g.buf.String()) + log.Fatal(err) + } + fi, err := os.Stat(fileName) + if err != nil { + log.Fatal(err) + } + if err := ioutil.WriteFile(genName, src, fi.Mode().Perm()); err != nil { + log.Fatal(err) + } +} diff --git a/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/syscall_linux.go b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/syscall_linux.go index c18e6f69186..dd6f4540650 100644 --- a/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/syscall_linux.go +++ b/Godeps/_workspace/src/github.com/syndtr/gocapability/capability/syscall_linux.go @@ -86,6 +86,10 @@ func getVfsCap(path string, dest *vfscapData) (err error) { } r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_vfsXattrName)), uintptr(unsafe.Pointer(dest)), vfscapDataSizeV2, 0, 0) if e1 != 0 { + if e1 == syscall.ENODATA { + dest.version = 2 + return + } err = e1 } switch dest.magic & vfsCapVerMask { @@ -128,8 +132,6 @@ func setVfsCap(path string, data *vfscapData) (err error) { data.magic = vfsCapVer2 if data.effective[0] != 0 || data.effective[1] != 0 { data.magic |= vfsCapFlageffective - data.data[0].permitted |= data.effective[0] - data.data[1].permitted |= data.effective[1] } size = vfscapDataSizeV2 } else { diff --git a/Godeps/_workspace/src/golang.org/x/exp/inotify/inotify_linux.go b/Godeps/_workspace/src/golang.org/x/exp/inotify/inotify_linux.go index 5c2f858cc31..41ac5583828 100644 --- a/Godeps/_workspace/src/golang.org/x/exp/inotify/inotify_linux.go +++ b/Godeps/_workspace/src/golang.org/x/exp/inotify/inotify_linux.go @@ -24,7 +24,7 @@ Example: } */ -package inotify // import "golang.org/x/exp/inotify" +package inotify import ( "errors" diff --git a/Godeps/_workspace/src/golang.org/x/net/context/context.go b/Godeps/_workspace/src/golang.org/x/net/context/context.go index 490245de9e6..66aff7cb4a0 100644 --- a/Godeps/_workspace/src/golang.org/x/net/context/context.go +++ b/Godeps/_workspace/src/golang.org/x/net/context/context.go @@ -34,7 +34,7 @@ // // See http://blog.golang.org/context for example code for a server that uses // Contexts. -package context // import "golang.org/x/net/context" +package context import ( "errors" diff --git a/Godeps/_workspace/src/golang.org/x/net/html/atom/atom.go b/Godeps/_workspace/src/golang.org/x/net/html/atom/atom.go index cd0a8ac1545..227404bdafa 100644 --- a/Godeps/_workspace/src/golang.org/x/net/html/atom/atom.go +++ b/Godeps/_workspace/src/golang.org/x/net/html/atom/atom.go @@ -15,7 +15,7 @@ // whether atom.H1 < atom.H2 may also change. The codes are not guaranteed to // be dense. The only guarantees are that e.g. looking up "div" will yield // atom.Div, calling atom.Div.String will return "div", and atom.Div != 0. -package atom // import "golang.org/x/net/html/atom" +package atom // Atom is an integer code for a string. The zero value maps to "". type Atom uint32 diff --git a/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go b/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go index 2e5f9ba2c56..b19f83b7276 100644 --- a/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go +++ b/Godeps/_workspace/src/golang.org/x/net/html/charset/charset.go @@ -6,7 +6,7 @@ // // The mapping from encoding labels to encodings is defined at // http://encoding.spec.whatwg.org. -package charset // import "golang.org/x/net/html/charset" +package charset import ( "bytes" diff --git a/Godeps/_workspace/src/golang.org/x/net/html/doc.go b/Godeps/_workspace/src/golang.org/x/net/html/doc.go index 32379a3246b..fac0f54e78a 100644 --- a/Godeps/_workspace/src/golang.org/x/net/html/doc.go +++ b/Godeps/_workspace/src/golang.org/x/net/html/doc.go @@ -93,7 +93,7 @@ The relevant specifications include: http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html and http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html */ -package html // import "golang.org/x/net/html" +package html // The tokenization algorithm implemented by this package is not a line-by-line // transliteration of the relatively verbose state-machine in the WHATWG diff --git a/Godeps/_workspace/src/golang.org/x/net/websocket/websocket.go b/Godeps/_workspace/src/golang.org/x/net/websocket/websocket.go index b8d2e6d1744..0f4917bf7e6 100644 --- a/Godeps/_workspace/src/golang.org/x/net/websocket/websocket.go +++ b/Godeps/_workspace/src/golang.org/x/net/websocket/websocket.go @@ -4,7 +4,7 @@ // Package websocket implements a client and server for the WebSocket protocol // as specified in RFC 6455. -package websocket // import "golang.org/x/net/websocket" +package websocket import ( "bufio"